Skip to content

Commit dc53654

Browse files
committed
use getuser instead of getlogin
thanks arsen Signed-off-by: Zen <[email protected]>
1 parent 4e81e89 commit dc53654

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/zenlib/namespace/namespace.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from os import CLONE_NEWNS, CLONE_NEWUSER, getlogin, unshare, getuid
1+
from os import CLONE_NEWNS, CLONE_NEWUSER, unshare, getuid
2+
from getpass import getuser
23
from subprocess import CalledProcessError, run
34

45

@@ -7,7 +8,7 @@ def unshare_namespace():
78

89

910
def get_id_map(username=None, id_type="uid"):
10-
username = username or getlogin()
11+
username = username or getuser()
1112
if id_type not in ("uid", "gid"):
1213
raise ValueError("id_type must be 'uid' or 'gid'")
1314

src/zenlib/namespace/namespace_process.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from multiprocessing import Event, Pipe, Process, Queue
2-
from os import chroot, chdir, getgid, getlogin, getuid, setgid, setuid
2+
from os import chroot, chdir, getgid, getuid, setgid, setuid
3+
from getpass import getuser
34

45
from .namespace import get_id_map, new_id_map, unshare_namespace
56

@@ -11,7 +12,7 @@ class NamespaceProcess(Process):
1112

1213
def __init__(self, target=None, args=None, kwargs=None, **ekwargs):
1314
self.target_root = kwargs.pop("target_root", "/")
14-
namespace_user = kwargs.pop("namespace_user", getlogin())
15+
namespace_user = kwargs.pop("namespace_user", getuser())
1516
self.subuid_start, self.subuid_count = get_id_map(namespace_user, "uid")
1617
self.subgid_start, self.subgid_count = get_id_map(namespace_user, "gid")
1718
self.orig_uid = getuid()

0 commit comments

Comments
 (0)