Bug 7782 - Samba transforms ShareName to lowercase (sharename) when adding new share via MMC
Samba transforms ShareName to lowercase (sharename) when adding new share via...
Status: RESOLVED DUPLICATE of bug 7781
Product: Samba 3.5
Classification: Unclassified
Component: DCE-RPCs and pipes
3.5.4
x86 Linux
: P3 normal
: ---
Assigned To: Samba QA Contact
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2010-11-08 06:28 UTC by Volodymyr Khomenko
Modified: 2010-11-08 06:29 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Volodymyr Khomenko 2010-11-08 06:28:49 UTC
Due a hidden side-effect of find_service() function when adding a new share via MMC (Microsoft Console: rclick on My Computer-> Manage -> Action -> Connect to another computer-> Enter samba server name -> System tools -> rclick on Shares -> New share...) entered share name is distorted (converted to lowercase).
In such view mixed-case share names are impossible (they are always lowercased).

For example, when adding new share 'MyShareWithCapitalLetters' via MMC, the following command-line is running:

[2010/11/08 13:05:12.022746, 10, pid=13966] rpc_server/srv_srvsvc_nt.c:2019(_srvsvc_NetShareAdd)
  _srvsvc_NetShareAdd: Running [./tools/add_share "smb.conf" "mysharewithcapitalletters" "/my_share" "Test share with capitals in the name" "0"]

Attached patch can fix this problem:

--- source3/rpc_server/srv_srvsvc_nt.c
+++ source3/rpc_server/srv_srvsvc_nt.c
@@ -1737,7 +1737,7 @@ WERROR _srvsvc_NetShareAdd(pipes_struct 
 			   struct srvsvc_NetShareAdd *r)
 {
 	char *command = NULL;
-	char *share_name = NULL;
+	char *share_name = NULL, *share_name_copy = NULL;
 	char *comment = NULL;
 	char *pathname = NULL;
 	int type;
@@ -1827,7 +1827,17 @@ WERROR _srvsvc_NetShareAdd(pipes_struct 
 		return WERR_ACCESS_DENIED;
 	}
 
-	snum = find_service(share_name);
+	/* Dell 2010 / Samba upgrade project / MMC-related small fixes:
+		Before call to find_service make a copy of share_name
+		because find_service() modifies its parameter -
+		it converts share_name to to canonical form (all lowercase letters).
+		NB: find_service() converts share_name as a size-effect only if the service was not found;
+		so this fix is not applicable for _srvsvc_NetShareSetInfo because no translation there. */
+
+	if ((share_name_copy = talloc_strdup(ctx, share_name)) == NULL) {
+		return WERR_NOMEM;
+	}
+	snum = find_service(share_name_copy);
 
 	/* Share already exists. */
 	if (snum >= 0) {
Comment 1 Volodymyr Khomenko 2010-11-08 06:29:19 UTC

*** This bug has been marked as a duplicate of bug 7781 ***