The classpath environment file might be user-writable, so we don't want the
user to be able to inject any variable in the container root shell.
command = ["lxc-attach", "-P", tools.config.defaults["lxc"],
"-n", "waydroid", "--clear-env", "--",
"/system/bin/cat" ,"/data/system/environ/classpath"]
command = ["lxc-attach", "-P", tools.config.defaults["lxc"],
"-n", "waydroid", "--clear-env", "--",
"/system/bin/cat" ,"/data/system/environ/classpath"]
+ allowed = ["CLASSPATH", "SYSTEMSERVER"]
try:
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
out, _ = p.communicate()
if p.returncode == 0:
for line in out.decode().splitlines():
_, k, v = line.split(' ', 2)
try:
p = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.DEVNULL)
out, _ = p.communicate()
if p.returncode == 0:
for line in out.decode().splitlines():
_, k, v = line.split(' ', 2)
+ if any(pattern in k for pattern in allowed):
+ local_env[k] = v
except:
pass
env = [k + "=" + v for k, v in local_env.items()]
except:
pass
env = [k + "=" + v for k, v in local_env.items()]