IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Bläddra i källkod

A right mix of quote() and shlex.quote() seems to be correct.

tags/0.92
förälder
incheckning
fb68e59676
1 ändrade filer med 8 tillägg och 5 borttagningar
  1. +8
    -5
      jail.py

+ 8
- 5
jail.py Visa fil

@@ -7,6 +7,7 @@ from tabulate import tabulate
import os
import jailconf
from .mount import getmntinfo
import shlex
def jail_fs_create(image):
@@ -26,7 +27,7 @@ def jail_fs_create(image):
def gen_env_command(command, env):
env = [ 'export ' + k + '=' + quote(v) \
env = [ 'export ' + k + '=' + shlex.quote(v) \
for (k, v) in env.items() ]
command = ' && '.join(env + [ command ])
return command
@@ -53,15 +54,15 @@ def jail_create(path, command, env, mounts, hostname=None):
print('command:', command)
blk['exec.start'] = command
prestart = [ 'cp /etc/resolv.conf ' +
quote(os.path.join(path, 'etc/resolv.conf')) ]
shlex.quote(os.path.join(path, 'etc/resolv.conf')) ]
poststop = []
if mounts:
for (from_, on) in mounts:
if not from_.startswith('/'):
from_, _ = zfs_find(from_, focker_type='volume')
from_ = zfs_mountpoint(from_)
prestart.append('mount -t nullfs ' + quote(from_) +
' ' + quote(os.path.join(path, on.strip('/'))))
prestart.append('mount -t nullfs ' + shlex.quote(from_) +
' ' + shlex.quote(os.path.join(path, on.strip('/'))))
poststop += [ 'umount -f ' +
os.path.join(path, on.strip('/')) \
for (_, on) in reversed(mounts) ]
@@ -215,7 +216,9 @@ def command_jail_oneshot(args):
for a in args.env }
mounts = [ [ a.split(':')[0], a.split(':')[1] ] \
for a in args.mounts]
jailname = jail_create(path, ' '.join(map(quote, args.command)), env, mounts)
jailname = jail_create(path,
' '.join(map(shlex.quote, args.command or ['/bin/sh'])),
env, mounts)
subprocess.run(['jail', '-c', jailname])
jail_remove(path)


Laddar…
Avbryt
Spara