Skip to content

ksmbd: resolve symlinks in share paths before writing ksmbd.conf#61

Open
ispyisail wants to merge 2 commits into
lantis1008:masterfrom
ispyisail:fix/ksmbd-symlink-path
Open

ksmbd: resolve symlinks in share paths before writing ksmbd.conf#61
ispyisail wants to merge 2 commits into
lantis1008:masterfrom
ispyisail:fix/ksmbd-symlink-path

Conversation

@ispyisail

Copy link
Copy Markdown

ksmbd's kernel module returns NT_STATUS_ACCESS_DENIED when a share
root path is a symlink. The "Same Partition On Any USB Drive" option
in the USB Storage page stores the dev-based symlink path
(e.g. /tmp/usb_mount/dev_sda1) rather than the UUID-based real path,
causing all shares configured with that option to be inaccessible.

Confirmed on hardware: connecting via smbclient to a share with a
symlink root returns NT_STATUS_ACCESS_DENIED; resolving the path
first gives a successful directory listing.

Add readlink -f in smb_add_share after reading the path from UCI
so ksmbd always receives a real directory path. The fallback || echo "$path"
preserves the original path if the target does not yet exist (drive
not plugged in).

Shane Ringrose and others added 2 commits June 25, 2026 07:42
ksmbd's kernel module returns NT_STATUS_ACCESS_DENIED when a share
root path is a symlink. The 'Same folder on all disks' / 'The Same
Partition On Any USB Drive' option stores the dev-based symlink path
(e.g. /tmp/usb_mount/dev_sda1) rather than the UUID-based real path,
causing all shares configured with that option to be inaccessible.

Resolve the path via readlink -f in smb_add_share before writing it
to ksmbd.conf so ksmbd always receives a real directory path.
The PR accidentally changed ksmbd.init from 755 to 644, likely due to a
local git core.fileMode mismatch. Init scripts on OpenWrt must be
executable for procd and direct service invocations to work.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@ispyisail ispyisail left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The readlink -f "$path" 2>/dev/null || echo "$path" pattern is correct — it resolves symlinks, suppresses errors when the path does not exist yet (e.g. drive not yet mounted at init time), and falls back to the original path safely.

One bug introduced: the diff includes a file mode change on ksmbd.init from 100755100644. Init scripts need to be executable or service ksmbd start/stop/restart and procd invocations break. This looks like a local core.fileMode mismatch rather than an intentional change.

Fixed in the branch with git update-index --chmod=+x.

ispyisail pushed a commit to ispyisail/gargoyle that referenced this pull request Jun 27, 2026
dhcp.sh, restriction.sh, qos_download.sh, and qos_upload.sh were committed
as 100644. Uhttpd invokes these as CGI executables and returns 403 if the
executable bit is absent. Same core.fileMode root cause as ksmbd.init in lantis1008#61.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
ispyisail pushed a commit to ispyisail/gargoyle that referenced this pull request Jun 27, 2026
dhcp.sh, restriction.sh, qos_download.sh, and qos_upload.sh were committed
as 100644. Uhttpd invokes these as CGI executables and returns 403 if the
executable bit is absent. Same core.fileMode root cause as ksmbd.init in lantis1008#61.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant