aboutsummaryrefslogtreecommitdiff
path: root/loginutils
diff options
context:
space:
mode:
authorGravatar Jon Kolb <kolbyjack@gmail.com>2018-07-31 21:30:24 -0400
committerGravatar Denys Vlasenko <vda.linux@googlemail.com>2018-08-01 15:33:41 +0200
commit4e30c67fa0eb0ddd9f68f783ee44806c4495cd82 (patch)
tree809513221af356e051569d67a48dcfc32699f1ee /loginutils
parent02cf149ed71b17326bdca69fcae8224d043fc7bb (diff)
downloadbusybox-4e30c67fa0eb0ddd9f68f783ee44806c4495cd82.tar.gz
busybox-4e30c67fa0eb0ddd9f68f783ee44806c4495cd82.tar.bz2
Add chroot support to chpasswd
function old new delta .rodata 170689 170724 +35 packed_usage 32850 32876 +26 chpasswd_main 411 436 +25 chpasswd_longopts 34 41 +7 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 4/0 up/down: 93/0) Total: 93 bytes Signed-off-by: Jon Kolb <kolbyjack@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'loginutils')
-rw-r--r--loginutils/chpasswd.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/loginutils/chpasswd.c b/loginutils/chpasswd.c
index 652e4f127..4b3602e7a 100644
--- a/loginutils/chpasswd.c
+++ b/loginutils/chpasswd.c
@@ -24,18 +24,20 @@
//kbuild:lib-$(CONFIG_CHPASSWD) += chpasswd.o
//usage:#define chpasswd_trivial_usage
-//usage: IF_LONG_OPTS("[--md5|--encrypted|--crypt-method]") IF_NOT_LONG_OPTS("[-m|-e|-c]")
+//usage: IF_LONG_OPTS("[--md5|--encrypted|--crypt-method|--root]") IF_NOT_LONG_OPTS("[-m|-e|-c|-R]")
//usage:#define chpasswd_full_usage "\n\n"
//usage: "Read user:password from stdin and update /etc/passwd\n"
//usage: IF_LONG_OPTS(
//usage: "\n -e,--encrypted Supplied passwords are in encrypted form"
-//usage: "\n -m,--md5 Eencrypt using md5, not des"
+//usage: "\n -m,--md5 Encrypt using md5, not des"
//usage: "\n -c,--crypt-method ALG "CRYPT_METHODS_HELP_STR
+//usage: "\n -R,--root DIR Directory to chroot into"
//usage: )
//usage: IF_NOT_LONG_OPTS(
//usage: "\n -e Supplied passwords are in encrypted form"
-//usage: "\n -m Eencrypt using md5, not des"
+//usage: "\n -m Encrypt using md5, not des"
//usage: "\n -c ALG "CRYPT_METHODS_HELP_STR
+//usage: "\n -R DIR Directory to chroot into"
//usage: )
#include "libbb.h"
@@ -45,6 +47,7 @@ static const char chpasswd_longopts[] ALIGN1 =
"encrypted\0" No_argument "e"
"md5\0" No_argument "m"
"crypt-method\0" Required_argument "c"
+ "root\0" Required_argument "R"
;
#endif
@@ -56,16 +59,21 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv)
{
char *name;
const char *algo = CONFIG_FEATURE_DEFAULT_PASSWD_ALGO;
+ const char *root = NULL;
int opt;
if (getuid() != 0)
bb_error_msg_and_die(bb_msg_perm_denied_are_you_root);
- opt = getopt32long(argv, "^" "emc:" "\0" "m--ec:e--mc:c--em",
+ opt = getopt32long(argv, "^" "emc:R:" "\0" "m--ec:e--mc:c--em",
chpasswd_longopts,
- &algo
+ &algo, &root
);
+ if (root) {
+ xchroot(root);
+ }
+
while ((name = xmalloc_fgetline(stdin)) != NULL) {
char *free_me;
char *pass;