From: Georges Discry Date: Sun, 23 Apr 2023 20:35:38 +0000 (+0200) Subject: Use `getpass.getuser()` to get the name of the current user X-Git-Tag: v15~211 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d8b32fbf3077b612db0024276e73cec3c2c87577;p=thirdparty%2Fmkosi.git Use `getpass.getuser()` to get the name of the current user `os.getlogin()` can fail and has no fallback, whereas `getpass.getuser()` takes the environment variables into account and falls back on `pwd`. --- diff --git a/mkosi/backend.py b/mkosi/backend.py index baedc7ac5..1a4f882a7 100644 --- a/mkosi/backend.py +++ b/mkosi/backend.py @@ -6,6 +6,7 @@ import contextlib import dataclasses import enum import functools +import getpass import importlib import itertools import os @@ -497,7 +498,7 @@ class InvokingUser: def name(self) -> str: if self._pw is not None: return self._pw.pw_name - return os.getlogin() + return getpass.getuser() @property def home(self) -> Path: