diff options
-rw-r--r-- | etc/inc/openvpn.inc | 35 | ||||
-rw-r--r-- | usr/local/pkg/openvpn.xml | 7 | ||||
-rw-r--r-- | usr/local/www/vpn_openvpn_certs.php | 23 | ||||
-rw-r--r-- | usr/local/www/vpn_openvpn_certs_create.php | 21 |
4 files changed, 25 insertions, 61 deletions
diff --git a/etc/inc/openvpn.inc b/etc/inc/openvpn.inc index a8581a9..6bba755 100644 --- a/etc/inc/openvpn.inc +++ b/etc/inc/openvpn.inc @@ -40,18 +40,31 @@ require_once('util.inc'); // Return the list of ciphers OpenVPN supports function openvpn_get_ciphers($pkg) { - foreach ($pkg['fields']['field'] as $i => $field) { - if ($field['fieldname'] == 'crypto') break; - } - $option_array = &$pkg['fields']['field'][$i]['options']['option']; - $ciphers_out = shell_exec('openvpn --show-ciphers | grep "default key" | awk \'{print $1, "(" $2 "-" $3 ")";}\''); - $ciphers = explode("\n", trim($ciphers_out)); - sort($ciphers); - foreach ($ciphers as $cipher) { - $value = explode(' ', $cipher); - $value = $value[0]; - $option_array[] = array('value' => $value, 'name' => $cipher); + global $config; + + foreach ($pkg['fields']['field'] as $i => $field) { + if ($field['fieldname'] == 'crypto') { + $option_array = &$pkg['fields']['field'][$i]['options']['option']; + $ciphers_out = shell_exec('openvpn --show-ciphers | grep "default key" | awk \'{print $1, "(" $2 "-" $3 ")";}\''); + $ciphers = explode("\n", trim($ciphers_out)); + sort($ciphers); + foreach ($ciphers as $cipher) { + $value = explode(' ', $cipher); + $value = $value[0]; + $option_array[] = array('value' => $value, 'name' => $cipher); + } + } + if ($field['fieldname'] == 'cipher') { + if (is_array($config['openvpn']['keys'])) { + if (count($config['openvpn']['keys']) > 0) { + $option_array = &$pkg['fields']['field'][$i]['options']['option']; + foreach ($config['openvpn']['keys'] as $cipher => $none) { + $option_array[] = array('value' => $cipher, 'name' => $cipher); + } + } + } } + } } diff --git a/usr/local/pkg/openvpn.xml b/usr/local/pkg/openvpn.xml index e492f81..622bd66 100644 --- a/usr/local/pkg/openvpn.xml +++ b/usr/local/pkg/openvpn.xml @@ -161,12 +161,7 @@ <fielddescr>Certificates to apply</fielddescr> <description>Certificates generated from the certificate generation tab.</description> <type>select</type> - <options> - <option> - <value>none</value> - <name>none</name> - </option> - </options> + <default_value>none</default_value> </field> <field> <fieldname>dhcp_domainname</fieldname> diff --git a/usr/local/www/vpn_openvpn_certs.php b/usr/local/www/vpn_openvpn_certs.php index dd0154c..5bbbb3f 100644 --- a/usr/local/www/vpn_openvpn_certs.php +++ b/usr/local/www/vpn_openvpn_certs.php @@ -51,29 +51,6 @@ if ($_GET['delete']) { write_config(); } } - /* XXX: Lets do some hacking now! This implies we are not on embedded platform!!! */ - $pkg_config = parse_xml_config_pkg("/usr/local/pkg/openvpn.xml", "packagegui"); - $options =& $pkg_config['fields']['field'][11]['options']['option']; - if (is_array($options)) { - for ($i = 0; $i < count($options); $i++) { - if ($options[$i]['name'] == $caname) { - unset($options[$i]); - break; - } - } - - conf_mount_rw(); - - $xmlcf = dump_xml_config_pkg($pkg_config, "packagegui"); - /* write new configuration */ - $fd = fopen("/usr/local/pkg/openvpn.xml", "w"); - if (!$fd) - die("Unable to open openvpn.xml for writing in write_config()\n"); - fwrite($fd, $xmlcf); - fclose($fd); - - conf_mount_ro(); - } } exec("cd ".$g['varetc_path']."/openvpn/certificates && /usr/bin/find . -type d -name \"[a-zA-Z0-9_]*\"", $certificates); diff --git a/usr/local/www/vpn_openvpn_certs_create.php b/usr/local/www/vpn_openvpn_certs_create.php index 676810f..f8bf4a6 100644 --- a/usr/local/www/vpn_openvpn_certs_create.php +++ b/usr/local/www/vpn_openvpn_certs_create.php @@ -190,27 +190,6 @@ if ($_POST) { $ovpnkeys[$caname]['dh_params.dh'] = file_get_contents("$ovpncapath/$caname/dh_params.dh"); /* save it */ write_config(); - /* XXX: Lets do some hacking now! This implies we are not on embedded platform!!! */ - $pkg_config = parse_xml_config_pkg("/usr/local/pkg/openvpn.xml", "packagegui"); - $options =& $pkg_config['fields']['field'][11]['options']['option']; - if (!is_array($options)) - $options = array(); - $opt = array(); - $opt['name'] = $caname; - $opt['value'] = $caname; - $options[] = $opt; - - conf_mount_rw(); - - $xmlcf = dump_xml_config_pkg($pkg_config, "packagegui"); - /* write new configuration */ - $fd = fopen("/usr/local/pkg/openvpn.xml", "w"); - if (!$fd) - die("Unable to open openvpn.xml for writing in write_config()\n"); - fwrite($fd, $xmlcf); - fclose($fd); - - conf_mount_ro(); } else { ?> <tr> <td width="35%" valign="top" class="vncell"><B>Certificate Name</td> |