diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2015-05-25 23:25:19 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-09-21 21:09:18 +0200 |
commit | 65db14ec50305236b9750b898fd1b6d8a97b7a52 (patch) | |
tree | a9e669dbfc556ebc78450f6a2342f8058c4273c7 | |
parent | 2beb52499eccaee26e7e5c6fc10df73f6802efd9 (diff) | |
download | busybox-w32-65db14ec50305236b9750b898fd1b6d8a97b7a52.tar.gz busybox-w32-65db14ec50305236b9750b898fd1b6d8a97b7a52.tar.bz2 busybox-w32-65db14ec50305236b9750b898fd1b6d8a97b7a52.zip |
adduser: Add -k /path/to/skel
function old new delta
.rodata 157069 157133 +64
adduser_main 921 936 +15
adduser_longopts 103 110 +7
packed_usage 30230 30236 +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/0 up/down: 92/0) Total: 92 bytes
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | loginutils/adduser.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/loginutils/adduser.c b/loginutils/adduser.c index 568a3018e..6da29304c 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c | |||
@@ -20,6 +20,7 @@ | |||
20 | //usage: "\n -D Don't assign a password" | 20 | //usage: "\n -D Don't assign a password" |
21 | //usage: "\n -H Don't create home directory" | 21 | //usage: "\n -H Don't create home directory" |
22 | //usage: "\n -u UID User id" | 22 | //usage: "\n -u UID User id" |
23 | //usage: "\n -k SKEL directory (/etc/skel)" | ||
23 | 24 | ||
24 | #include "libbb.h" | 25 | #include "libbb.h" |
25 | 26 | ||
@@ -39,6 +40,7 @@ | |||
39 | #define OPT_SYSTEM_ACCOUNT (1 << 5) | 40 | #define OPT_SYSTEM_ACCOUNT (1 << 5) |
40 | #define OPT_DONT_MAKE_HOME (1 << 6) | 41 | #define OPT_DONT_MAKE_HOME (1 << 6) |
41 | #define OPT_UID (1 << 7) | 42 | #define OPT_UID (1 << 7) |
43 | #define OPT_SKEL (1 << 8) | ||
42 | 44 | ||
43 | /* remix */ | 45 | /* remix */ |
44 | /* recoded such that the uid may be passed in *p */ | 46 | /* recoded such that the uid may be passed in *p */ |
@@ -134,6 +136,7 @@ static const char adduser_longopts[] ALIGN1 = | |||
134 | "system\0" No_argument "S" | 136 | "system\0" No_argument "S" |
135 | "no-create-home\0" No_argument "H" | 137 | "no-create-home\0" No_argument "H" |
136 | "uid\0" Required_argument "u" | 138 | "uid\0" Required_argument "u" |
139 | "skel\0" Required_argument "k" | ||
137 | ; | 140 | ; |
138 | #endif | 141 | #endif |
139 | 142 | ||
@@ -150,6 +153,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) | |||
150 | char *p; | 153 | char *p; |
151 | unsigned opts; | 154 | unsigned opts; |
152 | char *uid; | 155 | char *uid; |
156 | const char *skel = "/etc/skel"; | ||
153 | 157 | ||
154 | #if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS | 158 | #if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS |
155 | applet_long_options = adduser_longopts; | 159 | applet_long_options = adduser_longopts; |
@@ -168,7 +172,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) | |||
168 | /* at least one and at most two non-option args */ | 172 | /* at least one and at most two non-option args */ |
169 | /* disable interactive passwd for system accounts */ | 173 | /* disable interactive passwd for system accounts */ |
170 | opt_complementary = "-1:?2:SD"; | 174 | opt_complementary = "-1:?2:SD"; |
171 | opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &uid); | 175 | opts = getopt32(argv, "h:g:s:G:DSHu:k:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &uid, &skel); |
172 | if (opts & OPT_UID) | 176 | if (opts & OPT_UID) |
173 | pw.pw_uid = xatou_range(uid, 0, CONFIG_LAST_ID); | 177 | pw.pw_uid = xatou_range(uid, 0, CONFIG_LAST_ID); |
174 | 178 | ||
@@ -250,8 +254,9 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) | |||
250 | NULL | 254 | NULL |
251 | }; | 255 | }; |
252 | /* Be silent on any errors (like: no /etc/skel) */ | 256 | /* Be silent on any errors (like: no /etc/skel) */ |
253 | logmode = LOGMODE_NONE; | 257 | if (!(opts & OPT_SKEL)) |
254 | copy_file("/etc/skel", pw.pw_dir, FILEUTILS_RECUR); | 258 | logmode = LOGMODE_NONE; |
259 | copy_file(skel, pw.pw_dir, FILEUTILS_RECUR); | ||
255 | logmode = LOGMODE_STDIO; | 260 | logmode = LOGMODE_STDIO; |
256 | chown_main(4, (char**)args); | 261 | chown_main(4, (char**)args); |
257 | } | 262 | } |