diff options
author | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-05-10 00:24:51 +0000 |
---|---|---|
committer | A. Wilcox <AWilcox@Wilcox-Tech.com> | 2019-05-10 00:24:51 +0000 |
commit | d950a50ac6855d2a49328247ad0e6e9933547d33 (patch) | |
tree | 13e27624a878ce2688d0172afc1ee18171a92b8c /user/ppp/24_all_passwordfd-read-early.patch | |
parent | 70e535f4073f219b6905fe82326ac1563d5c09ad (diff) | |
download | packages-d950a50ac6855d2a49328247ad0e6e9933547d33.tar.gz packages-d950a50ac6855d2a49328247ad0e6e9933547d33.tar.bz2 packages-d950a50ac6855d2a49328247ad0e6e9933547d33.tar.xz packages-d950a50ac6855d2a49328247ad0e6e9933547d33.zip |
user/ppp: new package
Diffstat (limited to 'user/ppp/24_all_passwordfd-read-early.patch')
-rw-r--r-- | user/ppp/24_all_passwordfd-read-early.patch | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/user/ppp/24_all_passwordfd-read-early.patch b/user/ppp/24_all_passwordfd-read-early.patch new file mode 100644 index 000000000..f549540dc --- /dev/null +++ b/user/ppp/24_all_passwordfd-read-early.patch @@ -0,0 +1,84 @@ +--- ppp-2.4.5/pppd/plugins/passwordfd.c ++++ ppp-2.4.5/pppd/plugins/passwordfd.c +@@ -16,11 +16,11 @@ + + char pppd_version[] = VERSION; + +-static int passwdfd = -1; + static char save_passwd[MAXSECRETLEN]; + ++static int readpassword __P((char **)); + static option_t options[] = { +- { "passwordfd", o_int, &passwdfd, ++ { "passwordfd", o_special, (void *)readpassword, + "Receive password on this file descriptor" }, + { NULL } + }; +@@ -30,43 +30,39 @@ + return 1; + } + +-static int pwfd_passwd (char *user, char *passwd) ++static int readpassword(char **argv) + { +- int readgood, red; +- +- if (passwdfd == -1) +- return -1; +- +- if (passwd == NULL) +- return 1; +- +- if (passwdfd == -2) { +- strcpy (passwd, save_passwd); +- return 1; ++ char *arg = *argv; ++ int passwdfd = -1; ++ int chunk, len; ++ ++ if (sscanf(arg, "%d", &passwdfd) != 1 || passwdfd < 0) ++ { ++ error ("\"%s\" is not a valid file descriptor number", arg); ++ return 0; + } + +- readgood = 0; ++ len = 0; + do { +- red = read (passwdfd, passwd + readgood, MAXSECRETLEN - 1 - readgood); +- if (red == 0) +- break; +- if (red < 0) { +- error ("Can't read secret from fd\n"); +- readgood = -1; ++ chunk = read (passwdfd, save_passwd + len, MAXSECRETLEN - 1 - len); ++ if (chunk == 0) + break; ++ if (chunk < 0) { ++ error ("Can't read secret from fd %d", passwdfd); ++ return 0; + } +- readgood += red; +- } while (readgood < MAXSECRETLEN - 1); +- ++ len += chunk; ++ } while (len < MAXSECRETLEN - 1); ++ save_passwd[len] = 0; + close (passwdfd); + +- if (readgood < 0) +- return 0; +- +- passwd[readgood] = 0; +- strcpy (save_passwd, passwd); +- passwdfd = -2; ++ return 1; ++} + ++static int pwfd_passwd (char *user, char *passwd) ++{ ++ if (passwd != NULL) ++ strcpy (passwd, save_passwd); + return 1; + } + |