* src/groupmems.c: Reduce the number of checks. Isolate the
parameters setting and permissions checking.
This commit is contained in:
parent
d4227e75cd
commit
db98798134
@ -1,3 +1,8 @@
|
|||||||
|
2008-07-27 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
|
* src/groupmems.c: Reduce the number of checks. Isolate the
|
||||||
|
parameters setting and permissions checking.
|
||||||
|
|
||||||
2008-07-27 Nicolas François <nicolas.francois@centraliens.net>
|
2008-07-27 Nicolas François <nicolas.francois@centraliens.net>
|
||||||
|
|
||||||
* src/groupmems.c: Add functions process_flags() and check_perms()
|
* src/groupmems.c: Add functions process_flags() and check_perms()
|
||||||
|
@ -228,16 +228,19 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
process_flags (argc, argv);
|
process_flags (argc, argv);
|
||||||
|
|
||||||
if (!isroot () && NULL != thisgroup) {
|
if (NULL == thisgroup) {
|
||||||
fputs (_("Only root can add members to different groups\n"),
|
name = whoami ();
|
||||||
stderr);
|
if (NULL == name) {
|
||||||
exit (EXIT_NOT_ROOT);
|
fprintf (stderr, _("%s: your groupname does not match your username\n"), Prog);
|
||||||
} else if (isroot () && NULL != thisgroup) {
|
|
||||||
name = thisgroup;
|
|
||||||
} else if (NULL == (name = whoami ())) {
|
|
||||||
fputs (_("Not primary owner of current group\n"), stderr);
|
|
||||||
exit (EXIT_NOT_PRIMARY);
|
exit (EXIT_NOT_PRIMARY);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
name = thisgroup;
|
||||||
|
if (!isroot ()) {
|
||||||
|
fprintf (stderr, _("%s: only root can use the -g/--group option\n"), Prog);
|
||||||
|
exit (EXIT_NOT_ROOT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
check_perms ();
|
check_perms ();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user