3 @@ -77,6 +77,7 @@ enum {
11 @@ -91,6 +92,7 @@ enum {
14 OPT_PASSWORD_ON_STDIN,
17 OPT_RECONNECT_TIMEOUT,
19 @@ -139,7 +141,9 @@ static struct option long_options[] = {
20 OPTION("queue-len", 1, 'Q'),
21 OPTION("xmlconfig", 1, 'x'),
22 OPTION("cookie-on-stdin", 0, OPT_COOKIE_ON_STDIN),
23 + OPTION("cookie-file", 1, OPT_COOKIE_FILE),
24 OPTION("passwd-on-stdin", 0, OPT_PASSWORD_ON_STDIN),
25 + OPTION("passwd-file", 1, OPT_PASSWORD_FILE),
26 OPTION("no-passwd", 0, OPT_NO_PASSWD),
27 OPTION("reconnect-timeout", 1, OPT_RECONNECT_TIMEOUT),
28 OPTION("dtls-ciphers", 1, OPT_DTLS_CIPHERS),
29 @@ -177,6 +181,7 @@ static void usage(void)
30 printf(" -K, --key-type=TYPE %s\n", _("Private key type (PKCS#12 / TPM / PEM)"));
31 printf(" -C, --cookie=COOKIE %s\n", _("Use WebVPN cookie COOKIE"));
32 printf(" --cookie-on-stdin %s\n", _("Read cookie from standard input"));
33 + printf(" --cookie-file=FILE %s\n", _("Read cookie from a file"));
34 printf(" -d, --deflate %s\n", _("Enable compression (default)"));
35 printf(" -D, --no-deflate %s\n", _("Disable compression"));
36 printf(" --force-dpd=INTERVAL %s\n", _("Set minimum Dead Peer Detection interval"));
37 @@ -217,6 +222,7 @@ static void usage(void)
38 printf(" --no-cert-check %s\n", _("Do not require server SSL cert to be valid"));
39 printf(" --non-inter %s\n", _("Do not expect user input; exit if it is required"));
40 printf(" --passwd-on-stdin %s\n", _("Read password from standard input"));
41 + printf(" --passwd-file=FILE %s\n", _("Read password from a file"));
42 printf(" --reconnect-timeout %s\n", _("Connection retry timeout in seconds"));
43 printf(" --servercert=FINGERPRINT %s\n", _("Server's certificate SHA1 fingerprint"));
44 printf(" --useragent=STRING %s\n", _("HTTP header User-Agent: field"));
45 @@ -226,15 +232,28 @@ static void usage(void)
49 -static void read_stdin(char **string)
50 +static void read_file(const char *file, char **string)
52 char *c = malloc(100);
56 + f = fopen(file, "r");
58 + fprintf(stderr, _("Failed to open password file\n"));
67 - fprintf(stderr, _("Allocation failure for string from stdin\n"));
68 + fprintf(stderr, _("Allocation failure for string from %s\n"), file);
71 - if (!fgets(c, 100, stdin)) {
72 - perror(_("fgets (stdin)"));
73 + if (!fgets(c, 100, f)) {
78 @@ -332,14 +351,20 @@ int main(int argc, char **argv)
81 case OPT_COOKIE_ON_STDIN:
82 - read_stdin(&vpninfo->cookie);
85 + case OPT_COOKIE_FILE:
86 + read_file(optarg, &vpninfo->cookie);
87 /* If the cookie is empty, ignore it */
88 if (! *vpninfo->cookie) {
89 vpninfo->cookie = NULL;
92 case OPT_PASSWORD_ON_STDIN:
93 - read_stdin(&vpninfo->password);
96 + case OPT_PASSWORD_FILE:
97 + read_file(optarg, &vpninfo->password);
100 vpninfo->nopasswd = 1;