Skip to content

Commit

Permalink
Look for $USER for the username before reading /etc/passwd
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
DaanDeMeyer committed Jul 29, 2024
1 parent 0155cef commit a155ae8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion mkosi/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def is_running_user(cls) -> bool:
@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)
Expand Down

0 comments on commit a155ae8

Please sign in to comment.