By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,908 Members | 1,860 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,908 IT Pros & Developers. It's quick & easy.

Change user on UNIX

P: n/a
Hi all.
Is there any way to su or login as a different user within a python
script? I mainly need to temporarily impersonate another user to
execute a command and then come back to the original user.
I tried to google a little bit about it but I still didn't find a
solution.
Thanks in advance.

--- Giampaolo
http://code.google.com/p/pyftpdlib
Mar 20 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Giampaolo Rodola' wrote:
I mainly need to temporarily impersonate another user to
execute a command and then come back to the original user.
If the script is run as root, you can freely impersonate other users with
the os.seteuid() and os.setegid() methods.

If the script is not run as root (either directly or through sudo, as
suggested by other posters), then perhaps it should be.
Jeffrey
Mar 20 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.