* src/groupmems.c: Reduce the number of checks. Isolate the

parameters setting and permissions checking.
This commit is contained in:
nekral-guest 2008-07-27 01:16:13 +00:00
parent d4227e75cd
commit db98798134
2 changed files with 16 additions and 8 deletions

View File

@ -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>
* src/groupmems.c: Add functions process_flags() and check_perms()

View File

@ -228,16 +228,19 @@ int main (int argc, char **argv)
process_flags (argc, argv);
if (!isroot () && NULL != thisgroup) {
fputs (_("Only root can add members to different groups\n"),
stderr);
exit (EXIT_NOT_ROOT);
} else if (isroot () && NULL != thisgroup) {
name = thisgroup;
} else if (NULL == (name = whoami ())) {
fputs (_("Not primary owner of current group\n"), stderr);
if (NULL == thisgroup) {
name = whoami ();
if (NULL == name) {
fprintf (stderr, _("%s: your groupname does not match your username\n"), Prog);
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 ();