The branch, v3-2-test has been updated via 8c66020a82d9b92fb10d14359b1381d58ad4972b (commit) from d891d0563974ba7d91752b8b15712eb79cf4e387 (commit)
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test - Log ----------------------------------------------------------------- commit 8c66020a82d9b92fb10d14359b1381d58ad4972b Author: Andrew Tridgell <[EMAIL PROTECTED]> Date: Sun Aug 10 10:43:36 2008 +1000 I found lots of places where we assume error will be set when calling one of our virtualised functions, such as db_open(), but error is only set when a system call fails, and it is not uncommon for us to fail a function internally without ever making a system call. That led to us passing back success when a function had in fact failed. I found two places where we relied on map_nt_error_from_unix() returning success when errno==0, but lots and lots of places where we relied on the reverse, so I fixed those two places. map_nt_error_from_unix() will now always return an error, returning NT_STATUS_UNSUCCESSFUL if errno is 0 (cherry picked from commit 69d40ca4c1af925d4b0e59ddc69ef8c26e6501d1) ----------------------------------------------------------------------- Summary of changes: source/lib/errmap_unix.c | 12 ++++++++++-- source/smbd/reply.c | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) Changeset truncated at 500 lines: diff --git a/source/lib/errmap_unix.c b/source/lib/errmap_unix.c index 8194cf8..2cd2386 100644 --- a/source/lib/errmap_unix.c +++ b/source/lib/errmap_unix.c @@ -107,8 +107,16 @@ NTSTATUS map_nt_error_from_unix(int unix_error) { int i = 0; - if (unix_error == 0) - return NT_STATUS_OK; + if (unix_error == 0) { + /* we map this to an error, not success, as this + function is only called in an error path. Lots of + our virtualised functions may fail without making a + unix system call that fails (such as when they are + checking for some handle existing), so unix_error + may be unset + */ + return NT_STATUS_UNSUCCESSFUL; + } /* Look through list */ while(unix_dos_nt_errmap[i].unix_error != 0) { diff --git a/source/smbd/reply.c b/source/smbd/reply.c index ac9ccd6..ef49d58 100644 --- a/source/smbd/reply.c +++ b/source/smbd/reply.c @@ -2497,7 +2497,7 @@ NTSTATUS unlink_internals(connection_struct *conn, struct smb_request *req, TALLOC_FREE(dir_hnd); } - if (count == 0 && NT_STATUS_IS_OK(status)) { + if (count == 0 && NT_STATUS_IS_OK(status) && errno != 0) { status = map_nt_error_from_unix(errno); } @@ -5880,7 +5880,7 @@ NTSTATUS rename_internals(TALLOC_CTX *ctx, } TALLOC_FREE(dir_hnd); - if (count == 0 && NT_STATUS_IS_OK(status)) { + if (count == 0 && NT_STATUS_IS_OK(status) && errno != 0) { status = map_nt_error_from_unix(errno); } -- Samba Shared Repository