X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=loginutils%2Fchpasswd.c;h=6c4296faa0ff916e48bbe59a9b1adf1f7f6a6ec8;hb=b8709032a3fb57b3ec536bdf9b92b526ed63b995;hp=101920c03e2c94ea8dc0bf9e144f98a190dd0e31;hpb=0ef64bdb40c54681e8dd5ab8df42ac88e4ab1d4a;p=oweals%2Fbusybox.git diff --git a/loginutils/chpasswd.c b/loginutils/chpasswd.c index 101920c03..6c4296faa 100644 --- a/loginutils/chpasswd.c +++ b/loginutils/chpasswd.c @@ -7,6 +7,20 @@ */ #include "libbb.h" +//usage:#define chpasswd_trivial_usage +//usage: IF_LONG_OPTS("[--md5|--encrypted]") IF_NOT_LONG_OPTS("[-m|-e]") +//usage:#define chpasswd_full_usage "\n\n" +//usage: "Read user:password from stdin and update /etc/passwd\n" +//usage: "\nOptions:" +//usage: IF_LONG_OPTS( +//usage: "\n -e,--encrypted Supplied passwords are in encrypted form" +//usage: "\n -m,--md5 Use MD5 encryption instead of DES" +//usage: ) +//usage: IF_NOT_LONG_OPTS( +//usage: "\n -e Supplied passwords are in encrypted form" +//usage: "\n -m Use MD5 encryption instead of DES" +//usage: ) + #if ENABLE_LONG_OPTS static const char chpasswd_longopts[] ALIGN1 = "encrypted\0" No_argument "e" @@ -14,8 +28,8 @@ static const char chpasswd_longopts[] ALIGN1 = ; #endif -#define OPT_ENC 1 -#define OPT_MD5 2 +#define OPT_ENC 1 +#define OPT_MD5 2 int chpasswd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int chpasswd_main(int argc UNUSED_PARAM, char **argv) @@ -53,7 +67,10 @@ int chpasswd_main(int argc UNUSED_PARAM, char **argv) * we try to find & change his passwd in /etc/passwd */ #if ENABLE_FEATURE_SHADOWPASSWDS rc = update_passwd(bb_path_shadow_file, name, pass, NULL); - if (rc == 0) /* no lines updated, no errors detected */ + if (rc > 0) /* password in /etc/shadow was updated */ + pass = (char*)"x"; + if (rc >= 0) + /* 0 = /etc/shadow missing (not an error), >0 = passwd changed in /etc/shadow */ #endif rc = update_passwd(bb_path_passwd_file, name, pass, NULL); /* LOGMODE_BOTH logs to syslog also */