From fb96d3f84d0e1ee8f987a92eb4ea973b8c20a9c2 Mon Sep 17 00:00:00 2001 From: Masatake YAMATO Date: Wed, 20 Jul 2022 10:43:02 +0900 Subject: [PATCH] useradd: make the option specstr passed to getopt_long extensible It was hard to extend the option specification string passed to getopt_long as the third argument. The origian code had a branch with WITH_SELINUX ifdef condition. If one wants to add one more option char with another ifdef condition like ENABLE_SUBIDS to the spec, the one must enumerate the specs for all combinations of the conditions: * WITH_SELINUX && ENABLE_SUBIDS * WITH_SELINUX && !ENABLE_SUBIDS * !WITH_SELINUX && ENABLE_SUBIDS * !WITH_SELINUX && !ENABLE_SUBIDS With this change, you can append an option char to the spec. Signed-off-by: Masatake YAMATO --- src/useradd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/useradd.c b/src/useradd.c index 9e99892b..b999e0c4 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -1218,11 +1218,11 @@ static void process_flags (int argc, char **argv) {NULL, 0, NULL, '\0'} }; while ((c = getopt_long (argc, argv, + "b:c:d:De:f:g:G:hk:K:lmMNop:rR:P:s:u:U" #ifdef WITH_SELINUX - "b:c:d:De:f:g:G:hk:K:lmMNop:rR:P:s:u:UZ:", -#else /* !WITH_SELINUX */ - "b:c:d:De:f:g:G:hk:K:lmMNop:rR:P:s:u:U", -#endif /* !WITH_SELINUX */ + "Z:" +#endif /* WITH_SELINUX */ + "", long_options, NULL)) != -1) { switch (c) { case 'b':