From c97c6de178e727efdad42f08f6354d958fdb6b0d Mon Sep 17 00:00:00 2001 From: Helmut Grohne Date: Fri, 11 Jul 2025 14:47:37 +0200 Subject: prefer getpass.getuser() over os.getlogin() os.getlogin() returns an undesired value in a runuser environment and is not overridable with environment. --- linuxnamespaces/idmap.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'linuxnamespaces') 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(":") -- cgit v1.2.3