LinuxQuestions.org
Review your favorite Linux distribution.
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 10-05-2009, 05:32 AM   #1
Jeroen1000
Member
 
Registered: Sep 2009
Posts: 44

Rep: Reputation: 15
Setting file and script permissions


Hi everyone,

This one is still a little too hard to get my head around.

I've got a root script which (depending on a certain condition) decides whether or not to call a backup script.

This backup script needs to run with user privileges, and not with root privileges. The backup script will call the rsync deamon and will write files to the users backup directory. So the owner of the backup directory will be the one that calls the backup script with his/her user privileges.

The root script does a chown of backup directory and then I execute a su to the correct user just before executing the backup script.
I've been experimenting with chown but that does not allow the back up script to delete or add stuff.

Simply said, I don't know which commands to run to accomplish this task.

Any help is more than welcome

Last edited by Jeroen1000; 10-05-2009 at 05:34 AM.
 
Old 10-05-2009, 06:09 AM   #2
Jeroen1000
Member
 
Registered: Sep 2009
Posts: 44

Original Poster
Rep: Reputation: 15
when I switch to the user (terminal window) who should be able to access his folder, I keep getting
cd: 2: can't cd to jeroen. I did a chown user:user and chmod 777 but to no avail. What am I missing here?

below is the output from ls -l the user 'jeroen' should be able to access his directory, also called 'jeroen'

Code:
drwxrwxrwx 7 jeroen jeroen 4096 2009-10-05 12:37 jeroen

Last edited by Jeroen1000; 10-05-2009 at 06:15 AM.
 
Old 10-05-2009, 06:12 AM   #3
SharpyWarpy
Member
 
Registered: Feb 2003
Location: Florida
Distribution: Fedora 18
Posts: 862

Rep: Reputation: 91
Did you try running:
chmod 7666 on the dir?
 
Old 10-05-2009, 06:21 AM   #4
Jeroen1000
Member
 
Registered: Sep 2009
Posts: 44

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by SharpyWarpy View Post
Did you try running:
chmod 7666 on the dir?
Still no dice. Now it says

Code:
drwsrwsrwT 7 jeroen jeroen 4096 2009-10-05 12:37 jeroen
I've noticed I am able to ls when I'm in the dir jeroen. I just can cd to the directory. Or is this because the directory jeroen is a subdirectory of /root?

Last edited by Jeroen1000; 10-05-2009 at 06:25 AM.
 
Old 10-05-2009, 06:42 AM   #5
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
Don't use /root to contain users' backups. You should use it in only very rare occasions.
A user needs read and execute writes to the parent directory to save files in /root/. You don't want that.

A network NAS or external drive would make more sense. If your computer's drive becomes damaged, your backup and the original documents are on the same machine. Rsync can clone the permissions of files when copying them. Using su isn't necessary unless your reason is that you don't want your cron job running as root.
 
Old 10-05-2009, 10:36 AM   #6
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by Jeroen1000 View Post
Or is this because the directory jeroen is a subdirectory of /root?
Yes, that's the reason. Remember that in order to list or access files in a particular directory, that directory, plus all parent directories, must be accessible to the user in question.

The only reason that normal users have access to their own files under /home is because /home has these permissions:

Code:
drwxr-xr-x /home
And the only reason /home is accessible is because the system root directory has these permissions:

Code:
drwxr-xr-x /
(on a directory, "execute" permissions grant access)

Think of it as a set of doors to an inner sanctum -- you have to be able to pass through each door before accessing the treasure.
 
Old 10-05-2009, 10:44 AM   #7
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by lutusp View Post
Think of it as a set of doors to an inner sanctum -- you have to be able to pass through each door before accessing the treasure.
That's a great new perspective on the contents of /root
 
  


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
Setting Up A File Permissions Policy mistersnorfles Linux - Security 3 08-12-2007 06:10 AM
Setting initial file permissions glabiche Linux - Security 5 11-29-2005 05:37 AM
Need help regarding setting Perl and file permissions... mrbadi Programming 1 07-30-2005 04:43 PM
Need help regarding setting Perl and file permissions... mrbadi Linux - Software 1 07-26-2005 01:03 PM
Automatically Setting File Permissions in a Directory maneeshsethi Linux - Security 2 05-27-2004 07:42 PM

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

All times are GMT -5. The time now is 08:30 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