Index: fedkit/Makefile
===================================================================
--- fedkit/Makefile	(revision 2b35261f61016e7725db0611547bf3ec72c328b6)
+++ fedkit/Makefile	(revision 8d4e4fbcae7a2e91f87e7d36ad3aecc64cb498f6)
@@ -1,10 +1,10 @@
 BINARIES=federate.sh smbmount.FreeBSD.pl smbmount.Linux.pl \
 	 make_hosts fed-tun.pl fed_evrepeater rc.fedaccounts \
-	 config_from_tunnelip.pl active_config.pl combo_active.pl \
+	 config_from_tunnelip.pl active_config.pl combo.pl \
 	 prep_gateway.pl port_forward.pl setup_bridge.pl
 
 LIBRARIES=gateway_lib.pm 
 
-fedkit.tgz:	${BINARIES} ${PATCHES}
+fedkit.tgz:	${LIBRARIES} ${BINARIES} ${PATCHES}
 	mkdir -p /tmp/fedkit/local/federation/bin
 	mkdir -p /tmp/fedkit/local/federation/lib
Index: fedkit/active_config.pl
===================================================================
--- fedkit/active_config.pl	(revision 2b35261f61016e7725db0611547bf3ec72c328b6)
+++ fedkit/active_config.pl	(revision 8d4e4fbcae7a2e91f87e7d36ad3aecc64cb498f6)
@@ -15,8 +15,9 @@
 my $fedkit_dir= "/usr/local/federation";
 my $perl = "/usr/bin/perl";
-my $iface_file;
+my $iface_file = "/var/emulab/boot/ifmap";
 my $ssh = "/usr/bin/ssh";
+my $use_file;
 
-exit(20) unless GetOptions(
+my %opts = (
     'ssh_pubkey=s' => \$ssh_pubkey,
     'ssh_privkey=s' => \$ssh_privkey,
@@ -27,6 +28,11 @@
     'interfaces=s' => \$iface_file,
     'ssh=s' => \$ssh,
+    'use_file' => \$use_file,
 );
 
+exit(20) unless GetOptions(%opts);
+
+gateway_lib::read_config(gateway_lib::emulab_config_filename(), \%opts)
+    if $use_file;
 
 my $tunnelparam = $tunnelip ? '--tunnelip' : '';
@@ -109,4 +115,12 @@
 connectivity information
 
+=item B<use_file>
+
+If given read additional parameters from the file in
+/proj/I<project>/exp/I<experiment/tmp/I<hostname>.gw/conf where those are the
+current testbed project and experiment and the hostname is before the first
+dot.  The file is option: value.
+
+
 =back
 
Index: fedkit/combo.pl
===================================================================
--- fedkit/combo.pl	(revision 8d4e4fbcae7a2e91f87e7d36ad3aecc64cb498f6)
+++ fedkit/combo.pl	(revision 8d4e4fbcae7a2e91f87e7d36ad3aecc64cb498f6)
@@ -0,0 +1,143 @@
+#!/usr/bin/perl
+
+use strict;
+
+use gateway_lib;
+
+use IO::File;
+
+use Getopt::Long;
+
+my $ssh_pubkey;
+my $ssh_privkey;
+my $active;
+my $tunnelip;
+my $peer;
+my $fedkit_dir= "/usr/local/federation";
+my $perl = "/usr/bin/perl";
+my $iface_file = "/var/emulab/boot/ifmap";
+my $ssh = "/usr/bin/ssh";
+my @ports;
+my $use_file;
+
+my %opts = (
+    'ssh_pubkey=s' => \$ssh_pubkey,
+    'ssh_privkey=s' => \$ssh_privkey,
+    'tunnelip' => \$tunnelip,
+    'peer=s' => \$peer,
+    'fedkit=s' => \$fedkit_dir,
+    'perl=s' => \$perl,
+    'interfaces=s' => \$iface_file,
+    'ssh=s' => \$ssh,
+    'port=s' => \@ports,
+    'active' => \$active, 
+    'use_file' => \$use_file,
+);
+
+exit(20) unless GetOptions(%opts);
+
+gateway_lib::read_config(gateway_lib::emulab_config_filename(), \%opts)
+    if $use_file;
+
+my $tunnelparam = $tunnelip ? '--tunnelip' : '';
+if ($active) {
+    my $portparam = join(" --port=", @ports);
+
+    # join doesn't prefix the first one
+    $portparam="--port=$portparam" if $portparam;
+
+    system("$perl -I$fedkit_dir/lib $fedkit_dir/bin/active_config.pl " .
+	"--peer=$peer --ssh_pubkey=$ssh_pubkey --ssh_privkey=$ssh_privkey " .
+	" $tunnelparam --fedkit=$fedkit_dir --perl=$perl " .
+	"--ssh=$ssh --interfaces=$iface_file");
+    exit(20) if $?;
+
+    system("$perl -I$fedkit_dir/lib $fedkit_dir/bin/port_forward.pl " .
+	"--peer=$peer --ssh_pubkey=$ssh_pubkey --ssh_privkey=$ssh_privkey " .
+	" $tunnelparam --fedkit=$fedkit_dir --perl=$perl " .
+	"--ssh=$ssh $portparam");
+    exit(20) if $?;
+}
+else {
+    system("$perl -I$fedkit_dir/lib $fedkit_dir/bin/prep_gateway.pl " . 
+	"--peer=$peer --ssh_pubkey=$ssh_pubkey $tunnelparam");
+    exit(20) if $?;
+}
+
+=pod
+
+=head1 NAME
+
+B<combo_active.pl> - Do both the active configuration of a connectiveity gateway and service port forwarding.
+
+=head1 OPTIONS
+
+=over 8
+
+=item B<fedkit=>I<install_dir>
+
+Directory in which this software is installed.  Generally not needed.
+
+=item B<interfaces=>I<interface table>
+
+A list of interfaces to forward data on of the form:
+
+=begin text
+
+iface ip_addr
+
+=end text
+
+The interface is the operating system name of the interface and the IP address
+is given in standard dotted decimal notation.  Other characters on a line are
+ignored.
+
+=item B<peer=>I<hostname>
+
+The other gateway providing forwarding.
+
+=item B<perl=>I<perl_binary>
+ 
+Location of the perl binary.  Usually unneeded.
+
+=item B<port=>I<port_spec>
+
+Forward the given port.  The port is specified as 
+for B<port_forward.pl>
+
+=item B<ssh=>I<ssh_binary>
+
+The pathname of the ssh binary.  Unusally unnecessary.
+
+=item B<ssh_pubkey=>I<keyfile>
+
+A public to install as authorized.
+
+=item B<ssh_privkey=>I<identity_file>
+
+The identity to use for remote access
+
+=item B<tunnelip>
+
+True if the testbed uses the DETER tunnelip extension to provide external
+connectivity information
+
+=item B<use_file>
+
+If given read additional parameters from the file in
+/proj/I<project>/exp/I<experiment/tmp/I<hostname>.gw/conf where those are the
+current testbed project and experiment and the hostname is before the first
+dot.  The file is option: value.
+
+=back
+
+=head1 SYNOPSIS
+
+Call B<active_config.pl> and B<port_forward.pl> with the relevant parameters.
+
+
+=head1 AUTHORS
+
+Ted Faber <faber@isi.edu>
+
+=cut
Index: fedkit/combo_active.pl
===================================================================
--- fedkit/combo_active.pl	(revision 2b35261f61016e7725db0611547bf3ec72c328b6)
+++ 	(revision )
@@ -1,121 +1,0 @@
-#!/usr/bin/perl
-
-use strict;
-
-use gateway_lib;
-
-use IO::File;
-
-use Getopt::Long;
-
-my $ssh_pubkey;
-my $ssh_privkey;
-my $tunnelip;
-my $peer;
-my $fedkit_dir= "/usr/local/federation";
-my $perl = "/usr/bin/perl";
-my $iface_file;
-my $ssh = "/usr/bin/ssh";
-my @ports;
-
-exit(20) unless GetOptions(
-    'ssh_pubkey=s' => \$ssh_pubkey,
-    'ssh_privkey=s' => \$ssh_privkey,
-    'tunnelip' => \$tunnelip,
-    'peer=s' => \$peer,
-    'fedkit=s' => \$fedkit_dir,
-    'perl=s' => \$perl,
-    'interfaces=s' => \$iface_file,
-    'ssh=s' => \$ssh,
-    'port=s', \@ports,
-);
-
-
-my $tunnelparam = $tunnelip ? '--tunnelip' : '';
-my $portparam = join(" --port=", @ports);
-
-# join doesn't prefix the first one
-$portparam="--port=$portparam" if $portparam;
-
-system("$perl -I$fedkit_dir/lib $fedkit_dir/bin/active_config.pl " .
-    "--peer=$peer --ssh_pubkey=$ssh_pubkey --ssh_privkey=$ssh_privkey " .
-    " $tunnelparam --fedkit=$fedkit_dir --perl=$perl " .
-    "--ssh=$ssh --interfaces=$iface_file");
-exit(20) if $?;
-
-system("$perl -I$fedkit_dir/lib $fedkit_dir/bin/port_forward.pl " .
-    "--peer=$peer --ssh_pubkey=$ssh_pubkey --ssh_privkey=$ssh_privkey " .
-    " $tunnelparam --fedkit=$fedkit_dir --perl=$perl " .
-    "--ssh=$ssh $portparam");
-exit(20) if $?;
-
-=pod
-
-=head1 NAME
-
-B<combo_active.pl> - Do both the active configuration of a connectiveity gateway and service port forwarding.
-
-=head1 OPTIONS
-
-=over 8
-
-=item B<fedkit=>I<install_dir>
-
-Directory in which this software is installed.  Generally not needed.
-
-=item B<interfaces=>I<interface table>
-
-A list of interfaces to forward data on of the form:
-
-=begin text
-
-iface ip_addr
-
-=end text
-
-The interface is the operating system name of the interface and the IP address
-is given in standard dotted decimal notation.  Other characters on a line are
-ignored.
-
-=item B<peer=>I<hostname>
-
-The other gateway providing forwarding.
-
-=item B<perl=>I<perl_binary>
- 
-Location of the perl binary.  Usually unneeded.
-
-=item B<port=>I<port_spec>
-
-Forward the given port.  The port is specified as 
-for B<port_forward.pl>
-
-=item B<ssh=>I<ssh_binary>
-
-The pathname of the ssh binary.  Unusally unnecessary.
-
-=item B<ssh_pubkey=>I<keyfile>
-
-A public to install as authorized.
-
-=item B<ssh_privkey=>I<identity_file>
-
-The identity to use for remote access
-
-=item B<tunnelip>
-
-True if the testbed uses the DETER tunnelip extension to provide external
-connectivity information
-
-=back
-
-=head1 SYNOPSIS
-
-Call B<active_config.pl> and B<port_forward.pl> with the relevant parameters.
-
-
-=head1 AUTHORS
-
-Ted Faber <faber@isi.edu>
-
-=cut
Index: fedkit/gateway_lib.pm
===================================================================
--- fedkit/gateway_lib.pm	(revision 2b35261f61016e7725db0611547bf3ec72c328b6)
+++ fedkit/gateway_lib.pm	(revision 8d4e4fbcae7a2e91f87e7d36ad3aecc64cb498f6)
@@ -9,5 +9,6 @@
 @EXPORT_OK=qw(set_sshd_params import_key wait_for_DNS deter_tunnelip 
     configure_outgoing_iface add_route bind_tap_to_iface iface_to_addr
-    dest_to_iface addr_to_iface);
+    dest_to_iface addr_to_iface read_config emulab_config_filename);
+
 
 use strict;
@@ -24,4 +25,5 @@
 my $TMCC = "/usr/local/etc/emulab/tmcc";
 my $FINDIF = "/usr/local/etc/emulab/findif";
+my $TMCC = "/usr/local/etc/emulab/tmcc";
 
 # Takes an ssh config file and a reference to a hash of keys whose values must
@@ -242,3 +244,76 @@
 }
 
+# untested
+sub read_config {
+    my($file, $map) = @_;
+    my %param;
+    my %keywords;
+    my $f;
+
+    foreach my $k (keys %{$map}) {
+	if ( $k =~ /(\S+)=[si]/ ) {
+	    $keywords{$1} = $map->{$k};
+	    $param{$1}++;
+	}
+	else {
+	    $keywords{$k} = $map->{$k};
+	}
+    }
+
+    $f = new IO::File($file) || die "Can't open $file: $!\n";
+    while (<$f>) {
+	/^\s*([^:]+):\s*(.*)/ && do {
+	    my $keyw = $1;
+	    my $val = $2;
+
+	    $keyw =~ tr [A-Z] [a-z];
+
+	    if ($keywords{$keyw} ) {
+		if ( $param{$keyw} ) { 
+		    if ( ref($keywords{$keyw}) eq 'SCALAR') {
+			${$keywords{$keyw}} = $val;
+		    }
+		    elsif( ref($keywords{$keyw}) eq 'ARRAY') {
+			push(@{$keywords{$keyw}}, $val);
+		    }
+		    else {
+			die "Unknown variable type for $keyw\n";
+		    }
+		}
+		else  { ${$keywords{$keyw}}++; }
+	    }
+	    next;
+	};
+    }
+    $f->close();
+}
+
+
+sub emulab_config_filename {
+    # Find the configuration file in the usual place, which depends on what
+    # experiment and project we're in.
+    my $pid;
+    my $eid;
+    my $filename;
+    my $tmcd = new IO::Pipe() || die "Can't create pipe: $!\n";
+
+    $tmcd->reader("$TMCC status");
+
+    while (<$tmcd>) {
+	chomp;
+	/ALLOCATED=([^\/]+)\/(\S+)/ && do {
+	    $pid = $1;
+	    $eid = $2;
+	};
+    }
+    $tmcd->close();
+    my $hn = `hostname`;
+    chomp $hn;
+    $hn =~ s/\..*//;
+    $filename = "/proj/$pid/exp/$eid/tmp/$hn.gw.conf"
+	if $pid and $eid;
+
+    return $filename;
+}
+
 1;
Index: fedkit/prep_gateway.pl
===================================================================
--- fedkit/prep_gateway.pl	(revision 2b35261f61016e7725db0611547bf3ec72c328b6)
+++ fedkit/prep_gateway.pl	(revision 8d4e4fbcae7a2e91f87e7d36ad3aecc64cb498f6)
@@ -10,9 +10,16 @@
 my $tunnelip;
 my $peer;
-
-exit(20) unless GetOptions('ssh_pubkey=s' => \$ssh_pubkey,
+my $use_file;
+my %opts = (
+    'ssh_pubkey=s' => \$ssh_pubkey,
     'tunnelip' => \$tunnelip,
     'peer=s' => \$peer,
+    'use_file' => \$use_file,
 );
+
+exit(20) unless GetOptions(%opts);
+
+gateway_lib::read_config(gateway_lib::emulab_config_filename(), \%opts)
+    if $use_file;
 
 gateway_lib::set_sshd_params( 
@@ -64,4 +71,12 @@
 connectivity information
 
+=item B<use_file>
+
+If given read additional parameters from the file in
+/proj/I<project>/exp/I<experiment/tmp/I<hostname>.gw/conf where those are the
+current testbed project and experiment and the hostname is before the first
+dot.  The file is option: value.
+
+
 =back
 
