From: Daan De Meyer Date: Mon, 29 Jul 2024 15:47:47 +0000 (+0200) Subject: Look for $USER for the username before reading /etc/passwd X-Git-Tag: v24.2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=125cbfdc8ad37598ba90ba7a752267434a264684;p=thirdparty%2Fmkosi.git Look for $USER for the username before reading /etc/passwd Let's take $USER into account if set before reading /etc/passwd for the username. This gives a way out for environments where the uid of the user does not have an entry in /etc/passwd. --- diff --git a/mkosi/user.py b/mkosi/user.py index 4a0ec8339..6dc72eaa4 100644 --- a/mkosi/user.py +++ b/mkosi/user.py @@ -39,7 +39,7 @@ class INVOKING_USER: @classmethod @functools.lru_cache(maxsize=1) def name(cls) -> str: - return pwd.getpwuid(cls.uid).pw_name + return os.getenv("USER", pwd.getpwuid(cls.uid).pw_name) @classmethod @functools.lru_cache(maxsize=1)