Fix bug #7126 - [SMBD] With access denied error smbd return wrong NT_STATUS_OBJECT_PA...
authorJeremy Allison <jra@samba.org>
Fri, 12 Feb 2010 23:45:20 +0000 (15:45 -0800)
committerJeremy Allison <jra@samba.org>
Fri, 12 Feb 2010 23:45:20 +0000 (15:45 -0800)
As tridge's comment says, we should be ignoring ACCESS_DENIED
on the share path in a TconX call, instead allowing the mount
and having individual SMB calls fail (as Windows does). The
original code erroneously caught SMB_VFS_STAT != 0 and errored
out on that.

Jeremy.

source3/smbd/service.c

index d8ba4fee65d56c62bfeb156897a2c9990d5c7995..6e57e1f0d5faa41901edc134f62bd88b638c564f 100644 (file)
@@ -1019,20 +1019,27 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
           check during individual operations. To match this behaviour
           I have disabled this chdir check (tridge) */
        /* the alternative is just to check the directory exists */
-       if ((ret = SMB_VFS_STAT(conn, smb_fname_cpath)) != 0 ||
-           !S_ISDIR(smb_fname_cpath->st.st_ex_mode)) {
-               if (ret == 0 && !S_ISDIR(smb_fname_cpath->st.st_ex_mode)) {
+       if (SMB_VFS_STAT(conn, smb_fname_cpath) == 0) {
+               if (!S_ISDIR(smb_fname_cpath->st.st_ex_mode)) {
                        DEBUG(0,("'%s' is not a directory, when connecting to "
                                 "[%s]\n", conn->connectpath,
                                 lp_servicename(snum)));
-               } else {
-                       DEBUG(0,("'%s' does not exist or permission denied "
-                                "when connecting to [%s] Error was %s\n",
-                                conn->connectpath, lp_servicename(snum),
+                       *pstatus = NT_STATUS_BAD_NETWORK_NAME;
+                       goto err_root_exit;
+               }
+       } else {
+               /* Stat failed. Bail on any error except permission denied. */
+               if (errno != EACCES) {
+                       DEBUG(0,("Connecting to share [%s], path '%s' "
+                               "gives error %s\n",
+                               lp_servicename(snum),
+                                conn->connectpath,
                                 strerror(errno) ));
+                       *pstatus = NT_STATUS_BAD_NETWORK_NAME;
+                       goto err_root_exit;
                }
-               *pstatus = NT_STATUS_BAD_NETWORK_NAME;
-               goto err_root_exit;
+               /* As Windows does, on permsission denied we continue.
+                * Pathname calls fail, not TconX calls. */
        }
 
        string_set(&conn->origpath,conn->connectpath);