Add -B option to ring the bell before the password prompt.

This commit is contained in:
Todd C. Miller
2019-05-27 08:49:43 -06:00
parent dae484213e
commit 19c548fd57
6 changed files with 41 additions and 18 deletions

View File

@@ -133,11 +133,12 @@ struct environment {
* Note that we must disable arg permutation to support setting environment
* variables and to better support the optional arg of the -h flag.
*/
static const char short_opts[] = "+Aa:bC:c:D:Eeg:Hh::iKklnPp:r:SsT:t:U:u:Vv";
static const char short_opts[] = "+Aa:BbC:c:D:Eeg:Hh::iKklnPp:r:SsT:t:U:u:Vv";
static struct option long_opts[] = {
{ "askpass", no_argument, NULL, 'A' },
{ "auth-type", required_argument, NULL, 'a' },
{ "background", no_argument, NULL, 'b' },
{ "bell", no_argument, NULL, 'B' },
{ "close-from", required_argument, NULL, 'C' },
{ "login-class", required_argument, NULL, 'c' },
{ "preserve-env", optional_argument, NULL, 'E' },
@@ -317,6 +318,9 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
case 'b':
SET(flags, MODE_BACKGROUND);
break;
case 'B':
SET(tgetpass_flags, TGP_BELL);
break;
case 'C':
if (strtonum(optarg, 3, INT_MAX, NULL) == 0) {
sudo_warnx(U_("the argument to -C must be a number greater than or equal to 3"));
@@ -711,6 +715,8 @@ help(void)
#endif
sudo_lbuf_append(&lbuf, " -b, --background %s\n",
_("run command in the background"));
sudo_lbuf_append(&lbuf, " -B, --bell %s\n",
_("ring bell when prompting"));
sudo_lbuf_append(&lbuf, " -C, --close-from=num %s\n",
_("close all file descriptors >= num"));
#ifdef HAVE_LOGIN_CAP_H