summaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/addgroup.c7
-rw-r--r--loginutils/adduser.c13
-rw-r--r--loginutils/chpasswd.c6
-rw-r--r--loginutils/cryptpw.c7
-rw-r--r--loginutils/getty.c5
-rw-r--r--loginutils/vlock.c3
6 files changed, 23 insertions, 18 deletions
diff --git a/loginutils/addgroup.c b/loginutils/addgroup.c
index 5a2b043..adef232 100644
--- a/loginutils/addgroup.c
+++ b/loginutils/addgroup.c
@@ -152,11 +152,12 @@ int addgroup_main(int argc UNUSED_PARAM, char **argv)
}
/* Syntax:
* addgroup group
- * addgroup -g num group
+ * addgroup --gid num group
* addgroup user group
* Check for min, max and missing args */
- opt_complementary = "-1:?2";
- opts = getopt32long(argv, "g:S", addgroup_longopts, &gid);
+ opts = getopt32long(argv, "^" "g:S" "\0" "-1:?2", addgroup_longopts,
+ &gid
+ );
/* move past the commandline options */
argv += optind;
//argc -= optind;
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index 8b92df9..b2b5be5 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -201,12 +201,15 @@ int adduser_main(int argc UNUSED_PARAM, char **argv)
pw.pw_shell = (char *)get_shell_name();
pw.pw_dir = NULL;
- /* at least one and at most two non-option args */
- /* disable interactive passwd for system accounts */
- opt_complementary = "-1:?2:SD";
- opts = getopt32long(argv, "h:g:s:G:DSHu:k:", adduser_longopts,
+ opts = getopt32long(argv, "^"
+ "h:g:s:G:DSHu:k:"
+ /* at least one and at most two non-option args */
+ /* disable interactive passwd for system accounts */
+ "\0" "-1:?2:SD",
+ adduser_longopts,
&pw.pw_dir, &pw.pw_gecos, &pw.pw_shell,
- &usegroup, &uid, &skel);
+ &usegroup, &uid, &skel
+ );
if (opts & OPT_UID)
pw.pw_uid = xatou_range(uid, 0, CONFIG_LAST_ID);
diff --git a/loginutils/chpasswd.c b/loginutils/chpasswd.c
index 3c9ed68..652e4f1 100644
--- a/loginutils/chpasswd.c
+++ b/loginutils/chpasswd.c
@@ -61,8 +61,10 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
if (getuid() != 0)
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
- opt_complementary = "m--ec:e--mc:c--em";
- opt = getopt32long(argv, "emc:", chpasswd_longopts, &algo);
+ opt = getopt32long(argv, "^" "emc:" "\0" "m--ec:e--mc:c--em",
+ chpasswd_longopts,
+ &algo
+ );
while ((name = xmalloc_fgetline(stdin)) != NULL) {
char *free_me;
diff --git a/loginutils/cryptpw.c b/loginutils/cryptpw.c
index c10a0c8..76138a6 100644
--- a/loginutils/cryptpw.c
+++ b/loginutils/cryptpw.c
@@ -111,9 +111,10 @@ int cryptpw_main(int argc UNUSED_PARAM, char **argv)
opt_m = CONFIG_FEATURE_DEFAULT_PASSWD_ALGO;
opt_S = NULL;
/* at most two non-option arguments; -P NUM */
- opt_complementary = "?2";
- getopt32long(argv, "sP:+S:m:a:", mkpasswd_longopts,
- &fd, &opt_S, &opt_m, &opt_m);
+ getopt32long(argv, "^" "sP:+S:m:a:" "\0" "?2",
+ mkpasswd_longopts,
+ &fd, &opt_S, &opt_m, &opt_m
+ );
argv += optind;
/* have no idea how to handle -s... */
diff --git a/loginutils/getty.c b/loginutils/getty.c
index fd5116d..23e92bc 100644
--- a/loginutils/getty.c
+++ b/loginutils/getty.c
@@ -131,7 +131,7 @@ struct globals {
//usage: "\n"
//usage: "\nBAUD_RATE of 0 leaves it unchanged"
-static const char opt_string[] ALIGN1 = "I:LH:f:hil:mt:+wn";
+#define OPT_STR "I:LH:f:hil:mt:+wn"
#define F_INITSTRING (1 << 0) /* -I */
#define F_LOCAL (1 << 1) /* -L */
#define F_FAKEHOST (1 << 2) /* -H */
@@ -179,8 +179,7 @@ static void parse_args(char **argv)
char *ts;
int flags;
- opt_complementary = "-2"; /* at least 2 args; -t N */
- flags = getopt32(argv, opt_string,
+ flags = getopt32(argv, "^" OPT_STR "\0" "-2"/* at least 2 args*/,
&G.initstring, &G.fakehost, &G.issue,
&G.login, &G.timeout
);
diff --git a/loginutils/vlock.c b/loginutils/vlock.c
index bf46d08..9e319fe 100644
--- a/loginutils/vlock.c
+++ b/loginutils/vlock.c
@@ -66,8 +66,7 @@ int vlock_main(int argc UNUSED_PARAM, char **argv)
struct passwd *pw;
pw = xgetpwuid(getuid());
- opt_complementary = "=0"; /* no params! */
- getopt32(argv, "a");
+ getopt32(argv, "^" "a" "\0" "=0"/* no args!*/);
/* Ignore some signals so that we don't get killed by them */
bb_signals(0