Skip to content

Commit

Permalink
Add a command line option to continue in background after startup
Browse files Browse the repository at this point in the history
[dwmw2: Don't add background flag to struct openconnect_info]
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
thos authored and David Woodhouse committed Apr 28, 2009
1 parent b5ab55a commit 1541607
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 16 additions & 1 deletion main.c
Expand Up @@ -46,8 +46,10 @@ static void write_progress(struct openconnect_info *info, int level, const char
static void syslog_progress(struct openconnect_info *info, int level, const char *fmt, ...);

int verbose = PRG_INFO;
int background;

static struct option long_options[] = {
{"background", 0, 0, 'b'},
{"certificate", 1, 0, 'c'},
{"sslkey", 1, 0, 'k'},
{"cookie", 1, 0, 'C'},
Expand Down Expand Up @@ -85,6 +87,7 @@ void usage(void)
{
printf("Usage: openconnect [options] <server>\n");
printf("Open client for Cisco AnyConnect VPN, version %s\n\n", openconnect_version);
printf(" -b, --background Continue in background after startup\n");
printf(" -c, --certificate=CERT Use SSL client certificate CERT\n");
printf(" -k, --sslkey=KEY Use SSL private key file KEY\n");
printf(" -C, --cookie=COOKIE Use WebVPN cookie COOKIE\n");
Expand Down Expand Up @@ -174,7 +177,7 @@ int main(int argc, char **argv)
else
vpninfo->localname = "localhost";

while ((opt = getopt_long(argc, argv, "C:c:Ddg:hi:k:lp:Q:qSs:tU:u:Vvx:",
while ((opt = getopt_long(argc, argv, "bC:c:Ddg:hi:k:lp:Q:qSs:tU:u:Vvx:",
long_options, NULL))) {
if (opt < 0)
break;
Expand Down Expand Up @@ -211,6 +214,9 @@ int main(int argc, char **argv)
case '8':
vpninfo->dtls_ciphers = optarg;
break;
case 'b':
background = 1;
break;
case 'C':
vpninfo->cookie = optarg;
break;
Expand Down Expand Up @@ -361,6 +367,15 @@ int main(int argc, char **argv)
(vpninfo->deflate ? "SSL + deflate" : "SSL")
: "DTLS");

if (background) {
int pid;
if ((pid = fork ())) {
vpninfo->progress(vpninfo, PRG_INFO,
"Continuing in background; pid %d\n",
pid);
exit (1);
}
}
vpn_mainloop(vpninfo);
exit(1);
}
Expand Down
6 changes: 6 additions & 0 deletions openconnect.8
Expand Up @@ -4,6 +4,9 @@ openconnect \- Connect to Cisco AnyConnect VPN
.SH SYNOPSIS
.B openconnect
[
.B -b,--background
]
[
.B -c,--certificate
.I CERT
]
Expand Down Expand Up @@ -135,6 +138,9 @@ exchanged, which allows data transport over UDP to occur.

.SH OPTIONS
.TP
.B -b,--background
Continue in background after startup
.TP
.B -c,--certificate=CERT
Use SSL client certificate
.I CERT
Expand Down

0 comments on commit 1541607

Please sign in to comment.