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

how to use username instead of uid ? #30

Open
s4miii opened this issue Apr 10, 2023 · 1 comment
Open

how to use username instead of uid ? #30

s4miii opened this issue Apr 10, 2023 · 1 comment

Comments

@s4miii
Copy link

s4miii commented Apr 10, 2023

Hello, thank you for the great idea and the beautiful code you wrote.
I wonder if there is a way we can switch to another user instead of root?I mean, is there any way to change this line setuid(0); to something like setuser(root); ?
or better to ask, how to give the user's name instead of the user's uid?

I know my question may seem ridiculous, but I would be grateful if you could help me.

Thank you

@flashnuke
Copy link

flashnuke commented Aug 8, 2023

you can use a workaround to generate the userid using the username + the pwd module (which belongs to the standard library) and then pass it to setuid()

import pwd

user_id=pwd.getpwnam("username_here").pw_uid

# i.e: pwd.getpwnam("root").pw_uid = 0

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