From b9ecd1cf4237fa210417a95734a78656d48ec00f Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Mon, 18 May 2009 18:37:16 +0000 Subject: [PATCH] * NEWS, src/usermod.c: Check if the user is busy when the user's UID, name or home directory is changed. --- ChangeLog | 5 +++++ NEWS | 3 +++ src/usermod.c | 12 ++++++++++++ 3 files changed, 20 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7328c6aa..0462d7f9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2009-05-18 Nicolas François + + * NEWS, src/usermod.c: Check if the user is busy when the user's + UID, name or home directory is changed. + 2009-05-18 Nicolas François * src/userdel.c, libmisc/user_busy.c, libmisc/Makefile.am, diff --git a/NEWS b/NEWS index ff110f96..f6c74220 100644 --- a/NEWS +++ b/NEWS @@ -10,6 +10,9 @@ shadow-4.1.4 -> shadow-4.1.4.1 UNRELEASED the user is running some processes. * If not on Linux, continue to search for an utmp record, but make sure the process recorded in the utmp entry is still running. +- usermod + * Check if the user is busy when the user's UID, name or home directory + is changed. shadow-4.1.3.1 -> shadow-4.1.4 2009-05-10 diff --git a/src/usermod.c b/src/usermod.c index 4c87f153..f178a152 100644 --- a/src/usermod.c +++ b/src/usermod.c @@ -1715,6 +1715,18 @@ int main (int argc, char **argv) process_flags (argc, argv); + /* + * The home directory, the username and the user's UID should not + * be changed while the user is logged in. + */ + if ( (uflg || lflg || dflg) + && (user_busy (user_name, user_id) != 0)) { + fprintf (stderr, + _("%s: user %s is currently logged in\n"), + Prog, user_name); + exit (E_USER_BUSY); + } + #ifdef ACCT_TOOLS_SETUID #ifdef USE_PAM {