]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Remove unused and unecessary argv interfaces
authorHeiko Hund <heiko.hund@sophos.com>
Fri, 28 Oct 2016 16:42:38 +0000 (18:42 +0200)
committerGert Doering <gert@greenie.muc.de>
Mon, 14 Nov 2016 19:23:14 +0000 (20:23 +0100)
Signed-off-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: David Sommerseth <davids@redhat.com>
Message-Id: <1477672963-5724-3-git-send-email-heiko.hund@sophos.com>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg12812.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
src/openvpn/argv.c
src/openvpn/argv.h
src/openvpn/console_systemd.c
src/openvpn/route.c
src/openvpn/tun.c

index 2f2a5f504fd44d270fb958510694010f7392880a..19ae3ed0b24d812dfc3bb6a0fd6558a3438223f5 100644 (file)
@@ -39,7 +39,7 @@
 #include "argv.h"
 #include "options.h"
 
-void
+static void
 argv_init (struct argv *a)
 {
   a->capacity = 0;
@@ -157,12 +157,6 @@ argv_extract_cmd_name (const char *path)
   return ret;
 }
 
-const char *
-argv_system_str (const struct argv *a)
-{
-  return a->system_str;
-}
-
 static struct argv
 argv_clone (const struct argv *a, const size_t headroom)
 {
@@ -199,7 +193,7 @@ argv_insert_head (const struct argv *a, const char *head)
   return r;
 }
 
-char *
+static char *
 argv_term (const char **f)
 {
   const char *p = *f;
@@ -272,33 +266,13 @@ argv_msg_prefix (const int msglev, const struct argv *a, const char *prefix)
   gc_free (&gc);
 }
 
-void
-argv_printf (struct argv *a, const char *format, ...)
-{
-  va_list arglist;
-  va_start (arglist, format);
-  argv_printf_arglist (a, format, 0, arglist);
-  va_end (arglist);
- }
-
-void
-argv_printf_cat (struct argv *a, const char *format, ...)
-{
-  va_list arglist;
-  va_start (arglist, format);
-  argv_printf_arglist (a, format, APA_CAT, arglist);
-  va_end (arglist);
-}
-
-void
-argv_printf_arglist (struct argv *a, const char *format, const unsigned int flags, va_list arglist)
+static void
+argv_printf_arglist (struct argv *a, const char *format, va_list arglist)
 {
   struct gc_arena gc = gc_new ();
   char *term;
   const char *f = format;
 
-  if (!(flags & APA_CAT))
-    argv_reset (a);
   argv_extend (a, 1); /* ensure trailing NULL */
 
   while ((term = argv_term (&f)) != NULL)
@@ -409,3 +383,22 @@ argv_printf_arglist (struct argv *a, const char *format, const unsigned int flag
     }
   gc_free (&gc);
 }
+
+void
+argv_printf (struct argv *a, const char *format, ...)
+{
+  va_list arglist;
+  argv_reset (a);
+  va_start (arglist, format);
+  argv_printf_arglist (a, format, arglist);
+  va_end (arglist);
+ }
+
+void
+argv_printf_cat (struct argv *a, const char *format, ...)
+{
+  va_list arglist;
+  va_start (arglist, format);
+  argv_printf_arglist (a, format, arglist);
+  va_end (arglist);
+}
index df658a03784024ad34276b3289a9dbf9bc465bdc..5f8e21c51e89b8263153611c3bd9e09f323a57a4 100644 (file)
@@ -40,18 +40,12 @@ struct argv {
   char *system_str;
 };
 
-void argv_init (struct argv *a);
 struct argv argv_new (void);
 void argv_reset (struct argv *a);
-char *argv_term (const char **f);
 const char *argv_str (const struct argv *a, struct gc_arena *gc, const unsigned int flags);
 struct argv argv_insert_head (const struct argv *a, const char *head);
 void argv_msg (const int msglev, const struct argv *a);
 void argv_msg_prefix (const int msglev, const struct argv *a, const char *prefix);
-const char *argv_system_str (const struct argv *a);
-
-#define APA_CAT (1<<0) /* concatentate onto existing struct argv list */
-void argv_printf_arglist (struct argv *a, const char *format, const unsigned int flags, va_list arglist);
 
 void argv_printf (struct argv *a, const char *format, ...)
 #ifdef __GNUC__
index 9cd7575b147054e929345f4af90cd01baa24d3a1..8a953c97efb97060048ab56684db78a9715512af 100644 (file)
@@ -60,9 +60,8 @@ get_console_input_systemd (const char *prompt, const bool echo, char *input, con
 {
     int std_out;
     bool ret = false;
-    struct argv argv;
+    struct argv argv = argv_new ();
 
-    argv_init (&argv);
     argv_printf (&argv, SYSTEMD_ASK_PASSWORD_PATH);
 #ifdef SYSTEMD_NEWER_THAN_216
     /* the --echo support arrived in upstream systemd 217 */
index 96d4e11e35216c946123caee21d170cfb3bf688c..98bb228f7155cd3e537013a891f7fb5c076fc6fd 100644 (file)
@@ -1395,7 +1395,7 @@ add_route (struct route_ipv4 *r,
           const struct env_set *es)
 {
   struct gc_arena gc;
-  struct argv argv;
+  struct argv argv = argv_new ();
   const char *network;
   const char *netmask;
   const char *gateway;
@@ -1406,7 +1406,6 @@ add_route (struct route_ipv4 *r,
     return;
 
   gc_init (&gc);
-  argv_init (&argv);
 
   network = print_in_addr_t (r->network, 0, &gc);
   netmask = print_in_addr_t (r->netmask, 0, &gc);
@@ -1671,7 +1670,7 @@ void
 add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flags, const struct env_set *es)
 {
   struct gc_arena gc;
-  struct argv argv;
+  struct argv argv = argv_new ();
 
   const char *network;
   const char *gateway;
@@ -1693,7 +1692,6 @@ add_route_ipv6 (struct route_ipv6 *r6, const struct tuntap *tt, unsigned int fla
 #endif
 
   gc_init (&gc);
-  argv_init (&argv);
 
   route_ipv6_clear_host_bits (r6);
 
@@ -1933,7 +1931,7 @@ delete_route (struct route_ipv4 *r,
              const struct env_set *es)
 {
   struct gc_arena gc;
-  struct argv argv;
+  struct argv argv = argv_new ();
   const char *network;
   const char *netmask;
   const char *gateway;
@@ -1943,7 +1941,6 @@ delete_route (struct route_ipv4 *r,
     return;
 
   gc_init (&gc);
-  argv_init (&argv);
 
   network = print_in_addr_t (r->network, 0, &gc);
   netmask = print_in_addr_t (r->netmask, 0, &gc);
@@ -2108,7 +2105,7 @@ void
 delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigned int flags, const struct env_set *es)
 {
   struct gc_arena gc;
-  struct argv argv;
+  struct argv argv = argv_new ();
   const char *network;
   const char *gateway;
   const char *device = tt->actual_name;
@@ -2126,7 +2123,6 @@ delete_route_ipv6 (const struct route_ipv6 *r6, const struct tuntap *tt, unsigne
 #endif
 
   gc_init (&gc);
-  argv_init (&argv);
 
   network = print_in6_addr( r6->network, 0, &gc);
   gateway = print_in6_addr( r6->gateway, 0, &gc);
index a312d9112671fc05ff556a6441f4e337745f0bcc..2a87e09b35081ce238141ac7d45ddafc2519008e 100644 (file)
@@ -753,9 +753,7 @@ do_ifconfig (struct tuntap *tt,
       const char *ifconfig_ipv6_local = NULL;
       const char *ifconfig_ipv6_remote = NULL;
       bool do_ipv6 = false;
-      struct argv argv;
-
-      argv_init (&argv);
+      struct argv argv = argv_new ();
 
       msg( M_DEBUG, "do_ifconfig, tt->did_ifconfig_ipv6_setup=%d",
                    tt->did_ifconfig_ipv6_setup );
@@ -1864,9 +1862,8 @@ close_tun (struct tuntap *tt)
     {
        if (tt->type != DEV_TYPE_NULL && tt->did_ifconfig)
          {
-           struct argv argv;
+           struct argv argv = argv_new ();
            struct gc_arena gc = gc_new ();
-           argv_init (&argv);
 
 #ifdef ENABLE_IPROUTE
            if (is_tun_p2p (tt))
@@ -2149,8 +2146,7 @@ solaris_close_tun (struct tuntap *tt)
       /* IPv6 interfaces need to be 'manually' de-configured */
       if ( tt->did_ifconfig_ipv6_setup )
        {
-         struct argv argv;
-         argv_init (&argv);
+         struct argv argv = argv_new ();
          argv_printf( &argv, "%s %s inet6 unplumb",
                       IFCONFIG_PATH, tt->actual_name );
          argv_msg (M_INFO, &argv);
@@ -2213,8 +2209,7 @@ static void
 solaris_error_close (struct tuntap *tt, const struct env_set *es, 
                      const char *actual, bool unplumb_inet6 )
 {
-  struct argv argv;
-  argv_init (&argv);
+  struct argv argv = argv_new ();
 
   if (unplumb_inet6)
     {
@@ -2306,12 +2301,11 @@ close_tun (struct tuntap* tt)
   else if (tt)
     {
       struct gc_arena gc = gc_new ();
-      struct argv argv;
+      struct argv argv = argv_new ();
 
       /* setup command, close tun dev (clears tt->actual_name!), run command
        */
 
-      argv_init (&argv);
       argv_printf (&argv, "%s %s destroy",
                           IFCONFIG_PATH, tt->actual_name);
 
@@ -2392,12 +2386,11 @@ close_tun (struct tuntap *tt)
   else if (tt)
     {
       struct gc_arena gc = gc_new ();
-      struct argv argv;
+      struct argv argv = argv_new ();
 
       /* setup command, close tun dev (clears tt->actual_name!), run command
        */
 
-      argv_init (&argv);
       argv_printf (&argv, "%s %s destroy",
                           IFCONFIG_PATH, tt->actual_name);
 
@@ -2512,12 +2505,11 @@ close_tun (struct tuntap *tt)
     }
   else if (tt)                         /* close and destroy */
     {
-      struct argv argv;
+      struct argv argv = argv_new ();
 
       /* setup command, close tun dev (clears tt->actual_name!), run command
        */
 
-      argv_init (&argv);
       argv_printf (&argv, "%s %s destroy",
                           IFCONFIG_PATH, tt->actual_name);
 
@@ -2848,8 +2840,7 @@ close_tun (struct tuntap* tt)
   if (tt)
     {
       struct gc_arena gc = gc_new ();
-      struct argv argv;
-      argv_init (&argv);
+      struct argv argv = argv_new ();
 
       if (tt->did_ifconfig_ipv6_setup )
        {
@@ -2899,7 +2890,6 @@ open_tun (const char *dev, const char *dev_type, const char *dev_node, struct tu
   char tunname[256];
   char dynamic_name[20];
   const char *p;
-  struct argv argv;
 
   if (tt->type == DEV_TYPE_NULL)
     {
@@ -2950,8 +2940,8 @@ open_tun (const char *dev, const char *dev_type, const char *dev_node, struct tu
 
       /* tunnel device must be created with 'ifconfig tapN create'
        */
+      struct argv argv = argv_new ();
       struct env_set *es = env_set_create (NULL);
-      argv_init (&argv);
       argv_printf (&argv, "%s %s create", IFCONFIG_PATH, dev);
       argv_msg (M_INFO, &argv);
       env_set_add( es, "ODMDIR=/etc/objrepos" );
@@ -2983,15 +2973,13 @@ void
 close_tun (struct tuntap* tt)
 {
   struct gc_arena gc = gc_new ();
-  struct argv argv;
+  struct argv argv = argv_new ();
   struct env_set *es = env_set_create (NULL);
 
   if (!tt) return;
 
   /* persistent devices need IP address unconfig, others need destroyal
    */
-  argv_init (&argv);
-
   if (tt->persistent_if)
     {
       argv_printf (&argv, "%s %s 0.0.0.0 down",
@@ -4515,15 +4503,13 @@ netsh_command (const struct argv *a, int n, int msglevel)
 void
 ipconfig_register_dns (const struct env_set *es)
 {
-  struct argv argv;
+  struct argv argv = argv_new ();
   bool status;
   const char err[] = "ERROR: Windows ipconfig command failed";
 
   msg (D_TUNTAP_INFO, "Start net commands...");
   netcmd_semaphore_lock ();
 
-  argv_init (&argv);
-
   argv_printf (&argv, "%s%sc stop dnscache",
               get_win_sys_path(),
               WIN_NET_PATH_SUFFIX);
@@ -4791,8 +4777,7 @@ static void
 netsh_enable_dhcp (const struct tuntap_options *to,
                   const char *actual_name)
 {
-  struct argv argv;
-  argv_init (&argv);
+  struct argv argv = argv_new ();
 
   /* example: netsh interface ip set address my-tap dhcp */
   argv_printf (&argv,
@@ -5558,8 +5543,7 @@ close_tun (struct tuntap *tt)
           else
             {
               const char *ifconfig_ipv6_local;
-              struct argv argv;
-              argv_init (&argv);
+              struct argv argv = argv_new ();
 
               /* remove route pointing to interface */
               delete_route_connected_v6_net(tt, NULL);