From: Alexander Smirnov Date: Fri, 7 Aug 2020 07:52:03 +0000 (+0300) Subject: Disable asking password again when prompt program returns 128 X-Git-Tag: ppp-2.4.9~54^2 X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=0314df4b46a815922139ded9a2632015ddf260a7;hp=-c Disable asking password again when prompt program returns 128 Return code 128 is reserved for the case when a user hits cancel on the prompt program. We should not ask for the password again. Signed-off-by: Alexander Smirnov --- 0314df4b46a815922139ded9a2632015ddf260a7 diff --git a/pppd/plugins/passprompt.c b/pppd/plugins/passprompt.c index 44e3815..2091f13 100644 --- a/pppd/plugins/passprompt.c +++ b/pppd/plugins/passprompt.c @@ -17,6 +17,7 @@ char pppd_version[] = VERSION; static char promptprog[PATH_MAX+1]; +static int promptprog_refused = 0; static option_t options[] = { { "promptprog", o_string, promptprog, @@ -32,7 +33,7 @@ static int promptpass(char *user, char *passwd) int readgood, wstat; ssize_t red; - if (promptprog[0] == 0 || access(promptprog, X_OK) < 0) + if (promptprog_refused || promptprog[0] == 0 || access(promptprog, X_OK) < 0) return -1; /* sorry, can't help */ if (!passwd) @@ -97,9 +98,14 @@ static int promptpass(char *user, char *passwd) passwd[readgood] = 0; if (!WIFEXITED(wstat)) warn("%s terminated abnormally", promptprog); - if (WEXITSTATUS(wstat)) - warn("%s exited with code %d", promptprog, WEXITSTATUS(status)); - + if (WEXITSTATUS(wstat)) { + warn("%s exited with code %d", promptprog, WEXITSTATUS(wstat)); + /* code when cancel was hit in the prompt prog */ + if (WEXITSTATUS(wstat) == 128) { + promptprog_refused = 1; + } + return -1; + } return 1; }