pysmbd: handle file not found error
authorBjörn Baumbach <bb@sernet.de>
Wed, 19 Sep 2018 14:52:54 +0000 (16:52 +0200)
committerBjörn Baumbach <bb@sernet.de>
Thu, 11 Oct 2018 08:28:18 +0000 (10:28 +0200)
Avoid PANIC: internal error

Signed-off-by: Björn Baumbach <bb@sernet.de>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/smbd/pysmbd.c

index 25667198840fd42e4cf9186ce0ee29fb37495e4e..fd0c9fd46a7db5d587fe1cd6356401a675882fe2 100644 (file)
@@ -150,7 +150,11 @@ static NTSTATUS init_files_struct(TALLOC_CTX *mem_ctx,
        fsp->fsp_name = smb_fname;
        fsp->fh->fd = SMB_VFS_OPEN(conn, smb_fname, fsp, flags, 00644);
        if (fsp->fh->fd == -1) {
+               int err = errno;
                umask(saved_umask);
+               if (err == ENOENT) {
+                       return NT_STATUS_OBJECT_NAME_NOT_FOUND;
+               }
                return NT_STATUS_INVALID_PARAMETER;
        }
 
@@ -204,8 +208,11 @@ static NTSTATUS set_nt_acl_conn(const char *fname,
        }
 
        if (!NT_STATUS_IS_OK(status)) {
-               printf("open: error=%d (%s)\n", errno, strerror(errno));
-               SMB_VFS_CLOSE(fsp);
+               DBG_ERR("init_files_struct failed: %s\n",
+                       nt_errstr(status));
+               if (fsp != NULL) {
+                       SMB_VFS_CLOSE(fsp);
+               }
                TALLOC_FREE(frame);
                return status;
        }