LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 09-25-2008, 10:19 AM   #1
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
Ineffective sticky bit: what am I doing wrong here?


Here's a simple script test.sh:
Code:
#! /bin/bash

echo "This is being run by UID: $UID"
echo "There might be an EUID: $EUID"
and here's some diagnostics:
Code:
~$ ll
total 44
drwx------  2 user user  4096 2008-09-23 17:58 bin
-rw-------  1 user user 15068 2008-09-16 10:17 Database.kdb
drwx------  2 user user  4096 2008-09-23 21:33 Desktop
drwx------  8 user user  4096 2008-09-22 19:13 Documents
dr-x------  2 user user  4096 2008-09-15 09:21 Music
dr-x------ 30 user user  4096 2008-09-09 00:17 Pictures
-rwsrwxrwx  1 root user    89 2008-09-25 11:15 test.sh
drwx------  2 user user  4096 2008-09-22 14:16 Videos
~$ ./test.sh
This is being run by UID: 1000
There might be an EUID: 1000
Shouldn't EUID show 0 because the sticky bit is set for test.sh which is owned by root?
 
Old 09-25-2008, 11:43 AM   #2
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
The "run as" flag (which is a "sticky bit" set on a non-directory file) acts like a "sudo" rather than a "su -" so your environment settings are not changed, just the process ownership. Put as ps -e in the script and this should be clear.

Also, using "test" as an executable name invites confusion with the bash built-in test command. (Yes, I did note that you used "test.sh," not "test." The comment is for other readers of this thread.)
 
Old 09-25-2008, 11:55 AM   #3
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
The 's' flag is setuid, not sticky, but anyway...

Linux ignores setuid for scripts - too much of a security hazard.

Dave
 
Old 09-25-2008, 12:22 PM   #4
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Original Poster
Rep: Reputation: 67
Quote:
Originally Posted by ilikejam View Post
The 's' flag is setuid, not sticky, but anyway..
Ah damn, really bad "typo" I don't know what I was thinking. Which I could edit the title...


Thanks for the info though, didn't realize suid didn't apply to scripts. Is there a way to get around that?
 
Old 09-25-2008, 01:24 PM   #5
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
You could write a wrapper in C or any other non-interpreted language that just calls the script. As far as I'm aware, that's pretty much the only way around it directly (without hacking some Linux/GNU sources).

If you've got an operational need for untrusted users to run some stuff as root, look at sudo (or maybe even something like webmin).

Dave
 
  


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
About Sticky bit... masudur_iiu General 4 09-13-2006 10:23 AM
sgid and sticky bit levis_inferno Linux - Networking 5 06-01-2006 01:00 AM
Sticky Bit Doesn't Seem to work krishvij Linux - Newbie 5 05-10-2005 05:31 PM
Sticky Bit tarballed Linux - General 4 07-03-2002 03:54 PM
sticky bit motiram Linux - General 1 08-01-2001 12:34 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:00 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration