Solved

SUID issue

Posted on 2009-05-13
8
215 Views
Last Modified: 2013-12-16
Hi,
i am trying to understand a basic about SUID
i want to run a script to copy file to a directory which owned by root
files will be copied from directory one to myroot directory.
permission of my root is as follows :
[root@/]# ls -l  | grep myroot
drwxr-xr-x   2 root   root    4096 May 13 12:51 myroot
the script permission is as follows :
[root@ /]# ls -l copy.sh
-rwsrwxrwx 1 root root 30 May 13 12:51 copy.sh
so i have sent suid to root, chmod u+s copy.sh
now i am trying to run this script as normal user, but its unable to copy file in myroot directory as its saying permission denyed

but as a rule, if i set suid , so the script should run as Root previliges, then why still its unable to copy ??
0
Comment
Question by:yusuf01
  • 4
  • 4
8 Comments
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24373831
Hi,
the Linux kernel will not honour the setuid bit on shell scripts, as this could be a  major security issue!
setuid is only honoured with binaries.
wmp
0
 

Author Comment

by:yusuf01
ID: 24373860
HI,

by binaries you meant, programm such as sendmail or user defined program written by C or something like that??

then what about thsi article
http://lokams.blogspot.com/2008/03/about-suid-sgid-and-sticky-bit.html
http://www.codecoffee.com/tipsforlinux/articles/028.html

every where its saying "shell script"
0
 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24374048
With 'binaries' I mean compiled code. Sorry for not having been clear enough.
OK, it seems that I am right, since your script doesn't run as expected, does it?
Maybe there are Unix'es around which allow setuid for scripts, but I am not aware of any.
You could circumvent your problem either by using 'sudo' to start the script or by writing a small wrapper in C around the script employing 'popen' or 'execl' or 'system'.
wmp
 
 
 
 
0
 

Author Comment

by:yusuf01
ID: 24374114
you could be right, i just read for mandrive , it does not support script to use suid...

but its wired , every example in web for suid is showing for script, i never seen any site is saying that suid does not support sciprt ....

0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 68

Expert Comment

by:woolmilkporc
ID: 24374157
0
 

Author Comment

by:yusuf01
ID: 24374179
thanks
let me come back from launch, then will read that link
0
 
LVL 68

Accepted Solution

by:
woolmilkporc earned 135 total points
ID: 24374480
The link above is a bit misleading. The article mainly deals with a 'what if ...' scenario (what if setuid was possible with shell scripts).
Here is another, maybe better thingy -
http://rob.sun3.org/misc/setgid-and-setuid-shell-scripts/
 
0
 

Author Comment

by:yusuf01
ID: 24374973
yes the 2nd link is realy good
thanks to share information with me.
i will close this question now
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

After running Ubuntu some time, you will be asked to download updates for fixing bugs and security updates. All the packages you download replace the previous ones, except for the kernel, also called "linux-image". This is due to the fact that w…
This document is written for Red Hat Enterprise Linux AS release 4 and ORACLE 10g.  Earlier releases can be installed using this document as well however there are some additional steps for packages to be installed see Metalink. Disclaimer: I hav…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now