Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/loginutils/cryptpw.c
- Timestamp:
- Dec 20, 2016, 4:07:32 PM (7 years ago)
- Location:
- branches/3.3
- Files:
-
- 1 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mindi-busybox/loginutils/cryptpw.c
r3232 r3621 10 10 * Licensed under GPLv2, see file LICENSE in this source tree. 11 11 */ 12 //config:config CRYPTPW 13 //config: bool "cryptpw" 14 //config: default y 15 //config: help 16 //config: Encrypts the given password with the crypt(3) libc function 17 //config: using the given salt. 18 //config: 19 //config:config MKPASSWD 20 //config: bool "mkpasswd" 21 //config: default y 22 //config: help 23 //config: Encrypts the given password with the crypt(3) libc function 24 //config: using the given salt. Debian has this utility under mkpasswd 25 //config: name. Busybox provides mkpasswd as an alias for cryptpw. 26 27 //applet:IF_CRYPTPW(APPLET(cryptpw, BB_DIR_USR_BIN, BB_SUID_DROP)) 28 // APPLET_ODDNAME:name main location suid_type help 29 //applet:IF_MKPASSWD(APPLET_ODDNAME(mkpasswd, cryptpw, BB_DIR_USR_BIN, BB_SUID_DROP, cryptpw)) 30 31 //kbuild:lib-$(CONFIG_CRYPTPW) += cryptpw.o 32 //kbuild:lib-$(CONFIG_MKPASSWD) += cryptpw.o 12 33 13 34 //usage:#define cryptpw_trivial_usage … … 15 36 /* We do support -s, we just don't mention it */ 16 37 //usage:#define cryptpw_full_usage "\n\n" 17 //usage: "Crypt PASSWORD using crypt(3)\n"18 //usage: IF_LONG_OPTS(19 //usage: "\n -P,--password-fd=N Read password from fd N"20 /* //usage: "\n -s,--stdin Use stdin; like -P0" */21 //usage: "\n -m,--method=TYPE Encryption method"22 //usage: "\n -S,--salt=SALT"23 //usage: )24 //usage: IF_NOT_LONG_OPTS(25 //usage: "\n -P N Read password from fd N"26 /* //usage: "\n -s Use stdin; like -P0" */27 //usage: "\n -m TYPE Encryption method TYPE"28 //usage: "\n -S SALT"29 //usage: )30 31 /* mkpasswd is an alias to cryptpw */32 //usage:#define mkpasswd_trivial_usage33 //usage: "[OPTIONS] [PASSWORD] [SALT]"34 /* We do support -s, we just don't mention it */35 //usage:#define mkpasswd_full_usage "\n\n"36 38 //usage: "Crypt PASSWORD using crypt(3)\n" 37 39 //usage: IF_LONG_OPTS( … … 93 95 char salt[MAX_PW_SALT_LEN]; 94 96 char *salt_ptr; 97 char *password; 95 98 const char *opt_m, *opt_S; 96 99 int fd; … … 124 127 xmove_fd(fd, STDIN_FILENO); 125 128 126 p uts(pw_encrypt(127 argv[0] ? argv[0] : (128 129 130 (isatty(STDIN_FILENO) && applet_name[0] == 'm')129 password = argv[0]; 130 if (!password) { 131 /* Only mkpasswd, and only from tty, prompts. 132 * Otherwise it is a plain read. */ 133 password = (ENABLE_MKPASSWD && isatty(STDIN_FILENO) && applet_name[0] == 'm') 131 134 ? bb_ask_stdin("Password: ") 132 135 : xmalloc_fgetline(stdin) 133 ), 134 salt, 1)); 136 ; 137 /* may still be NULL on EOF/error */ 138 } 139 140 if (password) 141 puts(pw_encrypt(password, salt, 1)); 135 142 136 143 return EXIT_SUCCESS;
Note:
See TracChangeset
for help on using the changeset viewer.