aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--coreutils/mv.c2
-rw-r--r--include/libbb.h8
-rw-r--r--libbb/ask_confirmation.c4
-rw-r--r--libbb/bb_askpass.c6
-rw-r--r--libbb/copy_file.c2
-rw-r--r--libbb/correct_password.c2
-rw-r--r--libbb/remove_file.c6
-rw-r--r--loginutils/cryptpw.c2
-rw-r--r--loginutils/passwd.c10
-rw-r--r--mailutils/mail.c4
-rw-r--r--miscutils/i2c_tools.c2
11 files changed, 24 insertions, 24 deletions
diff --git a/coreutils/mv.c b/coreutils/mv.c
index aeafd1e40..6e11197a1 100644
--- a/coreutils/mv.c
+++ b/coreutils/mv.c
@@ -101,7 +101,7 @@ int mv_main(int argc, char **argv)
101 if (fprintf(stderr, "mv: overwrite '%s'? ", dest) < 0) { 101 if (fprintf(stderr, "mv: overwrite '%s'? ", dest) < 0) {
102 goto RET_1; /* Ouch! fprintf failed! */ 102 goto RET_1; /* Ouch! fprintf failed! */
103 } 103 }
104 if (!bb_ask_confirmation()) { 104 if (!bb_ask_y_confirmation()) {
105 goto RET_0; 105 goto RET_0;
106 } 106 }
107 } 107 }
diff --git a/include/libbb.h b/include/libbb.h
index ad1c7346f..c7e830c09 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -1408,11 +1408,11 @@ extern int set_loop(char **devname, const char *file, unsigned long long offset,
1408#define BB_LO_FLAGS_READ_ONLY 1 1408#define BB_LO_FLAGS_READ_ONLY 1
1409#define BB_LO_FLAGS_AUTOCLEAR 4 1409#define BB_LO_FLAGS_AUTOCLEAR 4
1410 1410
1411/* Like bb_ask below, but asks on stdin with no timeout. */ 1411/* Like bb_ask_noecho below, but asks on stdin with no timeout. */
1412char *bb_ask_stdin(const char * prompt) FAST_FUNC; 1412char *bb_ask_noecho_stdin(const char *prompt) FAST_FUNC;
1413//TODO: pass buf pointer or return allocated buf (avoid statics)? 1413//TODO: pass buf pointer or return allocated buf (avoid statics)?
1414char *bb_ask(const int fd, int timeout, const char * prompt) FAST_FUNC; 1414char *bb_ask_noecho(const int fd, int timeout, const char *prompt) FAST_FUNC;
1415int bb_ask_confirmation(void) FAST_FUNC; 1415int bb_ask_y_confirmation(void) FAST_FUNC;
1416 1416
1417/* Returns -1 if input is invalid. current_mode is a base for e.g. "u+rw" */ 1417/* Returns -1 if input is invalid. current_mode is a base for e.g. "u+rw" */
1418int bb_parse_mode(const char* s, unsigned cur_mode) FAST_FUNC; 1418int bb_parse_mode(const char* s, unsigned cur_mode) FAST_FUNC;
diff --git a/libbb/ask_confirmation.c b/libbb/ask_confirmation.c
index 6fbed89f4..ccd983c29 100644
--- a/libbb/ask_confirmation.c
+++ b/libbb/ask_confirmation.c
@@ -1,6 +1,6 @@
1/* vi: set sw=4 ts=4: */ 1/* vi: set sw=4 ts=4: */
2/* 2/*
3 * bb_ask_confirmation implementation for busybox 3 * bb_ask_y_confirmation implementation for busybox
4 * 4 *
5 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org> 5 * Copyright (C) 2003 Manuel Novoa III <mjn3@codepoet.org>
6 * 6 *
@@ -11,7 +11,7 @@
11/* Read a line from stdin. If the first non-whitespace char is 'y' or 'Y', 11/* Read a line from stdin. If the first non-whitespace char is 'y' or 'Y',
12 * return 1. Otherwise return 0. 12 * return 1. Otherwise return 0.
13 */ 13 */
14int FAST_FUNC bb_ask_confirmation(void) 14int FAST_FUNC bb_ask_y_confirmation(void)
15{ 15{
16 char first = 0; 16 char first = 0;
17 int c; 17 int c;
diff --git a/libbb/bb_askpass.c b/libbb/bb_askpass.c
index 5599c82ef..aadc69108 100644
--- a/libbb/bb_askpass.c
+++ b/libbb/bb_askpass.c
@@ -13,11 +13,11 @@ static void askpass_timeout(int UNUSED_PARAM ignore)
13{ 13{
14} 14}
15 15
16char* FAST_FUNC bb_ask_stdin(const char *prompt) 16char* FAST_FUNC bb_ask_noecho_stdin(const char *prompt)
17{ 17{
18 return bb_ask(STDIN_FILENO, 0, prompt); 18 return bb_ask_noecho(STDIN_FILENO, 0, prompt);
19} 19}
20char* FAST_FUNC bb_ask(const int fd, int timeout, const char *prompt) 20char* FAST_FUNC bb_ask_noecho(const int fd, int timeout, const char *prompt)
21{ 21{
22 /* Was static char[BIGNUM] */ 22 /* Was static char[BIGNUM] */
23 enum { sizeof_passwd = 128 }; 23 enum { sizeof_passwd = 128 };
diff --git a/libbb/copy_file.c b/libbb/copy_file.c
index be9006631..1b8befd65 100644
--- a/libbb/copy_file.c
+++ b/libbb/copy_file.c
@@ -48,7 +48,7 @@ static int ask_and_unlink(const char *dest, int flags)
48 // (No "opening without O_EXCL", no "unlink only if -f") 48 // (No "opening without O_EXCL", no "unlink only if -f")
49 // Or else we will end up having 3 open()s! 49 // Or else we will end up having 3 open()s!
50 fprintf(stderr, "%s: overwrite '%s'? ", applet_name, dest); 50 fprintf(stderr, "%s: overwrite '%s'? ", applet_name, dest);
51 if (!bb_ask_confirmation()) 51 if (!bb_ask_y_confirmation())
52 return 0; /* not allowed to overwrite */ 52 return 0; /* not allowed to overwrite */
53 } 53 }
54 if (unlink(dest) < 0) { 54 if (unlink(dest) < 0) {
diff --git a/libbb/correct_password.c b/libbb/correct_password.c
index a6f7d9b3d..cbe6cb387 100644
--- a/libbb/correct_password.c
+++ b/libbb/correct_password.c
@@ -106,7 +106,7 @@ int FAST_FUNC ask_and_check_password_extended(const struct passwd *pw,
106 if (!pw_pass[0]) /* empty password field? */ 106 if (!pw_pass[0]) /* empty password field? */
107 return CHECKPASS_PW_HAS_EMPTY_PASSWORD; 107 return CHECKPASS_PW_HAS_EMPTY_PASSWORD;
108 108
109 plaintext = bb_ask(STDIN_FILENO, timeout, prompt); 109 plaintext = bb_ask_noecho(STDIN_FILENO, timeout, prompt);
110 if (!plaintext) { 110 if (!plaintext) {
111 /* EOF (such as ^D) or error (such as ^C) or timeout */ 111 /* EOF (such as ^D) or error (such as ^C) or timeout */
112 return -1; 112 return -1;
diff --git a/libbb/remove_file.c b/libbb/remove_file.c
index 8a1324393..074ffae70 100644
--- a/libbb/remove_file.c
+++ b/libbb/remove_file.c
@@ -41,7 +41,7 @@ int FAST_FUNC remove_file(const char *path, int flags)
41 ) { 41 ) {
42 fprintf(stderr, "%s: descend into directory '%s'? ", applet_name, 42 fprintf(stderr, "%s: descend into directory '%s'? ", applet_name,
43 path); 43 path);
44 if (!bb_ask_confirmation()) 44 if (!bb_ask_y_confirmation())
45 return 0; 45 return 0;
46 } 46 }
47 47
@@ -68,7 +68,7 @@ int FAST_FUNC remove_file(const char *path, int flags)
68 68
69 if (flags & FILEUTILS_INTERACTIVE) { 69 if (flags & FILEUTILS_INTERACTIVE) {
70 fprintf(stderr, "%s: remove directory '%s'? ", applet_name, path); 70 fprintf(stderr, "%s: remove directory '%s'? ", applet_name, path);
71 if (!bb_ask_confirmation()) 71 if (!bb_ask_y_confirmation())
72 return status; 72 return status;
73 } 73 }
74 74
@@ -92,7 +92,7 @@ int FAST_FUNC remove_file(const char *path, int flags)
92 || (flags & FILEUTILS_INTERACTIVE) 92 || (flags & FILEUTILS_INTERACTIVE)
93 ) { 93 ) {
94 fprintf(stderr, "%s: remove '%s'? ", applet_name, path); 94 fprintf(stderr, "%s: remove '%s'? ", applet_name, path);
95 if (!bb_ask_confirmation()) 95 if (!bb_ask_y_confirmation())
96 return 0; 96 return 0;
97 } 97 }
98 98
diff --git a/loginutils/cryptpw.c b/loginutils/cryptpw.c
index 76138a61f..3ca7eda4a 100644
--- a/loginutils/cryptpw.c
+++ b/loginutils/cryptpw.c
@@ -134,7 +134,7 @@ int cryptpw_main(int argc UNUSED_PARAM, char **argv)
134 /* Only mkpasswd, and only from tty, prompts. 134 /* Only mkpasswd, and only from tty, prompts.
135 * Otherwise it is a plain read. */ 135 * Otherwise it is a plain read. */
136 password = (ENABLE_MKPASSWD && isatty(STDIN_FILENO) && applet_name[0] == 'm') 136 password = (ENABLE_MKPASSWD && isatty(STDIN_FILENO) && applet_name[0] == 'm')
137 ? bb_ask_stdin("Password: ") 137 ? bb_ask_noecho_stdin("Password: ")
138 : xmalloc_fgetline(stdin) 138 : xmalloc_fgetline(stdin)
139 ; 139 ;
140 /* may still be NULL on EOF/error */ 140 /* may still be NULL on EOF/error */
diff --git a/loginutils/passwd.c b/loginutils/passwd.c
index 3e1ef9abf..02303b575 100644
--- a/loginutils/passwd.c
+++ b/loginutils/passwd.c
@@ -52,7 +52,7 @@ static char* new_password(const struct passwd *pw, uid_t myuid, const char *algo
52 if (myuid != 0 && pw->pw_passwd[0]) { 52 if (myuid != 0 && pw->pw_passwd[0]) {
53 char *encrypted; 53 char *encrypted;
54 54
55 orig = bb_ask_stdin("Old password: "); /* returns ptr to static */ 55 orig = bb_ask_noecho_stdin("Old password: "); /* returns ptr to static */
56 if (!orig) 56 if (!orig)
57 goto err_ret; 57 goto err_ret;
58 encrypted = pw_encrypt(orig, pw->pw_passwd, 1); /* returns malloced str */ 58 encrypted = pw_encrypt(orig, pw->pw_passwd, 1); /* returns malloced str */
@@ -65,11 +65,11 @@ static char* new_password(const struct passwd *pw, uid_t myuid, const char *algo
65 if (ENABLE_FEATURE_CLEAN_UP) 65 if (ENABLE_FEATURE_CLEAN_UP)
66 free(encrypted); 66 free(encrypted);
67 } 67 }
68 orig = xstrdup(orig); /* or else bb_ask_stdin() will destroy it */ 68 orig = xstrdup(orig); /* or else bb_ask_noecho_stdin() will destroy it */
69 newp = bb_ask_stdin("New password: "); /* returns ptr to static */ 69 newp = bb_ask_noecho_stdin("New password: "); /* returns ptr to static */
70 if (!newp) 70 if (!newp)
71 goto err_ret; 71 goto err_ret;
72 newp = xstrdup(newp); /* we are going to bb_ask_stdin() again, so save it */ 72 newp = xstrdup(newp); /* we are going to bb_ask_noecho_stdin() again, so save it */
73 if (ENABLE_FEATURE_PASSWD_WEAK_CHECK 73 if (ENABLE_FEATURE_PASSWD_WEAK_CHECK
74 && obscure(orig, newp, pw) 74 && obscure(orig, newp, pw)
75 && myuid != 0 75 && myuid != 0
@@ -77,7 +77,7 @@ static char* new_password(const struct passwd *pw, uid_t myuid, const char *algo
77 goto err_ret; /* non-root is not allowed to have weak passwd */ 77 goto err_ret; /* non-root is not allowed to have weak passwd */
78 } 78 }
79 79
80 cp = bb_ask_stdin("Retype password: "); 80 cp = bb_ask_noecho_stdin("Retype password: ");
81 if (!cp) 81 if (!cp)
82 goto err_ret; 82 goto err_ret;
83 if (strcmp(cp, newp) != 0) { 83 if (strcmp(cp, newp) != 0) {
diff --git a/mailutils/mail.c b/mailutils/mail.c
index eceb89071..0fc615a7f 100644
--- a/mailutils/mail.c
+++ b/mailutils/mail.c
@@ -163,8 +163,8 @@ void FAST_FUNC encode_base64(char *fname, const char *text, const char *eol)
163void FAST_FUNC get_cred_or_die(int fd) 163void FAST_FUNC get_cred_or_die(int fd)
164{ 164{
165 if (isatty(fd)) { 165 if (isatty(fd)) {
166 G.user = xstrdup(bb_ask(fd, /* timeout: */ 0, "User: ")); 166 G.user = xstrdup(bb_ask_noecho(fd, /* timeout: */ 0, "User: "));
167 G.pass = xstrdup(bb_ask(fd, /* timeout: */ 0, "Password: ")); 167 G.pass = xstrdup(bb_ask_noecho(fd, /* timeout: */ 0, "Password: "));
168 } else { 168 } else {
169 G.user = xmalloc_reads(fd, /* maxsize: */ NULL); 169 G.user = xmalloc_reads(fd, /* maxsize: */ NULL);
170 G.pass = xmalloc_reads(fd, /* maxsize: */ NULL); 170 G.pass = xmalloc_reads(fd, /* maxsize: */ NULL);
diff --git a/miscutils/i2c_tools.c b/miscutils/i2c_tools.c
index 82f9842bd..8b201c0b1 100644
--- a/miscutils/i2c_tools.c
+++ b/miscutils/i2c_tools.c
@@ -422,7 +422,7 @@ static void confirm_or_abort(void)
422{ 422{
423 fprintf(stderr, "Continue? [y/N] "); 423 fprintf(stderr, "Continue? [y/N] ");
424 fflush_all(); 424 fflush_all();
425 if (!bb_ask_confirmation()) 425 if (!bb_ask_y_confirmation())
426 bb_error_msg_and_die("aborting"); 426 bb_error_msg_and_die("aborting");
427} 427}
428 428