Getting details from sudoers file

Login or Register to Reply

 
Thread Tools Search this Thread
# 1  
Old 12-02-2014
Getting details from sudoers file

Hi,

I need the details of which ids belong to the sudoers file, and which groups these ids belong to.
Can anyone suggest a way to derive that information into a flat file please?

G
# 2  
Old 12-02-2014
/etc/sudoers is readable only by root. You have to become root to read it.
Example:

Code:
somedata=$( sudo grep ADMINS /etc/sudoers)

# 3  
Old 12-03-2014
Quote:
which ids belong to the sudoers file
This question is too vague (I don't think Jim interpreted it correctly). Perhaps you mean "which users are allowed to execute what commands" in a sudoers file? If that is indeed the question, the answer is difficult since sudoers has a rather complex syntactical and semantic structure (user aliases, group policies, external files, etc).

On possibility is you can run "sudo -l" per user. This will show you which commands that user can run.

Code:
User mary may run the following commands on this host:
    (ALL) ALL
    (ALL) NOPASSWD: /opt/dplat/bin/Revision/CMUpdatePackage/Installer.app/Contents/MacOS/Installer

You could then run that for each host that has access to the server.

Last edited by Don Cragun; 12-03-2014 at 03:30 AM.. Reason: Chang ICODE to CODE tags for multi-line output.
This User Gave Thanks to otheus For This Post:
jim mcnamara (12-09-2014)
# 4  
Old 12-09-2014
Otheus' approach makes more sense than mine.

However direct access to /etc/sudoers is limited and must be limited to the root user only.
Code:
sudo -l

For every user could be painful unless NOPASSWD is specified in the sudoers file. In other words you may have to know user passwords to do this depending on how sudoers is set up.
# 5  
Old 12-13-2014
Assuming one has root access:
Code:
getent passwd | cut -d: -f1 | xargs -n 1 sudo -l -U

will list what commands can be run via sudo for all users. Parsing the output of sudo is left as an exersize to the reader. Smilie

Last edited by derekludwig; 12-13-2014 at 06:03 AM.. Reason: spelling error
Login or Register to Reply

|
Thread Tools Search this Thread
Search this Thread:
Advanced Search

More UNIX and Linux Forum Topics You Might Find Helpful
How to setup sudoers file ? mohtashims UNIX for Beginners Questions & Answers 3 08-19-2017 04:22 PM
Sudoers file nzonefx Solaris 1 11-03-2015 03:55 PM
Help with Sudoers file samnyc UNIX for Dummies Questions & Answers 2 02-10-2015 07:18 PM
Pls. help with sudoers file... samnyc UNIX for Dummies Questions & Answers 2 10-02-2013 05:14 AM
Scripting help with Sudoers file audis$ Shell Programming and Scripting 1 01-29-2013 02:16 AM
Help with sudoers file - AIX victorbrca Cybersecurity 0 02-01-2012 11:57 AM
at -l doesnt give details of the scheduled job. How to get the details? superparticle UNIX for Dummies Questions & Answers 2 11-09-2011 07:51 AM
Issue with sudoers file. Tuxidow Shell Programming and Scripting 3 03-28-2011 07:57 AM
usage of sudoers file? baluchen Solaris 4 01-10-2011 02:04 AM
sudoers file noam128 UNIX for Advanced & Expert Users 2 03-24-2010 10:25 AM
sudoers file not found bharu_sri Solaris 12 02-13-2009 01:06 PM
sudoers file with groups in LDAP em23 Solaris 6 11-13-2008 11:10 PM
sudoers file questions hemangjani UNIX for Dummies Questions & Answers 2 04-21-2008 01:35 PM
Parsing Sudoers File jasondavey UNIX for Advanced & Expert Users 3 08-30-2007 08:00 PM
sudoers file whatisthis Linux 4 12-02-2004 04:59 PM