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

Slightly ugly workaround for JID issues when numeric-only characters are used in jail name.

master
förälder
incheckning
c03598a2e2
2 ändrade filer med 9 tillägg och 4 borttagningar
  1. +4
    -3
      focker/jail.py
  2. +5
    -1
      focker/misc.py

+ 4
- 3
focker/jail.py Visa fil

@@ -17,7 +17,8 @@ from .mount import getmntinfo
import shlex
import stat
from .misc import focker_lock, \
focker_unlock
focker_unlock, \
random_sha256_hexdigest
def backup_file(fname, nbackups=10, chmod=0o600):
@@ -44,7 +45,7 @@ def jail_conf_write(conf):
def jail_fs_create(image=None):
sha256 = bytes([ random.randint(0, 255) for _ in range(32) ]).hex()
sha256 = random_sha256_hexdigest()
lst = zfs_list(fields=['focker:sha256'], focker_type='image')
lst = list(filter(lambda a: a[0] == sha256, lst))
if lst:
@@ -273,7 +274,7 @@ def command_jail_oneshot_old():
base, _ = zfs_snapshot_by_tag_or_sha256(args.image)
# root = '/'.join(base.split('/')[:-1])
for _ in range(10**6):
sha256 = bytes([ random.randint(0, 255) for _ in range(32) ]).hex()
sha256 = random_sha256_hexdigest()
name = sha256[:7]
name = base.split('/')[0] + '/focker/jails/' + name
if not zfs_exists(name):


+ 5
- 1
focker/misc.py Visa fil

@@ -12,7 +12,11 @@ import fcntl
def random_sha256_hexdigest():
return bytes([ random.randint(0, 255) for _ in range(32) ]).hex()
for _ in range(10**6):
res = bytes([ random.randint(0, 255) for _ in range(32) ]).hex()
if not res[:7].isnumeric():
return res
raise ValueError('Couldn\'t find random SHA256 hash with non-numeric 7-character prefix in 10^6 trials o_O')
def find_prefix(head, tail):


Laddar…
Avbryt
Spara