Solved

SUID issue

Posted on 2009-05-13
8
244 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
awk file 6 102
ignore other .htaccess 2 71
rsyslog raw message 4 38
Testing site for http code 200 or curl equiv for Windows 2 56
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

726 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