Changeset 01073f7


Ignore:
Timestamp:
Sep 22, 2008 2:15:46 PM (16 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-1.30, version-2.00, version-3.01, version-3.02
Children:
19cc408
Parents:
7a8d667
Message:

FreeBSD 7.0 compatibility

Location:
fedkit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fedkit/fed-tun.pl

    r7a8d667 r01073f7  
    2525my $IFCONFIG = "/sbin/ifconfig";
    2626my $TMCC = "/usr/local/etc/emulab/tmcc";
    27 my $SSH = "/usr/local/bin/ssh";
     27# If a special version of ssh is required, it will be installed in
     28# /usr/local/bin/ssh.  Otherwise use the usual one.
     29my $SSH = -x "/usr/local/bin/ssh" ? "/usr/local/bin/ssh" : "/usr/bin/ssh";
    2830my $NC = "/usr/bin/nc";
    2931my $SSH_PORT = 22;
     
    4345                                            # dodge the port on the
    4446                                            # remote tunnel node.
     47die "Cannot exec $SSH" unless -x $SSH;
     48
    4549sub setup_bridging;
    4650sub setup_tunnel_cfg;
     
    140144}
    141145
    142 # Both sides need to have GatewayPorts to be set.  Copy the existing
    143 # sshd_config, making sure GatewayPorts is set to yes, replace the original,
    144 # and restart sshd.
     146# Both sides need to have GatewayPorts and PermitTunnel set.  Copy the existing
     147# sshd_config, making sure GatewayPorts and PermitTunnel are set to yes,
     148# replace the original, and restart sshd.
    145149my $ports_on = 0;
     150my $tunnel_on = 0;
    146151
    147152my $conf = new IO::File($sshd_config) || die "Can't open $sshd_config: $!\n";
     
    154159        next;
    155160    };
     161    s/^\s*PermitTunnel.*/PermitTunnel yes/ && do {
     162        print $new_conf $_ unless $tunnel_on++;
     163        next;
     164    };
    156165    print $new_conf $_;
    157166}
    158167print $new_conf "GatewayPorts yes\n" unless $ports_on;
     168print $new_conf "PermitTunnel yes\n" unless $tunnel_on;
    159169$conf->close();
    160170$new_conf->close();
     
    166176
    167177# Need these to make the Ethernet tap and bridge to work...
    168 
     178system("kldload /boot/kernel/bridgestp.ko")
     179    if -r "/boot/kernel/bridgestp.ko";
    169180system("kldload /boot/kernel/if_bridge.ko");
    170181system("kldload /boot/kernel/if_tap.ko");
     
    240251            system("$cmd"); # or die "Failed to run ssh";
    241252        }
    242         $cmd =  "$SSH -w $count:$count -o \"StrictHostKeyChecking no\" " .
     253        # The Tunnel option specifies the level to tunnel at.  Ethernet creates
     254        # a tap device rather than a tun device.  Strict host key checking
     255        # avoids asking the user to OK a strange host key.
     256        $cmd =  "$SSH -w $count:$count -o \"Tunnel ethernet\" " .
     257            "-o \"StrictHostKeyChecking no\" " .
    243258            "$opts{'peer'}  \"$remote_script_dir/fed-tun.pl " .
    244259            "$remote_config_file -r $addr $count\" & |";
  • fedkit/fed-tun.ucb.pl

    r7a8d667 r01073f7  
    2222use IO::File;
    2323use IO::Pipe;
     24use File::Copy;
    2425
    2526my $IFCONFIG = "/sbin/ifconfig";
    2627my $TMCC = "/usr/local/etc/emulab/tmcc";
    27 my $SSH = "/usr/local/bin/ssh";
     28# If a special version of ssh is required, it will be installed in
     29# /usr/local/bin/ssh.  Otherwise use the usual one.
     30my $SSH = -x "/usr/local/bin/ssh" ? "/usr/local/bin/ssh" : "/usr/bin/ssh";
    2831my $NC = "/usr/bin/nc";
    2932my $SSH_PORT = 22;
     
    4245                                            # dodge the port on the
    4346                                            # remote tunnel node.
     47                                           
     48die "Cannot exec $SSH" unless -x $SSH;
     49
    4450sub setup_bridging;
    4551sub setup_tunnel_cfg;
     
    132138}
    133139
    134 # Both sides need to have GatewayPorts to be set.  Copy the existing
    135 # sshd_config, making sure GatewayPorts is set to yes, replace the original,
    136 # and restart sshd.
     140
     141# Both sides need to have GatewayPorts and PermitTunnel set.  Copy the existing
     142# sshd_config, making sure GatewayPorts and PermitTunnel are set to yes,
     143# replace the original, and restart sshd.
    137144my $ports_on = 0;
     145my $tunnel_on = 0;
    138146
    139147my $conf = new IO::File($sshd_config) || die "Can't open $sshd_config: $!\n";
     
    146154        next;
    147155    };
     156    s/^\s*PermitTunnel.*/PermitTunnel yes/ && do {
     157        print $new_conf $_ unless $tunnel_on++;
     158        next;
     159    };
    148160    print $new_conf $_;
    149161}
    150162print $new_conf "GatewayPorts yes\n" unless $ports_on;
     163print $new_conf "PermitTunnel yes\n" unless $tunnel_on;
    151164$conf->close();
    152165$new_conf->close();
     
    159172
    160173# Need these to make the Ethernet tap and bridge to work...
    161 
     174system("kldload /boot/kernel/bridgestp.ko")
     175    if -r "/boot/kernel/bridgestp.ko";
    162176system("kldload /boot/kernel/if_bridge.ko");
    163177system("kldload /boot/kernel/if_tap.ko");
     
    220234        # the expected single line of output when the tunnel is connected.
    221235
    222         print "$SSH -w $count:$count $ssh_port_fwds -o \"StrictHostKeyChecking no\" $opts{'peer'}  \"$remote_script_dir/fed-tun.pl $remote_config_file -r $addr $count\"\n" if $debug;
    223         open($SSHCMD[$count], "$SSH -w $count:$count $ssh_port_fwds -o \"StrictHostKeyChecking no\" $opts{'peer'}  \"$remote_script_dir/fed-tun.pl $remote_config_file -r $addr $count\" |") or die "Failed to run ssh";
     236        # The Tunnel option specifies the level to tunnel at.  Ethernet creates
     237        # a tap device rather than a tun device.  Strict host key checking
     238        # avoids asking the user to OK a strange host key.
     239        my $cmd =  "$SSH -w $count:$count -o \"Tunnel ethernet\" " .
     240            "-o \"StrictHostKeyChecking no\" " .
     241            "$opts{'peer'}  \"$remote_script_dir/fed-tun.pl " .
     242            "$remote_config_file -r $addr $count\" & |";
     243
     244        print "$cmd\n" if $debug;
     245        open($SSHCMD[$count], $cmd) or die "Failed to run ssh";
    224246
    225247        my $check = <$SSHCMD[$count]>;  # Make sure something ran...
Note: See TracChangeset for help on using the changeset viewer.