Skip to content

Not Able to Delete Files #125

@ChrisJBurns

Description

@ChrisJBurns

I am getting quite a lot of issues trying to delete files / directories on a Samba share.

I am able to create them without issue, but deleting them is where I just cannot get it to work.

docker-compose.yaml

---
version: "3.9"

services:
  samba:
    image: docker.io/servercontainers/samba:latest
    container_name: samba
    restart: unless-stopped
    # user: samba
    # network_mode: host
    # hostname: smb-server
    environment:

      GROUP_sambausers: 1500

      ACCOUNT_samba: test
      UID_samba: 1000
      GROUPS_samba: sambausers
         
         ## Groups definition ##

      SAMBA_GLOBAL_CONFIG_server_SPACE_min_SPACE_protocol: NT1
      SAMBA_GLOBAL_CONFIG_ntlm_SPACE_auth: ntlmv1-permitted
      SAMBA_VOLUME_CONFIG_shared_home: |
        vfs objects = catia fruit streams_xattr
        [home];
        path=/shares/home
        valid users = samba
        browsable = yes
        writeable = yes
        read only = no
        inherit owner = yes
        create mask = 777
        directory mask = 777
        force create mode = 777
        force directory mode = 777
        force user = samba
        force group = sambausers
    volumes:
      - ./shares/home:/shares/home
    ports:
      - 445:445
    cap_add:
      - CAP_NET_ADMIN

  myubuntu:
    image: ubuntu
    container_name: ubuntu
    stdin_open: true # docker run -i
    tty: true        # docker run -t
    build:
      dockerfile: Dockerfile
      context: .
    cap_add:
      - SYS_ADMIN
      - DAC_READ_SEARCH

When I docker exec onto the samba container, I can see that the /shares/home is owned by root, I change this using
chown -R 1000:1500 shares/

I use a separate Ubuntu container in order to mount the Samba share so I can test it. I originally did this with my Macbook but I had problems there so I wanted to remove the possibility that my Macbook was the problem. This is what is in my Dockerfile for the Ubuntu image:

FROM ubuntu

RUN apt update && apt install -y samba smbclient vim iputils-ping cifs-utils

COPY --chmod=0600 smbcreds /home/.smbcredentials

RUN echo "//samba/home /mnt/home cifs credentials=/home/.smbcredentials,uid=1000,gid=1500 0 0" > /etc/fstab

RUN mkdir -p /mnt/home

# RUN mount -a

Once I do a docker-compose up --force-recreate --build, both samba and ubuntu containers are up. I exec onto my Ubuntu container and run mount -a, i then go to /mnt/home and I can see all of the files/folders there that exist on my Macbook. I can even create files.

root@ee4447359d43:/mnt/home# ls -al
total 32
drwxr-xr-x 2 1000 1500    0 Mar 14 15:07 .
drwxr-xr-x 1 root root 4096 Mar 14 14:08 ..
-rwxr-xr-x 1 1000 1500    0 Mar 14 14:59 .DS_Store
-rwxr-xr-x 1 1000 1500    0 Mar 14 14:53 .hi.file.swp
-rwxr-xr-x 1 1000 1500    0 Mar 14 14:53 .hi.file.swx
-rwxr-xr-x 1 1000 1500    0 Mar 14 15:07 .new.file.swp
-rwxr-xr-x 1 1000 1500    0 Mar 14 15:07 .new.file.swx
-rwxr-xr-x 1 1000 1500    0 Mar 14 14:18 .new.text.swp
-rwxr-xr-x 1 1000 1500    0 Mar 14 14:18 .new.text.swx
-rwxr-xr-x 1 1000 1500 4096 Mar 14 15:07 .newnew.swo
-rwxr-xr-x 1 1000 1500    0 Mar 14 15:07 .newnew.swp
-rwxr-xr-x 1 1000 1500    0 Mar 14 15:07 .newnew.swpx
-rwxr-xr-x 1 1000 1500    4 Mar 14 14:53 hi.file
-rwxr-xr-x 1 1000 1500 4096 Mar 14 14:53 hi_file.swp
-rwxr-xr-x 1 1000 1500    4 Mar 14 15:07 new.file
-rwxr-xr-x 1 1000 1500    5 Mar 14 14:18 new.text
-rwxr-xr-x 1 1000 1500 4096 Mar 14 15:07 new_file.swp
-rwxr-xr-x 1 1000 1500 4096 Mar 14 14:18 new_text.swp

They even show that they are owned by 1000:1500 - which is the samba uid (1000) and sambausers gid (1500). However, I just cannot delete any files/directories. The error I get is

root@375f455c0b84:/mnt/home# rm new.text
rm: cannot remove 'new.text': Operation not supported

The fact that I can write new ones shows that write access is fine, but I have been racking my brains for the last couple of days trying to figure out why deletes don't work. I have tried all sorts of combinations in the smb.conf file. From forcing users, to forcing groups, to using root, to creating 777 masks, nothing I do get's deletes to work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions