diff options
author | Bernhard Reutner-Fischer | 2015-05-25 23:25:19 +0200 |
---|---|---|
committer | Denys Vlasenko | 2015-09-21 21:09:18 +0200 |
commit | 65db14ec50305236b9750b898fd1b6d8a97b7a52 (patch) | |
tree | a9e669dbfc556ebc78450f6a2342f8058c4273c7 /loginutils | |
parent | 2beb52499eccaee26e7e5c6fc10df73f6802efd9 (diff) | |
download | busybox-65db14ec50305236b9750b898fd1b6d8a97b7a52.zip busybox-65db14ec50305236b9750b898fd1b6d8a97b7a52.tar.gz |
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>
Diffstat (limited to 'loginutils')
-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 568a301..6da2930 100644 --- a/loginutils/adduser.c +++ b/loginutils/adduser.c @@ -20,6 +20,7 @@ //usage: "\n -D Don't assign a password" //usage: "\n -H Don't create home directory" //usage: "\n -u UID User id" +//usage: "\n -k SKEL directory (/etc/skel)" #include "libbb.h" @@ -39,6 +40,7 @@ #define OPT_SYSTEM_ACCOUNT (1 << 5) #define OPT_DONT_MAKE_HOME (1 << 6) #define OPT_UID (1 << 7) +#define OPT_SKEL (1 << 8) /* remix */ /* recoded such that the uid may be passed in *p */ @@ -134,6 +136,7 @@ static const char adduser_longopts[] ALIGN1 = "system\0" No_argument "S" "no-create-home\0" No_argument "H" "uid\0" Required_argument "u" + "skel\0" Required_argument "k" ; #endif @@ -150,6 +153,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) char *p; unsigned opts; char *uid; + const char *skel = "/etc/skel"; #if ENABLE_FEATURE_ADDUSER_LONG_OPTIONS applet_long_options = adduser_longopts; @@ -168,7 +172,7 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) /* at least one and at most two non-option args */ /* disable interactive passwd for system accounts */ opt_complementary = "-1:?2:SD"; - opts = getopt32(argv, "h:g:s:G:DSHu:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &uid); + opts = getopt32(argv, "h:g:s:G:DSHu:k:", &pw.pw_dir, &pw.pw_gecos, &pw.pw_shell, &usegroup, &uid, &skel); if (opts & OPT_UID) pw.pw_uid = xatou_range(uid, 0, CONFIG_LAST_ID); @@ -250,8 +254,9 @@ int adduser_main(int argc UNUSED_PARAM, char **argv) NULL }; /* Be silent on any errors (like: no /etc/skel) */ - logmode = LOGMODE_NONE; - copy_file("/etc/skel", pw.pw_dir, FILEUTILS_RECUR); + if (!(opts & OPT_SKEL)) + logmode = LOGMODE_NONE; + copy_file(skel, pw.pw_dir, FILEUTILS_RECUR); logmode = LOGMODE_STDIO; chown_main(4, (char**)args); } |