Changeset 2725 in MondoRescue for branches/2.2.9/mindi-busybox/loginutils/chpasswd.c
- Timestamp:
- Feb 25, 2011, 9:26:54 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mindi-busybox/loginutils/chpasswd.c
r1765 r2725 4 4 * 5 5 * Written for SLIND (from passwd.c) by Alexander Shishkin <virtuoso@slind.org> 6 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.6 * Licensed under GPLv2 or later, see file LICENSE in this source tree. 7 7 */ 8 9 8 #include "libbb.h" 10 9 11 #if ENABLE_GETOPT_LONG 12 #include <getopt.h> 13 10 #if ENABLE_LONG_OPTS 14 11 static const char chpasswd_longopts[] ALIGN1 = 15 12 "encrypted\0" No_argument "e" … … 18 15 #endif 19 16 20 #define OPT_ENC 21 #define OPT_MD5 17 #define OPT_ENC 1 18 #define OPT_MD5 2 22 19 23 int chpasswd_main(int argc, char **argv) ;24 int chpasswd_main(int argc , char **argv)20 int chpasswd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 21 int chpasswd_main(int argc UNUSED_PARAM, char **argv) 25 22 { 26 23 char *name, *pass; … … 33 30 34 31 opt_complementary = "m--e:e--m"; 35 USE_GETOPT_LONG(applet_long_options = chpasswd_longopts;)32 IF_LONG_OPTS(applet_long_options = chpasswd_longopts;) 36 33 opt = getopt32(argv, "em"); 37 34 38 while ((name = xmalloc_ getline(stdin)) != NULL) {35 while ((name = xmalloc_fgetline(stdin)) != NULL) { 39 36 pass = strchr(name, ':'); 40 37 if (!pass) … … 50 47 rnd = crypt_make_salt(salt + 3, 4, rnd); 51 48 } 52 pass = pw_encrypt(pass, salt );49 pass = pw_encrypt(pass, salt, 0); 53 50 } 54 51 … … 56 53 * we try to find & change his passwd in /etc/passwd */ 57 54 #if ENABLE_FEATURE_SHADOWPASSWDS 58 rc = update_passwd(bb_path_shadow_file, name, pass );55 rc = update_passwd(bb_path_shadow_file, name, pass, NULL); 59 56 if (rc == 0) /* no lines updated, no errors detected */ 60 57 #endif 61 rc = update_passwd(bb_path_passwd_file, name, pass );58 rc = update_passwd(bb_path_passwd_file, name, pass, NULL); 62 59 /* LOGMODE_BOTH logs to syslog also */ 63 60 logmode = LOGMODE_BOTH; … … 68 65 logmode = LOGMODE_STDIO; 69 66 free(name); 67 if (!(opt & OPT_ENC)) 68 free(pass); 70 69 } 71 72 return 0; 70 return EXIT_SUCCESS; 73 71 }
Note:
See TracChangeset
for help on using the changeset viewer.