daemon: Improve launching xterm from a sudo environment.

This commit is contained in:
tgoff0 2015-05-22 00:55:48 +00:00
parent 94ad16e256
commit ad60004fad

View file

@ -115,9 +115,13 @@ class VnodeClient(object):
return tmp return tmp
def term(self, sh = "/bin/sh"): def term(self, sh = "/bin/sh"):
return os.spawnlp(os.P_NOWAIT, "xterm", "xterm", "-ut", cmd = ("xterm", "-ut", "-title", self.name, "-e",
"-title", self.name, "-e",
VCMD, "-c", self.ctrlchnlname, "--", sh) VCMD, "-c", self.ctrlchnlname, "--", sh)
if "SUDO_USER" in os.environ:
cmd = ("su", "-s", "/bin/sh", "-c",
"exec " + " ".join(map(lambda x: "'%s'" % x, cmd)),
os.environ["SUDO_USER"])
return os.spawnvp(os.P_NOWAIT, cmd[0], cmd)
def termcmdstring(self, sh = "/bin/sh"): def termcmdstring(self, sh = "/bin/sh"):
return "%s -c %s -- %s" % (VCMD, self.ctrlchnlname, sh) return "%s -c %s -- %s" % (VCMD, self.ctrlchnlname, sh)