mirror of
https://github.com/samba-team/samba.git
synced 2025-07-25 00:59:11 +03:00
r6172: Tidy up error processing significantly. Remove unix_ERR_XXX global nastyness.
Jeremy.
This commit is contained in:
committed by
Gerald (Jerry) Carter
parent
981b44e600
commit
d3379fe61b
@ -56,6 +56,7 @@ typedef uint32 WERROR;
|
|||||||
|
|
||||||
#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0)
|
#define NT_STATUS_IS_OK(x) (NT_STATUS_V(x) == 0)
|
||||||
#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000)
|
#define NT_STATUS_IS_ERR(x) ((NT_STATUS_V(x) & 0xc0000000) == 0xc0000000)
|
||||||
|
#define NT_STATUS_IS_INVALID(x) (NT_STATUS_V(x) == 0xFFFFFFFF)
|
||||||
#define NT_STATUS_EQUAL(x,y) (NT_STATUS_V(x) == NT_STATUS_V(y))
|
#define NT_STATUS_EQUAL(x,y) (NT_STATUS_V(x) == NT_STATUS_V(y))
|
||||||
#define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0)
|
#define W_ERROR_IS_OK(x) (W_ERROR_V(x) == 0)
|
||||||
#define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y))
|
#define W_ERROR_EQUAL(x,y) (W_ERROR_V(x) == W_ERROR_V(y))
|
||||||
|
@ -37,6 +37,9 @@
|
|||||||
#define STATUS_NOTIFY_ENUM_DIR NT_STATUS(0x010c)
|
#define STATUS_NOTIFY_ENUM_DIR NT_STATUS(0x010c)
|
||||||
#define ERROR_INVALID_DATATYPE NT_STATUS(0x070c)
|
#define ERROR_INVALID_DATATYPE NT_STATUS(0x070c)
|
||||||
|
|
||||||
|
/* Special "invalid" NT status code. */
|
||||||
|
#define NT_STATUS_INVALID NT_STATUS(0xFFFFFFFF)
|
||||||
|
|
||||||
/* Win32 Error codes extracted using a loop in smbclient then printing a
|
/* Win32 Error codes extracted using a loop in smbclient then printing a
|
||||||
netmon sniff to a file. */
|
netmon sniff to a file. */
|
||||||
|
|
||||||
|
@ -357,14 +357,14 @@ typedef struct time_info
|
|||||||
} UTIME;
|
} UTIME;
|
||||||
|
|
||||||
/* Structure used when SMBwritebmpx is active */
|
/* Structure used when SMBwritebmpx is active */
|
||||||
typedef struct
|
typedef struct {
|
||||||
{
|
size_t wr_total_written; /* So we know when to discard this */
|
||||||
size_t wr_total_written; /* So we know when to discard this */
|
int32 wr_timeout;
|
||||||
int32 wr_timeout;
|
int32 wr_errclass; /* Cached errors */
|
||||||
int32 wr_errclass;
|
int32 wr_error; /* Cached errors */
|
||||||
int32 wr_error; /* Cached errors */
|
NTSTATUS wr_status; /* Cached errors */
|
||||||
BOOL wr_mode; /* write through mode) */
|
BOOL wr_mode; /* write through mode) */
|
||||||
BOOL wr_discard; /* discard all further data */
|
BOOL wr_discard; /* discard all further data */
|
||||||
} write_bmpx_struct;
|
} write_bmpx_struct;
|
||||||
|
|
||||||
typedef struct write_cache
|
typedef struct write_cache
|
||||||
@ -1384,13 +1384,6 @@ enum case_handling {CASE_LOWER,CASE_UPPER};
|
|||||||
*/
|
*/
|
||||||
#define COPYBUF_SIZE (8*1024)
|
#define COPYBUF_SIZE (8*1024)
|
||||||
|
|
||||||
/*
|
|
||||||
* Values used to override error codes.
|
|
||||||
*/
|
|
||||||
extern int unix_ERR_class;
|
|
||||||
extern int unix_ERR_code;
|
|
||||||
extern NTSTATUS unix_ERR_ntstatus;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Used in chaining code.
|
* Used in chaining code.
|
||||||
*/
|
*/
|
||||||
|
@ -97,9 +97,6 @@
|
|||||||
#define CHECK_WRITE(fsp) if (!(fsp)->can_write) \
|
#define CHECK_WRITE(fsp) if (!(fsp)->can_write) \
|
||||||
return(ERROR_DOS(ERRDOS,ERRbadaccess))
|
return(ERROR_DOS(ERRDOS,ERRbadaccess))
|
||||||
|
|
||||||
#define CHECK_ERROR(fsp) if (HAS_CACHED_ERROR(fsp)) \
|
|
||||||
return(CACHED_ERROR(fsp))
|
|
||||||
|
|
||||||
#define ERROR_WAS_LOCK_DENIED(status) (NT_STATUS_EQUAL((status), NT_STATUS_LOCK_NOT_GRANTED) || \
|
#define ERROR_WAS_LOCK_DENIED(status) (NT_STATUS_EQUAL((status), NT_STATUS_LOCK_NOT_GRANTED) || \
|
||||||
NT_STATUS_EQUAL((status), NT_STATUS_FILE_LOCK_CONFLICT) )
|
NT_STATUS_EQUAL((status), NT_STATUS_FILE_LOCK_CONFLICT) )
|
||||||
|
|
||||||
@ -158,25 +155,23 @@
|
|||||||
#define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx)))
|
#define SMB_LARGE_LKLEN_OFFSET_HIGH(indx) (12 + (20 * (indx)))
|
||||||
#define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx)))
|
#define SMB_LARGE_LKLEN_OFFSET_LOW(indx) (16 + (20 * (indx)))
|
||||||
|
|
||||||
/* Macro to cache an error in a write_bmpx_struct */
|
|
||||||
#define CACHE_ERROR(w,c,e) ((w)->wr_errclass = (c), (w)->wr_error = (e), \
|
|
||||||
w->wr_discard = True, -1)
|
|
||||||
/* Macro to test if an error has been cached for this fnum */
|
/* Macro to test if an error has been cached for this fnum */
|
||||||
#define HAS_CACHED_ERROR(fsp) ((fsp)->wbmpx_ptr && \
|
#define HAS_CACHED_ERROR(fsp) ((fsp)->wbmpx_ptr && \
|
||||||
(fsp)->wbmpx_ptr->wr_discard)
|
(fsp)->wbmpx_ptr->wr_discard)
|
||||||
/* Macro to turn the cached error into an error packet */
|
/* Macro to turn the cached error into an error packet */
|
||||||
#define CACHED_ERROR(fsp) cached_error_packet(outbuf,fsp,__LINE__,__FILE__)
|
#define CACHED_ERROR(fsp) cached_error_packet(outbuf,fsp,__LINE__,__FILE__)
|
||||||
|
|
||||||
/* these are the datagram types */
|
#define ERROR_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_OK,__LINE__,__FILE__)
|
||||||
#define DGRAM_DIRECT_UNIQUE 0x10
|
#define ERROR_FORCE_DOS(class,code) error_packet(outbuf,class,code,NT_STATUS_INVALID,__LINE__,__FILE__)
|
||||||
|
#define ERROR_NT(status) error_packet(outbuf,0,0,status,__LINE__,__FILE__)
|
||||||
#define ERROR_DOS(class,code) error_packet(outbuf,NT_STATUS_OK,class,code,False,__LINE__,__FILE__)
|
#define ERROR_FORCE_NT(status) error_packet(outbuf,-1,-1,status,__LINE__,__FILE__)
|
||||||
#define ERROR_FORCE_DOS(class,code) error_packet(outbuf,NT_STATUS_OK,class,code,True,__LINE__,__FILE__)
|
#define ERROR_BOTH(status,class,code) error_packet(outbuf,class,code,status,__LINE__,__FILE__)
|
||||||
#define ERROR_NT(status) error_packet(outbuf,status,0,0,False,__LINE__,__FILE__)
|
|
||||||
#define ERROR_BOTH(status,class,code) error_packet(outbuf,status,class,code,False,__LINE__,__FILE__)
|
|
||||||
|
|
||||||
/* this is how errors are generated */
|
/* this is how errors are generated */
|
||||||
#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,__LINE__,__FILE__)
|
#define UNIXERROR(defclass,deferror) unix_error_packet(outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__)
|
||||||
|
|
||||||
|
/* these are the datagram types */
|
||||||
|
#define DGRAM_DIRECT_UNIQUE 0x10
|
||||||
|
|
||||||
#define SMB_ROUNDUP(x,r) ( ((x)%(r)) ? ( (((x)+(r))/(r))*(r) ) : (x))
|
#define SMB_ROUNDUP(x,r) ( ((x)%(r)) ? ( (((x)+(r))/(r))*(r) ) : (x))
|
||||||
|
|
||||||
|
@ -20,23 +20,43 @@
|
|||||||
|
|
||||||
#include "includes.h"
|
#include "includes.h"
|
||||||
|
|
||||||
/* these can be set by some functions to override the error codes */
|
|
||||||
int unix_ERR_class=SMB_SUCCESS;
|
|
||||||
int unix_ERR_code=0;
|
|
||||||
NTSTATUS unix_ERR_ntstatus = NT_STATUS_OK;
|
|
||||||
|
|
||||||
/* From lib/error.c */
|
/* From lib/error.c */
|
||||||
extern struct unix_error_map unix_dos_nt_errmap[];
|
extern struct unix_error_map unix_dos_nt_errmap[];
|
||||||
|
|
||||||
|
/* these can be set by some functions to override the error codes */
|
||||||
|
static int override_ERR_class;
|
||||||
|
static int override_ERR_code;
|
||||||
|
static NTSTATUS override_ERR_ntstatus;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Ensure we don't have any errors cached.
|
Setting eclass and ecode only and status to NT_STATUS_INVALID forces DOS errors.
|
||||||
|
Setting status only and eclass and ecode to -1 forces NT errors.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void clear_cached_errors(void)
|
void set_saved_error_triple(int eclass, int ecode, NTSTATUS status)
|
||||||
{
|
{
|
||||||
unix_ERR_class = SMB_SUCCESS;
|
override_ERR_class = eclass;
|
||||||
unix_ERR_code = 0;
|
override_ERR_code = ecode;
|
||||||
unix_ERR_ntstatus = NT_STATUS_OK;
|
override_ERR_ntstatus = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
Return the current settings of the error triple. Return True if any are set.
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
BOOL get_saved_error_triple(int *peclass, int *pecode, NTSTATUS *pstatus)
|
||||||
|
{
|
||||||
|
if (peclass) {
|
||||||
|
*peclass = override_ERR_class;
|
||||||
|
}
|
||||||
|
if (pecode) {
|
||||||
|
*pecode = override_ERR_code;
|
||||||
|
}
|
||||||
|
if (pstatus) {
|
||||||
|
*pstatus = override_ERR_ntstatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (override_ERR_class || !NT_STATUS_IS_OK(override_ERR_ntstatus));
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -46,36 +66,29 @@ void clear_cached_errors(void)
|
|||||||
int cached_error_packet(char *outbuf,files_struct *fsp,int line,const char *file)
|
int cached_error_packet(char *outbuf,files_struct *fsp,int line,const char *file)
|
||||||
{
|
{
|
||||||
write_bmpx_struct *wbmpx = fsp->wbmpx_ptr;
|
write_bmpx_struct *wbmpx = fsp->wbmpx_ptr;
|
||||||
|
|
||||||
int32 eclass = wbmpx->wr_errclass;
|
int32 eclass = wbmpx->wr_errclass;
|
||||||
int32 err = wbmpx->wr_error;
|
int32 err = wbmpx->wr_error;
|
||||||
|
NTSTATUS ntstatus = wbmpx->wr_status;
|
||||||
|
|
||||||
/* We can now delete the auxiliary struct */
|
/* We can now delete the auxiliary struct */
|
||||||
free((char *)wbmpx);
|
SAFE_FREE(fsp->wbmpx_ptr);
|
||||||
fsp->wbmpx_ptr = NULL;
|
return error_packet(outbuf,eclass,err,ntstatus,line,file);
|
||||||
return error_packet(outbuf,NT_STATUS_OK,eclass,err,False,line,file);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Create an error packet from errno.
|
Create an error packet from errno.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int unix_error_packet(char *outbuf,int def_class,uint32 def_code,
|
int unix_error_packet(char *outbuf,int def_class,uint32 def_code, NTSTATUS def_status, int line, const char *file)
|
||||||
int line, const char *file)
|
|
||||||
{
|
{
|
||||||
int eclass=def_class;
|
int eclass=def_class;
|
||||||
int ecode=def_code;
|
int ecode=def_code;
|
||||||
NTSTATUS ntstatus = NT_STATUS_OK;
|
NTSTATUS ntstatus = def_status;
|
||||||
int i=0;
|
int i=0;
|
||||||
|
|
||||||
if (unix_ERR_class != SMB_SUCCESS) {
|
if (errno != 0) {
|
||||||
eclass = unix_ERR_class;
|
DEBUG(3,("unix_error_packet: error string = %s\n",strerror(errno)));
|
||||||
ecode = unix_ERR_code;
|
|
||||||
ntstatus = unix_ERR_ntstatus;
|
|
||||||
unix_ERR_class = SMB_SUCCESS;
|
|
||||||
unix_ERR_code = 0;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_OK;
|
|
||||||
} else {
|
|
||||||
while (unix_dos_nt_errmap[i].dos_class != 0) {
|
while (unix_dos_nt_errmap[i].dos_class != 0) {
|
||||||
if (unix_dos_nt_errmap[i].unix_error == errno) {
|
if (unix_dos_nt_errmap[i].unix_error == errno) {
|
||||||
eclass = unix_dos_nt_errmap[i].dos_class;
|
eclass = unix_dos_nt_errmap[i].dos_class;
|
||||||
@ -87,39 +100,44 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return error_packet(outbuf,ntstatus,eclass,ecode,False,line,file);
|
return error_packet(outbuf,eclass,ecode,ntstatus,line,file);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Create an error packet. Normally called using the ERROR() macro.
|
Create an error packet. Normally called using the ERROR() macro.
|
||||||
|
Setting eclass and ecode only and status to NT_STATUS_OK forces DOS errors.
|
||||||
|
Setting status only and eclass and ecode to zero forces NT errors.
|
||||||
|
If the override errors are set they take precedence over any passed in values.
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int error_packet(char *outbuf,NTSTATUS ntstatus,
|
int error_packet(char *outbuf, uint8 eclass, uint32 ecode, NTSTATUS ntstatus, int line, const char *file)
|
||||||
uint8 eclass,uint32 ecode,BOOL force_dos, int line, const char *file)
|
|
||||||
{
|
{
|
||||||
int outsize = set_message(outbuf,0,0,True);
|
int outsize = set_message(outbuf,0,0,True);
|
||||||
extern uint32 global_client_caps;
|
extern uint32 global_client_caps;
|
||||||
|
BOOL force_nt_status = False;
|
||||||
|
BOOL force_dos_status = False;
|
||||||
|
|
||||||
if (errno != 0)
|
if (override_ERR_class != SMB_SUCCESS || !NT_STATUS_IS_OK(override_ERR_ntstatus)) {
|
||||||
DEBUG(3,("error string = %s\n",strerror(errno)));
|
eclass = override_ERR_class;
|
||||||
|
ecode = override_ERR_code;
|
||||||
#if defined(DEVELOPER)
|
ntstatus = override_ERR_ntstatus;
|
||||||
if (unix_ERR_class != SMB_SUCCESS || unix_ERR_code != 0 || !NT_STATUS_IS_OK(unix_ERR_ntstatus))
|
override_ERR_class = SMB_SUCCESS;
|
||||||
smb_panic("logic error in error processing");
|
override_ERR_code = 0;
|
||||||
#endif
|
override_ERR_ntstatus = NT_STATUS_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
if (eclass == (uint8)-1) {
|
||||||
* We can explicitly force 32 bit error codes even when the
|
force_nt_status = True;
|
||||||
* parameter "nt status" is set to no by pre-setting the
|
} else if (NT_STATUS_IS_INVALID(ntstatus)) {
|
||||||
* FLAGS2_32_BIT_ERROR_CODES bit in the smb_flg2 outbuf.
|
force_dos_status = True;
|
||||||
* This is to allow work arounds for client bugs that are needed
|
}
|
||||||
* when talking with clients that normally expect nt status codes. JRA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if ((lp_nt_status_support() || (SVAL(outbuf,smb_flg2) & FLAGS2_32_BIT_ERROR_CODES)) && (global_client_caps & CAP_STATUS32) && (!force_dos)) {
|
if (force_nt_status || (!force_dos_status && lp_nt_status_support() && (global_client_caps & CAP_STATUS32))) {
|
||||||
if (NT_STATUS_V(ntstatus) == 0 && eclass)
|
/* We're returning an NT error. */
|
||||||
|
if (NT_STATUS_V(ntstatus) == 0 && eclass) {
|
||||||
ntstatus = dos_to_ntstatus(eclass, ecode);
|
ntstatus = dos_to_ntstatus(eclass, ecode);
|
||||||
|
}
|
||||||
SIVAL(outbuf,smb_rcls,NT_STATUS_V(ntstatus));
|
SIVAL(outbuf,smb_rcls,NT_STATUS_V(ntstatus));
|
||||||
SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)|FLAGS2_32_BIT_ERROR_CODES);
|
SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)|FLAGS2_32_BIT_ERROR_CODES);
|
||||||
DEBUG(3,("error packet at %s(%d) cmd=%d (%s) %s\n",
|
DEBUG(3,("error packet at %s(%d) cmd=%d (%s) %s\n",
|
||||||
@ -127,22 +145,23 @@ int error_packet(char *outbuf,NTSTATUS ntstatus,
|
|||||||
(int)CVAL(outbuf,smb_com),
|
(int)CVAL(outbuf,smb_com),
|
||||||
smb_fn_name(CVAL(outbuf,smb_com)),
|
smb_fn_name(CVAL(outbuf,smb_com)),
|
||||||
nt_errstr(ntstatus)));
|
nt_errstr(ntstatus)));
|
||||||
return outsize;
|
} else {
|
||||||
}
|
/* We're returning a DOS error only. */
|
||||||
|
if (eclass == 0 && NT_STATUS_V(ntstatus)) {
|
||||||
|
ntstatus_to_dos(ntstatus, &eclass, &ecode);
|
||||||
|
}
|
||||||
|
|
||||||
if (eclass == 0 && NT_STATUS_V(ntstatus))
|
SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)&~FLAGS2_32_BIT_ERROR_CODES);
|
||||||
ntstatus_to_dos(ntstatus, &eclass, &ecode);
|
SSVAL(outbuf,smb_rcls,eclass);
|
||||||
|
SSVAL(outbuf,smb_err,ecode);
|
||||||
|
|
||||||
SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)&~FLAGS2_32_BIT_ERROR_CODES);
|
DEBUG(3,("error packet at %s(%d) cmd=%d (%s) eclass=%d ecode=%d\n",
|
||||||
SSVAL(outbuf,smb_rcls,eclass);
|
file, line,
|
||||||
SSVAL(outbuf,smb_err,ecode);
|
(int)CVAL(outbuf,smb_com),
|
||||||
|
smb_fn_name(CVAL(outbuf,smb_com)),
|
||||||
DEBUG(3,("error packet at %s(%d) cmd=%d (%s) eclass=%d ecode=%d\n",
|
eclass,
|
||||||
file, line,
|
ecode));
|
||||||
(int)CVAL(outbuf,smb_com),
|
}
|
||||||
smb_fn_name(CVAL(outbuf,smb_com)),
|
|
||||||
eclass,
|
|
||||||
ecode));
|
|
||||||
|
|
||||||
return outsize;
|
return outsize;
|
||||||
}
|
}
|
||||||
|
@ -95,15 +95,13 @@ files_struct *file_new(connection_struct *conn)
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(0,("ERROR! Out of file structures\n"));
|
DEBUG(0,("ERROR! Out of file structures\n"));
|
||||||
unix_ERR_class = ERRSRV;
|
set_saved_error_triple(ERRSRV, ERRnofids, NT_STATUS_TOO_MANY_OPENED_FILES);
|
||||||
unix_ERR_code = ERRnofids;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
fsp = SMB_MALLOC_P(files_struct);
|
fsp = SMB_MALLOC_P(files_struct);
|
||||||
if (!fsp) {
|
if (!fsp) {
|
||||||
unix_ERR_class = ERRSRV;
|
set_saved_error_triple(ERRDOS, ERRnomem, NT_STATUS_NO_MEMORY);
|
||||||
unix_ERR_code = ERRnofids;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -889,10 +889,8 @@ create_options = 0x%x root_dir_fid = 0x%x\n", flags, desired_access, file_attrib
|
|||||||
|
|
||||||
if (create_options & FILE_NON_DIRECTORY_FILE) {
|
if (create_options & FILE_NON_DIRECTORY_FILE) {
|
||||||
restore_case_semantics(conn, file_attributes);
|
restore_case_semantics(conn, file_attributes);
|
||||||
SSVAL(outbuf, smb_flg2,
|
|
||||||
SVAL(outbuf,smb_flg2) | FLAGS2_32_BIT_ERROR_CODES);
|
|
||||||
END_PROFILE(SMBntcreateX);
|
END_PROFILE(SMBntcreateX);
|
||||||
return ERROR_NT(NT_STATUS_FILE_IS_A_DIRECTORY);
|
return ERROR_FORCE_NT(NT_STATUS_FILE_IS_A_DIRECTORY);
|
||||||
}
|
}
|
||||||
|
|
||||||
oplock_request = 0;
|
oplock_request = 0;
|
||||||
@ -909,7 +907,6 @@ create_options = 0x%x root_dir_fid = 0x%x\n", flags, desired_access, file_attrib
|
|||||||
END_PROFILE(SMBntcreateX);
|
END_PROFILE(SMBntcreateX);
|
||||||
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
||||||
/* We have re-scheduled this call. */
|
/* We have re-scheduled this call. */
|
||||||
clear_cached_errors();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS,ERRnoaccess);
|
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS,ERRnoaccess);
|
||||||
@ -1493,8 +1490,7 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o
|
|||||||
|
|
||||||
if (create_options & FILE_NON_DIRECTORY_FILE) {
|
if (create_options & FILE_NON_DIRECTORY_FILE) {
|
||||||
restore_case_semantics(conn, file_attributes);
|
restore_case_semantics(conn, file_attributes);
|
||||||
SSVAL(outbuf, smb_flg2, SVAL(outbuf,smb_flg2) | FLAGS2_32_BIT_ERROR_CODES);
|
return ERROR_FORCE_NT(NT_STATUS_FILE_IS_A_DIRECTORY);
|
||||||
return ERROR_NT(NT_STATUS_FILE_IS_A_DIRECTORY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
oplock_request = 0;
|
oplock_request = 0;
|
||||||
@ -1510,7 +1506,6 @@ static int call_nt_transact_create(connection_struct *conn, char *inbuf, char *o
|
|||||||
restore_case_semantics(conn, file_attributes);
|
restore_case_semantics(conn, file_attributes);
|
||||||
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
||||||
/* We have re-scheduled this call. */
|
/* We have re-scheduled this call. */
|
||||||
clear_cached_errors();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS,ERRnoaccess);
|
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS,ERRnoaccess);
|
||||||
@ -1782,12 +1777,11 @@ static NTSTATUS copy_internals(connection_struct *conn, char *oldname, char *new
|
|||||||
&access_mode,&smb_action);
|
&access_mode,&smb_action);
|
||||||
|
|
||||||
if (!fsp1) {
|
if (!fsp1) {
|
||||||
status = NT_STATUS_ACCESS_DENIED;
|
get_saved_error_triple(NULL, NULL, &status);
|
||||||
if (unix_ERR_class == ERRDOS && unix_ERR_code == ERRbadshare)
|
if (NT_STATUS_IS_OK(status)) {
|
||||||
status = NT_STATUS_SHARING_VIOLATION;
|
status = NT_STATUS_ACCESS_DENIED;
|
||||||
unix_ERR_class = 0;
|
}
|
||||||
unix_ERR_code = 0;
|
set_saved_error_triple(0, 0, NT_STATUS_OK);
|
||||||
unix_ERR_ntstatus = NT_STATUS_OK;
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1796,12 +1790,11 @@ static NTSTATUS copy_internals(connection_struct *conn, char *oldname, char *new
|
|||||||
&access_mode,&smb_action);
|
&access_mode,&smb_action);
|
||||||
|
|
||||||
if (!fsp2) {
|
if (!fsp2) {
|
||||||
status = NT_STATUS_ACCESS_DENIED;
|
get_saved_error_triple(NULL, NULL, &status);
|
||||||
if (unix_ERR_class == ERRDOS && unix_ERR_code == ERRbadshare)
|
if (NT_STATUS_IS_OK(status)) {
|
||||||
status = NT_STATUS_SHARING_VIOLATION;
|
status = NT_STATUS_ACCESS_DENIED;
|
||||||
unix_ERR_class = 0;
|
}
|
||||||
unix_ERR_code = 0;
|
set_saved_error_triple(0, 0, NT_STATUS_OK);
|
||||||
unix_ERR_ntstatus = NT_STATUS_OK;
|
|
||||||
close_file(fsp1,False);
|
close_file(fsp1,False);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -1907,7 +1900,6 @@ int reply_ntrename(connection_struct *conn,
|
|||||||
END_PROFILE(SMBntrename);
|
END_PROFILE(SMBntrename);
|
||||||
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
||||||
/* We have re-scheduled this call. */
|
/* We have re-scheduled this call. */
|
||||||
clear_cached_errors();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return ERROR_NT(status);
|
return ERROR_NT(status);
|
||||||
|
@ -76,9 +76,7 @@ static void check_for_pipe(const char *fname)
|
|||||||
strlower_m(s);
|
strlower_m(s);
|
||||||
if (strstr(s,"pipe/")) {
|
if (strstr(s,"pipe/")) {
|
||||||
DEBUG(3,("Rejecting named pipe open for %s\n",fname));
|
DEBUG(3,("Rejecting named pipe open for %s\n",fname));
|
||||||
unix_ERR_class = ERRSRV;
|
set_saved_error_triple(ERRSRV, ERRaccess, NT_STATUS_ACCESS_DENIED);
|
||||||
unix_ERR_code = ERRaccess;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_ACCESS_DENIED;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,9 +248,7 @@ static BOOL open_file(files_struct *fsp,connection_struct *conn,
|
|||||||
|
|
||||||
/* Don't create files with Microsoft wildcard characters. */
|
/* Don't create files with Microsoft wildcard characters. */
|
||||||
if ((local_flags & O_CREAT) && !VALID_STAT(*psbuf) && ms_has_wild(fname)) {
|
if ((local_flags & O_CREAT) && !VALID_STAT(*psbuf) && ms_has_wild(fname)) {
|
||||||
unix_ERR_class = ERRDOS;
|
set_saved_error_triple(ERRDOS, ERRinvalidname, NT_STATUS_OBJECT_NAME_INVALID);
|
||||||
unix_ERR_code = ERRinvalidname;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_OBJECT_NAME_INVALID;
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,9 +483,7 @@ static BOOL check_share_mode(connection_struct *conn, share_mode_entry *share, i
|
|||||||
DEBUG(5,("check_share_mode: Failing open on file %s as delete on close flag is set.\n",
|
DEBUG(5,("check_share_mode: Failing open on file %s as delete on close flag is set.\n",
|
||||||
fname ));
|
fname ));
|
||||||
/* Use errno to map to correct error. */
|
/* Use errno to map to correct error. */
|
||||||
unix_ERR_class = SMB_SUCCESS;
|
set_saved_error_triple(SMB_SUCCESS, 0, NT_STATUS_OK);
|
||||||
unix_ERR_code = 0;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_OK;
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,10 +523,7 @@ static BOOL check_share_mode(connection_struct *conn, share_mode_entry *share, i
|
|||||||
(!GET_ALLOW_SHARE_DELETE(share->share_mode) || !GET_ALLOW_SHARE_DELETE(share_mode))) {
|
(!GET_ALLOW_SHARE_DELETE(share->share_mode) || !GET_ALLOW_SHARE_DELETE(share_mode))) {
|
||||||
DEBUG(5,("check_share_mode: Failing open on file %s as delete access requests conflict.\n",
|
DEBUG(5,("check_share_mode: Failing open on file %s as delete access requests conflict.\n",
|
||||||
fname ));
|
fname ));
|
||||||
unix_ERR_class = ERRDOS;
|
set_saved_error_triple(ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION);
|
||||||
unix_ERR_code = ERRbadshare;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
|
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,10 +548,7 @@ existing desired access (0x%x).\n", fname, (unsigned int)desired_access, (unsign
|
|||||||
if ((desired_access & DELETE_ACCESS) && !GET_ALLOW_SHARE_DELETE(share->share_mode)) {
|
if ((desired_access & DELETE_ACCESS) && !GET_ALLOW_SHARE_DELETE(share->share_mode)) {
|
||||||
DEBUG(5,("check_share_mode: Failing open on file %s as delete access requested and allow share delete not set.\n",
|
DEBUG(5,("check_share_mode: Failing open on file %s as delete access requested and allow share delete not set.\n",
|
||||||
fname ));
|
fname ));
|
||||||
unix_ERR_class = ERRDOS;
|
set_saved_error_triple(ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION);
|
||||||
unix_ERR_code = ERRbadshare;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
|
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -573,18 +561,14 @@ existing desired access (0x%x).\n", fname, (unsigned int)desired_access, (unsign
|
|||||||
if ((share->desired_access & DELETE_ACCESS) && !GET_ALLOW_SHARE_DELETE(share_mode)) {
|
if ((share->desired_access & DELETE_ACCESS) && !GET_ALLOW_SHARE_DELETE(share_mode)) {
|
||||||
DEBUG(5,("check_share_mode: Failing open on file %s as delete access granted and allow share delete not requested.\n",
|
DEBUG(5,("check_share_mode: Failing open on file %s as delete access granted and allow share delete not requested.\n",
|
||||||
fname ));
|
fname ));
|
||||||
unix_ERR_class = ERRDOS;
|
set_saved_error_triple(ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION);
|
||||||
unix_ERR_code = ERRbadshare;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
/* Bluarc test may need this ... needs further investigation. */
|
/* Bluarc test may need this ... needs further investigation. */
|
||||||
if (deny_mode == DENY_ALL || old_deny_mode == DENY_ALL) {
|
if (deny_mode == DENY_ALL || old_deny_mode == DENY_ALL) {
|
||||||
unix_ERR_class = ERRDOS;
|
set_saved_error_triple(ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION);
|
||||||
unix_ERR_code = ERRbadshare;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -614,10 +598,7 @@ existing desired access (0x%x).\n", fname, (unsigned int)desired_access, (unsign
|
|||||||
deny_mode,old_deny_mode,old_open_mode,
|
deny_mode,old_deny_mode,old_open_mode,
|
||||||
(int)share->pid,fname, fcbopen, *flags, access_allowed));
|
(int)share->pid,fname, fcbopen, *flags, access_allowed));
|
||||||
|
|
||||||
unix_ERR_class = ERRDOS;
|
set_saved_error_triple(ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION);
|
||||||
unix_ERR_code = ERRbadshare;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
|
|
||||||
|
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -768,10 +749,7 @@ dev = %x, inode = %.0f\n", *p_oplock_request, share_entry->op_type, fname, (unsi
|
|||||||
DEBUG(0,("open_mode_check: FAILED when breaking oplock (%x) on file %s, \
|
DEBUG(0,("open_mode_check: FAILED when breaking oplock (%x) on file %s, \
|
||||||
dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (double)inode));
|
dev = %x, inode = %.0f\n", old_shares[i].op_type, fname, (unsigned int)dev, (double)inode));
|
||||||
SAFE_FREE(old_shares);
|
SAFE_FREE(old_shares);
|
||||||
errno = EACCES;
|
set_saved_error_triple(ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION);
|
||||||
unix_ERR_class = ERRDOS;
|
|
||||||
unix_ERR_code = ERRbadshare;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -835,9 +813,7 @@ after break ! For file %s, dev = %x, inode = %.0f. Deleting it to continue...\n"
|
|||||||
if (del_share_entry(dev, inode, &broken_entry->entry, NULL) == -1) {
|
if (del_share_entry(dev, inode, &broken_entry->entry, NULL) == -1) {
|
||||||
free_broken_entry_list(broken_entry_list);
|
free_broken_entry_list(broken_entry_list);
|
||||||
errno = EACCES;
|
errno = EACCES;
|
||||||
unix_ERR_class = ERRDOS;
|
set_saved_error_triple(ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION);
|
||||||
unix_ERR_code = ERRbadshare;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1104,9 +1080,7 @@ files_struct *open_file_shared1(connection_struct *conn,char *fname, SMB_STRUCT_
|
|||||||
delete_defered_open_entry_record(conn, dib.dev, dib.inode);
|
delete_defered_open_entry_record(conn, dib.dev, dib.inode);
|
||||||
unlock_share_entry(conn, dib.dev, dib.inode);
|
unlock_share_entry(conn, dib.dev, dib.inode);
|
||||||
|
|
||||||
unix_ERR_class = ERRDOS;
|
set_saved_error_triple(ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION);
|
||||||
unix_ERR_code = ERRbadshare;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
/* Ensure we don't reprocess this message. */
|
/* Ensure we don't reprocess this message. */
|
||||||
@ -1136,11 +1110,8 @@ files_struct *open_file_shared1(connection_struct *conn,char *fname, SMB_STRUCT_
|
|||||||
ofun = FILE_EXISTS_FAIL | FILE_CREATE_IF_NOT_EXIST;
|
ofun = FILE_EXISTS_FAIL | FILE_CREATE_IF_NOT_EXIST;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
unix_ERR_class = ERRDOS;
|
/* Cause caller to force dos errors. */
|
||||||
unix_ERR_code = ERRinvalidparam;
|
set_saved_error_triple(ERRDOS, ERRbadaccess, NT_STATUS_INVALID);
|
||||||
unix_ERR_ntstatus = NT_STATUS_INVALID_LOCK_SEQUENCE;
|
|
||||||
/* need to reset errno or DEVELOPER will cause us to coredump */
|
|
||||||
errno = 0;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1163,13 +1134,9 @@ files_struct *open_file_shared1(connection_struct *conn,char *fname, SMB_STRUCT_
|
|||||||
|
|
||||||
/* this is for OS/2 long file names - say we don't support them */
|
/* this is for OS/2 long file names - say we don't support them */
|
||||||
if (strstr(fname,".+,;=[].")) {
|
if (strstr(fname,".+,;=[].")) {
|
||||||
unix_ERR_class = ERRDOS;
|
|
||||||
/* OS/2 Workplace shell fix may be main code stream in a later release. */
|
/* OS/2 Workplace shell fix may be main code stream in a later release. */
|
||||||
unix_ERR_code = ERRcannotopen;
|
set_saved_error_triple(ERRDOS, ERRcannotopen, NT_STATUS_OBJECT_NAME_NOT_FOUND);
|
||||||
unix_ERR_ntstatus = NT_STATUS_OBJECT_NAME_NOT_FOUND;
|
|
||||||
DEBUG(5,("open_file_shared: OS/2 long filenames are not supported.\n"));
|
DEBUG(5,("open_file_shared: OS/2 long filenames are not supported.\n"));
|
||||||
/* need to reset errno or DEVELOPER will cause us to coredump */
|
|
||||||
errno = 0;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1232,11 +1199,8 @@ files_struct *open_file_shared1(connection_struct *conn,char *fname, SMB_STRUCT_
|
|||||||
desired_access = FILE_READ_DATA|FILE_WRITE_DATA;
|
desired_access = FILE_READ_DATA|FILE_WRITE_DATA;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
unix_ERR_class = ERRDOS;
|
/* Force DOS error. */
|
||||||
unix_ERR_code = ERRinvalidparam;
|
set_saved_error_triple(ERRDOS, ERRinvalidparam, NT_STATUS_INVALID);
|
||||||
unix_ERR_ntstatus = NT_STATUS_INVALID_LOCK_SEQUENCE;
|
|
||||||
/* need to reset errno or DEVELOPER will cause us to coredump */
|
|
||||||
errno = 0;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1311,9 +1275,8 @@ flags=0x%X flags2=0x%X mode=0%o returned %d\n",
|
|||||||
flags,(flags2&~(O_TRUNC|O_CREAT)),(int)mode,(int)fsp_open ));
|
flags,(flags2&~(O_TRUNC|O_CREAT)),(int)mode,(int)fsp_open ));
|
||||||
|
|
||||||
if (!fsp_open && errno) {
|
if (!fsp_open && errno) {
|
||||||
unix_ERR_class = ERRDOS;
|
/* Default error. */
|
||||||
unix_ERR_code = ERRnoaccess;
|
set_saved_error_triple(ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED);
|
||||||
unix_ERR_ntstatus = NT_STATUS_ACCESS_DENIED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1321,9 +1284,13 @@ flags=0x%X flags2=0x%X mode=0%o returned %d\n",
|
|||||||
* the braindead 1 second delay.
|
* the braindead 1 second delay.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!internal_only_open && NT_STATUS_EQUAL(unix_ERR_ntstatus,NT_STATUS_SHARING_VIOLATION)) {
|
if (!internal_only_open) {
|
||||||
/* The fsp->open_time here represents the current time of day. */
|
NTSTATUS status;
|
||||||
defer_open_sharing_error(conn, &fsp->open_time, fname, dev, inode);
|
get_saved_error_triple(NULL, NULL, &status);
|
||||||
|
if (NT_STATUS_EQUAL(status,NT_STATUS_SHARING_VIOLATION)) {
|
||||||
|
/* The fsp->open_time here represents the current time of day. */
|
||||||
|
defer_open_sharing_error(conn, &fsp->open_time, fname, dev, inode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unlock_share_entry(conn, dev, inode);
|
unlock_share_entry(conn, dev, inode);
|
||||||
@ -1333,9 +1300,7 @@ flags=0x%X flags2=0x%X mode=0%o returned %d\n",
|
|||||||
* We have detected a sharing violation here
|
* We have detected a sharing violation here
|
||||||
* so return the correct error code
|
* so return the correct error code
|
||||||
*/
|
*/
|
||||||
unix_ERR_class = ERRDOS;
|
set_saved_error_triple(ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION);
|
||||||
unix_ERR_code = ERRbadshare;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
|
|
||||||
}
|
}
|
||||||
file_free(fsp);
|
file_free(fsp);
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -1407,7 +1372,9 @@ flags=0x%X flags2=0x%X mode=0%o returned %d\n",
|
|||||||
* the braindead 1 second delay.
|
* the braindead 1 second delay.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!internal_only_open && NT_STATUS_EQUAL(unix_ERR_ntstatus,NT_STATUS_SHARING_VIOLATION)) {
|
NTSTATUS status;
|
||||||
|
get_saved_error_triple(NULL, NULL, &status);
|
||||||
|
if (NT_STATUS_EQUAL(status,NT_STATUS_SHARING_VIOLATION)) {
|
||||||
/* The fsp->open_time here represents the current time of day. */
|
/* The fsp->open_time here represents the current time of day. */
|
||||||
defer_open_sharing_error(conn, &fsp->open_time, fname, dev, inode);
|
defer_open_sharing_error(conn, &fsp->open_time, fname, dev, inode);
|
||||||
}
|
}
|
||||||
@ -1419,9 +1386,7 @@ flags=0x%X flags2=0x%X mode=0%o returned %d\n",
|
|||||||
* We have detected a sharing violation here, so
|
* We have detected a sharing violation here, so
|
||||||
* return the correct code.
|
* return the correct code.
|
||||||
*/
|
*/
|
||||||
unix_ERR_class = ERRDOS;
|
set_saved_error_triple(ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION);
|
||||||
unix_ERR_code = ERRbadshare;
|
|
||||||
unix_ERR_ntstatus = NT_STATUS_SHARING_VIOLATION;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1549,9 +1514,7 @@ flags=0x%X flags2=0x%X mode=0%o returned %d\n",
|
|||||||
fd_close(conn,fsp);
|
fd_close(conn,fsp);
|
||||||
file_free(fsp);
|
file_free(fsp);
|
||||||
ntstatus_to_dos(result, &u_e_c, &u_e_code);
|
ntstatus_to_dos(result, &u_e_c, &u_e_code);
|
||||||
unix_ERR_ntstatus = result;
|
set_saved_error_triple(u_e_c, u_e_code, result);
|
||||||
unix_ERR_class = u_e_c;
|
|
||||||
unix_ERR_code = u_e_code;
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1704,7 +1667,7 @@ files_struct *open_directory(connection_struct *conn, const char *fname, SMB_STR
|
|||||||
fname, strerror(errno) ));
|
fname, strerror(errno) ));
|
||||||
file_free(fsp);
|
file_free(fsp);
|
||||||
/* Ensure we return the correct NT status to the client. */
|
/* Ensure we return the correct NT status to the client. */
|
||||||
unix_ERR_ntstatus = status;
|
set_saved_error_triple(0, 0, status);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -934,6 +934,9 @@ static BOOL oplock_break(SMB_DEV_T dev, SMB_INO_T inode, unsigned long file_id,
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We know we have no saved errors here. */
|
||||||
|
set_saved_error_triple(0, 0, NT_STATUS_OK);
|
||||||
|
|
||||||
if( DEBUGLVL( 3 ) ) {
|
if( DEBUGLVL( 3 ) ) {
|
||||||
dbgtext( "oplock_break: returning success for " );
|
dbgtext( "oplock_break: returning success for " );
|
||||||
dbgtext( "dev = %x, inode = %.0f, file_id = %lu\n", (unsigned int)dev, (double)inode, file_id );
|
dbgtext( "dev = %x, inode = %.0f, file_id = %lu\n", (unsigned int)dev, (double)inode, file_id );
|
||||||
|
@ -211,6 +211,7 @@ BOOL open_was_deferred(uint16 mid)
|
|||||||
|
|
||||||
for (pml = smb_sharing_violation_queue; pml; pml = pml->next) {
|
for (pml = smb_sharing_violation_queue; pml; pml = pml->next) {
|
||||||
if (SVAL(pml->buf.data,smb_mid) == mid) {
|
if (SVAL(pml->buf.data,smb_mid) == mid) {
|
||||||
|
set_saved_error_triple(SMB_SUCCESS, 0, NT_STATUS_OK);
|
||||||
return True;
|
return True;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -859,6 +860,8 @@ static int switch_message(int type,char *inbuf,char *outbuf,int size,int bufsize
|
|||||||
pid = sys_getpid();
|
pid = sys_getpid();
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
|
set_saved_error_triple(0, 0, NT_STATUS_OK);
|
||||||
|
|
||||||
last_message = type;
|
last_message = type;
|
||||||
|
|
||||||
/* Make sure this is an SMB packet. smb_size contains NetBIOS header so subtract 4 from it. */
|
/* Make sure this is an SMB packet. smb_size contains NetBIOS header so subtract 4 from it. */
|
||||||
|
@ -1206,7 +1206,6 @@ int reply_open(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
|
|||||||
END_PROFILE(SMBopen);
|
END_PROFILE(SMBopen);
|
||||||
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
||||||
/* We have re-scheduled this call. */
|
/* We have re-scheduled this call. */
|
||||||
clear_cached_errors();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS, ERRnoaccess);
|
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS, ERRnoaccess);
|
||||||
@ -1304,7 +1303,6 @@ int reply_open_and_X(connection_struct *conn, char *inbuf,char *outbuf,int lengt
|
|||||||
END_PROFILE(SMBopenX);
|
END_PROFILE(SMBopenX);
|
||||||
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
||||||
/* We have re-scheduled this call. */
|
/* We have re-scheduled this call. */
|
||||||
clear_cached_errors();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS, ERRnoaccess);
|
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS, ERRnoaccess);
|
||||||
@ -1453,7 +1451,6 @@ int reply_mknew(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
|
|||||||
END_PROFILE(SMBcreate);
|
END_PROFILE(SMBcreate);
|
||||||
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
||||||
/* We have re-scheduled this call. */
|
/* We have re-scheduled this call. */
|
||||||
clear_cached_errors();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS, ERRnoaccess);
|
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS, ERRnoaccess);
|
||||||
@ -1537,7 +1534,6 @@ int reply_ctemp(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
|
|||||||
END_PROFILE(SMBctemp);
|
END_PROFILE(SMBctemp);
|
||||||
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
||||||
/* We have re-scheduled this call. */
|
/* We have re-scheduled this call. */
|
||||||
clear_cached_errors();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS, ERRnoaccess);
|
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS, ERRnoaccess);
|
||||||
@ -1599,20 +1595,19 @@ static NTSTATUS can_rename(connection_struct *conn, char *fname, uint16 dirtype,
|
|||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
|
|
||||||
/* We need a better way to return NT status codes from open... */
|
/* We need a better way to return NT status codes from open... */
|
||||||
unix_ERR_class = 0;
|
set_saved_error_triple(0, 0, NT_STATUS_OK);
|
||||||
unix_ERR_code = 0;
|
|
||||||
|
|
||||||
fsp = open_file_shared1(conn, fname, pst, DELETE_ACCESS, SET_DENY_MODE(DENY_ALL),
|
fsp = open_file_shared1(conn, fname, pst, DELETE_ACCESS, SET_DENY_MODE(DENY_ALL),
|
||||||
(FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, 0, &access_mode, &smb_action);
|
(FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, 0, &access_mode, &smb_action);
|
||||||
|
|
||||||
if (!fsp) {
|
if (!fsp) {
|
||||||
NTSTATUS ret = NT_STATUS_ACCESS_DENIED;
|
NTSTATUS ret;
|
||||||
if (unix_ERR_class == ERRDOS && unix_ERR_code == ERRbadshare)
|
if (get_saved_error_triple(NULL, NULL, &ret)) {
|
||||||
ret = NT_STATUS_SHARING_VIOLATION;
|
set_saved_error_triple(0, 0, NT_STATUS_OK);
|
||||||
unix_ERR_class = 0;
|
return ret;
|
||||||
unix_ERR_code = 0;
|
}
|
||||||
unix_ERR_ntstatus = NT_STATUS_OK;
|
set_saved_error_triple(0, 0, NT_STATUS_OK);
|
||||||
return ret;
|
return NT_STATUS_ACCESS_DENIED;
|
||||||
}
|
}
|
||||||
close_file(fsp,False);
|
close_file(fsp,False);
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
@ -1672,22 +1667,19 @@ NTSTATUS can_delete(connection_struct *conn, char *fname, int dirtype, BOOL bad_
|
|||||||
don't do it here as we'll get it wrong. */
|
don't do it here as we'll get it wrong. */
|
||||||
|
|
||||||
/* We need a better way to return NT status codes from open... */
|
/* We need a better way to return NT status codes from open... */
|
||||||
unix_ERR_class = 0;
|
set_saved_error_triple(0, 0, NT_STATUS_OK);
|
||||||
unix_ERR_code = 0;
|
|
||||||
|
|
||||||
fsp = open_file_shared1(conn, fname, &sbuf, DELETE_ACCESS, SET_DENY_MODE(DENY_ALL),
|
fsp = open_file_shared1(conn, fname, &sbuf, DELETE_ACCESS, SET_DENY_MODE(DENY_ALL),
|
||||||
(FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, 0, &access_mode, &smb_action);
|
(FILE_FAIL_IF_NOT_EXIST|FILE_EXISTS_OPEN), FILE_ATTRIBUTE_NORMAL, 0, &access_mode, &smb_action);
|
||||||
|
|
||||||
if (!fsp) {
|
if (!fsp) {
|
||||||
NTSTATUS ret = NT_STATUS_ACCESS_DENIED;
|
NTSTATUS ret;
|
||||||
if (!NT_STATUS_IS_OK(unix_ERR_ntstatus))
|
if (get_saved_error_triple(NULL, NULL, &ret)) {
|
||||||
ret = unix_ERR_ntstatus;
|
set_saved_error_triple(0, 0, NT_STATUS_OK);
|
||||||
else if (unix_ERR_class == ERRDOS && unix_ERR_code == ERRbadshare)
|
return ret;
|
||||||
ret = NT_STATUS_SHARING_VIOLATION;
|
}
|
||||||
unix_ERR_class = 0;
|
set_saved_error_triple(0, 0, NT_STATUS_OK);
|
||||||
unix_ERR_code = 0;
|
return NT_STATUS_ACCESS_DENIED;
|
||||||
unix_ERR_ntstatus = NT_STATUS_OK;
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
close_file(fsp,False);
|
close_file(fsp,False);
|
||||||
}
|
}
|
||||||
@ -1856,7 +1848,6 @@ int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size
|
|||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
||||||
/* We have re-scheduled this call. */
|
/* We have re-scheduled this call. */
|
||||||
clear_cached_errors();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return ERROR_NT(status);
|
return ERROR_NT(status);
|
||||||
@ -3456,21 +3447,6 @@ NTSTATUS mkdir_internal(connection_struct *conn, const pstring directory, BOOL b
|
|||||||
return map_nt_error_from_unix(errno);
|
return map_nt_error_from_unix(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The following 2 clauses set explicit DOS error codes. JRA. */
|
|
||||||
if (ms_has_wild(directory)) {
|
|
||||||
DEBUG(5,("mkdir_internal: failing create on filename %s with wildcards\n", directory));
|
|
||||||
unix_ERR_class = ERRDOS;
|
|
||||||
unix_ERR_code = ERRinvalidname;
|
|
||||||
return NT_STATUS_OBJECT_NAME_INVALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
if( strchr_m(directory, ':')) {
|
|
||||||
DEBUG(5,("mkdir_internal: failing create on filename %s with colon in name\n", directory));
|
|
||||||
unix_ERR_class = ERRDOS;
|
|
||||||
unix_ERR_code = ERRinvalidname;
|
|
||||||
return NT_STATUS_NOT_A_DIRECTORY;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bad_path) {
|
if (bad_path) {
|
||||||
return NT_STATUS_OBJECT_PATH_NOT_FOUND;
|
return NT_STATUS_OBJECT_PATH_NOT_FOUND;
|
||||||
}
|
}
|
||||||
@ -3521,6 +3497,12 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
|
|||||||
|
|
||||||
unix_convert(directory,conn,0,&bad_path,&sbuf);
|
unix_convert(directory,conn,0,&bad_path,&sbuf);
|
||||||
|
|
||||||
|
if( strchr_m(directory, ':')) {
|
||||||
|
DEBUG(5,("reply_mkdir: failing create on filename %s with colon in name\n", directory));
|
||||||
|
END_PROFILE(SMBmkdir);
|
||||||
|
return ERROR_FORCE_DOS(ERRDOS, ERRinvalidname);
|
||||||
|
}
|
||||||
|
|
||||||
status = mkdir_internal(conn, directory,bad_path);
|
status = mkdir_internal(conn, directory,bad_path);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
END_PROFILE(SMBmkdir);
|
END_PROFILE(SMBmkdir);
|
||||||
@ -3530,7 +3512,7 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
|
|||||||
if (lp_inherit_owner(SNUM(conn))) {
|
if (lp_inherit_owner(SNUM(conn))) {
|
||||||
/* Ensure we're checking for a symlink here.... */
|
/* Ensure we're checking for a symlink here.... */
|
||||||
/* We don't want to get caught by a symlink racer. */
|
/* We don't want to get caught by a symlink racer. */
|
||||||
|
|
||||||
if(SMB_VFS_LSTAT(conn,directory, &sbuf) != 0) {
|
if(SMB_VFS_LSTAT(conn,directory, &sbuf) != 0) {
|
||||||
END_PROFILE(SMBmkdir);
|
END_PROFILE(SMBmkdir);
|
||||||
return(UNIXERROR(ERRDOS,ERRnoaccess));
|
return(UNIXERROR(ERRDOS,ERRnoaccess));
|
||||||
@ -4328,7 +4310,6 @@ int reply_mv(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
|
|||||||
END_PROFILE(SMBmv);
|
END_PROFILE(SMBmv);
|
||||||
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
||||||
/* We have re-scheduled this call. */
|
/* We have re-scheduled this call. */
|
||||||
clear_cached_errors();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return ERROR_NT(status);
|
return ERROR_NT(status);
|
||||||
@ -4592,8 +4573,7 @@ int reply_copy(connection_struct *conn, char *inbuf,char *outbuf, int dum_size,
|
|||||||
return ERROR_DOS(ERRDOS,error);
|
return ERROR_DOS(ERRDOS,error);
|
||||||
} else {
|
} else {
|
||||||
if((errno == ENOENT) && (bad_path1 || bad_path2)) {
|
if((errno == ENOENT) && (bad_path1 || bad_path2)) {
|
||||||
unix_ERR_class = ERRDOS;
|
set_saved_error_triple(ERRDOS, ERRbadpath, NT_STATUS_OK);
|
||||||
unix_ERR_code = ERRbadpath;
|
|
||||||
}
|
}
|
||||||
END_PROFILE(SMBcopy);
|
END_PROFILE(SMBcopy);
|
||||||
return(UNIXERROR(ERRDOS,error));
|
return(UNIXERROR(ERRDOS,error));
|
||||||
@ -5149,7 +5129,9 @@ int reply_writebmpx(connection_struct *conn, char *inbuf,char *outbuf, int size,
|
|||||||
|
|
||||||
CHECK_FSP(fsp,conn);
|
CHECK_FSP(fsp,conn);
|
||||||
CHECK_WRITE(fsp);
|
CHECK_WRITE(fsp);
|
||||||
CHECK_ERROR(fsp);
|
if (HAS_CACHED_ERROR(fsp)) {
|
||||||
|
return(CACHED_ERROR(fsp));
|
||||||
|
}
|
||||||
|
|
||||||
tcount = SVAL(inbuf,smb_vwv1);
|
tcount = SVAL(inbuf,smb_vwv1);
|
||||||
startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv3);
|
startpos = IVAL_TO_SMB_OFF_T(inbuf,smb_vwv3);
|
||||||
@ -5292,8 +5274,12 @@ int reply_writebs(connection_struct *conn, char *inbuf,char *outbuf, int dum_siz
|
|||||||
END_PROFILE(SMBwriteBs);
|
END_PROFILE(SMBwriteBs);
|
||||||
return(ERROR_DOS(ERRHRD,ERRdiskfull));
|
return(ERROR_DOS(ERRHRD,ERRdiskfull));
|
||||||
}
|
}
|
||||||
|
wbms->wr_errclass = ERRHRD;
|
||||||
|
wbms->wr_error = ERRdiskfull;
|
||||||
|
wbms->wr_status = NT_STATUS_DISK_FULL;
|
||||||
|
wbms->wr_discard = True;
|
||||||
END_PROFILE(SMBwriteBs);
|
END_PROFILE(SMBwriteBs);
|
||||||
return(CACHE_ERROR(wbms,ERRHRD,ERRdiskfull));
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Increment the total written, if this matches tcount
|
/* Increment the total written, if this matches tcount
|
||||||
|
@ -814,7 +814,6 @@ static int call_trans2open(connection_struct *conn, char *inbuf, char *outbuf, i
|
|||||||
talloc_destroy(ctx);
|
talloc_destroy(ctx);
|
||||||
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
if (open_was_deferred(SVAL(inbuf,smb_mid))) {
|
||||||
/* We have re-scheduled this call. */
|
/* We have re-scheduled this call. */
|
||||||
clear_cached_errors();
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS,ERRnoaccess);
|
return set_bad_path_error(errno, bad_path, outbuf, ERRDOS,ERRnoaccess);
|
||||||
|
Reference in New Issue
Block a user