Check that the new fields set with -u, -s, -l, -g, -f, -e, -d, and -c
differ from the old ones. If a requested new value is equal to the old one, no changes will be performed for that field. If no fields are changed, usermod will exist successfully with a warning. This avoids logging changes to syslog when there are actually no changes.
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
2008-01-23 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* NEWS, src/usermod.c: Check that the new fields set with -u, -s,
|
||||||
|
-l, -g, -f, -e, -d, and -c differ from the old ones. If a
|
||||||
|
requested new value is equal to the old one, no changes will
|
||||||
|
be performed for that field. If no fields are changed, usermod
|
||||||
|
will exist successfully with a warning. This avoids logging
|
||||||
|
changes to syslog when there are actually no changes.
|
||||||
|
|
||||||
2008-01-23 Nicolas François <nicolas.francois@centraliens.net>
|
2008-01-23 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/usermod.c: Always define user_newcomment, user_newshell,
|
* src/usermod.c: Always define user_newcomment, user_newshell,
|
||||||
|
5
NEWS
5
NEWS
@ -50,6 +50,11 @@ shadow-4.1.0 -> shadow-4.1.1 UNRELEASED
|
|||||||
- usermod
|
- usermod
|
||||||
* Keep the access and modification time of files when moving an user's home
|
* Keep the access and modification time of files when moving an user's home
|
||||||
directory.
|
directory.
|
||||||
|
* Check that the new fields set with -u, -s, -l, -g, -f, -e, -d, and -c
|
||||||
|
differ from the old ones. If a requested new value is equal to the old
|
||||||
|
one, no changes will be performed for that field. If no fields are
|
||||||
|
changed, usermod will exist successfully with a warning. This avoids
|
||||||
|
logging changes to syslog when there are actually no changes.
|
||||||
- vipw/vigr
|
- vipw/vigr
|
||||||
* Recommend editing the shadowed (resp. regular) file if the regular (resp.
|
* Recommend editing the shadowed (resp. regular) file if the regular (resp.
|
||||||
shadowed) file was edited.
|
shadowed) file was edited.
|
||||||
|
@ -930,15 +930,7 @@ static void process_flags (int argc, char **argv)
|
|||||||
Prog, optarg);
|
Prog, optarg);
|
||||||
exit (E_BAD_ARG);
|
exit (E_BAD_ARG);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* If the name does not really change, we mustn't
|
|
||||||
* set the flag as this will cause rather serious
|
|
||||||
* problems later!
|
|
||||||
*/
|
|
||||||
if (strcmp (user_name, optarg))
|
|
||||||
lflg++;
|
lflg++;
|
||||||
|
|
||||||
user_newname = optarg;
|
user_newname = optarg;
|
||||||
break;
|
break;
|
||||||
case 'L':
|
case 'L':
|
||||||
@ -982,6 +974,38 @@ static void process_flags (int argc, char **argv)
|
|||||||
fprintf (stderr, _("%s: no flags given\n"), Prog);
|
fprintf (stderr, _("%s: no flags given\n"), Prog);
|
||||||
exit (E_USAGE);
|
exit (E_USAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (user_newid == user_id) {
|
||||||
|
uflg = 0;
|
||||||
|
}
|
||||||
|
if (user_newgid == user_gid) {
|
||||||
|
gflg = 0;
|
||||||
|
}
|
||||||
|
if (strcmp (user_newshell, user_shell) == 0) {
|
||||||
|
sflg = 0;
|
||||||
|
}
|
||||||
|
if (strcmp (user_newname, user_name) == 0) {
|
||||||
|
lflg = 0;
|
||||||
|
}
|
||||||
|
if (user_newinactive == user_inactive) {
|
||||||
|
fflg = 0;
|
||||||
|
}
|
||||||
|
if (user_newexpire == user_expire) {
|
||||||
|
eflg = 0;
|
||||||
|
}
|
||||||
|
if (strcmp (user_newhome, user_home) == 0) {
|
||||||
|
dflg = 0;
|
||||||
|
}
|
||||||
|
if (strcmp (user_newcomment, user_comment) == 0) {
|
||||||
|
cflg = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Uflg + uflg + sflg + pflg + oflg + mflg + Lflg + lflg + Gflg +
|
||||||
|
gflg + fflg + eflg + dflg + cflg == 0) {
|
||||||
|
fprintf (stderr, _("%s: no changes\n"), Prog);
|
||||||
|
exit (E_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
if (!is_shadow_pwd && (eflg || fflg)) {
|
if (!is_shadow_pwd && (eflg || fflg)) {
|
||||||
fprintf (stderr,
|
fprintf (stderr,
|
||||||
_
|
_
|
||||||
|
Reference in New Issue
Block a user