Simplify vsh, fix bug preventing bash arguments from being passed via ssh
authorSapan Bhatia <gwsapan@gmail.com>
Fri, 7 Sep 2012 12:43:44 +0000 (08:43 -0400)
committerSapan Bhatia <gwsapan@gmail.com>
Fri, 7 Sep 2012 12:43:44 +0000 (08:43 -0400)
lxcsu
lxctools.spec
vsh.c

diff --git a/lxcsu b/lxcsu
index ea63d18..36cc5a5 100644 (file)
--- a/lxcsu
+++ b/lxcsu
@@ -3,11 +3,13 @@
 
 import setns
 import os
+import sys
 
-from optparse import OptionParser
+#from optparse import OptionParser
 
 drop_capabilities='cap_sys_admin,cap_net_admin,cap_sys_boot,cap_sys_module'.split(',')
 
+"""
 parser = OptionParser()
 parser.add_option("-n", "--net",
                   action="store_true", dest="netns", default=False,
@@ -20,6 +22,8 @@ parser.add_option("-p", "--pid",
                   help="Enter pid namespace")
 
 (options, args) = parser.parse_args()
+"""
+args = sys.argv[1:]
 
 try:
        slice_name = args[0]
@@ -69,6 +73,6 @@ pid = os.fork()
 cap_args = map(lambda c:'--drop='+c, drop_capabilities)
     
 if (pid == 0):
-    os.execv('/usr/sbin/capsh',cap_args+['--'])
+    os.execv('/usr/sbin/capsh',cap_args+['--']+args[1:])
 else:
     os.waitpid(pid,0)
index c83d98f..b2073f9 100644 (file)
@@ -1,5 +1,5 @@
 %define name lxctools
-%define version 0.2
+%define version 0.4
 %define taglevel 1
 
 %define percent %
diff --git a/vsh.c b/vsh.c
index 76deb8b..8780b24 100644 (file)
--- a/vsh.c
+++ b/vsh.c
@@ -45,7 +45,7 @@ char **extend_argv(int argc, char **argv, int num_extra_args) {
     return argv2;
 }
 
-#define NUM_LXCSU_EXEC_ARGS 3
+#define NUM_LXCSU_EXEC_ARGS 1
 
 int main(int argc, char **argv, char **envp)
 {
@@ -69,9 +69,7 @@ int main(int argc, char **argv, char **envp)
     // Populate arguments
     snprintf(slice_id_str, 255, "%u", slice_xid);
     argv2[0] = strdup(LXCSU_PATH);
-    argv2[1] = strdup("-n");
-    argv2[2] = strdup("-m");
-    argv2[3] = strdup(slice_name);
+    argv2[1] = strdup(slice_name);
 
     if (setuid(geteuid())) goto out_exception;