Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 888189 - acct-user.eclass - usermod fails if the uid, username, or homedir is changed for a running process
Summary: acct-user.eclass - usermod fails if the uid, username, or homedir is changed ...
Status: CONFIRMED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Eclasses (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Michał Górny
URL:
Whiteboard:
Keywords: PullRequest
: 888191 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-12-24 19:42 UTC by tdr
Modified: 2023-06-26 18:58 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description tdr 2022-12-24 19:42:08 UTC
acct-user/at fails vs clean exit if at daemon is running during emerge -e or similar


 * Package:    acct-user/at-0:0
 * Repository: gentoo
 * Maintainer: blueness@gentoo.org
 * USE:        abi_x86_64 amd64 elibc_glibc kernel_linux userland_GNU
 * FEATURES:   network-sandbox preserve-libs sandbox userpriv usersandbox

>>> Unpacking source...
>>> Source unpacked in /var/tmp/portage/acct-user/at-0/work
>>> Preparing source in /var/tmp/portage/acct-user/at-0/work ...
>>> Source prepared.
>>> Configuring source in /var/tmp/portage/acct-user/at-0/work ...
>>> Source configured.
>>> Compiling source in /var/tmp/portage/acct-user/at-0/work ...
>>> Source compiled.
>>> Test phase [not enabled]: acct-user/at-0

>>> Install acct-user/at-0 into /var/tmp/portage/acct-user/at-0/image
>>> Completed installing acct-user/at-0 into /var/tmp/portage/acct-user/at-0/image

 * Final size of build directory: 0 KiB
 * Final size of installed tree:  4 KiB


 * User at already exists
 * Updating user at
usermod: user at is currently used by process 2002
 * ERROR: acct-user/at-0::gentoo failed (postinst phase):
 *   usermod failed
 *
 * Call stack:
 *     ebuild.sh, line 136:  Called pkg_postinst
 *   environment, line 834:  Called acct-user_pkg_postinst
 *   environment, line 365:  Called die
 * The specific snippet of code:
 *           die "usermod failed";



# ps aux | grep 2002
at        2002  0.0  0.0   2308   120 ?        Ss   Dec23   0:00 /usr/sbin/atd
Comment 1 Mike Gilbert gentoo-dev 2022-12-24 23:50:05 UTC Comment hidden (obsolete)
Comment 2 Mike Gilbert gentoo-dev 2022-12-24 23:50:37 UTC Comment hidden (obsolete)
Comment 3 Mike Gilbert gentoo-dev 2022-12-25 00:06:21 UTC
usermod aborts if we try to change the uid, username, or home directory of a user that currently has any processes running.

I don't see any way to really avoid this other than stopping atd before you attempt to install acct-user/at.
Comment 4 Mike Gilbert gentoo-dev 2022-12-25 00:16:10 UTC
*** Bug 888191 has been marked as a duplicate of this bug. ***
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2022-12-26 13:01:53 UTC
Hmm, perhaps there's room for improvement.

One option would be to move this to preinst, so that package wouldn't be considered installed.  We could also print instructions how to manually perform the update, so that the user could stop atd, update the user and restart it without having to retrigger the ebuild.
Comment 6 Larry the Git Cow gentoo-dev 2023-06-26 18:58:02 UTC
The bug has been referenced in the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2f06a34a08c256ca49f68ead9968738c49be6f0c

commit 2f06a34a08c256ca49f68ead9968738c49be6f0c
Author:     Mike Gilbert <floppym@gentoo.org>
AuthorDate: 2023-06-24 16:52:13 +0000
Commit:     Mike Gilbert <floppym@gentoo.org>
CommitDate: 2023-06-26 18:57:38 +0000

    acct-user.eclass: improve error message when usermod fails
    
    usermod refuses to update the home directory for a user with running
    processes. Output a more helpful message and avoid calling die for this.
    
    For other usermod failures, output stderr as an eerror message and die.
    
    Example output:
    
     * Failed to update user portage
     * This user currently has one or more running processes.
     * Please update this user manually with the following command:
     *   usermod '--comment' 'System user; portage' '--home' '/var/lib/portage/home' '--shell' '/bin/bash' '--gid' 'portage' '--groups' '' portage
    
    Bug: https://bugs.gentoo.org/888189
    Signed-off-by: Mike Gilbert <floppym@gentoo.org>

 eclass/acct-user.eclass | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)