From 17dfe634fb2e4fbee16103c8ced700001574bdf8 Mon Sep 17 00:00:00 2001 From: Sapan Bhatia Date: Fri, 7 Sep 2012 08:43:44 -0400 Subject: [PATCH] Simplify vsh, fix bug preventing bash arguments from being passed via ssh --- lxcsu | 8 ++++++-- lxctools.spec | 2 +- vsh.c | 6 ++---- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/lxcsu b/lxcsu index ea63d18..36cc5a5 100644 --- 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) diff --git a/lxctools.spec b/lxctools.spec index c83d98f..b2073f9 100644 --- a/lxctools.spec +++ b/lxctools.spec @@ -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 --- 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; -- 2.43.0