Solved

SUID issue

Posted on 2009-05-13
8
249 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

690 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