Skip to content

Commit

Permalink
Merge pull request #1225 from liangxin1300/20230727_get_user_crmsh45
Browse files Browse the repository at this point in the history
[crmsh-4.5] Fix: userdir: Get the effictive user name instead of using getpass.getuser (bsc#1213821)
  • Loading branch information
liangxin1300 authored Aug 1, 2023
2 parents 6efcdd3 + 621e911 commit 341044e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crmsh/userdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import os
import typing
import pwd

from . import log

Expand All @@ -11,9 +12,10 @@


def getuser():
"Returns the name of the current user"
import getpass
return getpass.getuser()
"Returns the name of the current effective user"
effective_uid = os.geteuid()
user_info = pwd.getpwuid(effective_uid)
return user_info.pw_name


def get_sudoer() -> typing.Optional[str]:
Expand Down

0 comments on commit 341044e

Please sign in to comment.