summaryrefslogtreecommitdiff
path: root/linuxnamespaces/idmap.py
diff options
context:
space:
mode:
authorHelmut Grohne <helmut@subdivi.de>2025-07-11 14:47:37 +0200
committerHelmut Grohne <helmut@subdivi.de>2025-07-11 14:47:37 +0200
commitc97c6de178e727efdad42f08f6354d958fdb6b0d (patch)
tree8cb307b0290b5cf5c50ce1dbb56800e22dc127dc /linuxnamespaces/idmap.py
parent58dca9beea23e4e18c67f6f13838f5a895ca150f (diff)
downloadpython-linuxnamespaces-c97c6de178e727efdad42f08f6354d958fdb6b0d.tar.gz
prefer getpass.getuser() over os.getlogin()
os.getlogin() returns an undesired value in a runuser environment and is not overridable with environment.
Diffstat (limited to 'linuxnamespaces/idmap.py')
-rw-r--r--linuxnamespaces/idmap.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/linuxnamespaces/idmap.py b/linuxnamespaces/idmap.py
index a10ec12..8f33d70 100644
--- a/linuxnamespaces/idmap.py
+++ b/linuxnamespaces/idmap.py
@@ -7,6 +7,7 @@ namespace.
import bisect
import dataclasses
+import getpass
import os
import subprocess
import typing
@@ -21,7 +22,7 @@ def subidranges(
user. Return all ranges as (start, count) pairs.
"""
if login is None:
- login = os.getlogin()
+ login = getpass.getuser()
with open(f"/etc/sub{kind}") as filelike:
for line in filelike:
parts = line.strip().split(":")