diff options
author | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2008-07-26 07:27:03 +0000 |
---|---|---|
committer | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2008-07-26 07:27:03 +0000 |
commit | 5a2e9a2587372aeb4b74fa1aadf53283ed7cae10 (patch) | |
tree | bc79922f81699bc51c2ac047309e6ab594eebcd2 /lladdr.c | |
parent | Added argv_x functions to buffer.[ch] to be used to safely build (diff) | |
download | openvpn-5a2e9a2587372aeb4b74fa1aadf53283ed7cae10.tar.xz |
Completely revamped the system for calling external programs and scripts:
* All external programs and scripts are now called by execve() on unix and
CreateProcess on Windows.
* The system() function is no longer used.
* Argument lists for external programs and scripts are now built by the new
argv_printf function which natively outputs to string arrays (i.e.
char *argv[] lists), never truncates its output, and eliminates the security
issues inherent in formatting and parsing command lines, and dealing with
argument quoting.
* The --script-security directive has been added to offer policy controls on
OpenVPN's execution of external programs and scripts.
Also added a new plugin example (openvpn/plugin/examples/log.c) that logs
information to stdout for every plugin method called by OpenVPN.
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@3122 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'lladdr.c')
-rw-r--r-- | lladdr.c | 34 |
1 files changed, 21 insertions, 13 deletions
@@ -9,7 +9,7 @@ int set_lladdr(const char *ifname, const char *lladdr, const struct env_set *es) { - char cmd[256]; + struct argv argv = argv_new (); int r; if (!ifname || !lladdr) @@ -17,37 +17,45 @@ int set_lladdr(const char *ifname, const char *lladdr, #if defined(TARGET_LINUX) #ifdef CONFIG_FEATURE_IPROUTE - openvpn_snprintf (cmd, sizeof (cmd), + argv_printf (&argv, "%s link set addr %s dev %s", iproute_path, lladdr, ifname); #else - openvpn_snprintf (cmd, sizeof (cmd), - IFCONFIG_PATH " %s hw ether %s", + argv_printf (&argv, + "%s %s hw ether %s", + IFCONFIG_PATH, ifname, lladdr); #endif #elif defined(TARGET_SOLARIS) - openvpn_snprintf (cmd, sizeof (cmd), - IFCONFIG_PATH " %s ether %s", + argv_printf (&argv, + "%s %s ether %s", + IFCONFIG_PATH, ifname, lladdr); #elif defined(TARGET_OPENBSD) - openvpn_snprintf (cmd, sizeof (cmd), - IFCONFIG_PATH " %s lladdr %s", + argv_printf (&argv, + "%s %s lladdr %s", + IFCONFIG_PATH, ifname, lladdr); #elif defined(TARGET_DARWIN) - openvpn_snprintf (cmd, sizeof (cmd), - IFCONFIG_PATH " %s lladdr %s", + argv_printf (&argv, + "%s %s lladdr %s", + IFCONFIG_PATH, ifname, lladdr); #elif defined(TARGET_FREEBSD) - openvpn_snprintf (cmd, sizeof (cmd), - IFCONFIG_PATH " %s ether %s", + argv_printf (&argv, + "%s %s ether %s", + IFCONFIG_PATH, ifname, lladdr); #else msg (M_WARN, "Sorry, but I don't know how to configure link layer addresses on this operating system."); return -1; #endif - r = system_check (cmd, es, M_WARN, "ERROR: Unable to set link layer address."); + argv_msg (M_INFO, &argv); + r = openvpn_execve_check (&argv, es, M_WARN, "ERROR: Unable to set link layer address."); if (r) msg (M_INFO, "TUN/TAP link layer address set to %s", lladdr); + + argv_reset (&argv); return r; } |