LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-24-2007, 12:04 PM   #1
xlq
Member
 
Registered: Feb 2007
Distribution: Slackware 12.0
Posts: 58

Rep: Reputation: 15
How does sudo work?


After making sure the user is allowed to use sudo, it manages to run a program as root. But if sudo can run a program as root without a password, why can't other programs?
 
Old 05-24-2007, 12:09 PM   #2
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 555Reputation: 555Reputation: 555Reputation: 555Reputation: 555Reputation: 555
SUDO is a special tool, which allows users in the 'sudoers' list to be able to run programs with some or all super user (typically root) priveleges. It doesn't act on programs directly, but rather acts to elevate users priveleges, to allow the user to run stuff. Programs cannot be added to the 'sudoers' list, only users.

Can you give a specific example of what you want to know? Is there a particular program you are inquiring about?
 
Old 05-24-2007, 12:17 PM   #3
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
I just looked at random at Synaptic (ubuntu's package manager). The only user who can execute it is root. Apparently, the sudo command gives specified users root powers for just one action. The users that can use sudo are listed in /etc/sudoers.

So, you can either have root powers for all actions bu using su, or for ONE action using sudo.
 
Old 05-24-2007, 12:24 PM   #4
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 555Reputation: 555Reputation: 555Reputation: 555Reputation: 555Reputation: 555
Sudo

Quote:
Originally Posted by Pixellany
The only user who can execute it is root.
What does this mean? In context, I mean, the SUDO binary on my system is SUID-executable, as in rws--x--x meaning anyone could execute it, no?
I don't use SUDO anyways, but would like to clarify this for myself, and the OP.

Last edited by GrapefruiTgirl; 05-24-2007 at 12:25 PM.
 
Old 05-24-2007, 01:32 PM   #5
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
Quote:
Originally Posted by GrapefruiTgirl
What does this mean? In context, I mean, the SUDO binary on my system is SUID-executable, as in rws--x--x meaning anyone could execute it, no?
I don't use SUDO anyways, but would like to clarify this for myself, and the OP.
Yes, my sudo is the same....

I was referring to the Synaptic binary--it can only be run by root. (But also can be run by sudo)

I agree on not using sudo. It only comes up when using Ubuntu and the silly no-root-user thing.
 
Old 05-24-2007, 02:21 PM   #6
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian Stable
Posts: 2,546
Blog Entries: 8

Rep: Reputation: 465Reputation: 465Reputation: 465Reputation: 465Reputation: 465
Quote:
Originally Posted by xlq
After making sure the user is allowed to use sudo, it manages to run a program as root. But if sudo can run a program as root without a password, why can't other programs?
Some other programs can. The relevant attribute is setuid. This is an attribute on an executable file which determines whether the program runs with the calling user's permissions or with the exectuable file's owner's permissions.

Most executables are owned by root; if the setuid bit is set, then this executable runs with root permissions. Otherwise, the exectuable runs with the permissions of the calling user.

This feature is useful for writing a shell script to do some particular task with a different user's files. For example, you might want to let a user run a database maintenance script, but you don't want to give him unrestricted access to the database.
 
Old 05-24-2007, 02:48 PM   #7
frob23
Senior Member
 
Registered: Jan 2004
Location: Roughly 29.467N / 81.206W
Distribution: OpenBSD, Debian, FreeBSD
Posts: 1,450

Rep: Reputation: 48
Quote:
Originally Posted by IsaacKuo
This feature is useful for writing a shell script to do some particular task with a different user's files. For example, you might want to let a user run a database maintenance script, but you don't want to give him unrestricted access to the database.
Shell scripts do not respect the suid bit (not on Linux or most *nix systems out there -- there are rare exceptions but you should never expect that behavior). It's a security thing because of how shell scripts are actually executed on the system.

If you absolutely must run a shell script with a different user ID (and using sudo or su is out of the question) then you will need to write an executable wrapper which you can setuid... and whose sole function would be to call the shell script.

If you are interested in knowing why this is the case, a simple google for suid shell scripts and security should give you plenty to read.
 
Old 05-25-2007, 03:12 AM   #8
xlq
Member
 
Registered: Feb 2007
Distribution: Slackware 12.0
Posts: 58

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by IsaacKuo
The relevant attribute is setuid[...]
Ahh. Klever! So a non-root user can't execute their own sudo program, because they can't 'chown root' it.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: The Ultimate Sudo FAQ — To Sudo Or Not To Sudo? LXer Syndicated Linux News 13 04-13-2013 01:36 AM
sudo doesn't work slack_prad Linux - General 2 02-21-2007 07:38 AM
sudo does not work powah Linux - Security 1 12-06-2005 04:49 PM
sudo doesn't work mla Linux - Software 1 10-01-2003 08:24 PM
sudo doesn't work mla Linux - Software 4 10-01-2003 07:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:45 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration