X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lxcsu;h=c1ad9d139e2ded1e18e67af5d3a3abd8108be7f9;hb=085591ee34b8ae79b8950510970d5d273fc9467b;hp=988036081d19679c8b8ee2510e3578f98af97b80;hpb=5985e6f9de65189b238b60121b1c6f8d10d69175;p=lxc-userspace.git diff --git a/lxcsu b/lxcsu index 9880360..c1ad9d1 100755 --- a/lxcsu +++ b/lxcsu @@ -47,8 +47,17 @@ def main (): parser.add_argument("-d","--debug", action='store_true', dest='debug', default=False, help="debug option") - parser.add_argument("-s","--nosliceuid", dest="nosliceuid", default=False, + parser.add_argument("-s","--nosliceuid", + action='store_true', dest="nosliceuid", default=False, help="do not change to slice uid inside of slice") + parser.add_argument("-o","--noslicehome", + action='store_true', dest="noslicehome", default=False, + help="do not change to slice home directory inside of slice") + + if os.path.exists("/etc/lxcsu_default"): + defaults = parser.parse_args(file("/etc/lxcsu_default","r").read().split()) + parser.set_defaults(**defaults.__dict__) + parser.add_argument ("slice_name") parser.add_argument ("command_to_run",nargs="*") @@ -180,9 +189,7 @@ def main (): for (sysctl_file, sysctl_name, sysctl_val) in sysctls: for fn in ["/sbin/sysctl", "/usr/sbin/sysctl", "/bin/sysctl", "/usr/bin/sysctl"]: if os.path.exists(fn): - os.system("mount -o remount,rw none /proc/sys") os.system('%s -w %s=%s'%(fn, sysctl_name,sysctl_val)) - os.system("mount -o remount,ro none /proc/sys") break else: print "Error: image does not have a sysctl binary" @@ -242,9 +249,11 @@ def main (): exec_args = [arch,'/usr/sbin/capsh','--','--login']+args.command_to_run os.environ['SHELL'] = '/bin/sh' - os.environ['HOME'] = '/home/%s'%slice_name - os.environ['LD_PRELOAD'] = '/etc/planetlab/lib/bind_public.so' - os.chdir("/home/%s"%(slice_name)) + if os.path.exists('/etc/planetlab/lib/bind_public.so'): + os.environ['LD_PRELOAD'] = '/etc/planetlab/lib/bind_public.so' + if not args.noslicehome: + os.environ['HOME'] = '/home/%s'%slice_name + os.chdir("/home/%s"%(slice_name)) if debug: print 'lxcsu:execv:','/usr/bin/setarch',exec_args os.execv('/usr/bin/setarch',exec_args) else: