LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   allowed to create/edit a file but not to DELETE A FILE. (https://www.linuxquestions.org/questions/linux-newbie-8/allowed-to-create-edit-a-file-but-not-to-delete-a-file-944025/)

micro_xii 05-09-2012 04:29 AM

allowed to create/edit a file but not to DELETE A FILE.
 
greetings;

centos 6

I command this chmod o+rwx /folder. From my xp I can access \\server\folder, create and delete into this file.

But how to provide permission where he can create/edit a file BUT RESTRICTED TO DELETE A FILE.
In windows this can be done in advnce security how about in linux?

Any ideas guys...pls help..

em31amit 05-09-2012 04:55 AM

seems you are referening here a stick bit permission, use chmod 1777 /folder


else you need to play with acl's and selinux policy to prevent this.

micro_xii 05-09-2012 08:12 PM

Quote:

Originally Posted by em31amit (Post 4674092)
seems you are referening here a stick bit permission, use chmod 1777 /folder


else you need to play with acl's and selinux policy to prevent this.

Hello, Thanks for the reply. I've search and command this:

setfacl -m u:linix:rwx /folder

But doesn't solved my problem. I want read,write, execute BUT RESTRICT TO DELETE A FILE.

can anyone help me...tnx in advance

chrism01 05-09-2012 08:31 PM

You may be able to do it via Samba cfg, but in *nix, creating/deleting a file is a write operation on the dir inode, not the file.
I don't think *nix perms or even ACLs is going to do it.
Sticky bit only prevents others from deleting a file you create; it can't stop you deleting a file you created.

micro_xii 05-09-2012 09:05 PM

Now, I get it..sticky bit prevents others from deleting your files except the owner/creator.

By the way, your referring samba cfg, what exactly do i need to look for? coz i dont see *cfg in /etc/samba. Can you just give me tips to start with.

thnx..

jlinkels 05-09-2012 09:57 PM

Quote:

Originally Posted by chrism01 (Post 4674676)
You may be able to do it via Samba cfg, but in *nix, creating/deleting a file is a write operation on the dir inode, not the file.
I don't think *nix perms or even ACLs is going to do it.
Sticky bit only prevents others from deleting a file you create; it can't stop you deleting a file you created.

So doesn't that mean that setting write restrictions on the directory does exactly that? Enable to write the file, but not to delete it. I recall that I had this problems (in conjunction with Samba) where I could not delete files.

jlinkels

chrism01 05-10-2012 01:14 AM

You need write access on the dir to create file (in that dir) and also to delete one; they both count as write ops on the dir inode/file itself. There's no delete perm in *nix, unlike eg OpenVMS.
I think(?) you can get what you want if you go via a Samba/cifs cxn; check the Samba docs.

em31amit 05-10-2012 02:19 AM

have you tried to set chattr on files ?


setting +a (append only attributes to files can helps you to append the data but not to delete or rename file)

but still only root can set these attributes .


lsattr /path/to/file #to show the extended attributes

chattr +a /path/to/file #TO change


Thanks,
em31amit
Amit m.

micro_xii 05-10-2012 05:00 AM

Quote:

Originally Posted by chrism01 (Post 4674813)
You need write access on the dir to create file (in that dir) and also to delete one; they both count as write ops on the dir inode/file itself. There's no delete perm in *nix, unlike eg OpenVMS.
I think(?) you can get what you want if you go via a Samba/cifs cxn; check the Samba docs.


This are what i command:

note: centos is joined in win2003

1. chmod 1070 /folder
2. under my samba..
directory mask = 0770
create mask = 0770


drwxr-xr-x. 2 nixuser domain users 4096 May 10 16:24 nix1 (folder nix1 created in centos)
drwxrwx---. 2 xpuser domain users 4096 May 10 16:29 win1 (folder win1 created in windows)

base on the problem i raise, the sticky bit answered my question only owners can create/delete their own file..done

the issue right now is creating/editing between folders..

Maybe this is a good start for me...I really dont know if im going the right way

chrism01 05-10-2012 07:22 PM

If Samba won't do it, you may have to resort to dir monitoring eg dnotify/fam and call a script to move the completed file to another area where the dir perms are r-x only.
Alternately, use a code ctrl system eg cvs, subversion etc.


All times are GMT -5. The time now is 12:29 PM.