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!
소스 검색

Locking for entire focker by default.

master
부모
커밋
d6e85d675b
3개의 변경된 파일24개의 추가작업 그리고 14개의 파일을 삭제
  1. +2
    -0
      focker/focker.py
  2. +3
    -14
      focker/jail.py
  3. +19
    -0
      focker/misc.py

+ 2
- 0
focker/focker.py 파일 보기

@@ -38,6 +38,7 @@ from .compose import \
command_compose_build, \
command_compose_run
from .bootstrap import command_bootstrap
from .misc import focker_lock
class ListForwarderFunctor(object):
@@ -203,6 +204,7 @@ def create_parser():
def main():
focker_lock()
zfs_init()
parser = create_parser()
args = parser.parse_args()


+ 3
- 14
focker/jail.py 파일 보기

@@ -15,8 +15,6 @@ import os
import jailconf
from .mount import getmntinfo
import shlex
import fcntl
# import pdb
import stat
@@ -38,18 +36,9 @@ def backup_file(fname, nbackups=10):
def jail_conf_write(conf):
os.makedirs('/var/lock', exist_ok=True)
with open('/var/lock/focker.lock', 'a+') as f:
print('Waiting for /var/lock/focker.lock ...')
fcntl.flock(f, fcntl.LOCK_EX)
print('Lock acquired')
try:
bakname = backup_file('/etc/jail.conf')
os.chmod(bakname, 0o600)
conf.write('/etc/jail.conf')
finally:
fcntl.flock(f, fcntl.LOCK_UN)
print('Lock released')
bakname = backup_file('/etc/jail.conf')
os.chmod(bakname, 0o600)
conf.write('/etc/jail.conf')
def jail_fs_create(image=None):


+ 19
- 0
focker/misc.py 파일 보기

@@ -7,6 +7,8 @@
import random
from .zfs import zfs_exists
import os
import fcntl
def random_sha256_hexdigest():
@@ -19,3 +21,20 @@ def find_prefix(head, tail):
if not zfs_exists(name):
break
return name
def focker_lock():
os.makedirs('/var/lock', exist_ok=True)
if focker_lock.fd is None:
focker_lock.fd = open('/var/lock/focker.lock', 'a+')
print('Waiting for /var/lock/focker.lock ...')
fcntl.flock(focker_lock.fd, fcntl.LOCK_EX)
print('Lock acquired.')
focker_lock.fd = None
def focker_unlock():
if focker_lock.fd is None:
return
fcntl.flock(focker_lock.fd, fcntl.LOCK_UN)
print('Lock released')

불러오는 중...
취소
저장