skill: use rpmatch() to yes/no question
The patch also removes fixed size of input, which can be problematic. I do not know how long the string `yes' might be in all of the worlds languages. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
72e37c7d11
commit
b40353c91e
@ -73,6 +73,7 @@ AC_FUNC_REALLOC
|
|||||||
AC_FUNC_STRTOD
|
AC_FUNC_STRTOD
|
||||||
AC_CHECK_FUNCS([\
|
AC_CHECK_FUNCS([\
|
||||||
alarm \
|
alarm \
|
||||||
|
getline \
|
||||||
getpagesize \
|
getpagesize \
|
||||||
gettimeofday \
|
gettimeofday \
|
||||||
iswprint \
|
iswprint \
|
||||||
@ -83,6 +84,7 @@ AC_CHECK_FUNCS([\
|
|||||||
nl_langinfo \
|
nl_langinfo \
|
||||||
putenv \
|
putenv \
|
||||||
regcomp \
|
regcomp \
|
||||||
|
rpmatch \
|
||||||
select \
|
select \
|
||||||
setlocale \
|
setlocale \
|
||||||
strcasecmp \
|
strcasecmp \
|
||||||
|
14
skill.c
14
skill.c
@ -82,15 +82,17 @@ static void hurt_proc(int tty, int uid, int pid, const char *restrict const cmd,
|
|||||||
char dn_buf[1000];
|
char dn_buf[1000];
|
||||||
dev_to_tty(dn_buf, 999, tty, pid, ABBREV_DEV);
|
dev_to_tty(dn_buf, 999, tty, pid, ABBREV_DEV);
|
||||||
if (run_time->interactive) {
|
if (run_time->interactive) {
|
||||||
char buf[8];
|
char *buf;
|
||||||
|
size_t len = 0;
|
||||||
fprintf(stderr, "%-8s %-8s %5d %-16.16s ? ",
|
fprintf(stderr, "%-8s %-8s %5d %-16.16s ? ",
|
||||||
(char *)dn_buf, user_from_uid(uid), pid, cmd);
|
(char *)dn_buf, user_from_uid(uid), pid, cmd);
|
||||||
if (!fgets(buf, 7, stdin)) {
|
fflush (stdout);
|
||||||
printf("\n");
|
getline(&buf, &len, stdin);
|
||||||
exit(EXIT_FAILURE);
|
if (rpmatch(buf) < 1) {
|
||||||
}
|
free(buf);
|
||||||
if (*buf != 'y' && *buf != 'Y')
|
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
free(buf);
|
||||||
}
|
}
|
||||||
/* do the actual work */
|
/* do the actual work */
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user