I can only mount a remote cifs share as root even though I am using uid and gid with a valid user.
This did work for years, with fstab remaining unchanged. I have been patching (this is openSUSE Leap 15.3) so I'm wondering if something has been broken or deprecated. If there's no obvious answer, how best do I troubleshoot this?
# whoami
root
# uname -a
Linux my_user7 5.3.18-59.40-preempt #1 SMP PREEMPT Mon Jan 3 18:43:20 UTC 2022 (34edd9c) x86_64 x86_64 x86_64 GNU/Linux
# ls -lah /external/
total 0
drwxr-xr-x 1 root root 76 Apr 13 2021 .
drwxr-xr-x 1 root root 422 Sep 4 14:26 ..
drwxr-xr-x 1 my_user users 0 Jul 28 2018 Data1
drwxr-xr-x 1 my_user users 0 Nov 26 2019 Data2
drwxr-xr-x 1 my_user users 0 Jul 27 2018 Data3
drwxr-xr-x 1 my_user users 0 Jul 27 2018 Data4
drwxr-xr-x 1 my_user users 0 Jul 27 2018 Data5
drwxr-xr-x 1 my_user users 0 Apr 13 2021 Data6
# mount -v -t cifs -o username=my_user,password=my_pass,vers=1.0,uid=my_user,gid=users //192.168.1.1/Data5 /external/Data5
mount.cifs kernel mount options: ip=192.168.1.1,unc=\\192.168.1.1\Data5,vers=1.0,uid=1000,gid=100,user=my_user,pass=********
# ls -lah /external/
total 0
drwxr-xr-x 1 root root 76 Apr 13 2021 .
drwxr-xr-x 1 root root 422 Sep 4 14:26 ..
drwxr-xr-x 1 my_user users 0 Jul 28 2018 Data1
drwxr-xr-x 1 my_user users 0 Nov 26 2019 Data2
drwxr-xr-x 1 my_user users 0 Jul 27 2018 Data3
drwxr-xr-x 1 my_user users 0 Jul 27 2018 Data4
drwxrwxrwx 1 root root 0 Jul 27 14:14 Data5
drwxr-xr-x 1 my_user users 0 Apr 13 2021 Data6
# id my_user
uid=1000(my_user) gid=100(users) groups=491(cdrom),463(vboxusers),100(users)
What am I missing?
Thanks in advance.
EDIT: Additional info...
mount cifs can only be run as root
# whoami
my_user
# mount -v -t cifs -o username=my_user,password=my_pass,vers=1.0,uid=my_user,gid=users //192.168.1.1/Data5 /external/Data5
This program is not installed setuid root - "user" CIFS mounts not supported.
It will run OK if I sudo
# sudo mount -v -t cifs -o username=my_user,password=my_pass,vers=1.0,uid=my_user,gid=users //192.168.1.1/Data5 /external/Data5
mount.cifs kernel mount options: ip=192.168.1.1,unc=\\192.168.1.1\Data5,vers=1.0,uid=1000,gid=100,user=my_user,pass=********
But with the same end result, we're mounted as root
# ls -lah /external/
total 0
drwxr-xr-x 1 root root 76 Apr 13 2021 .
drwxr-xr-x 1 root root 422 Sep 4 14:26 ..
drwxr-xr-x 1 my_user users 0 Jul 28 2018 Data1
drwxr-xr-x 1 my_user users 0 Nov 26 2019 Data2
drwxr-xr-x 1 my_user users 0 Jul 27 2018 Data3
drwxr-xr-x 1 my_user users 0 Jul 27 2018 Data4
drwxrwxrwx 1 root root 0 Jul 27 14:14 Data5
drwxr-xr-x 1 my_user users 0 Apr 13 2021 Data6
My fstab looks as follows
# cat /etc/fstab | grep Data5
//192.168.1.1/Data5 /external/Data5 cifs user,nofail,x-systemd.device-timeout=10,x-systemd.automount,x-systemd.idle-timeout=60,uid=my_user,gid=users,username=my_user,password=my_pass,vers=1.0 0 0
Which runs successfully
# sudo mount -a
But still mounts as root
# ls -lah /external/
total 16K
drwxr-xr-x 1 root root 76 Apr 13 2021 .
drwxr-xr-x 1 root root 422 Sep 4 14:26 ..
drwxr-xr-x 1 my_user users 12K Nov 4 14:14 Data1
drwxr-xr-x 8 my_user users 170 May 6 2021 Data2
drwxr-xr-x 2 my_user users 4.0K Oct 4 10:04 Data3
drwxr-xr-x 5 my_user users 110 Nov 19 12:02 Data4
drwxrwxrwx 1 root root 0 Jul 27 14:14 Data5
drwxr-xr-x 1 my_user users 0 Apr 13 2021 Data6
Still baffled!
Edit II...
A partial solution.
Adding forceuid and forcegid fixes the ownership but I can't set the mode, even with file_mode and dir_mode:
# mount -v -t cifs -o username=my_user,password=my_pass,uid=my_user,gid=users,forceuid,forcegid,file_mode=0755,dir_mode=0755,vers=1.0 //192.168.1.1/Data5 /external/Data5
mount.cifs kernel mount options: ip=192.168.1.1,unc=\\192.168.1.1\Data5,forceuid,forcegid,file_mode=0755,dir_mode=0755,vers=1.0,uid=1000,gid=100,user=my_user,pass=********
# ls -lah /external/
total 0
drwxr-xr-x 1 root root 76 Jan 25 14:20 .
drwxr-xr-x 1 root root 422 Sep 4 14:26 ..
drwxr-xr-x 1 my_user users 0 Jul 28 2018 Data1
drwxr-xr-x 1 my_user users 0 Nov 26 2019 Data2
drwxr-xr-x 1 my_user users 0 Jul 27 2018 Data3
drwxr-xr-x 1 my_user users 0 Jul 27 2018 Data4
drwxrwxrwx 1 my_user users 0 Jul 27 14:14 Data5
drwxr-xr-x 1 my_user users 0 Apr 13 2021 Data6
Just need to figure out the mode, now...
#
as your shell prompt when you’re not root — at least not in examples — it’s very confusing.