[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Jailkit-dev] Patch for /dev/ node creation in OpenBSD
From: |
Aisha Tammy |
Subject: |
[Jailkit-dev] Patch for /dev/ node creation in OpenBSD |
Date: |
Fri, 10 Apr 2020 10:56:59 -0400 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 |
Hi devs,
I am taking over the maintaining of this package in OpenBSD and noticed a
couple of bugs in the python 3 port of the current software.
I've added a diff in the mail for the file `py/jk_lib.py` and have verified
that this works. Am actually hosting all my nodejs and django apps inside these
jails :D
I've also got other patches but they are openbsd specific so I am not adding
them.
Do let me know if you can add them so I can remove them from obsd repo in the
next release :)
Thanks for the amazing software,
Aisha
$OpenBSD: patch-py_jk_lib_py,v 1.4 2020/04/08 16:36:23 aisha Exp $
checks for directory creation, handling edge cases, in initial jail creation
streamlined major/minor handling for creating /dev/ nodes
Index: py/jk_lib.py
--- py/jk_lib.py.orig
+++ py/jk_lib.py
@@ -404,7 +404,11 @@ def OLD_create_parent_path(chroot, path, be_verbose=0,
chrootname =
resolve_realpath(chroot+directory[:indx],chroot)
if (be_verbose):
print('Creating directory '+chrootname)
- os.mkdir(chrootname, dir_mode)
+ try:
+ os.mkdir(chrootname, dir_mode)
+ except OSError as e:
+ _, stderror = e.args
+ sys.stderr.write('ERROR: failed to make
directory "'+chrootname+'": ' + stderror + '\n')
if (copy_permissions):
try:
copy_time_and_permissions(directory[:indx], chrootname, be_verbose, allow_suid,
copy_ownership)
@@ -482,7 +486,11 @@ def create_parent_path(chroot,path,be_verbose=0, copy_
if (stat.S_ISDIR(sb.st_mode)):
if (be_verbose):
print('Create directory '+jailpath)
- os.mkdir(jailpath, dir_mode)
+ try:
+ os.mkdir(jailpath, dir_mode)
+ except OSError as e:
+ _, stderror = e.args
+ sys.stderr.write('ERROR: failed to make
directory "'+jailpath+'": ' + stderror + '\n')
if (copy_permissions):
try:
copy_time_and_permissions(origpath,
jailpath, be_verbose, allow_suid, copy_ownership)
@@ -515,7 +523,11 @@ def copy_dir_with_permissions_and_owner(srcdir,dstdir,
try:
if (be_verbose):
print('Creating directory'+dstdir)
- os.mkdir(dstdir)
+ try:
+ os.mkdir(dstdir, dir_mode)
+ except OSError as e:
+ _, stderror = e.args
+ sys.stderr.write('ERROR: failed to make directory
"'+dstdir+'": ' + stderror + '\n')
copy_time_and_permissions(srcdir, dstdir, be_verbose,
allow_suid=0, copy_ownership=1)
except (IOError, OSError) as e:
_, strerror = e.args
@@ -575,22 +587,10 @@ def copy_device(chroot, path, be_verbose=1, retain_own
if (os.path.exists(chrootpath)):
print('Device '+chrootpath+' does exist already')
return
- sb = os.stat(path)
+ sb = os.lstat(path)
try:
- if (sys.platform[:5] == 'linux'):
- major = sb.st_rdev / 256 #major = st_rdev divided by
256 (8bit reserved for the minor number)
- minor = sb.st_rdev % 256 #minor = remainder of st_rdev
divided by 256
- elif (sys.platform == 'sunos5'):
- if (sys.maxint == 2147483647):
- major = sb.st_rdev / 262144 #major = st_rdev
divided by 256 (18 bits reserved for the minor number)
- minor = sb.st_rdev % 262144 #minor = remainder
of st_rdev divided by 256
- else:
- #64 bit solaris has 32 bit minor/32bit major
- major = sb.st_rdev / 2147483647
- minor = sb.st_rdev % 2147483647
- else:
- major = sb.st_rdev / 256 #major = st_rdev divided by 256
- minor = sb.st_rdev % 256 #minor = remainder of st_rdev
divided by 256
+ major=os.major(sb.st_rdev)
+ minor=os.minor(sb.st_rdev)
if (stat.S_ISCHR(sb.st_mode)):
mode = 'c'
elif (stat.S_ISBLK(sb.st_mode)):
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Jailkit-dev] Patch for /dev/ node creation in OpenBSD,
Aisha Tammy <=