diff -aur source_orig/smbd/service.c source/smbd/service.c --- source_orig/smbd/service.c 2009-07-28 10:30:39.000000000 +0200 +++ source/smbd/service.c 2009-08-11 23:37:03.000000000 +0200 @@ -1064,20 +1064,33 @@ 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, conn->connectpath, &st)) != 0 || - !S_ISDIR(st.st_mode)) { - if (ret == 0 && !S_ISDIR(st.st_mode)) { - DEBUG(0,("'%s' is not a directory, when connecting to " - "[%s]\n", conn->connectpath, + + /* Check the directory exists is possible only if stat function + return success */ + if ((ret = SMB_VFS_STAT(conn, conn->connectpath, &st)) == 0) { + if (!S_ISDIR(st.st_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), - strerror(errno) )); - } - *pstatus = NT_STATUS_BAD_NETWORK_NAME; - goto err_root_exit; + *pstatus = NT_STATUS_OBJECT_PATH_INVALID; + goto err_root_exit; + } + } else { + DEBUG(0, ("'%s' does not exist or permission denied when " + "connecting to [%s] Error was %s\n", + conn->connectpath, lp_servicename(snum), + strerror(errno))); + + *pstatus = NT_STATUS_ACCESS_DENIED; + switch (errno) { + case ENOENT: { + *pstatus = NT_STATUS_OBJECT_PATH_INVALID; + break; } + case EACCES: { + *pstatus = NT_STATUS_ACCESS_DENIED; + break; } + } + goto err_root_exit; } string_set(&conn->origpath,conn->connectpath);