The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Shutdown aewpcoles UNIX for Advanced & Expert Users 6 08-03-2006 09:46 AM
using 'cat' to in 'while read line' chugger06 UNIX for Dummies Questions & Answers 3 01-18-2006 02:40 PM
SCO 5.06 :automatic shutdown on the job? rendechen SCO 1 01-06-2005 06:05 PM
non root shutdown???? byblyk Linux 4 07-26-2004 02:01 AM
to shutdown rajashekaran UNIX for Advanced & Expert Users 2 02-18-2002 01:42 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 11-25-2008
scottsiddharth scottsiddharth is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 5
Red face 'shutdown' and 'cat'

Hi All,

This is actually a good interview question.

On linux, the permissions and group for 'shutdown' and 'cat' is the same.

-rwxr-xr-x 1 root root 18K 2008-05-21 10:43 shutdown
-rwxr-xr-x 1 root root 17K 2007-01-30 19:51 cat

Then why is it that a normal user cannot run the 'shutdown' command ?

I've done some searching and I think it has something to do with SUID.
The 'shutdown' command calls the seteuid(0) where as the 'cat' command does not.

Is this correct ? Could someone please verify? Also is there a list of commands which can only be run by su even though the permissions are the same? I mean how can we know?
Thanks.

Last edited by scottsiddharth; 11-25-2008 at 01:00 AM..
  #2 (permalink)  
Old 11-25-2008
zaxxon's Avatar
zaxxon zaxxon is offline Forum Staff  
Moderator
  
 

Join Date: Sep 2007
Location: Germany
Posts: 2,257
Since there is no SETUID bit set, as you can see yourself looking at the permissions, I think it is the binary itself checking who is executing it. If you try different binaries in /sbin as a non root user you get different output, so it seems not to be a system wide mechanism.

Here is a good explanation for SETUID bit etc., 6.2:

Linux permissions
  #3 (permalink)  
Old 11-25-2008
nj78 nj78 is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 103
The following:

/sbin/halt

in suse uses geteuid. If it's not superuser it reportsL
halt: must be superuser.
  #4 (permalink)  
Old 11-25-2008
bagmc bagmc is offline
Registered User
  
 

Join Date: Sep 2007
Location: Portugal
Posts: 16
This happen because your normal user can't setuid to 0. Try this and see why you cannot run successfully shutdown with normal user:

$ strace shutdown

and

# strace shutdown
  #5 (permalink)  
Old 11-25-2008
nj78 nj78 is offline
Registered User
  
 

Join Date: Jul 2005
Posts: 103
Yes, shutdown uses this, I was reporting halt. Thanks.
  #6 (permalink)  
Old 11-26-2008
scottsiddharth scottsiddharth is offline
Registered User
  
 

Join Date: Nov 2008
Posts: 5
$ strace ./shutdown

execve("./shutdown", ["./shutdown"], [/* 16 vars */]) = 0
.
. *****text omitted*****
.
getuid32() = 8218
geteuid32() = 8218
setuid32(8218) = 0
getuid32() = 8218
write(2, "shutdown: you must be root to do"..., 39shutdown: you must be root to do that!
) = 39
exit_group(1) = ?
Process 6144 detached
*************************************************

$ ./shutdown
shutdown: you must be root to do that!


Wow. Thanks dude. Never knew such a command existed even.
Sponsored Links
Closed Thread

Bookmarks

Tags
linux commands

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 06:24 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0