]>
Commit | Line | Data |
---|---|---|
33f297c9 AM |
1 | #!/usr/bin/perl |
2 | ||
3 | ############################################################################### | |
4 | # # | |
5 | # IPFire.org - A linux based firewall # | |
6 | # Copyright (C) 2013 Alexander Marx <amarx@ipfire.org> # | |
7 | # # | |
8 | # This program is free software: you can redistribute it and/or modify # | |
9 | # it under the terms of the GNU General Public License as published by # | |
10 | # the Free Software Foundation, either version 3 of the License, or # | |
11 | # (at your option) any later version. # | |
12 | # # | |
13 | # This program is distributed in the hope that it will be useful, # | |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # | |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # | |
16 | # GNU General Public License for more details. # | |
17 | # # | |
18 | # You should have received a copy of the GNU General Public License # | |
19 | # along with this program. If not, see <http://www.gnu.org/licenses/>. # | |
20 | # # | |
21 | ############################################################################### | |
22 | # # | |
23 | # This script converts old openvpn ccd files with underscore # | |
24 | # to files with spaces to make them working with openvpn 2.3 again # | |
25 | # STEP1: read ovpnconfig and verify cert names # | |
26 | # STEP2: if neccessary convert ccd file # | |
27 | # # | |
28 | ############################################################################### | |
29 | ||
42dbdb20 MT |
30 | require '/var/ipfire/general-functions.pl'; |
31 | ||
33f297c9 AM |
32 | my %configovpn=(); |
33 | my $ccdpath="/var/ipfire/ovpn/ccd/"; | |
34 | my $ovpnconfig="/var/ipfire/ovpn/ovpnconfig"; | |
33f297c9 AM |
35 | |
36 | &General::readhasharray ($ovpnconfig,\%configovpn); | |
37 | ||
42dbdb20 | 38 | &check_config(); |
33f297c9 | 39 | |
42dbdb20 MT |
40 | sub check_config { |
41 | print "Converting CCD files...\n"; | |
42 | chdir($ccdpath); | |
33f297c9 | 43 | |
33f297c9 | 44 | foreach my $key (sort keys %configovpn){ |
42dbdb20 MT |
45 | # Skip everything else but roadwarrior connections. |
46 | next if ($configovpn{$key}[3] ne 'host'); | |
47 | ||
48 | # Skip all connections with no space in the CN name. | |
49 | next if ($configovpn{$key}[2] !~ " "); | |
50 | ||
51 | my $ccdname = $configovpn{$key}[2]; | |
52 | $ccdname =~ tr/ /_/; | |
53 | ||
54 | # Rename the CCD file if one with the old format exists. | |
55 | if (-e "$ccdname") { | |
56 | print " Renaming $ccdname -> $configovpn{$key}[2]...\n"; | |
57 | rename($ccdname, $configovpn{$key}[2]); | |
33f297c9 AM |
58 | } |
59 | } | |
60 | } |