Skip to content

Commit

Permalink
Only look at $USER if we're not invoked as root
Browse files Browse the repository at this point in the history
  • Loading branch information
DaanDeMeyer committed Jul 29, 2024
1 parent e311f66 commit b4d9c4a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mkosi/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ def is_running_user(cls) -> bool:
@classmethod
@functools.lru_cache(maxsize=1)
def name(cls) -> str:
return os.getenv("USER", pwd.getpwuid(cls.uid).pw_name)
if not cls.invoked_as_root and (user := os.getenv("USER")):
return user

return pwd.getpwuid(cls.uid).pw_name

@classmethod
@functools.lru_cache(maxsize=1)
Expand Down

0 comments on commit b4d9c4a

Please sign in to comment.