LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-01-2008, 04:28 AM   #1
freeindy
Member
 
Registered: Nov 2002
Posts: 205

Rep: Reputation: 30
super user privileges check for a normal user in bash script


Hi,

I want to check if a normal user has super user privileges. For example, I run a script as user bond:

Code:
bond $ ./run.sh
in my run.sh I want to find out if bond has super user privileges, i.e he/she can run sudo command.

Is it possible? Consider I can't read /etc/sudoers file. I don't wan't to ask for password and then fail. I just want to say:
"You don't have sudo privileges... aborting"

Thanks,
Indy
 
Old 08-01-2008, 05:03 AM   #2
jcookeman
Member
 
Registered: Jul 2003
Location: London, UK
Distribution: FreeBSD, OpenSuse, Ubuntu, RHEL
Posts: 417

Rep: Reputation: 33
No you cannot do this. The problem is that anyone CAN run the sudo command, but until authentication it is not known what privileges they have. What you can do is grab the password and run a `CMD_LIST=$(echo $PASSWD | sudo -L -S)` and process the output and/or exit code to determine if they have necessary rights.
 
Old 08-01-2008, 06:08 AM   #3
freeindy
Member
 
Registered: Nov 2002
Posts: 205

Original Poster
Rep: Reputation: 30
ok.

that's a bummer, but not much one can do. Thanks jcookeman

Indy
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Root user check in bash script doesn't work tawalker Programming 6 12-18-2011 03:06 AM
Create a normal “user” with “shut down” privileges? John79 Linux - Newbie 2 02-18-2008 03:43 AM
Linux - How to add a new user with the same root/super-user's privileges? asgarcymed Linux - General 8 12-23-2006 07:45 PM
Running super user commands as normal user mickyg Linux - Security 5 10-14-2005 07:25 PM
normal user = super user jayakrishnan Linux - General 4 03-19-2002 09:58 AM


All times are GMT -5. The time now is 07:03 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration