documentazione_3di_riservata:manuali_sysadmin:pcf2vpnc
Differenze
Queste sono le differenze tra la revisione selezionata e la versione attuale della pagina.
documentazione_3di_riservata:manuali_sysadmin:pcf2vpnc [2015/11/25 14:34] – creata spassarotto | documentazione_3di_riservata:manuali_sysadmin:pcf2vpnc [Data sconosciuta] (versione attuale) – eliminata - modifica esterna (Data sconosciuta) 127.0.0.1 | ||
---|---|---|---|
Linea 1: | Linea 1: | ||
- | # | ||
- | # Stefan Tomanek < | ||
- | # updated by Wolfram Sang < | ||
- | ## | ||
- | # pcf2vpnc <pcf file> [vpnc file] | ||
- | ## | ||
- | # This program is free software; you can redistribute it and/or modify | ||
- | # it under the terms of the GNU General Public License as published by | ||
- | # the Free Software Foundation; either version 2 of the License, or | ||
- | # (at your option) any later version. | ||
- | # | ||
- | # This program is distributed in the hope that it will be useful, | ||
- | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
- | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | ||
- | # GNU General Public License for more details. | ||
- | # | ||
- | # You should have received a copy of the GNU General Public License | ||
- | # along with this program; if not, write to the Free Software | ||
- | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 | ||
- | # | ||
- | # $Id$ | ||
- | |||
- | use IO::File; | ||
- | use strict; | ||
- | use warnings; | ||
- | |||
- | my %authmode = ( 1 => ' | ||
- | my $needs_cert = 0; | ||
- | my $no_decrypt = 0; | ||
- | if (system(" | ||
- | $no_decrypt = 1; | ||
- | print STDERR " | ||
- | print STDERR " | ||
- | } | ||
- | |||
- | sub readPCF($) { | ||
- | my ($file) = @_; | ||
- | my %config; | ||
- | while (< | ||
- | # Filter unnecessary chars at beginning & end of line | ||
- | s/^!*//; s/[\r ]*$//; | ||
- | if (/ | ||
- | # We don't need emtpy config strings | ||
- | next if ($2 eq "" | ||
- | if ($1 eq " | ||
- | $config{IPSec}{gateway} = $2; | ||
- | } elsif ($1 eq " | ||
- | $config{IPSec}{ID} = $2; | ||
- | } elsif ($1 eq " | ||
- | $config{IPSec}{secret} = $2; | ||
- | } elsif ($1 eq " | ||
- | if ($no_decrypt) { | ||
- | $config{IPSec}{obfuscated} = " | ||
- | } else { | ||
- | $config{IPSec}{secret} = `cisco-decrypt $2`; | ||
- | } | ||
- | } elsif ($1 eq " | ||
- | $config{IKE}{Authmode} = $authmode{$2}; | ||
- | if ($2 == 3 || $2 == 5) { | ||
- | $needs_cert = 1; | ||
- | } | ||
- | } elsif ($1 eq " | ||
- | $config{IKE}{DH} = "Group dh$2"; | ||
- | } elsif ($1 eq " | ||
- | $config{Xauth}{username} = $2; | ||
- | } elsif ($1 eq " | ||
- | $config{Xauth}{password} = $2; | ||
- | } elsif ($1 eq " | ||
- | if ($no_decrypt) { | ||
- | $config{Xauth}{obfuscated} = " | ||
- | } else { | ||
- | $config{Xauth}{password} = `cisco-decrypt $2`; | ||
- | } | ||
- | } elsif ($1 eq " | ||
- | $config{Domain}{"" | ||
- | } | ||
- | } | ||
- | } | ||
- | return \%config; | ||
- | } | ||
- | |||
- | sub writeVPNC($) { | ||
- | my ($config) = @_; | ||
- | my $text = "## generated by pcf2vpnc\n"; | ||
- | foreach my $section (keys %$config) { | ||
- | foreach my $item (keys %{ $config-> | ||
- | $text .= " | ||
- | } | ||
- | } | ||
- | unless (defined $config-> | ||
- | $text .= "\n## To add your username and password, | ||
- | $text .= "## use the following lines: | ||
- | $text .= "# Xauth username <your username> | ||
- | $text .= "# Xauth password <your password> | ||
- | } | ||
- | return $text; | ||
- | } | ||
- | |||
- | if (defined $ARGV[0]) { | ||
- | my $src = new IO:: | ||
- | if (defined $ARGV[1]) { | ||
- | my $dst = new IO:: | ||
- | $dst-> | ||
- | $dst-> | ||
- | printf STDERR "vpnc config written to ' | ||
- | print | ||
- | } else { | ||
- | print writeVPNC(readPCF($src)); | ||
- | } | ||
- | $src-> | ||
- | if ($needs_cert) { | ||
- | print STDERR " | ||
- | } | ||
- | } else { | ||
- | print STDERR "$0 converts VPN-config files from pcf to vpnc-format.\n"; | ||
- | print STDERR " | ||
- | } | ||
/data/attic/documentazione_3di_riservata/manuali_sysadmin/pcf2vpnc.1448458473.txt.gz · Ultima modifica: (modifica esterna)