LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 07-20-2004, 10:46 AM   #1
jingo_man
LQ Newbie
 
Registered: Jul 2004
Distribution: red hat fedora core 1
Posts: 9

Rep: Reputation: 0
file permissions and SUID


hi,

i have recently created a script that performs an rsync between 2 directories. it then ensures that the directory that was "sync'ed" has the correct permissions (it is a web directory so needs apache permissions...)

so within my shell script, there is a call to an "rsync" and another to a "chown"

i can run this script fine when logged in as root (the creator of the file) and also when i have it scheduled as a cron job (as it runs as root).

i would like any other user to be able to manually run it at any time though (in case they cannot wait for the next 5 mins!!)

i changed the SUID so the file perms are:

-rwsr-xr-x

this should allow any person to run the script with correct perms. but i recieve the following outputted errors:

[user@hostname ftp]$ ./syncweb.sh
RSYNCing the FTP and apache areas
building file list ... opendir(images): Permission denied
done
IO error encountered - skipping file deletion
wrote 270 bytes read 20 bytes 580.00 bytes/sec
total size is 54667 speedup is 188.51
rsync error: some files could not be transferred (code 23) at main.c(620)
Changing Permissions in web directory
chown: `/var/www/html/images': Permission denied

have i set this up right? do i need to set the SUID on both the rsync and chown apps aswell so that they can be run in elevated priveleges? this is not something i want to do though!!

any help would be appreciated

jingo_man
 
Old 07-20-2004, 10:55 AM   #2
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Shell scripts ignore the SUID bit. That's why you get the errors. I used to have a link to a page that said as much, but I can't dig it up. If you search for "shell script suid" on google, it might turn up something about it.

Some options you have:
1. Make the constituent programs suid. This is probably not what you want if normal users have access to rsync and definitely chown.
2. Write the script in a programming language, compile it as an executable, and set the executable's suid bit (i.e. turn the script into something other than a script)
 
Old 07-20-2004, 12:35 PM   #3
jingo_man
LQ Newbie
 
Registered: Jul 2004
Distribution: red hat fedora core 1
Posts: 9

Original Poster
Rep: Reputation: 0
thanks dark_helmet

this is what is was thinking - that would need to make the actual apps inside SUID.

will have to look at the second solution i think - but as a newbie may take a period of time. any useful links for this?

many thanks for the reply though...

jingo_man
 
Old 07-20-2004, 12:35 PM   #4
jingo_man
LQ Newbie
 
Registered: Jul 2004
Distribution: red hat fedora core 1
Posts: 9

Original Poster
Rep: Reputation: 0
could even run the script using "sudo"....
 
Old 07-20-2004, 02:02 PM   #5
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 374Reputation: 374Reputation: 374Reputation: 374
Yeah, I am a complete dunce for not suggesting sudo or "su -c". I need to get around to setting up sudo one of these days. That might help me remember it more often.
 
  


Reply



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
file permissions OK, but command permissions? stabu Linux - General 2 10-05-2005 12:00 PM
SUID file drops suid bit on append? c_coder Programming 1 03-12-2004 07:59 AM
locking a usage policy file/ftp file permissions gbow Linux - Newbie 0 02-16-2004 05:35 AM
file permissions and file owner won't change Nadim Slackware 5 11-29-2003 06:03 PM
Changing file permissions on a SAMBA file share apenney Linux - Software 0 02-11-2002 04:42 PM

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

All times are GMT -5. The time now is 04:03 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
Open Source Consulting | Domain Registration