[PATCH] Add --no-logout option for cookie re-use

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Make it easier to shut down the tunnel without invalidating the auth
cookie, by optionally skipping the logout phase.

Signed-off-by: Robin H. Johnson <robbat2 at gentoo.org>
---
 library.c              | 1 +
 main.c                 | 6 ++++++
 mainloop.c             | 2 +-
 openconnect-internal.h | 1 +
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/library.c b/library.c
index e5bbda4..aad274f 100644
--- a/library.c
+++ b/library.c
@@ -88,6 +88,7 @@ struct openconnect_info *openconnect_vpninfo_new(const char *useragent,
 	vpninfo->try_http_auth = 1;
 	vpninfo->proxy_auth[AUTH_TYPE_BASIC].state = AUTH_DEFAULT_DISABLED;
 	vpninfo->http_auth[AUTH_TYPE_BASIC].state = AUTH_DEFAULT_DISABLED;
+	vpninfo->logout = 1;
 	openconnect_set_reported_os(vpninfo, NULL);
 
 	if (!vpninfo->localname || !vpninfo->useragent)
diff --git a/main.c b/main.c
index 2450eba..027b793 100644
--- a/main.c
+++ b/main.c
@@ -188,6 +188,7 @@ enum {
 	OPT_LOCAL_HOSTNAME,
 	OPT_PROTOCOL,
 	OPT_PASSTOS,
+	OPT_NO_LOGOUT,
 };
 
 #ifdef __sun__
@@ -272,6 +273,7 @@ static const struct option long_options[] = {
 #ifdef OPENCONNECT_GNUTLS
 	OPTION("gnutls-debug", 1, OPT_GNUTLS_DEBUG),
 #endif
+	OPTION("no-logout", 0, OPT_NO_LOGOUT),
 	OPTION(NULL, 0, 0)
 };
 
@@ -870,6 +872,7 @@ static void usage(void)
 	printf("      --no-dtls                   %s\n", _("Disable DTLS and ESP"));
 	printf("      --dtls-ciphers=LIST         %s\n", _("OpenSSL ciphers to support for DTLS"));
 	printf("  -Q, --queue-len=LEN             %s\n", _("Set packet queue limit to LEN pkts"));
+	printf("      --no-logout                 %s\n", _("Do not logout on exit"));
 
 	printf("\n%s:\n", _("Local system information"));
 	printf("      --useragent=STRING          %s\n", _("HTTP header User-Agent: field"));
@@ -1469,6 +1472,9 @@ int main(int argc, char **argv)
 			gnutls_global_set_log_function(oc_gnutls_log_func);
 			break;
 #endif
+		case OPT_NO_LOGOUT:
+			vpninfo->logout = 0;
+			break;
 		default:
 			usage();
 		}
diff --git a/mainloop.c b/mainloop.c
index fe185fe..345b521 100644
--- a/mainloop.c
+++ b/mainloop.c
@@ -307,7 +307,7 @@ int openconnect_mainloop(struct openconnect_info *vpninfo,
 #endif
 	}
 
-	if (vpninfo->quit_reason && vpninfo->proto->vpn_close_session)
+	if (vpninfo->quit_reason && vpninfo->proto->vpn_close_session && vpninfo->logout)
 		vpninfo->proto->vpn_close_session(vpninfo, vpninfo->quit_reason);
 
 	if (tun_is_up(vpninfo))
diff --git a/openconnect-internal.h b/openconnect-internal.h
index 038cb35..b502400 100644
--- a/openconnect-internal.h
+++ b/openconnect-internal.h
@@ -639,6 +639,7 @@ struct openconnect_info {
 	char *useragent;
 
 	const char *quit_reason;
+	int logout;
 
 	int verbose;
 	void *cbdata;
-- 
2.14.1




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux