import enum
import fnmatch
import functools
+import getpass
import graphlib
import inspect
import io
"--genkey-common-name",
metavar="CN",
help="Template for the CN when generating keys",
- default=f"mkosi of {INVOKING_USER.name()}",
+ default=f"mkosi of {getpass.getuser()}",
)
parser.add_argument(
"-B",
class INVOKING_USER:
- @classmethod
- def name(cls) -> str:
- try:
- return pwd.getpwuid(os.getuid()).pw_name
- except KeyError:
- if os.getuid() == 0:
- return "root"
-
- if not (user := os.getenv("USER")):
- die(f"Could not find user name for UID {os.getuid()}")
-
- return user
-
@classmethod
def is_regular_user(cls, uid: int) -> bool:
return uid >= 1000