cifsd-team / ksmbd

ksmbd kernel server(SMB/CIFS server)
154 stars 23 forks source link

can't set group write permissions to created files and directories #586

Open freepaddler opened 1 year ago

freepaddler commented 1 year ago

It seems that umask 022 is always applied to created files and directories. And it is impossible to set g+w and o+w permissions.

ksmbd.conf:

create mask = 0664
directory mask = 2775
; following options also do not help 
; force create mode = 0664
; force directory mode = 0775

ls -la .

drwxrwsr-x    3 user   storage       4096 Jan 18 18:21 .
drwxr-xr-x    6 root   root          4096 Jan 18 15:31 ..
-rw-r--r--    1 user   storage          2 Mar 30  2022 dummy3.txt
drwxr-sr-x    2 user   storage       4096 Jan 18 18:21 dummy

Alpine Linux 3.17 with 5.15.86 kernel.

namjaejeon commented 1 year ago

Sorry, where did you command "ls -al" ? mount point ? or share directory ?

namjaejeon commented 1 year ago

Have you tried "modefromsid" mount option if you have used cifs mount ?

freepaddler commented 1 year ago

Sorry, where did you command "ls -al" ? mount point ? or share directory ?

at share directory (where ksmbd is running)

Have you tried "modefromsid" mount option if you have used cifs mount ? yep, just tried - the same result

it really behaves as umask 0022, I tried different "create mask" values

namjaejeon commented 1 year ago

Hm... Stranged.. I also checked it again. but it work fine as expected. what is your local filesystem ?

create mask = 0664

-rw-rw-r--  1 linkinjeon linkinjeon      0  1월 20 14:47  aa
-rw-rw-r--  1 linkinjeon linkinjeon      0  1월 20 14:49  bb
-rw-rw-r--  1 linkinjeon linkinjeon      0  1월 20 14:49  cc
freepaddler commented 1 year ago

here are system specs:

$ uname -a
Linux alpine2 5.15.88-0-lts #1-Alpine SMP Mon, 16 Jan 2023 08:10:32 +0000 aarch64 Linux
$ head -1 /etc/fstab
UUID=40b62555-076a-4d1d-837f-63e1814d80cc   /   ext4    rw,relatime 0 1
$ ksmbd.mountd -V
ksmbd-tools version : 3.4.6

don't know if it makes sence, but also I checked umask of ksmbd running processess:

namjaejeon commented 1 year ago

Ah, Okay, Are you using ksmbd in alpine2's linux kernel ? or out of tree ksmbd(cifsd-team/ksmbd) ? If you are using the one in alpine2's linux kernel, I want to check kernel source.

I am wondering the below patch is in your kernel source... https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/fs/ksmbd/ksmbd_netlink.h?h=v5.15.89&id=8202aa60f077be8977bda2ecd5bd4350a0a5ab1e

freepaddler commented 1 year ago

Ah, Okay, Are you using ksmbd in alpine2's linux kernel ? or out of tree ksmbd(cifsd-team/ksmbd) ? If you are using the one in alpine2's linux kernel, I want to check kernel source.

I use ksmbd in alpine2's linux kernel (the default alpine kernel from alpine main repo branch 3.17)

namjaejeon commented 1 year ago

Hm, Can you check it with out of tree ksmbd here ?

namjaejeon commented 1 year ago

I can't find it's kernel source or tree. I guess that alpine2's linux kernel doesn't update ksmbd from the latest linux 5.15 stable kernel.

freepaddler commented 1 year ago

Hm, Can you check it with out of tree ksmbd here ?

tried cifsd-team/ksmbd on 5.15.89 and even 6.1.7 (alpine edge repository) with the same result :(

namjaejeon commented 1 year ago

Hm.. Don't know.. can you share your ksmb.conf file with me ? want to check it.

freepaddler commented 1 year ago

Hm.. Don't know.. can you share your ksmb.conf file with me ? want to check it.

# cat /etc/ksmbd/ksmbd.conf
[global]
        ; server settings
        server string = alpine2
        netbios name = alpine2
        workgroup = alpinelab
        interfaces = eth0
        bind interfaces only = yes
        tcp port = 445

        ; share settings              
        root directory = /opt
        guest account = nobody
        map to guest = bad user
        restrict anonymous = 0
        create mask = 0664
        directory mask = 2775
        guest ok = no
        browseable = no
        hide dot files = yes
        ;force user = nobody
        ;force group = nobody
        ;force directory mode = 0777
        ;force create mode = 0777
        ;inherit owner = yes

[user]
    path = /user
    writeable = yes
    valid users = user
freepaddler commented 1 year ago

Hm.. Don't know.. can you share your ksmb.conf file with me ? want to check it.

just tested on Debian sid Linux deb11 6.1.0-2-arm64 #1 SMP Debian 6.1.7-1 (2023-01-18) aarch64 GNU/Linux and here it works as expected

also ksmbd processes have umask 0000

# ps afx | grep ksmbd
   1090 ?        S      0:00  \_ [ksmbd-ens160]
   1119 ?        S      0:00  \_ [ksmbd:60445]
   1127 pts/0    S+     0:00          \_ grep ksmbd
   1088 ?        Ss     0:00 ksmbd.mountd -c /etc/ksmbd/ksmbd.conf
   1089 ?        S      0:00  \_ ksmbd.mountd -c /etc/ksmbd/ksmbd.conf

# grep -i umask /proc/{1090,1119}/status
/proc/1090/status:Umask:    0000
/proc/1119/status:Umask:    0000
namjaejeon commented 1 year ago

@freepaddler Can I understand that there is no problem if you change alpine2 to Debian?

freepaddler commented 1 year ago

@freepaddler Can I understand that there is no problem if you change alpine2 to Debian?

yep, I raised an issue in Alpinelinux community, thanks for support!

neheb commented 1 year ago

Sounds like an issue with ksmbd-tools. musl probably handles the necessary function differently.