Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 296267 | Differences between
and this patch

Collapse All | Expand All

(-)ppp-2.4.4.orig/pppd/plugins/passwordfd.c (-30 / +26 lines)
Lines 16-26 Link Here
16
16
17
char pppd_version[] = VERSION;
17
char pppd_version[] = VERSION;
18
18
19
static int passwdfd = -1;
20
static char save_passwd[MAXSECRETLEN];
19
static char save_passwd[MAXSECRETLEN];
21
20
21
static int readpassword __P((char **));
22
static option_t options[] = {
22
static option_t options[] = {
23
    { "passwordfd", o_int, &passwdfd,
23
    { "passwordfd", o_special, (void *)readpassword,
24
      "Receive password on this file descriptor" },
24
      "Receive password on this file descriptor" },
25
    { NULL }
25
    { NULL }
26
};
26
};
Lines 30-72 Link Here
30
    return 1;
30
    return 1;
31
}
31
}
32
32
33
static int pwfd_passwd (char *user, char *passwd)
33
static int readpassword(char **argv)
34
{
34
{
35
    int readgood, red;
35
    char *arg = *argv;
36
36
    int passwdfd = -1;
37
    if (passwdfd == -1)
37
    int chunk, len;
38
	return -1;
38
39
39
    if (sscanf(arg, "%d", &passwdfd) != 1 || passwdfd < 0)
40
    if (passwd == NULL)
40
    {
41
	return 1;
41
	error ("\"%s\" is not a valid file descriptor number", arg);
42
42
	return 0;
43
    if (passwdfd == -2) {
44
	strcpy (passwd, save_passwd);
45
	return 1;
46
    }
43
    }
47
44
48
    readgood = 0;
45
    len = 0;
49
    do {
46
    do {
50
	red = read (passwdfd, passwd + readgood, MAXSECRETLEN - 1 - readgood);
47
	chunk = read (passwdfd, save_passwd + len, MAXSECRETLEN - 1 - len);
51
	if (red == 0)
48
	if (chunk == 0)
52
	    break;
53
	if (red < 0) {
54
	    error ("Can't read secret from fd\n");
55
	    readgood = -1;
56
	    break;
49
	    break;
50
	if (chunk < 0) {
51
	    error ("Can't read secret from fd %d", passwdfd);
52
	    return 0;
57
	}
53
	}
58
	readgood += red;
54
	len += chunk;
59
    } while (readgood < MAXSECRETLEN - 1);
55
    } while (len < MAXSECRETLEN - 1);
60
56
    save_passwd[len] = 0;
61
    close (passwdfd);
57
    close (passwdfd);
62
58
63
    if (readgood < 0)
59
    return 1;
64
	return 0;
60
}
65
66
    passwd[readgood] = 0;
67
    strcpy (save_passwd, passwd);
68
    passwdfd = -2;
69
61
62
static int pwfd_passwd (char *user, char *passwd)
63
{
64
    if (passwd != NULL)
65
	strcpy (passwd, save_passwd);
70
    return 1;
66
    return 1;
71
}
67
}
72
68

Return to bug 296267