diff --git a/ChangeLog b/ChangeLog index 912df94c..191ed849 100644 --- a/ChangeLog +++ b/ChangeLog @@ -22,6 +22,8 @@ * src/groupadd.c: Avoid implicit brackets. * src/groupadd.c: Split the processing and checking of options out of main() (process_flags). + * src/groupadd.c: New function check_flags(). Split the validation of + options and arguments out of process_flags. * src/groupadd.c: Add the parameters' names in the prototypes. 2007-12-27 Nicolas François diff --git a/src/groupadd.c b/src/groupadd.c index d28a22b9..fddba80f 100644 --- a/src/groupadd.c +++ b/src/groupadd.c @@ -91,6 +91,7 @@ static void open_files (void); static void fail_exit (int code); static gid_t get_gid (const char *gidstr); static void process_flags (int argc, char **argv); +static void check_flags (void); static void check_perms (void); /* @@ -434,16 +435,21 @@ static void process_flags (int argc, char **argv) /* * Check the flags consistency */ - if (oflg && !gflg) { - usage (); - } - if (optind != argc - 1) { usage (); } - group_name = argv[optind]; + check_flags (); +} + +static void check_flags (void) +{ + /* -o does not make sense without -g */ + if (oflg && !gflg) { + usage (); + } + check_new_name (); /*