Skip to content

Commit

Permalink
Improve error reporting for vpnc-script
Browse files Browse the repository at this point in the history
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Jul 16, 2012
1 parent 101a904 commit 7bc1abf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tun.c
Expand Up @@ -26,6 +26,7 @@
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <string.h>
#include <signal.h>
#include <fcntl.h>
Expand Down Expand Up @@ -373,17 +374,33 @@ static void set_script_env(struct openconnect_info *vpninfo)

int script_config_tun(struct openconnect_info *vpninfo, const char *reason)
{
int ret;

if (!vpninfo->vpnc_script)
return 0;

setenv("reason", reason, 1);
if (system(vpninfo->vpnc_script)) {
ret = system(vpninfo->vpnc_script);
if (ret == -1) {
int e = errno;
vpn_progress(vpninfo, PRG_ERR,
_("Failed to spawn script '%s' for %s: %s\n"),
vpninfo->vpnc_script, reason, strerror(e));
return -e;
}
if (!WIFEXITED(ret)) {
vpn_progress(vpninfo, PRG_ERR,
_("Script '%s' exited abnormally (%x)\n"),
vpninfo->vpnc_script, ret);
return -EIO;
}
ret = WEXITSTATUS(ret);
if (ret) {
vpn_progress(vpninfo, PRG_ERR,
_("Script '%s' returned error %d\n"),
vpninfo->vpnc_script, ret);
return -EIO;
}
return 0;
}

Expand Down
1 change: 1 addition & 0 deletions www/changelog.xml
Expand Up @@ -17,6 +17,7 @@
<ul>
<li><b>OpenConnect HEAD</b>
<ul>
<li>Improve error handing when <tt>vpnc-script</tt> exits with error.</li>
<li>Handle PKCS#11 tokens which won't list keys without login.</li>
</ul><br/>
</li>
Expand Down

0 comments on commit 7bc1abf

Please sign in to comment.