Revert "Fix bug #7781 (Samba transforms "ShareName" to lowercase when adding new...
[samba.git] / source3 / smbd / service.c
index 572861a08467b88b1f950c321d94238dfb3a38e3..2de9384893568d8cec52c5fcf3da8d82c062debe 100644 (file)
@@ -339,7 +339,7 @@ int find_service(fstring service)
                if ((iPrinterService = lp_servicenumber(PRINTERS_NAME)) < 0) {
                        iPrinterService = load_registry_service(PRINTERS_NAME);
                }
-               if (iPrinterService) {
+               if (iPrinterService >= 0) {
                        DEBUG(3,("checking whether %s is a valid printer name...\n", service));
                        if (pcap_printername_ok(service)) {
                                DEBUG(3,("%s is a valid printer name\n", service));
@@ -746,6 +746,14 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
                        return NULL;
                }
 
+               /* We don't want to replace the original sanitized_username
+                  as it is the original user given in the connect attempt.
+                  This is used in '%U' substitutions. */
+               TALLOC_FREE(forced_serverinfo->sanitized_username);
+               forced_serverinfo->sanitized_username =
+                       talloc_move(forced_serverinfo,
+                                       &conn->server_info->sanitized_username);
+
                TALLOC_FREE(conn->server_info);
                conn->server_info = forced_serverinfo;
 
@@ -1033,6 +1041,7 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
                *pstatus = NT_STATUS_BAD_NETWORK_NAME;
                goto err_root_exit;
        }
+       conn->base_share_dev = smb_fname_cpath->st.st_ex_dev;
 
        string_set(&conn->origpath,conn->connectpath);