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
Sticky Bit???? skyineyes UNIX for Dummies Questions & Answers 10 05-29-2008 01:15 PM
Sticky Bit teenu18 UNIX for Dummies Questions & Answers 3 12-17-2007 03:08 PM
sticky bit manu.vmr Shell Programming and Scripting 2 02-02-2007 07:43 AM
Sticky Bit rob11g UNIX for Dummies Questions & Answers 1 03-14-2005 04:51 PM
Sticky bit LivinFree UNIX for Dummies Questions & Answers 3 07-20-2001 11:28 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-04-2002
hedrict hedrict is offline
Registered User
  
 

Join Date: Jun 2001
Posts: 35
Question sticky bit??

I have a script that I want to be able to let user 'wcs1234' execute it, but when it runs, it will do so under the higher authority of 'cdunix'. It is my understanding that I accomplish this with a sticky bit. I have tried every variation of this but am unable to get this to work.

my script is as follows:

!bin/ksh
cd /opt/cmunix/teststage
ls -lt
#
whoami
print -n "enter file to copy....."
read file
echo $file " copied to stage directory.."
#
cp -p /opt/cmunix/teststage/$file /opt/cmunix/stage/
exit 0


my permissions are as follows:

-rwxrwsr-x 1 cdunix sterling 511 Feb 04 15:41 cptostage.sh

any help would be greatly appreciated....
Todd
  #2 (permalink)  
Old 02-04-2002
peter.herlihy peter.herlihy is offline
Registered User
  
 

Join Date: Nov 2001
Location: New Zealand
Posts: 333
The checking for user bit is as per below:

SCRIPT_USER=wcs1234
WHOAMI=$(/usr/ucb/whoami)

if [ "$WHOAMI" != "$SCRIPT_USER" ];then
echo "$CallName: script must be run by $SCRIPT_USER"
exit 1
else
echo "You are $WHOAMI - OK to continue..."
fi

Not sure how to make this execute with another user though....but here's half to check the user.
  #3 (permalink)  
Old 02-05-2002
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
I think that the question involves inode permissions rather than checking for which user is running the program.

And I think the OP got the sticky bit, suid bit and sgid bit confused since he set the sgid bit and then posted a question calling it the sticky bit while describing the behavior of the suid bit.

chmod 4775 file # set the suid bit
chmod 2775 file # set the sgid bit
chmod 1775 file # set the sticky bit

The suid bit causes an executable to assume the effective uid of its owner whenever it runs. But it only works with executables, not shell scripts. For awhile some kernels allowed it to work with shell scripts too, but this a major security hole.

To run shell scripts in an suid envirorment look at the freeware program called "sudo". It can do this securely.
Closed Thread

Bookmarks

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 11:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
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