]> www.infradead.org Git - nvme.git/commitdiff
ksmbd: ignore trailing slashes in share paths
authorNandor Kracser <bonifaido@gmail.com>
Tue, 21 May 2024 13:56:17 +0000 (22:56 +0900)
committerSteve French <stfrench@microsoft.com>
Wed, 22 May 2024 23:26:29 +0000 (18:26 -0500)
Trailing slashes in share paths (like: /home/me/Share/) caused permission
issues with shares for clients on iOS and on Android TV for me,
but otherwise they work fine with plain old Samba.

Cc: stable@vger.kernel.org
Signed-off-by: Nandor Kracser <bonifaido@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/server/mgmt/share_config.c

index a2f0a2edceb8ae49852dde1b40cf7594df6084d9..e0a6b758094fc57c5fd47d0be2ab9f4d1e94ee70 100644 (file)
@@ -165,8 +165,12 @@ static struct ksmbd_share_config *share_config_request(struct unicode_map *um,
 
                share->path = kstrndup(ksmbd_share_config_path(resp), path_len,
                                      GFP_KERNEL);
-               if (share->path)
+               if (share->path) {
                        share->path_sz = strlen(share->path);
+                       while (share->path_sz > 1 &&
+                              share->path[share->path_sz - 1] == '/')
+                               share->path[--share->path_sz] = '\0';
+               }
                share->create_mask = resp->create_mask;
                share->directory_mask = resp->directory_mask;
                share->force_create_mode = resp->force_create_mode;