aboutsummaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-02-15 15:17:23 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-02-15 15:17:23 +0000
commit753f42ab8d50f92e36d3b06a2a47630bed69f257 (patch)
treef79be7056a4e5ddc0066bffd5daab406d961175e /loginutils
parent0e6f661e23d358cca104c24f8438d0ec64df32f1 (diff)
downloadbusybox-w32-753f42ab8d50f92e36d3b06a2a47630bed69f257.tar.gz
busybox-w32-753f42ab8d50f92e36d3b06a2a47630bed69f257.tar.bz2
busybox-w32-753f42ab8d50f92e36d3b06a2a47630bed69f257.zip
adduser: optional support for long options. +110 bytes.
closes bug 2134.
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/Config.in7
-rw-r--r--loginutils/adduser.c17
2 files changed, 24 insertions, 0 deletions
diff --git a/loginutils/Config.in b/loginutils/Config.in
index 6f2702e95..6ee154c61 100644
--- a/loginutils/Config.in
+++ b/loginutils/Config.in
@@ -88,6 +88,13 @@ config ADDUSER
88 help 88 help
89 Utility for creating a new user account. 89 Utility for creating a new user account.
90 90
91config FEATURE_ADDUSER_LONG_OPTIONS
92 bool "Enable long options"
93 default n
94 depends on ADDUSER && GETOPT_LONG
95 help
96 Support long options for the adduser applet.
97
91config DELUSER 98config DELUSER
92 bool "deluser" 99 bool "deluser"
93 default n 100 default n
diff --git a/loginutils/adduser.c b/loginutils/adduser.c
index a859f4b0c..7b5283e99 100644
--- a/loginutils/adduser.c
+++ b/loginutils/adduser.c
@@ -66,6 +66,19 @@ static void passwd_wrapper(const char *login)
66 bb_error_msg_and_die("cannot execute %s, you must set password manually", prog); 66 bb_error_msg_and_die("cannot execute %s, you must set password manually", prog);
67} 67}
68 68
69#if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS
70static const char adduser_longopts[] ALIGN1 =
71 "home\0" Required_argument "h"
72 "gecos\0" Required_argument "g"
73 "shell\0" Required_argument "s"
74 "ingroup\0" Required_argument "G"
75 "disabled-password\0" No_argument "D"
76 "empty-password\0" No_argument "D"
77 "system\0" No_argument "S"
78 "no-create-home\0" No_argument "H"
79 ;
80#endif
81
69/* 82/*
70 * adduser will take a login_name as its first parameter. 83 * adduser will take a login_name as its first parameter.
71 * home, shell, gecos: 84 * home, shell, gecos:
@@ -78,6 +91,10 @@ int adduser_main(int argc, char **argv)
78 const char *usegroup = NULL; 91 const char *usegroup = NULL;
79 FILE *file; 92 FILE *file;
80 93
94#if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS
95 applet_long_options = adduser_longopts;
96#endif
97
81 /* got root? */ 98 /* got root? */
82 if (geteuid()) { 99 if (geteuid()) {
83 bb_error_msg_and_die(bb_msg_perm_denied_are_you_root); 100 bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);