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!
瀏覽代碼

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

master
父節點
當前提交
c03598a2e2
共有 2 個檔案被更改,包括 9 行新增4 行删除
  1. +4
    -3
      focker/jail.py
  2. +5
    -1
      focker/misc.py

+ 4
- 3
focker/jail.py 查看文件

@@ -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 查看文件

@@ -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):


Loading…
取消
儲存