From 77cb6b99a436c20bb171e6cdad7b8b8b5ce3692c Mon Sep 17 00:00:00 2001 From: Denys Vlasenko Date: Sat, 7 Apr 2018 15:08:12 +0200 Subject: libbb: rename bb_ask -> bb_ask_noecho, bb_ask_confirmation -> bb_ask_y_confirmation Signed-off-by: Denys Vlasenko --- coreutils/mv.c | 2 +- include/libbb.h | 8 ++++---- libbb/ask_confirmation.c | 4 ++-- libbb/bb_askpass.c | 6 +++--- libbb/copy_file.c | 2 +- libbb/correct_password.c | 2 +- libbb/remove_file.c | 6 +++--- loginutils/cryptpw.c | 2 +- loginutils/passwd.c | 10 +++++----- mailutils/mail.c | 4 ++-- miscutils/i2c_tools.c | 2 +- 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) if (fprintf(stderr, "mv: overwrite '%s'? ", dest) < 0) { goto RET_1; /* Ouch! fprintf failed! */ } - if (!bb_ask_confirmation()) { + if (!bb_ask_y_confirmation()) { goto RET_0; } } 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, #define BB_LO_FLAGS_READ_ONLY 1 #define BB_LO_FLAGS_AUTOCLEAR 4 -/* Like bb_ask below, but asks on stdin with no timeout. */ -char *bb_ask_stdin(const char * prompt) FAST_FUNC; +/* Like bb_ask_noecho below, but asks on stdin with no timeout. */ +char *bb_ask_noecho_stdin(const char *prompt) FAST_FUNC; //TODO: pass buf pointer or return allocated buf (avoid statics)? -char *bb_ask(const int fd, int timeout, const char * prompt) FAST_FUNC; -int bb_ask_confirmation(void) FAST_FUNC; +char *bb_ask_noecho(const int fd, int timeout, const char *prompt) FAST_FUNC; +int bb_ask_y_confirmation(void) FAST_FUNC; /* Returns -1 if input is invalid. current_mode is a base for e.g. "u+rw" */ int 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 @@ /* vi: set sw=4 ts=4: */ /* - * bb_ask_confirmation implementation for busybox + * bb_ask_y_confirmation implementation for busybox * * Copyright (C) 2003 Manuel Novoa III * @@ -11,7 +11,7 @@ /* Read a line from stdin. If the first non-whitespace char is 'y' or 'Y', * return 1. Otherwise return 0. */ -int FAST_FUNC bb_ask_confirmation(void) +int FAST_FUNC bb_ask_y_confirmation(void) { char first = 0; 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) { } -char* FAST_FUNC bb_ask_stdin(const char *prompt) +char* FAST_FUNC bb_ask_noecho_stdin(const char *prompt) { - return bb_ask(STDIN_FILENO, 0, prompt); + return bb_ask_noecho(STDIN_FILENO, 0, prompt); } -char* FAST_FUNC bb_ask(const int fd, int timeout, const char *prompt) +char* FAST_FUNC bb_ask_noecho(const int fd, int timeout, const char *prompt) { /* Was static char[BIGNUM] */ 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) // (No "opening without O_EXCL", no "unlink only if -f") // Or else we will end up having 3 open()s! fprintf(stderr, "%s: overwrite '%s'? ", applet_name, dest); - if (!bb_ask_confirmation()) + if (!bb_ask_y_confirmation()) return 0; /* not allowed to overwrite */ } 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, if (!pw_pass[0]) /* empty password field? */ return CHECKPASS_PW_HAS_EMPTY_PASSWORD; - plaintext = bb_ask(STDIN_FILENO, timeout, prompt); + plaintext = bb_ask_noecho(STDIN_FILENO, timeout, prompt); if (!plaintext) { /* EOF (such as ^D) or error (such as ^C) or timeout */ 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) ) { fprintf(stderr, "%s: descend into directory '%s'? ", applet_name, path); - if (!bb_ask_confirmation()) + if (!bb_ask_y_confirmation()) return 0; } @@ -68,7 +68,7 @@ int FAST_FUNC remove_file(const char *path, int flags) if (flags & FILEUTILS_INTERACTIVE) { fprintf(stderr, "%s: remove directory '%s'? ", applet_name, path); - if (!bb_ask_confirmation()) + if (!bb_ask_y_confirmation()) return status; } @@ -92,7 +92,7 @@ int FAST_FUNC remove_file(const char *path, int flags) || (flags & FILEUTILS_INTERACTIVE) ) { fprintf(stderr, "%s: remove '%s'? ", applet_name, path); - if (!bb_ask_confirmation()) + if (!bb_ask_y_confirmation()) return 0; } 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) /* Only mkpasswd, and only from tty, prompts. * Otherwise it is a plain read. */ password = (ENABLE_MKPASSWD && isatty(STDIN_FILENO) && applet_name[0] == 'm') - ? bb_ask_stdin("Password: ") + ? bb_ask_noecho_stdin("Password: ") : xmalloc_fgetline(stdin) ; /* 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 if (myuid != 0 && pw->pw_passwd[0]) { char *encrypted; - orig = bb_ask_stdin("Old password: "); /* returns ptr to static */ + orig = bb_ask_noecho_stdin("Old password: "); /* returns ptr to static */ if (!orig) goto err_ret; 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 if (ENABLE_FEATURE_CLEAN_UP) free(encrypted); } - orig = xstrdup(orig); /* or else bb_ask_stdin() will destroy it */ - newp = bb_ask_stdin("New password: "); /* returns ptr to static */ + orig = xstrdup(orig); /* or else bb_ask_noecho_stdin() will destroy it */ + newp = bb_ask_noecho_stdin("New password: "); /* returns ptr to static */ if (!newp) goto err_ret; - newp = xstrdup(newp); /* we are going to bb_ask_stdin() again, so save it */ + newp = xstrdup(newp); /* we are going to bb_ask_noecho_stdin() again, so save it */ if (ENABLE_FEATURE_PASSWD_WEAK_CHECK && obscure(orig, newp, pw) && myuid != 0 @@ -77,7 +77,7 @@ static char* new_password(const struct passwd *pw, uid_t myuid, const char *algo goto err_ret; /* non-root is not allowed to have weak passwd */ } - cp = bb_ask_stdin("Retype password: "); + cp = bb_ask_noecho_stdin("Retype password: "); if (!cp) goto err_ret; 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) void FAST_FUNC get_cred_or_die(int fd) { if (isatty(fd)) { - G.user = xstrdup(bb_ask(fd, /* timeout: */ 0, "User: ")); - G.pass = xstrdup(bb_ask(fd, /* timeout: */ 0, "Password: ")); + G.user = xstrdup(bb_ask_noecho(fd, /* timeout: */ 0, "User: ")); + G.pass = xstrdup(bb_ask_noecho(fd, /* timeout: */ 0, "Password: ")); } else { G.user = xmalloc_reads(fd, /* maxsize: */ NULL); 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) { fprintf(stderr, "Continue? [y/N] "); fflush_all(); - if (!bb_ask_confirmation()) + if (!bb_ask_y_confirmation()) bb_error_msg_and_die("aborting"); } -- cgit v1.2.3