Add --cookieonly option
authorDavid Woodhouse <David.Woodhouse@intel.com>
Wed, 1 Oct 2008 21:11:20 +0000 (22:11 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Wed, 1 Oct 2008 21:11:20 +0000 (22:11 +0100)
http.c
main.c

diff --git a/http.c b/http.c
index d209c23..7c67d77 100644 (file)
--- a/http.c
+++ b/http.c
@@ -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;
 }
diff --git a/main.c b/main.c
index 825679f..ee7fc6f 100644 (file)
--- a/main.c
+++ b/main.c
@@ -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'},
 };
 
@@ -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);
@@ -83,6 +85,7 @@ int main(int argc, char **argv)
 {
        struct anyconnect_info *vpninfo;
        struct utsname utsbuf;
+       int cookieonly;
        int opt;
 
        vpn_init_openssl();
@@ -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;
@@ -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);