r51523 - in /trunk/libconfig-model-openssh-perl: ChangeLog MANIFEST META.yml debian/changelog lib/Config/Model/OpenSsh.pm lib/Config/Model/models/Ssh/HostElement.pl lib/Config/Model/models/Ssh/PortForward.pl t/ssh_config.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Mon Jan 25 02:08:54 UTC 2010


Author: jawnsy-guest
Date: Mon Jan 25 02:08:49 2010
New Revision: 51523

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=51523
Log:
New upstream release

Added:
    trunk/libconfig-model-openssh-perl/lib/Config/Model/models/Ssh/PortForward.pl
      - copied unchanged from r51521, branches/upstream/libconfig-model-openssh-perl/current/lib/Config/Model/models/Ssh/PortForward.pl
Modified:
    trunk/libconfig-model-openssh-perl/ChangeLog
    trunk/libconfig-model-openssh-perl/MANIFEST
    trunk/libconfig-model-openssh-perl/META.yml
    trunk/libconfig-model-openssh-perl/debian/changelog
    trunk/libconfig-model-openssh-perl/lib/Config/Model/OpenSsh.pm
    trunk/libconfig-model-openssh-perl/lib/Config/Model/models/Ssh/HostElement.pl
    trunk/libconfig-model-openssh-perl/t/ssh_config.t

Modified: trunk/libconfig-model-openssh-perl/ChangeLog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-model-openssh-perl/ChangeLog?rev=51523&op=diff
==============================================================================
--- trunk/libconfig-model-openssh-perl/ChangeLog (original)
+++ trunk/libconfig-model-openssh-perl/ChangeLog Mon Jan 25 02:08:49 2010
@@ -1,3 +1,11 @@
+2010-01-22  Dominique Dumont  <dominique.dumont at hp.com> v1.210
+
+	* lib/Config/Model/OpenSsh.pm: Modified to read and write Port
+	forward information from PortForward config class.
+
+	* lib/Config/Model/models/Ssh/PortForward.pl: New configuration
+	class to make ssh port forwarding configuration easier.
+
 2010-01-18  Dominique Dumont  <dominique.dumont at hp.com> v1.209
 
 	* lib/Config/Model/models/Sshd.pl: Added automatic migration of

Modified: trunk/libconfig-model-openssh-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-model-openssh-perl/MANIFEST?rev=51523&op=diff
==============================================================================
--- trunk/libconfig-model-openssh-perl/MANIFEST (original)
+++ trunk/libconfig-model-openssh-perl/MANIFEST Mon Jan 25 02:08:49 2010
@@ -4,6 +4,7 @@
 config-edit-sshd
 lib/Config/Model/models/Ssh.pl
 lib/Config/Model/models/Ssh/HostElement.pl
+lib/Config/Model/models/Ssh/PortForward.pl
 lib/Config/Model/models/Sshd.pl
 lib/Config/Model/models/Sshd/MatchBlock.pl
 lib/Config/Model/models/Sshd/MatchCondition.pl

Modified: trunk/libconfig-model-openssh-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-model-openssh-perl/META.yml?rev=51523&op=diff
==============================================================================
--- trunk/libconfig-model-openssh-perl/META.yml (original)
+++ trunk/libconfig-model-openssh-perl/META.yml Mon Jan 25 02:08:49 2010
@@ -4,7 +4,7 @@
   - 'Dominique Dumont (ddumont at cpan dot org)'
 configure_requires:
   Module::Build: 0.36
-generated_by: 'Module::Build version 0.3601'
+generated_by: 'Module::Build version 0.3603'
 license: lgpl
 meta-spec:
   url: http://module-build.sourceforge.net/META-spec-v1.4.html
@@ -13,7 +13,7 @@
 provides:
   Config::Model::OpenSsh:
     file: lib/Config/Model/OpenSsh.pm
-    version: 1.209
+    version: 1.210
 recommends:
   Config::Model::Backend::Augeas: 0
   Config::Model::CursesUI: 0
@@ -25,4 +25,4 @@
   perl: v5.8.0
 resources:
   license: http://opensource.org/licenses/lgpl-license.php
-version: 1.209
+version: 1.210

Modified: trunk/libconfig-model-openssh-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-model-openssh-perl/debian/changelog?rev=51523&op=diff
==============================================================================
--- trunk/libconfig-model-openssh-perl/debian/changelog (original)
+++ trunk/libconfig-model-openssh-perl/debian/changelog Mon Jan 25 02:08:49 2010
@@ -1,3 +1,9 @@
+libconfig-model-openssh-perl (1.210-1) UNRELEASED; urgency=low
+
+  * New upstream release
+
+ -- Jonathan Yu <jawnsy at cpan.org>  Sun, 24 Jan 2010 21:14:29 -0500
+
 libconfig-model-openssh-perl (1.209-1) unstable; urgency=low
 
   [ Jonathan Yu ]

Modified: trunk/libconfig-model-openssh-perl/lib/Config/Model/OpenSsh.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-model-openssh-perl/lib/Config/Model/OpenSsh.pm?rev=51523&op=diff
==============================================================================
--- trunk/libconfig-model-openssh-perl/lib/Config/Model/OpenSsh.pm (original)
+++ trunk/libconfig-model-openssh-perl/lib/Config/Model/OpenSsh.pm Mon Jan 25 02:08:49 2010
@@ -18,7 +18,7 @@
 use Parse::RecDescent ;
 use vars qw($VERSION $grammar $parser)  ;
 
-$VERSION = '1.209' ;
+$VERSION = '1.210' ;
 
 
 my $logger = Log::Log4perl::get_logger(__PACKAGE__);
@@ -177,7 +177,7 @@
 sshd_parse: <skip: qr/[^\S\n]*/> line[@arg](s) 
 
 #line: match_line | client_alive_line | host_line | any_line
-line: match_line | host_line | any_line
+line: match_line | host_line | forward_line | single_arg_line | any_line
 
 match_line: /match/i arg(s) "\n"
 {
@@ -192,6 +192,16 @@
 host_line: /host\b/i arg(s) "\n"
 {
    Config::Model::OpenSsh::host($arg[0],@{$item[2]}) ;
+}
+
+forward_line: /(local|remote)forward/i arg(s) "\n"
+{
+   Config::Model::OpenSsh::forward($arg[0],$item[1],@{$item[2]}) ;
+}
+
+single_arg_line: /localcommand/i /[^\n]+/ "\n"
+{
+   Config::Model::OpenSsh::assign($arg[0],$item[1],$item[2]) ;
 }
 
 any_line: key arg(s) "\n"  
@@ -282,6 +292,39 @@
     $current_node = $hash_obj->fetch_with_id("@patterns");
   }
 
+  sub forward {
+    my ($root,$key, at args)  = @_;
+    $current_node = $root unless defined $current_node ;
+
+    my $elt_name = $key =~ /local/i ? 'Localforward' : 'RemoteForward' ;
+    my $size = $current_node->fetch_element($key)->fetch_size;
+
+    $logger->info("ssh: load $key '".join("','", @args)."'");
+
+    my $v6 = ($args[1] =~ m![/\[\]]!) ? 1 : 0;
+
+    # cleanup possible square brackets used for IPv6
+    foreach (@args) {s/[\[\]]+//g;}
+
+    # reverse enable to assign string to port even if no bind_adress
+    # is specified
+    my $re = $v6 ? qr!/! : qr!:! ; 
+    my ($port,$bind_adr ) = reverse split $re,$args[0] ;
+    my ($host,$host_port) = split $re,$args[1] ;
+
+    my $load_str = '';
+    $load_str .= "GatewayPorts=1 " if $bind_adr ;
+
+    $load_str .= "$key:$size ";
+
+    $load_str .= 'ipv6=1 ' if $v6 ;
+
+    $load_str .= "bind_address=$bind_adr " if defined $bind_adr ;
+    $load_str .= "port=$port host=$host hostport=$host_port";
+
+    $current_node -> load($load_str) ;
+  }
+
   sub clear {
     $current_node = undef ;
   }
@@ -383,6 +426,9 @@
 	}
 	elsif    ($name eq 'Host') { 
 	    $match .= write_all_host_block($elt,$mode) ;
+	}
+	elsif    ($name =~ /^(Local|Remote)Forward$/) { 
+	    map { $result .= write_forward($_,$mode) ;} $elt->fetch_all() ;
 	}
 #	elsif    ($name eq 'ClientAliveCheck') { 
 #	    # special case that must be skipped
@@ -484,6 +530,29 @@
     }
     return $result ;
 }
+
+sub write_forward {
+    my $forward_elt = shift ;
+    my $mode = shift || '';
+
+    my $result = '' ;
+
+    my $v6 = $forward_elt->grab_value('ipv6') ;
+    my $sep = $v6 ? '/' : ':';
+
+    my $line = '';
+    foreach my $name ($forward_elt->get_element_name(for => 'master') ) {
+	next if $name eq 'ipv6' ;
+	my $elt = $forward_elt->fetch_element($name) ;
+	my $v = $elt->fetch($mode) ;
+	next unless defined $v;
+	$line .=  $name =~ /bind|host$/ ? "$v$sep"
+	       :  $name eq 'port'       ? "$v "
+	       :                           $v ;
+    }
+
+    return write_line($forward_elt->element_name,$line) ;
+}
 1;
 
 =head1 AUTHOR

Modified: trunk/libconfig-model-openssh-perl/lib/Config/Model/models/Ssh/HostElement.pl
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-model-openssh-perl/lib/Config/Model/models/Ssh/HostElement.pl?rev=51523&op=diff
==============================================================================
--- trunk/libconfig-model-openssh-perl/lib/Config/Model/models/Ssh/HostElement.pl (original)
+++ trunk/libconfig-model-openssh-perl/lib/Config/Model/models/Ssh/HostElement.pl Mon Jan 25 02:08:49 2010
@@ -238,13 +238,6 @@
 See the X11 SECURITY extension specification for full details on the restrictions imposed on untrusted clients.
 '
                            },
-                           'GatewayPorts',
-                           {
-                             'value_type' => 'boolean',
-                             'upstream_default' => '0',
-                             'type' => 'leaf',
-                             'description' => 'Specifies whether remote hosts are allowed to connect to local forwarded ports. By default, ssh(1) binds local port forwardings to the loopback address. This prevents other remote hosts from connecting to forwarded ports. GatewayPorts can be used to specify that ssh should bind local port forwardings to the wildcard address, thus allowing remote hosts to connect to forwarded ports. '
-                           },
                            'GlobalKnownHostsFile',
                            {
                              'value_type' => 'uniline',
@@ -357,11 +350,19 @@
                              'type' => 'list',
                              'description' => 'Specifies the list of methods to use in keyboard-interactive authentication.  Multiple method names must be comma-separated. The default is to use the server specified list. The methods available vary depending on what the server supports. For an OpenSSH server, it may be zero or more of: ``bsdauth\'\', ``pam\'\', and ``skey\'\'.'
                            },
+                           'GatewayPorts',
+                           {
+                             'value_type' => 'boolean',
+                             'upstream_default' => '0',
+                             'experience' => 'advanced',
+                             'type' => 'leaf',
+                             'description' => 'Specifies whether remote hosts are allowed to connect to local forwarded ports. By default, ssh(1) binds local port forwardings to the loopback address. This prevents other remote hosts from connecting to forwarded ports. GatewayPorts can be used to specify that ssh should bind local port forwardings to the wildcard address, thus allowing remote hosts to connect to forwarded ports. '
+                           },
                            'LocalForward',
                            {
                              'cargo' => {
-                                          'value_type' => 'uniline',
-                                          'type' => 'leaf'
+                                          'type' => 'node',
+                                          'config_class_name' => 'Ssh::PortForward'
                                         },
                              'summary' => 'Local port forwarding',
                              'experience' => 'advanced',
@@ -531,15 +532,15 @@
                            {
                              'level' => 'important',
                              'cargo' => {
-                                          'value_type' => 'uniline',
-                                          'type' => 'leaf'
+                                          'type' => 'node',
+                                          'config_class_name' => 'Ssh::PortForward'
                                         },
                              'summary' => 'remote port forward to local',
                              'experience' => 'advanced',
                              'type' => 'list',
-                             'description' => 'Specifies that a TCP port on the remote machine be forwarded over the secure channel to the specified host and port from the local machine.  The first argument must be [bind_address:]port and the second argument must be host:hostport.  IPv6 addresses can be specified by enclosing addresses in square brackets or by using an alternative syntax: [bind_address/]port and host/hostport. Multiple forwardings may be specified, and additional forwardings can be given on the command line.  Only the superuser can forward privileged ports.
-
-If the bind_address is not specified, the default is to only bind to loopback addresses.  If the bind_address is \'*\' or an empty string, then the forwarding is requested to listen on all inter faces.  Specifying a remote bind_address will only succeed if the server\'s GatewayPorts option is enabled (see sshd_config(5)).'
+                             'description' => 'Specifies that a TCP port on the remote machine be forwarded over the secure channel to the specified host and port from the local machine. Multiple forwardings may be specified, and additional forwardings can be given on the command line. Only the superuser can forward privileged ports.
+
+If the bind_address is not specified, the default is to only bind to loopback addresses. If the bind_address is \'*\' or an empty string, then the forwarding is requested to listen on all inter faces. Specifying a remote bind_address will only succeed if the server\'s GatewayPorts option is enabled (see sshd_config(5)).'
                            },
                            'RhostsRSAAuthentication',
                            {

Modified: trunk/libconfig-model-openssh-perl/t/ssh_config.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libconfig-model-openssh-perl/t/ssh_config.t?rev=51523&op=diff
==============================================================================
--- trunk/libconfig-model-openssh-perl/t/ssh_config.t (original)
+++ trunk/libconfig-model-openssh-perl/t/ssh_config.t Mon Jan 25 02:08:49 2010
@@ -4,7 +4,7 @@
 # $Revision: 608 $
 
 use ExtUtils::testlib;
-use Test::More tests => 12;
+use Test::More tests => 17;
 use Config::Model ;
 use Config::Model::OpenSsh ; # required for tests
 use Log::Log4perl qw(:easy) ;
@@ -94,9 +94,14 @@
 print $dump if $trace ;
 
 like($dump,qr/Host:foo\.\*,\*\.bar/, "check Host pattern") ;
-
-$root_inst->write_back() ;
-ok(1,"wrote ssh_config data in $wr_dir") ;
+like($dump,qr/LocalForward:0\s+port=20022/, "check user LocalForward port") ;
+like($dump,qr/host=10.3.244.4/, "check user LocalForward host") ;
+like($dump,qr/LocalForward:1\s+ipv6=1/, "check user LocalForward ipv6") ;
+like($dump,qr/port=22080/, "check user LocalForward port ipv6") ;
+like($dump,qr/host=2001:0db8:85a3:0000:0000:8a2e:0370:7334/, 
+     "check user LocalForward host ipv6") ;
+
+$root_inst->write_back() ; ok(1,"wrote ssh_config data in $wr_dir") ;
 
 my $inst2 = $model->instance (root_class_name   => 'Ssh',
 			      instance_name     => 'root_ssh_instance2',
@@ -194,3 +199,23 @@
 Host foo.*,*.bar
     ForwardX11 yes
     SendEnv FOO BAR
+
+Host *.gre.hp.com
+ForwardX11           yes
+User                 tester
+
+Host picosgw
+ForwardAgent         yes
+HostName             sshgw.truc.bidule
+IdentityFile         ~/.ssh/%r
+LocalForward         20022         10.3.244.4:22
+# IPv6 example
+LocalForward         all.com/22080       2001:0db8:85a3:0000:0000:8a2e:0370:7334/80
+User                 k0013
+
+Host picos
+ForwardX11           yes
+HostName             localhost
+Port                 20022
+User                 ocad
+




More information about the Pkg-perl-cvs-commits mailing list