LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 05-02-2008, 06:58 PM   #1
gabosdenes
LQ Newbie
 
Registered: Jan 2008
Posts: 8

Rep: Reputation: 0
Undeleteable symbolic links


Is there a way to create symbolic links with special permissions so that users cannot delete them?

Thanks,
 
Old 05-02-2008, 07:56 PM   #2
rlhartmann
Member
 
Registered: Mar 2008
Posts: 73

Rep: Reputation: 16
Check the directory permissions

The ability to delete a file (symbolic links are just pointer files) from a directory, requires write permissions to the directory the file is in. If you take away write permission for those users, they will not be able to delete the file.

If those users really need write permission to that directory, the is another alternative. You can set the "sticky" bit on the directory.

The sticky bit allows users to only delete files they own, even
though many users have write access to the directory.

To set the permissions on the directory, use

chmod 1777 /tmp

permissions will look like this:

ls -ld /tmp
drwxrwxrwt 37 root root 51200 May 2 20:08 /tmp
 
Old 05-02-2008, 09:26 PM   #3
gabosdenes
LQ Newbie
 
Registered: Jan 2008
Posts: 8

Original Poster
Rep: Reputation: 0
I have a symlink in /home/samba/public that points to /some/path, my samba directory is read only(dr-xr-xr-x), but the symlink gets created with lrwxrwxrwx permission. I'we recreated the link several times but the permissions are the same lrwxrwxrwx
Is there anything else i should do?
 
Old 05-02-2008, 10:07 PM   #4
eggixyz
Member
 
Registered: Apr 2008
Posts: 310

Rep: Reputation: 30
Hey There,

Symlinks will always have those permissions. In the case of symlinks you have to be either the owner or a member of the symlink's group to delete it. Of course, if an upper level directory is keeping you from getting there, that doesn't matter.

If you want to keep someone from accessing your file via the symlink you just need to set the permissions on your file to be restrictive enough, and (unfortunately) if you want them to be able to access it (and it points into your home directory), they would have to be able to access it via the direct path as well (as far as permissions go), so you'd be giving up some security.

Hope that helps out

, Mike
 
Old 05-03-2008, 07:19 AM   #5
gabosdenes
LQ Newbie
 
Registered: Jan 2008
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by eggixyz View Post
Hey There,

Symlinks will always have those permissions. In the case of symlinks you have to be either the owner or a member of the symlink's group to delete it.
This is not correct in my case because the owner of the symlink is root(lrwxrwxrwx 1 root root), and users are still able to delete them.
I applied the desired secutiry permissions on the target directory, it's just that users ca delete the symlinks and cause (un)intentional problems. Is there any other way to make symlinks undeletable?
 
Old 05-03-2008, 03:09 PM   #6
rlhartmann
Member
 
Registered: Mar 2008
Posts: 73

Rep: Reputation: 16
It sounds like the key to your problem is in samba.
The base user of samba is root which means it can
can delete any file reguardless of the directory permissions.

Do users need write permission on this share? If
not, make sure smb.conf has this share set with read only = no.

There may be some other settings in samba to look at also,
like force user = pubic.

A work around would be to create a shell script to checks for the
link and recreates if it gets deleted.

#!/bin/bash

# Create deleted symbolic link

LINKNAME=/home/samba/public/link

while [ forever ]
do
if [ ! -e "$LINKNAME" ]
then

ln -s /home/samba/public/orginalfile $LINKNAME

## Wait one minute and check again VERY IMPORTANT LINE
sleep 60 # Could wait 5m (5 minutes, etc) done run too often

done

This could be put in the smbd startup script right after
the "start)" line to execute on reboot.
 
Old 05-05-2008, 01:05 PM   #7
nflenz
Member
 
Registered: Feb 2006
Distribution: CRUX 2.4
Posts: 96

Rep: Reputation: 18
Code:
# chmod 555 /home/samba/public/[symlink]
Replace [symlink] with the correct file name.
 
Old 05-06-2008, 02:19 AM   #8
gabosdenes
LQ Newbie
 
Registered: Jan 2008
Posts: 8

Original Poster
Rep: Reputation: 0
rlhartmann you were right in your first post, i had to make the directory the symlink is in read only for users, and now thei can't delete the symlinks.
Thanks everyone for helping.
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cp and symbolic links? sausagejohnson Linux - General 3 07-19-2005 01:25 AM
Symbolic Links Greg_courageous Linux - Newbie 1 05-10-2004 07:05 AM
Symbolic links? TongueTied Linux - Newbie 3 08-27-2003 06:00 AM
symbolic links winger Linux - General 5 04-06-2002 05:16 PM
Symbolic links Valerie Linux - Newbie 12 03-31-2002 01:49 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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