3 * Author: Arvin Schnell <arvin@suse.de>
5 * This plugin let's you pass the password to the pppd via
6 * a file descriptor. That's easy and secure - no fiddling
7 * with pap- and chap-secrets files.
19 #include <pppd/pppd.h>
20 #include <pppd/upap.h>
21 #include <pppd/chap.h>
23 #include <pppd/options.h>
25 char pppd_version[] = PPPD_VERSION;
27 static char save_passwd[MAXSECRETLEN];
29 static int pwfd_read_password(char **argv)
31 ssize_t readgood, red;
33 char passwd[MAXSECRETLEN];
35 if (!ppp_int_option(argv[0], &passwdfd))
40 red = read (passwdfd, passwd + readgood, MAXSECRETLEN - 1 - readgood);
44 error ("Can't read secret from fd\n");
49 } while (readgood < MAXSECRETLEN - 1);
57 strcpy (save_passwd, passwd);
62 static struct option options[] = {
63 { "passwordfd", o_special, pwfd_read_password,
64 "Receive password on this file descriptor" },
68 static int pwfd_check (void)
73 static int pwfd_passwd (char *user, char *passwd)
76 strcpy(passwd, save_passwd);
80 void plugin_init (void)
82 ppp_add_options (options);
84 pap_check_hook = pwfd_check;
85 pap_passwd_hook = pwfd_passwd;
87 chap_check_hook = pwfd_check;
88 chap_passwd_hook = pwfd_passwd;
90 #ifdef PPP_WITH_EAPTLS
91 eaptls_passwd_hook = pwfd_passwd;