Index: fedd/federation/emulab_access.py
===================================================================
--- fedd/federation/emulab_access.py	(revision a2ca699a12824ef27df96abb2796effdafccf0c3)
+++ fedd/federation/emulab_access.py	(revision 8fbef04ada29580d58ea7a0c51ac1d061782b57a)
@@ -32,4 +32,5 @@
 import list_log
 import emulab_segment
+import emulab_shared_nat_segment
 
 
@@ -91,4 +92,5 @@
 	self.node_startcommand = config.get("access", "node_startcommand")
 	self.nat_portal = config.get("access", "nat_portal")
+	self.shared_nat = config.getboolean("access", "shared_nat")
 
 	self.uri = 'https://%s:%d' % (socket.getfqdn(), 
@@ -100,9 +102,16 @@
 
 	self.access_type = self.access_type.lower()
-	self.start_segment = emulab_segment.start_segment
-	self.stop_segment = emulab_segment.stop_segment
-	self.info_segment = emulab_segment.info_segment
-	self.operation_segment = emulab_segment.operation_segment
-	self.exports_segment = emulab_segment.exports_segment
+	if self.shared_nat:
+	    self.start_segment = emulab_shared_nat_segment.start_segment
+	    self.stop_segment = emulab_shared_nat_segment.stop_segment
+	    self.info_segment = emulab_shared_nat_segment.info_segment
+	    self.operation_segment = emulab_shared_nat_segment.operation_segment
+	    self.exports_segment = emulab_shared_nat_segment.exports_segment
+	else:
+	    self.start_segment = emulab_segment.start_segment
+	    self.stop_segment = emulab_segment.stop_segment
+	    self.info_segment = emulab_segment.info_segment
+	    self.operation_segment = emulab_segment.operation_segment
+	    self.exports_segment = emulab_segment.exports_segment
 
         self.restricted = [ ]
@@ -541,6 +550,9 @@
 
 	if self.portal_command:
+	    if self.shared_nat: suffix = 'shared nat 0/0/tcp rdr 22/tcp'
+	    else: suffix = ''
+
 	    filters.append(topdl.generate_portal_command_filter(
-		self.portal_command, add_filter=add_filter))
+		self.portal_command, add_filter=add_filter, suffix=suffix))
 
 	if self.portal_image:
@@ -977,5 +989,7 @@
 		    debug=self.create_debug, log=alloc_log, boss=self.boss,
 		    ops=self.ops, cert=xmlrpc_cert)
-	    exporter(self, ename, proj, user, connInfo, tmpdir, gid)
+	    if not exporter(self, ename, proj, user, connInfo, tmpdir, gid):
+		raise service_error(service_error.internal,
+			'Failed to gather export variables')
 	    self.export_store_info(certfile, proj, ename, connInfo)
 	    self.import_store_info(certfile, connInfo)
Index: fedd/federation/ssh_emulab_segment.py
===================================================================
--- fedd/federation/ssh_emulab_segment.py	(revision a2ca699a12824ef27df96abb2796effdafccf0c3)
+++ fedd/federation/ssh_emulab_segment.py	(revision 8fbef04ada29580d58ea7a0c51ac1d061782b57a)
@@ -59,4 +59,29 @@
 	return rv == 0
 
+    def scp_file_from(self, file, user, host, dest=""):
+	"""
+	scp a file to the remote host.  If debug is set the action is only
+	logged.
+	"""
+
+	scp_cmd = [self.scp_exec, '-o', 'IdentitiesOnly yes',
+		'-o', 'StrictHostKeyChecking no', '-o', 'ForwardX11 no','-i',
+		self.ssh_privkey_file, "%s@%s:%s" % (user, host, file), dest]
+	rv = 0
+
+	try:
+	    dnull = open("/dev/null", "w")
+	except EnvironmentError:
+	    self.log.debug("[ssh_file]: failed to open " + \
+		    "/dev/null for redirect")
+	    dnull = Null
+
+	self.log.debug("[scp_file]: %s" % " ".join(scp_cmd))
+	if not self.debug:
+	    rv = subprocess.call(scp_cmd, stdout=dnull,
+		    stderr=dnull, close_fds=True)
+
+	return rv == 0
+
     def ssh_cmd(self, user, host, cmd, wname=None, timeout=None):
 	"""
Index: fedd/federation/xmlrpc_emulab_segment.py
===================================================================
--- fedd/federation/xmlrpc_emulab_segment.py	(revision a2ca699a12824ef27df96abb2796effdafccf0c3)
+++ fedd/federation/xmlrpc_emulab_segment.py	(revision 8fbef04ada29580d58ea7a0c51ac1d061782b57a)
@@ -141,10 +141,14 @@
 	return state
 
-    def make_null_experiment(self, pid, eid, tmpdir, gid=None):
+    def make_null_experiment(self, pid, eid, tmpdir, gid=None, ns_str=None):
 	"""
 	Create a null copy of the experiment so that we capture any logs there
 	if the modify fails.  Emulab software discards the logs from a failed
-	startexp.
-	"""
+	startexp.  If ns_str is given, use that to construct the null
+	experiment.
+	"""
+
+	if ns_str is None:
+	    ns_str = self.null
 
 	if self.debug:
@@ -157,5 +161,5 @@
 		    'proj': pid,
 		    'exp': eid, 
-		    'nsfilestr': self.null,
+		    'nsfilestr': ns_str,
 		    'batch': False,
 		    'idleswap': 0,
