[PATCH] Fix vfs_dfs_samba4 with POSIX-style paths

Robin McCorkell rmccorkell at karoshi.org.uk
Sun Feb 15 10:29:25 MST 2015


Hi,

I noticed a bug in the handling of the share path in vfs_dfs_samba4,
which hardcoded the path separator to a backslash. The old samba3 code
detected if the share path begins with a forward slash or backslash, and
along with a config parameter, switched between the two. This patch
fixes the samba4 vfs code to do the same, however the config parameter
was very specific to the samba3 code and so I couldn't bring that across.

While smbclient uses backslashes to mount a share, mount.cifs (at least
version 6.0 on Ubuntu 14.04) uses forward slashes, triggering the error.

BTW, this is my first patch to Samba, so if I got anything wrong tell
me! (Ignore the PATCH 2/2 header in the patch file, I'm submitting two
patches today)

Regards,
Robin McCorkell
The Linux Schools Project
-------------- next part --------------
From 0c23dace2f82c73d26bce4c7dfdcf1f72475ef67 Mon Sep 17 00:00:00 2001
From: Robin McCorkell <rmccorkell at karoshi.org.uk>
Date: Thu, 5 Feb 2015 15:31:30 +0000
Subject: [PATCH 2/2] Fix MSDFS with POSIX paths in vfs_dfs_samba4

---
 dfs_server/dfs_server_ad.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/dfs_server/dfs_server_ad.c b/dfs_server/dfs_server_ad.c
index 3d93e19..8785eda 100644
--- a/dfs_server/dfs_server_ad.c
+++ b/dfs_server/dfs_server_ad.c
@@ -801,6 +801,7 @@ NTSTATUS dfs_server_ad_get_referrals(struct loadparm_context *lp_ctx,
 	const char *netbios_name;
 	const char *dns_name;
 	const char **netbios_aliases;
+	char path_separator;
 
 	if (!lpcfg_host_msdfs(lp_ctx)) {
 		return NT_STATUS_FS_DRIVER_REQUIRED;
@@ -827,17 +828,18 @@ NTSTATUS dfs_server_ad_get_referrals(struct loadparm_context *lp_ctx,
 	if (server_name == NULL) {
 		return NT_STATUS_NO_MEMORY;
 	}
+	path_separator = (*server_name == '/') ? '/' : '\\';
 
-	while(*server_name && *server_name == '\\') {
+	while(*server_name && *server_name == path_separator) {
 		server_name++;
 	}
 
-	dfs_name = strchr(server_name, '\\');
+	dfs_name = strchr(server_name, path_separator);
 	if (dfs_name != NULL) {
 		dfs_name[0] = '\0';
 		dfs_name++;
 
-		link_path = strchr(dfs_name, '\\');
+		link_path = strchr(dfs_name, path_separator);
 		if (link_path != NULL) {
 			link_path[0] = '\0';
 			link_path++;
-- 
1.9.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20150215/67abcfba/attachment.pgp>


More information about the samba-technical mailing list