libbb: rename bb_ask -> bb_ask_noecho, bb_ask_confirmation -> bb_ask_y_confirmation
authorDenys Vlasenko <vda.linux@googlemail.com>
Sat, 7 Apr 2018 13:08:12 +0000 (15:08 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Sat, 7 Apr 2018 13:08:12 +0000 (15:08 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
coreutils/mv.c
include/libbb.h
libbb/ask_confirmation.c
libbb/bb_askpass.c
libbb/copy_file.c
libbb/correct_password.c
libbb/remove_file.c
loginutils/cryptpw.c
loginutils/passwd.c
mailutils/mail.c
miscutils/i2c_tools.c

index aeafd1e40c8ce3c12b479629ba587cbf84fabbee..6e11197a1d35a926ce7e8a747220606aadfca8ef 100644 (file)
@@ -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;
                                }
                        }
index ad1c7346fa9c9546c890310f4ef08beb2f45d5cf..c7e830c09d0408e23e591b7107d4b63e4eeaefcd 100644 (file)
@@ -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;
index 6fbed89f4d7a01726db4e49383d922e2b1440383..ccd983c29f224311587edf215f3bbdb29d770aa5 100644 (file)
@@ -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  <mjn3@codepoet.org>
  *
@@ -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;
index 5599c82ef982b8bf7e6aebb411f2b13ae585f225..aadc6910811bad1449ec2e5ee1c478469bbb2466 100644 (file)
@@ -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 };
index be90066311fbb34c48e8c0def9d206db9c262068..1b8befd65440e394dd0e0be119926aac3b6b6975 100644 (file)
@@ -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) {
index a6f7d9b3d4c463b07220fe2155134d7c6ba618e2..cbe6cb38706828aeb7ffb723915c35dbd76c3eaf 100644 (file)
@@ -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;
index 8a13243930cee5ab53be218115c23c9a8ba56280..074ffae707421ef6fc4a1d19bdbd683e89aa134a 100644 (file)
@@ -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;
        }
 
index 76138a61ffb42ed4f86a08cd0c61a4798b50b9d5..3ca7eda4a8eaa437fcc29aed0f5a0b0d9b67cf53 100644 (file)
@@ -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 */
index 3e1ef9abfa25500b9b9b46f5dcb2b02caf4608e8..02303b5755d5a629a4f841314662ac504afc4487 100644 (file)
@@ -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) {
index eceb890715a0d48de5afd0115506eebb15c6c321..0fc615a7f8d7896a53e150a8e1e84b74291b68f6 100644 (file)
@@ -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);
index 82f9842bd1beb83c9ca29a8367696aad72abafc8..8b201c0b154fb637ecca82952de514c25bf6a8e3 100644 (file)
@@ -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");
 }