Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Whoami returns root when invoked from script started with sudo #5

Open
Yethal opened this issue Apr 22, 2019 · 2 comments
Open

Whoami returns root when invoked from script started with sudo #5

Yethal opened this issue Apr 22, 2019 · 2 comments

Comments

@Yethal
Copy link
Contributor

Yethal commented Apr 22, 2019

When script s started with sudo, whoami returns root instead of the username of calling user. Replace with logname for the last two lines to work correctly.

@mstaal
Copy link
Owner

mstaal commented Aug 6, 2019

I have tried to update the README to solve the issue. Can you test it?

@Yethal
Copy link
Contributor Author

Yethal commented Aug 7, 2019

Yes, this does work. But you can simply replace $(whoami) with $(logname) to achieve the desired effect. You can test that by running following commands
sudo sh -c 'echo $(whoami)' - that will return root
sudo sh -c 'echo $(logname)' - that will return the correct username

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants