On Thu, 2009-07-23 at 00:17 +0200, Piet van Oostrum wrote: > Being a sudoer is not a privilege to issue the os.setuid system call. It > is only a permission to use the sudo command. > Yes, So I would like to know if python can change the user to some other non-privileged user during the script execution?
> >K> I tryed using subprocess but that did not help me either. I tryed sudo > >K> su into the Popen command but it throws me into the terminal (shell) > >K> with postgres as the user. > > You could execute the command: > sudo -u postgres required_command > with subprocess. > Ok, but the problem is much more complex. What if I want to do the following. 1, change the user for a particular script to the postgres user. 2. now execute the python code for connecting to the postgresql database. In the second point I actually want to execute python code not shell level command so will the sudo -u in the subprocess.Popen change the user in the script? In short I would just like to have the script run under another user let's say postgres as long as a certain action is going on, for example connecting to the postgresql database. > You have another problem then: your password must be supplied unless the > NOPASSWD flag is set in the sudoers file. > That is clear, the only problem is that I want the script to run as postgres user although it was started by the user kk. happy hacking. Krishnakant. -- http://mail.python.org/mailman/listinfo/python-list