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;
}
}
#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;
/* 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>
*
/* 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;
{
}
-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 };
// (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) {
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;
) {
fprintf(stderr, "%s: descend into directory '%s'? ", applet_name,
path);
- if (!bb_ask_confirmation())
+ if (!bb_ask_y_confirmation())
return 0;
}
if (flags & FILEUTILS_INTERACTIVE) {
fprintf(stderr, "%s: remove directory '%s'? ", applet_name, path);
- if (!bb_ask_confirmation())
+ if (!bb_ask_y_confirmation())
return status;
}
|| (flags & FILEUTILS_INTERACTIVE)
) {
fprintf(stderr, "%s: remove '%s'? ", applet_name, path);
- if (!bb_ask_confirmation())
+ if (!bb_ask_y_confirmation())
return 0;
}
/* 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 */
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 */
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
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) {
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);
{
fprintf(stderr, "Continue? [y/N] ");
fflush_all();
- if (!bb_ask_confirmation())
+ if (!bb_ask_y_confirmation())
bb_error_msg_and_die("aborting");
}