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 int passwdfd = -1;
28 static char save_passwd[MAXSECRETLEN];
30 static struct option options[] = {
31 { "passwordfd", o_int, &passwdfd,
32 "Receive password on this file descriptor" },
36 static int pwfd_check (void)
41 static int pwfd_passwd (char *user, char *passwd)
52 strcpy (passwd, save_passwd);
58 red = read (passwdfd, passwd + readgood, MAXSECRETLEN - 1 - readgood);
62 error ("Can't read secret from fd\n");
67 } while (readgood < MAXSECRETLEN - 1);
75 strcpy (save_passwd, passwd);
81 void plugin_init (void)
83 ppp_add_options (options);
85 pap_check_hook = pwfd_check;
86 pap_passwd_hook = pwfd_passwd;
88 chap_check_hook = pwfd_check;
89 chap_passwd_hook = pwfd_passwd;
91 #ifdef PPP_WITH_EAPTLS
92 eaptls_passwd_hook = pwfd_passwd;