diff --git a/ChangeLog b/ChangeLog index 33bb208f..60d61100 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-08-20 Nicolas François + + * NEWS, src/gpasswd.c: Use getopt_long instead of getopt. Added + support for long options --add (-a), --delete (-d), + --remove-password (-r), --restrict (-R), --administrators (-A), + and --members (-M) + * man/gpasswd.1.xml: Document the new long options. + * src/gpasswd.c: The sgrp structure is only used if SHADOWGRP is + defined. + 2008-08-18 Nicolas François * src/grpck.c: Added function fail_exit(). Check failure to unlock diff --git a/NEWS b/NEWS index 4b4f51fe..16af8c04 100644 --- a/NEWS +++ b/NEWS @@ -6,6 +6,10 @@ shadow-4.1.2.1 -> shadow-4.1.3 UNRELEASED - packaging * Added support for OpenPAM. +- gpasswd + * Added support for long options --add (-a), --delete (-d), + --remove-password (-r), --restrict (-R), --administrators (-A), and + --members (-M). - groupmems * Check if user exist before they are added to groups. * Avoid segfault in case the specified group does not exist in /etc/group. diff --git a/man/gpasswd.1.xml b/man/gpasswd.1.xml index b57312e5..819ee1eb 100644 --- a/man/gpasswd.1.xml +++ b/man/gpasswd.1.xml @@ -91,7 +91,7 @@ - user + , user @@ -104,7 +104,7 @@ - user + , user @@ -117,7 +117,7 @@ - + , @@ -132,7 +132,7 @@ - + , @@ -147,7 +147,7 @@ - user,... + , user,... @@ -159,7 +159,7 @@ - user,... + , user,... diff --git a/src/gpasswd.c b/src/gpasswd.c index ba11e7b1..9e1edb47 100644 --- a/src/gpasswd.c +++ b/src/gpasswd.c @@ -36,6 +36,7 @@ #include #include +#include #include #include #include @@ -244,8 +245,18 @@ static void failure (void) static void process_flags (int argc, char **argv) { int flag; + int option_index = 0; + static struct option long_options[] = { + {"add", required_argument, NULL, 'a'}, + {"delete", required_argument, NULL, 'd'}, + {"remove-password", no_argument, NULL, 'r'}, + {"restrict", no_argument, NULL, 'R'}, + {"administrators", required_argument, NULL, 'A'}, + {"members", required_argument, NULL, 'M'}, + {NULL, 0, NULL, '\0'} + }; - while ((flag = getopt (argc, argv, "a:A:d:gM:rR")) != EOF) { + while ((flag = getopt_long (argc, argv, "a:A:d:gM:rR", long_options, &option_index)) != -1) { switch (flag) { case 'a': /* add a user */ user = optarg; @@ -605,7 +616,9 @@ static void get_group (struct group *gr) #endif { struct group const*tmpgr = NULL; +#ifdef SHADOWGRP struct sgrp const*tmpsg = NULL; +#endif if (gr_open (O_RDONLY) == 0) { fprintf (stderr, _("%s: cannot open %s\n"), Prog, gr_dbname ());