0

I configured a basic samba shire to share media files over SMB on my local network without credentials (i.e., as a SMB guest)

/etc/samba/smb.conf

[media]                                                                                                                               
Comment = Media directory                                                                                                             
Path = /mnt/media                                                                                                                     
Browseable = yes                                                                                                                      
Writeable = Yes                                                                                                                       
create mask = 0666                                                                                                                    
directory mask = 0777                                                                                                                 
Public = yes

When I create a directory called example using SMB on Windows, the directory structure looks like this

ls -alh

total 28K                                                                                                                             
drwxrwxrwt 4 root   root    4.0K Oct 21 13:44 ./                                                                                      
drwxr-xr-x 3 root   root    4.0K Oct 20 13:33 ../                                                                                     
drwxrwxrwx 2 nobody nogroup 4.0K Oct 21 13:44 example/                                                                                
drwx------ 2 root   root     16K Oct 20 13:36 lost+found/
lsattr

--------------e----- ./example

When I try to delete the directory from the system using a standard user account, I get an error message.

rmdir: failed to remove 'example': Operation not permitted

Yet, I can delete the folder from using SMB on Windows. What is happening here, and how can I allow any local unix user to delete or modify files created by a guest over SMB?

1
  • You are nobody via SMB :-P You can probably change the permissions too, so that your normal local userID can remove it. Otherwise you should be able to use elevated permissions (as root or via sudo) and do 'whatever you want' with it.
    – sudodus
    Oct 21, 2021 at 18:21

1 Answer 1

2

The t flag in the parent directory permissions declares that only the owner of a directory (or root) can delete a file or directory from it.

Samba appears to be configured to provide user access as the account nobody. You aren't nobody so you don't have the rights to delete the directory.

I not recommend you create files and directories at the top level. Leave that for lost+found and one data directory, and share that data directory rather than the mountpoint.

# Remove global write permission from the mountpoint
chmod go-w,-t /mnt/media

# Create your files and directories in here
mkdir -m777 /mnt/media/data

Now fix up the Samba data path

[media]                                                                                                                               
    comment = Media directory
    path = /mnt/media/data
    browseable = yes
    read only = no
    guest ok = yes
    force directory mode = 0777
    force create mode = 0666

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .