September 25, 2022

COSFONE

Networking, PBX, IT, DIY Solution

How to achieve that samba can be written but not delete?

2 min read

How to achieve that samba can be written but not delete?



How to achieve that samba can be written but not delete?

How to achieve linux writable and non-deletable, and using POSIX ACL also.

If we are facing below requirement, how to achieve it?

Using POSIX ACL are as follows (different requirements, slightly corrected) shared directory To_manager.

Only the user of manager has full permissions to this directory.

Other users only have permission to copy and create new files in this directory. But you can’t delete the file, you can’t copy the file, and you can’t read the file.

Steps:

1. Change smb.conf as follows

[To_manager]

comment=To_manager

path=/To_manager

writable=yes

create mask =1600

directory mask= 1600

2. Let Linux support POSIX ACL (this POSIX ACL function is officially supported in Linux kernel 2.6, and then back-ported to 2.4 kernel.

Common file systems, such as: ext3, xfs, jfs, and ReiserFS, can be Use ACL. Of course, you need to enable ACL when compiling the kernel.)

We can also add options to /etc/fstab:

/dev/sda1 /home ext3 acl 1 2

3. Write a small script

#!/bin/bash
mkdir /To_manager
chmod 777 /To_manager
chown manager:manager/To_manager
chmod o+t /To_manager
setfacl -md:u:manager:rwx /To_manager

Finally run the script and restart smb.



Copyright © All rights reserved. | Newsphere by AF themes.