X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fplugins%2Fpasswordfd.c;h=c3f9793e41a01b141da91d7a5370e04dec51af83;hb=HEAD;hp=9a0cd822fa96a8a4f80c4a14eb862b89892ac6fd;hpb=b2c21894e165d7a0b4f1600fd8a8fd1b21305752;p=ppp.git diff --git a/pppd/plugins/passwordfd.c b/pppd/plugins/passwordfd.c index 9a0cd82..be3088c 100644 --- a/pppd/plugins/passwordfd.c +++ b/pppd/plugins/passwordfd.c @@ -7,47 +7,33 @@ * with pap- and chap-secrets files. */ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - #include #include #include #include +#include +#include +#include +#include -#include "pppd.h" +#include +#include +#include +#include +#include -char pppd_version[] = VERSION; +char pppd_version[] = PPPD_VERSION; -static int passwdfd = -1; static char save_passwd[MAXSECRETLEN]; -static option_t options[] = { - { "passwordfd", o_int, &passwdfd, - "Receive password on this file descriptor" }, - { NULL } -}; - -static int pwfd_check (void) +static int pwfd_read_password(char **argv) { - return 1; -} - -static int pwfd_passwd (char *user, char *passwd) -{ - int readgood, red; + ssize_t readgood, red; + int passwdfd; + char passwd[MAXSECRETLEN]; - if (passwdfd == -1) - return -1; - - if (passwd == NULL) - return 1; - - if (passwdfd == -2) { - strcpy (passwd, save_passwd); - return 1; - } + if (!ppp_int_option(argv[0], &passwdfd)) + return 0; readgood = 0; do { @@ -69,14 +55,31 @@ static int pwfd_passwd (char *user, char *passwd) passwd[readgood] = 0; strcpy (save_passwd, passwd); - passwdfd = -2; return 1; } +static struct option options[] = { + { "passwordfd", o_special, pwfd_read_password, + "Receive password on this file descriptor" }, + { NULL } +}; + +static int pwfd_check (void) +{ + return 1; +} + +static int pwfd_passwd (char *user, char *passwd) +{ + if (passwd != NULL) + strcpy(passwd, save_passwd); + return 1; +} + void plugin_init (void) { - add_options (options); + ppp_add_options (options); pap_check_hook = pwfd_check; pap_passwd_hook = pwfd_passwd;