Skip to content

Commit

Permalink
Add --cookieonly option
Browse files Browse the repository at this point in the history
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Oct 1, 2008
1 parent 97049f5 commit 077d4ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 2 additions & 3 deletions http.c
Expand Up @@ -658,10 +658,9 @@ int obtain_cookie(struct anyconnect_info *vpninfo)
}
}
}
if (vpninfo->cookie) {
printf("WebVPN cookie is %s\n", vpninfo->cookie);
if (vpninfo->cookie)
return 0;
}

fprintf(stderr, "Server claimed successful login, but no cookie!\n");
return -1;
}
11 changes: 11 additions & 0 deletions main.c
Expand Up @@ -53,6 +53,7 @@ static struct option long_options[] = {
{"verbose", 1, 0, 'v'},
{"cafile", 1, 0, '0'},
{"no-dtls", 0, 0, '1'},
{"cookieonly", 0, 0, '2'},
{"xmlconfig", 1, 0, 'x'},
};

Expand All @@ -74,6 +75,7 @@ void usage(void)
printf(" -u, --user=NAME Set login username\n");
printf(" -v, --verbose More output\n");
printf(" -x, --xmlconfig=CONFIG XML config file\n");
printf(" --fetchcookie Fetch webvpn cookie only; don't connect\n");
printf(" --cafile=FILE Cert file for server verification\n");
printf(" --no-dtls Disable DTLS\n");
exit(1);
Expand All @@ -83,6 +85,7 @@ int main(int argc, char **argv)
{
struct anyconnect_info *vpninfo;
struct utsname utsbuf;
int cookieonly;
int opt;

vpn_init_openssl();
Expand Down Expand Up @@ -123,6 +126,9 @@ int main(int argc, char **argv)
case '1':
vpninfo->trydtls = 0;
break;
case '2':
cookieonly = 1;
break;
case 'C':
vpninfo->cookie = optarg;
break;
Expand Down Expand Up @@ -203,6 +209,11 @@ int main(int argc, char **argv)
exit(1);
}

if (cookieonly) {
printf("%s\n", vpninfo->cookie);
exit(0);
}

if (make_ssl_connection(vpninfo)) {
fprintf(stderr, "Creating SSL connection failed\n");
exit(1);
Expand Down

0 comments on commit 077d4ed

Please sign in to comment.