On Sun, 11 Oct 2009 09:30:38 +0200, a a <valaprgrmr gmail com> wrote:
Hello.I'd like to replace the content of the file /etc/sudoers . In the terminal I can do it using echo '#attempt' | gksudo tee /etc/sudoers
I'm sure there's a much better way to do it... PolicyKit or something would presumably provide a better method. I'll be watching to see for myself, too. But if you're going to do it that way... This is the best way that I know of... I do this with most files my app doesn't own, just to be on the safe size. Start by opening up a regular temporary file with minimal initial permissions (NO permissions at all, I believe, works quite okay, and set open() to fail if the file already exists). Then just write your new sudoers data to that temporary file, and finally move it into position, set permissions, and whatever else. To move the file into position and set its ownership and permissions, there's an "install" command, which you can run with gksudo. It lets you specify everything all in the one command. I've also done something similar by building a tar file on-the-fly and letting the tar command "install" the files with proper ownership and permissions, though that was invoking tar on a remote machine over ssh. -- Fredderic Debian/unstable (LC#384816) on i686 2.6.30-1-686 2009 (up 5 days, 20:11)
Attachment:
signature.asc
Description: PGP signature