Hi again,
I wrote a simple C program:
#define PYTHON "/home/mikib/t.py"
main(argc, argv)
char **argv;
{
setreuid(0,0);
setregid(0,0);
execvp(PYTHON, argv);
}
But after I compiled the C program and run it the Pyton program did not run
as 'root' user, and I'm getting this error:
Traceback (most recent call last):
File "/home/mikib/t.py", line 5, in ?
tt = file("/opt/ttt/1.txt","a")
IOError: [Errno 13] Permission denied: '/opt/ttt/1.txt'
I'm running Linux UBUNTU 6.10 :)
all I need is to write to some files that the users does not have a
permissions to those files like /etc/hosts.
Any idea how in Python I can open a file for write mode with privileges?
Thanks for any help,
Miki
On 3/12/07, Greg Ewing <[EMAIL PROTECTED]> wrote:
>
> Miki wrote:
>
> > How can I run pygtk application in root (setuid) mode
>
> It would be very dangerous to run the whole application
> setuid, since what a Python program does depends a lot
> on the environment (via PYTHONPATH, etc).
>
> The usual advice in situations like this is to write
> a small C program that does just the parts that really
> need privilege, make that setuid, and control it from
> the main application.
>
> > or how can I ask the user to enter the root password
>
> If the user needs to know the root password, then this
> is a very different situation from "any user" being
> able to run it! The sudo mechanism is better for this,
> since it allows specific users to be given specific
> abilities without having to give them the root password.
>
> --
> Greg
>
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/