0

UPDATE: It seems like the problem was caused because of another service which had nothing to do with smb. Apologies for not having a proper resolution and I am just closing the issue.


I have mounted a share with SMB to an Ubuntu 17.10 VM and I am trying to delete a file from the mount location (/mnt/smb_mnt).

I have first did the mount as guest: sudo mount -t cifs //ipaddress/share /mnt/smb_mnt/ -oguest,vers=2.0 and as a root too and none of it worked. Also, I tried the mount -o remount,rw /mnt/smb_mnt to remount using read and write privileges but the file can still not be deleted.

I give the file 777 permissions and I execute the rm command as root which is also the owner of the file. I checked with ls -l and the permissions are the ones I assign to both file and parent file (smb_mnt)

I have tried to use chattr -i command based on other related questions I have found but I get: chattr: Permission denied while setting flags on /mnt/smb_mnt/file.

What else can I try to be able to achieve the deletion?

I know files can be deleted easily locally on the machine, but I need to delete the file from the mounted location because the module I want to test works only over smb so I can't just ssh to the machine and delete the file manually.

Here is the SMB config file:

[global]
# Include the base global configuration options. These don't usually change.
include = /etc/samba/base_global.conf
# These are configurable via the module
max protocol = SMB2
hide files = //:2eDS_Store/:2eFBCLockFolder/.FBCLockFolder/:2eFBCIndex/.FBCIndex/TheVolumeSettingsFolder/TheFindByContentFolder/Temporary Items/Network Trash Folder/.AppleDB/:2eVolumeIcon.icns/.VolumeIcon.icns/Icon/.AppleDouble/.AppleDesktop/desktop.ini/RECYCLER//

# (Options from the currently enabled Global Profile. Will overwrite any previous options)
# Enabled Global profile: Default Global
# Authentication is handled by the UserDirectory module.
# The "security" option is put in this file as well.
include = /etc/samba/auth.conf

[Space]
# Profile: Guest Read/Write
path = /share/Space
guest ok = True
read only = False
browseable = True
preexec = /opt/space/modules/SMB/bin/scripts/event.py --event connect --profile 105 --service %S --user %u --client-ip %I --server-ip %i --path %P --pid %d
root preexec = /opt/space/modules/SMB/bin/scripts/event.py --root --event connect --profile 105 --service %S --user %u --client-ip %I --server-ip %i --path %P --pid %d
postexec = /opt/space/modules/SMB/bin/scripts/event.py --event disconnect --profile 105 --service %S --user %u --client-ip %I --server-ip %i --path %P --pid %d

# Optional extra definitions created by other programs.
# Will scan /etc/samba/includes.d/ for extra configuation files as well
# A SMB.createConf() will need to be run for it to detect new SMB config files
# The first line (includes.conf) is included for backwards compatibility. Modules should use the includes.d folder and make their own files.
include = /etc/samba/includes.conf
  • 2
    It also depends how is the share shared, ie. if it's just read only, you won't be able to delete anything. – Jaroslav Kucera Apr 12 '18 at 12:54
  • it is not read-only, I have checked the SMB config options – Marialena Apr 12 '18 at 12:58
  • And can you share those SMB config options? – Jaroslav Kucera Apr 12 '18 at 12:59
  • I have just added it to my question @JaroslavKucera . Thank you – Marialena Apr 12 '18 at 13:02
1

Samba does not represent the correct File Permissions on the Client Machine for the Samba Share.
Accessing the Files on the Samba Server over a Samba Connection you access them as the Samba User even if you are Logged In as root User on the Client Machine.
Changes you make to the Files over the Samba Connection are not reflected in that way on the Samber Server.

Try to login over ssh to the Samba Server and see the real File Permissions.
Probably those Files belong to a different User and/or different Group on the Samba Server.

In your Samba Share Configuration [Space] you do not define any User or Group asignation, so other Users connected to the same Samba Share create those files with their own System User Account and their own User File Permissions.

  • that was very very useful, thank you. After I ssh the permissions where nobody even if I changed it to root from my VM. How can i sync these permissions through the SMB config file? I have tried to do umask 000 , chmod 777 to the file from the ssh and then sudo su - from my VM and rm -r but i still get permission denied. – Marialena Apr 12 '18 at 14:28
  • There are several ways you can manage the Ownership and the Permissions for Files created through Samba Connections within the Samba Configuration File. Setting up allowed Groups valid users, write list, force user and define Default File and Directory Permissions with create mask and directory mask. Important for the allowed Groups and Users is the System User Account on the Samba Server with which you connect to it. – Bodo Hugo Barwich Apr 12 '18 at 14:59
  • thanks. I have added this to the config file of SMB (each one in a new line) for the share I work on: create mask = 0777 directory mask = 0777 force create mode = 0777 force directory mode = 0777 write list = root read list = root. I changed the config file on the machine directly. The machine has owner nobody and in the VM /mnt the owner is root. I still can't delete any files even if I change the owner to root in the machine with chown or even if I change in /mnt of my VM the permissions to 777 (-rwxr-xr-x while in the machine is -rw-rw-rw- if i don't chown to root) – Marialena Apr 13 '18 at 8:06
  • Samba works similar to FTP you log in to the Server over a User Account that exists on the Samba Server where you want to place the files on. If your Client Machine does not have the same User Account as the Samba Server certainly you are logged in as Anonymous User. From Command Line I usually use this Command to access the Samba Server temporally smbclient //samba-server/share/ -U user-account This will you log in into the Samber Server as user-account User. This can be different than the current User Session on you Client Machine. – Bodo Hugo Barwich Apr 14 '18 at 10:19
  • I have accessed the smb share files in that way but how can my automated python scripts execute unix commands in that system like I was doing in the mounted smb location? – Marialena Apr 16 '18 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.