[sudo-users] Editing sudoers from python

Stanley, Jon Jon.Stanley at savvis.net
Tue Oct 10 10:39:46 EDT 2006


/etc/sudoers is a file with mode 440 (and sudo won't work any other way)
- so you don't have to use visudo, you simply have to overwrite the file
(using :wq! in vi for example).  What visudo does do, however, is ensure
that the file is syntactically correct - i.e. you won't break sudo using
that file.  use visudo -cf <somefile> to verify a different sudoers
file.  I would use that, and verify that your proposed new sudoers file
actually parses before using it.

>-----Original Message-----
>From: sudo-users-bounces at courtesan.com 
>[mailto:sudo-users-bounces at courtesan.com] On Behalf Of Marcus 
>Dean Adams
>Sent: Tuesday, October 10, 2006 9:55 AM
>To: sudo-users at sudo.ws
>Subject: [sudo-users] Editing sudoers from python
>
>I'm currently working on a python project, and it involves compiling
>software and to make sure the user can run the compiled 
>software, I need
>to make sure that 'make' is ran as that user, so I'm revising my
>installer bash script and just sticking sudo in everywhere that root
>permissions would be needed, but here's my question.  I'd never used
>sudo until now, I'd always just became root directly with 
>"su", and when
>I tried running it I noticed that by default, I wasn't a member of
>sudoers, and I had to add myself and I figured if I had the problem
>other people will too.  My question is, is it possible to import and
>edit /etc/sudoers like a normal text file with python, or do you really
>"have" to use visudo?  I noticed it won't accept changes from any other
>regular text editor such as gedit, but if I could somehow automate the
>process of giving the current user permission to run sudo with this
>python script, it would be really handy.  It would make things a lot
>easier than trying to explain using visudo, I want this installer I'm
>writing to be as hands-off as possible.
>
>____________________________________________________________ 
>sudo-users mailing list <sudo-users at sudo.ws>
>For list information, options, or to unsubscribe, visit:
>http://www.sudo.ws/mailman/listinfo/sudo-users
>




More information about the sudo-users mailing list