Contents of /trunk/ppp/patches/ppp-2.4.4-passwordfd-read-early.patch
Parent Directory | Revision Log
Revision 797 -
(show annotations)
(download)
Mon May 11 09:46:04 2009 UTC (15 years, 4 months ago) by niro
File size: 2001 byte(s)
Mon May 11 09:46:04 2009 UTC (15 years, 4 months ago) by niro
File size: 2001 byte(s)
-added patches from gentoo
1 | diff -Nru ppp-2.4.4.orig/pppd/plugins/passwordfd.c ppp-2.4.4/pppd/plugins/passwordfd.c |
2 | --- ppp-2.4.4.orig/pppd/plugins/passwordfd.c 2002-02-12 01:55:25.000000000 +0100 |
3 | +++ ppp-2.4.4/pppd/plugins/passwordfd.c 2008-06-27 21:11:22.000000000 +0200 |
4 | @@ -16,11 +16,11 @@ |
5 | |
6 | char pppd_version[] = VERSION; |
7 | |
8 | -static int passwdfd = -1; |
9 | static char save_passwd[MAXSECRETLEN]; |
10 | |
11 | +static int readpassword __P((char **)); |
12 | static option_t options[] = { |
13 | - { "passwordfd", o_int, &passwdfd, |
14 | + { "passwordfd", o_special, (void *)readpassword, |
15 | "Receive password on this file descriptor" }, |
16 | { NULL } |
17 | }; |
18 | @@ -30,43 +30,39 @@ |
19 | return 1; |
20 | } |
21 | |
22 | -static int pwfd_passwd (char *user, char *passwd) |
23 | +static int readpassword(char **argv) |
24 | { |
25 | - int readgood, red; |
26 | - |
27 | - if (passwdfd == -1) |
28 | - return -1; |
29 | - |
30 | - if (passwd == NULL) |
31 | - return 1; |
32 | - |
33 | - if (passwdfd == -2) { |
34 | - strcpy (passwd, save_passwd); |
35 | - return 1; |
36 | + char *arg = *argv; |
37 | + int passwdfd = -1; |
38 | + int chunk, len; |
39 | + |
40 | + if (sscanf(arg, "%d", &passwdfd) != 1 || passwdfd < 0) |
41 | + { |
42 | + error ("\"%s\" is not a valid file descriptor number", arg); |
43 | + return 0; |
44 | } |
45 | |
46 | - readgood = 0; |
47 | + len = 0; |
48 | do { |
49 | - red = read (passwdfd, passwd + readgood, MAXSECRETLEN - 1 - readgood); |
50 | - if (red == 0) |
51 | - break; |
52 | - if (red < 0) { |
53 | - error ("Can't read secret from fd\n"); |
54 | - readgood = -1; |
55 | + chunk = read (passwdfd, save_passwd + len, MAXSECRETLEN - 1 - len); |
56 | + if (chunk == 0) |
57 | break; |
58 | + if (chunk < 0) { |
59 | + error ("Can't read secret from fd %d", passwdfd); |
60 | + return 0; |
61 | } |
62 | - readgood += red; |
63 | - } while (readgood < MAXSECRETLEN - 1); |
64 | - |
65 | + len += chunk; |
66 | + } while (len < MAXSECRETLEN - 1); |
67 | + save_passwd[len] = 0; |
68 | close (passwdfd); |
69 | |
70 | - if (readgood < 0) |
71 | - return 0; |
72 | - |
73 | - passwd[readgood] = 0; |
74 | - strcpy (save_passwd, passwd); |
75 | - passwdfd = -2; |
76 | + return 1; |
77 | +} |
78 | |
79 | +static int pwfd_passwd (char *user, char *passwd) |
80 | +{ |
81 | + if (passwd != NULL) |
82 | + strcpy (passwd, save_passwd); |
83 | return 1; |
84 | } |
85 |