One liner: I can’t even ls the NTFS folder, samba responds with NT_STATUS_ACCESS_DENIED listing \*
I wanted to setup Samba (smbd) to share on my LAN. I followed the arch wiki tutorial, set up an extra user and specified the few folders I wanted.
For tests I let it run on localhost and connect using Dolphin/smbclient. At first it would not let me use my home user’s folder via smb user “smb_leaky” due to the basic permissions issue (/home/leaky was only listable for leaky). When I added “leaky” as supplementary group to “smb_leaky” and set g+x on the /home/leaky folder - I could list the /home/leaky/shared folder via smb.
TLDR: Basic auth and listing works fine.
Next I wanted to share two folders from a mounted NTFS partition. Here comes the issue I can’t overcome.
- Mounted ntfs-3g part:
/run/media/Xpartition
- Shared path:
/run/media/Xpartition/SteamLibrary/
- /etc/fstab:
UUID=__its_uuid__ /run/media/Xpartition ntfs rw,noatime,nosuid,nodev,relatime,uid=1000,gid=1000,default_permissions,allow_other,windows_names 0 0
Permissions along the path
getfacl /run
getfacl: Removing leading '/' from absolute path names
# file: run
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
getfacl /run/media
getfacl: Removing leading '/' from absolute path names
# file: run/media
# owner: root
# group: root
user::rwx
group::r-x
other::r-x
getfacl /run/media/Xpartition
getfacl: Removing leading '/' from absolute path names
# file: run/media/Xpartition
# owner: leaky
# group: leaky
user::rwx
group::rwx
other::rwx
getfacl /run/media/Xpartition/SteamLibrary
getfacl: Removing leading '/' from absolute path names
# file: run/media/Xpartition/SteamLibrary
# owner: leaky
# group: leaky
user::rwx
group::rwx
other::rwx
drwxrwxrwx 1 leaky leaky 65536 2. Jan 14:05 SteamLibrary
When I try to connect and list the folder with smbclient:
$ smbclient //127.0.0.1/test --user 'smb_leaky' --debuglevel=2
smb: \> ls
NT_STATUS_ACCESS_DENIED listing \*
In log level 3 output I see:
root# journalctl -f -u smb
[2024/01/02 19:11:17.780980, 3] ../../source3/smbd/smb2_server.c:4031(smbd_smb2_request_error_ex)
Jan 02 19:11:17 myhostname smbd[32507]: smbd_smb2_request_error_ex: smbd_smb2_request_error_ex: idx[1] status[NT_STATUS_ACCESS_DENIED] || at ../../source3/smbd/smb2_create.c:360
Again, the listing for the home subfolder works. Answers online usually end with AppArmor/SELinux but I didn’t install those.
journactl log when I connect and then ls using smbclient
You can see the ls command output at 20:17:12
20:17:09 smbd[37419]: Trying _Get_Pwnam(), username as lowercase is smb_leaky
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215133, 5] ../../source3/lib/username.c:159(Get_Pwnam_internals)
20:17:09 smbd[37419]: Get_Pwnam_internals did find user [smb_leaky]!
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215171, 4] ../../source3/smbd/sec_ctx.c:206(push_sec_ctx)
20:17:09 smbd[37419]: push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 2
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215191, 4] ../../source3/smbd/uid.c:566(push_conn_ctx)
20:17:09 smbd[37419]: push_conn_ctx(0) : conn_ctx_stack_ndx = 1
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215208, 4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
20:17:09 smbd[37419]: setting sec ctx (0, 0) - sec_ctx_stack_ndx = 2
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215226, 5] ../../libcli/security/security_token.c:49(security_token_debug)
20:17:09 smbd[37419]: Security token: (NULL)
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215243, 5] ../../source3/auth/token_util.c:873(debug_unix_user_token)
20:17:09 smbd[37419]: UNIX token of user 0
20:17:09 smbd[37419]: Primary group is 0 and contains 0 supplementary groups
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215278, 4] ../../source3/smbd/sec_ctx.c:443(pop_sec_ctx)
20:17:09 smbd[37419]: pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 1
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215301, 3] ../../source3/passdb/lookup_sid.c:1720(get_primary_group_sid)
20:17:09 smbd[37419]: Forcing Primary Group to 'Domain Users' for smb_leaky
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215319, 4] ../../source3/smbd/sec_ctx.c:206(push_sec_ctx)
20:17:09 smbd[37419]: push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 2
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215337, 4] ../../source3/smbd/uid.c:566(push_conn_ctx)
20:17:09 smbd[37419]: push_conn_ctx(0) : conn_ctx_stack_ndx = 1
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215355, 4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
20:17:09 smbd[37419]: setting sec ctx (0, 0) - sec_ctx_stack_ndx = 2
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215374, 5] ../../libcli/security/security_token.c:49(security_token_debug)
20:17:09 smbd[37419]: Security token: (NULL)
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215390, 5] ../../source3/auth/token_util.c:873(debug_unix_user_token)
20:17:09 smbd[37419]: UNIX token of user 0
20:17:09 smbd[37419]: Primary group is 0 and contains 0 supplementary groups
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215424, 4] ../../source3/smbd/sec_ctx.c:443(pop_sec_ctx)
20:17:09 smbd[37419]: pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 1
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215455, 4] ../../source3/smbd/sec_ctx.c:206(push_sec_ctx)
20:17:09 smbd[37419]: push_sec_ctx(0, 0) : sec_ctx_stack_ndx = 2
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215476, 4] ../../source3/smbd/uid.c:566(push_conn_ctx)
20:17:09 smbd[37419]: push_conn_ctx(0) : conn_ctx_stack_ndx = 1
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215500, 4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
20:17:09 smbd[37419]: setting sec ctx (0, 0) - sec_ctx_stack_ndx = 2
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215517, 5] ../../libcli/security/security_token.c:49(security_token_debug)
20:17:09 smbd[37419]: Security token: (NULL)
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215535, 5] ../../source3/auth/token_util.c:873(debug_unix_user_token)
20:17:09 smbd[37419]: UNIX token of user 0
20:17:09 smbd[37419]: Primary group is 0 and contains 0 supplementary groups
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215568, 4] ../../source3/smbd/sec_ctx.c:443(pop_sec_ctx)
20:17:09 smbd[37419]: pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 1
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215594, 4] ../../source3/smbd/sec_ctx.c:443(pop_sec_ctx)
20:17:09 smbd[37419]: pop_sec_ctx (0, 0) - sec_ctx_stack_ndx = 0
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215636, 4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
20:17:09 smbd[37419]: setting sec ctx (1001, 1001) - sec_ctx_stack_ndx = 0
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215658, 5] ../../libcli/security/security_token.c:53(security_token_debug)
20:17:09 smbd[37419]: Security token SIDs (8):
20:17:09 smbd[37419]: SID[ 0]: S-1-5-21-1939806183-2778731130-2165616960-1000
20:17:09 smbd[37419]: SID[ 1]: S-1-5-21-1939806183-2778731130-2165616960-513
20:17:09 smbd[37419]: SID[ 2]: S-1-22-2-1001
20:17:09 smbd[37419]: SID[ 3]: S-1-22-2-1000
20:17:09 smbd[37419]: SID[ 4]: S-1-1-0
20:17:09 smbd[37419]: SID[ 5]: S-1-5-2
20:17:09 smbd[37419]: SID[ 6]: S-1-5-11
20:17:09 smbd[37419]: SID[ 7]: S-1-22-1-1001
20:17:09 smbd[37419]: Privileges (0x 0):
20:17:09 smbd[37419]: Rights (0x 0):
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215751, 5] ../../source3/auth/token_util.c:873(debug_unix_user_token)
20:17:09 smbd[37419]: UNIX token of user 1001
20:17:09 smbd[37419]: Primary group is 1001 and contains 2 supplementary groups
20:17:09 smbd[37419]: Group[ 0]: 1001
20:17:09 smbd[37419]: Group[ 1]: 1000
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215804, 5] ../../source3/smbd/uid.c:294(print_impersonation_info)
20:17:09 smbd[37419]: print_impersonation_info: Impersonated user: uid=(1001,1001), gid=(0,1001), cwd=[/]
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215825, 4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
20:17:09 smbd[37419]: setting sec ctx (0, 0) - sec_ctx_stack_ndx = 0
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215844, 5] ../../libcli/security/security_token.c:49(security_token_debug)
20:17:09 smbd[37419]: Security token: (NULL)
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215862, 5] ../../source3/auth/token_util.c:873(debug_unix_user_token)
20:17:09 smbd[37419]: UNIX token of user 0
20:17:09 smbd[37419]: Primary group is 0 and contains 0 supplementary groups
20:17:09 smbd[37419]: [2024/01/02 20:17:09.215893, 5] ../../source3/smbd/uid.c:494(smbd_change_to_root_user)
20:17:09 smbd[37419]: change_to_root_user: now uid=(0,0) gid=(0,0)
20:17:09 smbd[37419]: [2024/01/02 20:17:09.216077, 3] ../../source3/smbd/smb2_service.c:814(make_connection_snum)
20:17:09 smbd[37419]: v(ipv4:127.0.0.1:40150) signed connect to service test initially as user smb_leaky (uid=1001, gid=1001) (pid 37419)
20:17:09 smbd[37419]: [2024/01/02 20:17:09.216108, 5] ../../libcli/smb/smb2_signing.c:574(smb2_signing_sign_pdu)
20:17:09 smbd[37419]: signed SMB2 message (sign_algo_id=2)
20:17:12 smbd[37419]: [2024/01/02 20:17:12.671655, 4] ../../source3/smbd/sec_ctx.c:317(set_sec_ctx_internal)
20:17:12 smbd[37419]: setting sec ctx (1001, 1001) - sec_ctx_stack_ndx = 0
20:17:12 smbd[37419]: [2024/01/02 20:17:12.671762, 5] ../../libcli/security/security_token.c:53(security_token_debug)
20:17:12 smbd[37419]: Security token SIDs (8):
20:17:12 smbd[37419]: SID[ 0]: S-1-5-21-1939806183-2778731130-2165616960-1000
20:17:12 smbd[37419]: SID[ 1]: S-1-5-21-1939806183-2778731130-2165616960-513
20:17:12 smbd[37419]: SID[ 2]: S-1-22-2-1001
20:17:12 smbd[37419]: SID[ 3]: S-1-22-2-1000
20:17:12 smbd[37419]: SID[ 4]: S-1-1-0
20:17:12 smbd[37419]: SID[ 5]: S-1-5-2
20:17:12 smbd[37419]: SID[ 6]: S-1-5-11
20:17:12 smbd[37419]: SID[ 7]: S-1-22-1-1001
20:17:12 smbd[37419]: Privileges (0x 0):
20:17:12 smbd[37419]: Rights (0x 0):
20:17:12 smbd[37419]: [2024/01/02 20:17:12.672005, 5] ../../source3/auth/token_util.c:873(debug_unix_user_token)
20:17:12 smbd[37419]: UNIX token of user 1001
20:17:12 smbd[37419]: Primary group is 1001 and contains 2 supplementary groups
20:17:12 smbd[37419]: Group[ 0]: 1001
20:17:12 smbd[37419]: Group[ 1]: 1000
20:17:12 smbd[37419]: [2024/01/02 20:17:12.672127, 4] ../../source3/smbd/vfs.c:937(vfs_ChDir)
20:17:12 smbd[37419]: vfs_ChDir to /run/media/Xpartition/SteamLibrary
20:17:12 smbd[37419]: [2024/01/02 20:17:12.672384, 5] ../../source3/smbd/vfs.c:999(vfs_ChDir)
20:17:12 smbd[37419]: vfs_ChDir: vfs_ChDir got /run/media/Xpartition/SteamLibrary
20:17:12 smbd[37419]: [2024/01/02 20:17:12.672556, 5] ../../source3/smbd/uid.c:294(print_impersonation_info)
20:17:12 smbd[37419]: print_impersonation_info: Impersonated user: uid=(1001,1001), gid=(0,1001), cwd=[/run/media/Xpartition/SteamLibrary]
20:17:12 smbd[37419]: [2024/01/02 20:17:12.672611, 5] ../../lib/dbwrap/dbwrap.c:172(dbwrap_lock_order_lock)
20:17:12 smbd[37419]: dbwrap_lock_order_lock: check lock order 1 for /var/cache/samba/smbXsrv_tcon_global.tdb
20:17:12 smbd[37419]: [2024/01/02 20:17:12.672685, 5] ../../lib/dbwrap/dbwrap.c:204(dbwrap_lock_order_unlock)
20:17:12 smbd[37419]: dbwrap_lock_order_unlock: release lock order 1 for /var/cache/samba/smbXsrv_tcon_global.tdb
20:17:12 smbd[37419]: [2024/01/02 20:17:12.672758, 5] ../../source3/smbd/files.c:77(fsp_new)
20:17:12 smbd[37419]: fsp_new: allocated files structure (1 used)
20:17:12 smbd[37419]: [2024/01/02 20:17:12.672886, 5] ../../source3/smbd/files.c:77(fsp_new)
20:17:12 smbd[37419]: fsp_new: allocated files structure (2 used)
20:17:12 smbd[37419]: [2024/01/02 20:17:12.673008, 5] ../../lib/dbwrap/dbwrap.c:172(dbwrap_lock_order_lock)
20:17:12 smbd[37419]: dbwrap_lock_order_lock: check lock order 1 for /var/cache/samba/smbXsrv_open_global.tdb
20:17:12 smbd[37419]: [2024/01/02 20:17:12.673251, 5] ../../lib/dbwrap/dbwrap.c:204(dbwrap_lock_order_unlock)
20:17:12 smbd[37419]: dbwrap_lock_order_unlock: release lock order 1 for /var/cache/samba/smbXsrv_open_global.tdb
20:17:12 smbd[37419]: [2024/01/02 20:17:12.673310, 5] ../../source3/smbd/open.c:4731(open_directory)
20:17:12 smbd[37419]: open_directory: opening directory ., access_mask = 0x81, share_access = 0x3 create_options = 0x1, create_disposition = 0x1, file_attributes = 0x10
20:17:12 smbd[37419]: [2024/01/02 20:17:12.673437, 5] ../../source3/smbd/open.c:4931(open_directory)
20:17:12 smbd[37419]: open_directory: Could not open fd for [.]: NT_STATUS_ACCESS_DENIED
20:17:12 smbd[37419]: [2024/01/02 20:17:12.673491, 5] ../../lib/dbwrap/dbwrap.c:172(dbwrap_lock_order_lock)
20:17:12 smbd[37419]: dbwrap_lock_order_lock: check lock order 1 for /var/cache/samba/smbXsrv_open_global.tdb
20:17:12 smbd[37419]: [2024/01/02 20:17:12.673538, 5] ../../lib/dbwrap/dbwrap.c:204(dbwrap_lock_order_unlock)
20:17:12 smbd[37419]: dbwrap_lock_order_unlock: release lock order 1 for /var/cache/samba/smbXsrv_open_global.tdb
20:17:12 smbd[37419]: [2024/01/02 20:17:12.673580, 5] ../../source3/smbd/files.c:1977(file_free)
20:17:12 smbd[37419]: file_free: freed files structure 225076796 (1 used)
20:17:12 smbd[37419]: [2024/01/02 20:17:12.673628, 3] ../../source3/smbd/smb2_server.c:4031(smbd_smb2_request_error_ex)
20:17:12 smbd[37419]: smbd_smb2_request_error_ex: smbd_smb2_request_error_ex: idx[1] status[NT_STATUS_ACCESS_DENIED] || at ../../source3/smbd/smb2_create.c:360
20:17:12 smbd[37419]: [2024/01/02 20:17:12.673715, 5] ../../source3/smbd/files.c:1977(file_free)
20:17:12 smbd[37419]: file_free: freed files structure 0 (0 used)
Notably:
20:17:12 smbd[37419]: vfs_ChDir: vfs_ChDir got /run/media/Xpartition/SteamLibrary
20:17:12 smbd[37419]: [2024/01/02 20:17:12.672556, 5] ../../source3/smbd/uid.c:294(print_impersonation_info)
20:17:12 smbd[37419]: print_impersonation_info: Impersonated user: uid=(1001,1001), gid=(0,1001), cwd=[/run/media/Xpartition/SteamLibrary]
20:17:12 smbd[37419]: [2024/01/02 20:17:12.673310, 5] ../../source3/smbd/open.c:4731(open_directory)
20:17:12 smbd[37419]: open_directory: opening directory ., access_mask = 0x81, share_access = 0x3 create_options = 0x1, create_disposition = 0x1, file_attributes = 0x10
20:17:12 smbd[37419]: [2024/01/02 20:17:12.673437, 5] ../../source3/smbd/open.c:4931(open_directory)
20:17:12 smbd[37419]: open_directory: Could not open fd for [.]: NT_STATUS_ACCESS_DENIED
My Manjaro user is uid/gid 1000 and the new samba share user is uid/gid 1001, plus supplementary group 1000. From my understanding, there’s nothing on the path that’d block smb user’s ability to list the directory. For a sanity check:
su -s /bin/bash smb_leaky
and then cd’ing into /home/leaky/shared
works and /run/media/Xpartition/SteamLibrary
works too. Touching, rm’ing files too. So it’s not a pure Unix permission issue.
But the /run/media mounts don’t work with Samba
Cleaned from comments config file /etc/samba/smb.conf
:
[global]
workgroup = WORKGROUP
server string = myHost PC
netbios name = myhostname
server role = standalone server
security = user
logging = systemd
log level = 5
max log size = 50
interfaces = 127.0.0.1/8
bind interfaces only = yes
load printers = no
# Windows 8.1+
server min protocol = SMB2
server max protocol = SMB3
dns proxy = no
#============================ Share Definitions ==============================
[homes]
comment = Home Directories
browsable = no
writable = no
comment = All Printers
path = /usr/spool/samba
browsable = no
# Change 'guest ok' from 'no' to 'yes' to allow the 'guest account' user to print
guest ok = no
writable = no
printable = no
[game2archive]
comment = Game Archive
path = /run/media/Xpartition/Game-Versions
valid users = smb_leaky
public = no
writable = yes
inherit acls = yes
[steamonx]
comment = Steam Library on X
path = /run/media/Xpartition/SteamLibrary
valid users = smb_leaky
public = no
writable = no
guest ok = yes
inherit acls = yes
[leakygit]
comment = Leaky Git Folder
path = /home/leaky/git/
valid users = smb_leaky
public = no
writable = yes
inherit acls = yes
[test]
comment = Test Share
path = /run/media/Xpartition/SteamLibrary
valid users = smb_leaky
public = no
writable = yes