~smoser/ubuntu/oneiric/openvpn/lp-794916

« back to all changes in this revision

Viewing changes to multi.c

  • Committer: Bazaar Package Importer
  • Author(s): Alberto Gonzalez Iniesta
  • Date: 2008-08-16 13:34:24 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20080816133424-0i83yb6dw4hjglo1
Tags: 2.1~rc9-3
* debian/rules: run ./configure with path to 'route', for
  those build daemons without 'route'. (Closes: #495082)
* Created NEWS.Debian with info on new option script-security.
  (Closes: #494998)

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
 *             packet encryption, packet authentication, and
6
6
 *             packet compression.
7
7
 *
8
 
 *  Copyright (C) 2002-2008 OpenVPN Solutions LLC <info@openvpn.net>
 
8
 *  Copyright (C) 2002-2008 Telethra, Inc. <sales@openvpn.net>
9
9
 *
10
10
 *  This program is free software; you can redistribute it and/or modify
11
11
 *  it under the terms of the GNU General Public License version 2
85
85
 
86
86
  if (plugin_defined (plugins, OPENVPN_PLUGIN_LEARN_ADDRESS))
87
87
    {
88
 
      struct buffer cmd = alloc_buf_gc (256, &gc);
89
 
 
90
 
      buf_printf (&cmd, "\"%s\" \"%s\"",
91
 
                  op,
92
 
                  mroute_addr_print (addr, &gc));
 
88
      struct argv argv = argv_new ();
 
89
      argv_printf (&argv, "%s %s",
 
90
                   op,
 
91
                   mroute_addr_print (addr, &gc));
93
92
      if (mi)
94
 
        buf_printf (&cmd, " \"%s\"", tls_common_name (mi->context.c2.tls_multi, false));
95
 
 
96
 
      if (plugin_call (plugins, OPENVPN_PLUGIN_LEARN_ADDRESS, BSTR (&cmd), NULL, es) != OPENVPN_PLUGIN_FUNC_SUCCESS)
 
93
        argv_printf_cat (&argv, "%s", tls_common_name (mi->context.c2.tls_multi, false));
 
94
      if (plugin_call (plugins, OPENVPN_PLUGIN_LEARN_ADDRESS, &argv, NULL, es) != OPENVPN_PLUGIN_FUNC_SUCCESS)
97
95
        {
98
96
          msg (M_WARN, "WARNING: learn-address plugin call failed");
99
97
          ret = false;
100
98
        }
 
99
      argv_reset (&argv);
101
100
    }
102
101
 
103
102
  if (m->top.options.learn_address_script)
104
103
    {
105
 
      struct buffer cmd = alloc_buf_gc (256, &gc);
106
 
 
 
104
      struct argv argv = argv_new ();
107
105
      setenv_str (es, "script_type", "learn-address");
108
 
 
109
 
      buf_printf (&cmd, "%s \"%s\" \"%s\"",
110
 
                  m->top.options.learn_address_script,
111
 
                  op,
112
 
                  mroute_addr_print (addr, &gc));
 
106
      argv_printf (&argv, "%s %s %s",
 
107
                   m->top.options.learn_address_script,
 
108
                   op,
 
109
                   mroute_addr_print (addr, &gc));
113
110
      if (mi)
114
 
        buf_printf (&cmd, " \"%s\"", tls_common_name (mi->context.c2.tls_multi, false));
115
 
 
116
 
      if (!system_check (BSTR (&cmd), es, S_SCRIPT, "WARNING: learn-address command failed"))
 
111
        argv_printf_cat (&argv, "%s", tls_common_name (mi->context.c2.tls_multi, false));
 
112
      if (!openvpn_execve_check (&argv, es, S_SCRIPT, "WARNING: learn-address command failed"))
117
113
        ret = false;
 
114
      argv_reset (&argv);
118
115
    }
119
116
 
120
117
  gc_free (&gc);
474
471
 
475
472
      if (mi->context.options.client_disconnect_script)
476
473
        {
477
 
          struct gc_arena gc = gc_new ();
478
 
          struct buffer cmd = alloc_buf_gc (256, &gc);
479
 
 
 
474
          struct argv argv = argv_new ();
480
475
          setenv_str (mi->context.c2.es, "script_type", "client-disconnect");
481
 
          
482
 
          buf_printf (&cmd, "%s", mi->context.options.client_disconnect_script);
483
 
 
484
 
          system_check (BSTR (&cmd), mi->context.c2.es, S_SCRIPT, "client-disconnect command failed");
485
 
          
486
 
          gc_free (&gc);
 
476
          argv_printf (&argv, "%s", mi->context.options.client_disconnect_script);
 
477
          openvpn_execve_check (&argv, mi->context.c2.es, S_SCRIPT, "client-disconnect command failed");
 
478
          argv_reset (&argv);
487
479
        }
488
480
#ifdef MANAGEMENT_DEF_AUTH
489
481
      if (management)
1523
1515
      /* deprecated callback, use a file for passing back return info */
1524
1516
      if (plugin_defined (mi->context.plugins, OPENVPN_PLUGIN_CLIENT_CONNECT))
1525
1517
        {
 
1518
          struct argv argv = argv_new ();
1526
1519
          const char *dc_file = create_temp_filename (mi->context.options.tmp_dir, "cc", &gc);
1527
 
 
 
1520
          argv_printf (&argv, "%s", dc_file);
1528
1521
          delete_file (dc_file);
1529
 
 
1530
 
          if (plugin_call (mi->context.plugins, OPENVPN_PLUGIN_CLIENT_CONNECT, dc_file, NULL, mi->context.c2.es) != OPENVPN_PLUGIN_FUNC_SUCCESS)
 
1522
          if (plugin_call (mi->context.plugins, OPENVPN_PLUGIN_CLIENT_CONNECT, &argv, NULL, mi->context.c2.es) != OPENVPN_PLUGIN_FUNC_SUCCESS)
1531
1523
            {
1532
1524
              msg (M_WARN, "WARNING: client-connect plugin call failed");
1533
1525
              cc_succeeded = false;
1537
1529
              multi_client_connect_post (m, mi, dc_file, option_permissions_mask, &option_types_found);
1538
1530
              ++cc_succeeded_count;
1539
1531
            }
 
1532
          argv_reset (&argv);
1540
1533
        }
1541
1534
 
1542
1535
      /* V2 callback, use a plugin_return struct for passing back return info */
1566
1559
       */
1567
1560
      if (mi->context.options.client_connect_script && cc_succeeded)
1568
1561
        {
1569
 
          struct buffer cmd = alloc_buf_gc (256, &gc);
 
1562
          struct argv argv = argv_new ();
1570
1563
          const char *dc_file = NULL;
1571
1564
 
1572
1565
          setenv_str (mi->context.c2.es, "script_type", "client-connect");
1575
1568
 
1576
1569
          delete_file (dc_file);
1577
1570
 
1578
 
          buf_printf (&cmd, "%s %s",
1579
 
                      mi->context.options.client_connect_script,
1580
 
                      dc_file);
 
1571
          argv_printf (&argv, "%s %s",
 
1572
                       mi->context.options.client_connect_script,
 
1573
                       dc_file);
1581
1574
 
1582
 
          if (system_check (BSTR (&cmd), mi->context.c2.es, S_SCRIPT, "client-connect command failed"))
 
1575
          if (openvpn_execve_check (&argv, mi->context.c2.es, S_SCRIPT, "client-connect command failed"))
1583
1576
            {
1584
1577
              multi_client_connect_post (m, mi, dc_file, option_permissions_mask, &option_types_found);
1585
1578
              ++cc_succeeded_count;
1586
1579
            }
1587
1580
          else
1588
1581
            cc_succeeded = false;
 
1582
 
 
1583
          argv_reset (&argv);
1589
1584
        }
1590
1585
 
1591
1586
      /*