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. --- examples/unschroot_fs.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'examples/unschroot_fs.py') diff --git a/examples/unschroot_fs.py b/examples/unschroot_fs.py index 68e2320..a07f32d 100755 --- a/examples/unschroot_fs.py +++ b/examples/unschroot_fs.py @@ -18,6 +18,7 @@ between calls with no background processes or persistent namespaces. import argparse import grp +import getpass import os import pathlib import pwd @@ -474,7 +475,9 @@ def main() -> None: parser.add_argument("-d", "--directory", action="store") parser.add_argument("-p", "--preserve-environment", action="store_true") parser.add_argument("-q", "--quiet", action="store_true") - parser.add_argument("-u", "--user", action="store", default=os.getlogin()) + parser.add_argument( + "-u", "--user", action="store", default=getpass.getuser() + ) parser.add_argument("--isolate-network", action="store_true") parser.add_argument("command", nargs="*") args = parser.parse_args() -- cgit v1.2.3