diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-08-27 17:52:23 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-08-27 17:52:23 +0000 |
commit | ee5f7237decfe446f4fdb08422beb2e6cb43af7f (patch) | |
tree | 80b217a2938d7e0d46a5d20517c9adb0807ecd1a /source3/smbd | |
parent | e8e98c9ea0690e3acf1126b50882e59e1056c7b3 (diff) | |
download | samba-ee5f7237decfe446f4fdb08422beb2e6cb43af7f.tar.gz samba-ee5f7237decfe446f4fdb08422beb2e6cb43af7f.tar.bz2 samba-ee5f7237decfe446f4fdb08422beb2e6cb43af7f.zip |
started converting NTSTATUS to be a structure on systems with gcc in order to make it type incompatible with BOOL so we catch errors sooner. This has already found a number of bugs
(This used to be commit 1b778bc7d22efff3f90dc450eb12baa1241cf68f)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/auth.c | 17 | ||||
-rw-r--r-- | source3/smbd/blocking.c | 8 | ||||
-rw-r--r-- | source3/smbd/error.c | 10 | ||||
-rw-r--r-- | source3/smbd/nttrans.c | 14 | ||||
-rw-r--r-- | source3/smbd/reply.c | 24 |
5 files changed, 38 insertions, 35 deletions
diff --git a/source3/smbd/auth.c b/source3/smbd/auth.c index 8ea867fe8c..ec493b7c06 100644 --- a/source3/smbd/auth.c +++ b/source3/smbd/auth.c @@ -56,10 +56,11 @@ static BOOL check_domain_match(char *user, char *domain) as it makes the calls itself when needed. ****************************************************************************/ -uint32 check_password(const auth_usersupplied_info *user_info, auth_serversupplied_info *server_info) +NTSTATUS check_password(const auth_usersupplied_info *user_info, + auth_serversupplied_info *server_info) { - uint32 nt_status = NT_STATUS_LOGON_FAILURE; + NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE; BOOL done_pam = False; DEBUG(3, ("check_password: Checking password for user %s with the new password interface\n", user_info->smb_username.str)); @@ -120,9 +121,9 @@ SMB hash return True if the password is correct, False otherwise ****************************************************************************/ -uint32 pass_check_smb_with_chal(char *user, char *domain, uchar chal[8], - uchar *lm_pwd, int lm_pwd_len, - uchar *nt_pwd, int nt_pwd_len) +NTSTATUS pass_check_smb_with_chal(char *user, char *domain, uchar chal[8], + uchar *lm_pwd, int lm_pwd_len, + uchar *nt_pwd, int nt_pwd_len) { auth_usersupplied_info user_info; @@ -196,9 +197,9 @@ uint32 pass_check_smb_with_chal(char *user, char *domain, uchar chal[8], return check_password(&user_info, &server_info); } -uint32 pass_check_smb(char *user, char *domain, - uchar *lm_pwd, int lm_pwd_len, - uchar *nt_pwd, int nt_pwd_len) +NTSTATUS pass_check_smb(char *user, char *domain, + uchar *lm_pwd, int lm_pwd_len, + uchar *nt_pwd, int nt_pwd_len) { uchar chal[8]; diff --git a/source3/smbd/blocking.c b/source3/smbd/blocking.c index 697e1df194..1365985660 100644 --- a/source3/smbd/blocking.c +++ b/source3/smbd/blocking.c @@ -276,7 +276,7 @@ static BOOL process_lockread(blocking_lock_record *blr) status = do_lock( fsp, conn, SVAL(inbuf,smb_pid), (SMB_BIG_UINT)numtoread, (SMB_BIG_UINT)startpos, READ_LOCK); - if (status != NT_STATUS_NOPROBLEMO) { + if (NT_STATUS_V(status)) { if ((errno != EACCES) && (errno != EAGAIN)) { /* * We have other than a "can't get lock" POSIX @@ -342,7 +342,7 @@ static BOOL process_lock(blocking_lock_record *blr) errno = 0; status = do_lock(fsp, conn, SVAL(inbuf,smb_pid), (SMB_BIG_UINT)count, (SMB_BIG_UINT)offset, WRITE_LOCK); - if (status != NT_STATUS_NOPROBLEMO) { + if (NT_STATUS_IS_ERR(status)) { if((errno != EACCES) && (errno != EAGAIN)) { /* * We have other than a "can't get lock" POSIX @@ -391,7 +391,7 @@ static BOOL process_lockingX(blocking_lock_record *blr) uint16 lock_pid; BOOL large_file_format = (locktype & LOCKING_ANDX_LARGE_FILES); char *data; - NTSTATUS status = 0; + NTSTATUS status = NT_STATUS_OK; data = smb_buf(inbuf) + ((large_file_format ? 20 : 10)*num_ulocks); @@ -414,7 +414,7 @@ static BOOL process_lockingX(blocking_lock_record *blr) errno = 0; status = do_lock(fsp,conn,count,lock_pid,offset, ((locktype & 1) ? READ_LOCK : WRITE_LOCK)); - if (status != NT_STATUS_NOPROBLEMO) break; + if (NT_STATUS_IS_ERR(status)) break; } if(blr->lock_num == num_locks) { diff --git a/source3/smbd/error.c b/source3/smbd/error.c index 27dacda377..f2613dc3a8 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -84,14 +84,14 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code,int line) } } - return error_packet(outbuf,0,eclass,ecode,line); + return error_packet(outbuf,NT_STATUS_OK,eclass,ecode,line); } /**************************************************************************** create an error packet. Normally called using the ERROR() macro ****************************************************************************/ -int error_packet(char *outbuf,uint32 ntstatus, +int error_packet(char *outbuf,NTSTATUS ntstatus, uint8 eclass,uint32 ecode,int line) { int outsize = set_message(outbuf,0,0,True); @@ -101,10 +101,10 @@ int error_packet(char *outbuf,uint32 ntstatus, DEBUG(3,("error string = %s\n",strerror(errno))); if (global_client_caps & CAP_STATUS32) { - if (ntstatus == 0 && eclass) { + if (NT_STATUS_V(ntstatus) == 0 && eclass) { ntstatus = dos_to_ntstatus(eclass, ecode); } - SIVAL(outbuf,smb_rcls,ntstatus); + SIVAL(outbuf,smb_rcls,NT_STATUS_V(ntstatus)); SSVAL(outbuf,smb_flg2, SVAL(outbuf,smb_flg2)|FLAGS2_32_BIT_ERROR_CODES); DEBUG(3,("error packet at line %d cmd=%d (%s) %s\n", line, @@ -114,7 +114,7 @@ int error_packet(char *outbuf,uint32 ntstatus, return outsize; } - if (eclass == 0 && ntstatus) { + if (eclass == 0 && NT_STATUS_V(ntstatus)) { ntstatus_to_dos(ntstatus, &eclass, &ecode); } diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 2981c6bfb2..8a70e69365 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -63,7 +63,7 @@ struct generic_mapping file_generic_mapping = { HACK ! Always assumes smb_setup field is zero. ****************************************************************************/ -static int send_nt_replies(char *inbuf, char *outbuf, int bufsize, uint32 nt_error, char *params, +static int send_nt_replies(char *inbuf, char *outbuf, int bufsize, NTSTATUS nt_error, char *params, int paramsize, char *pdata, int datasize) { extern int max_send; @@ -83,7 +83,7 @@ static int send_nt_replies(char *inbuf, char *outbuf, int bufsize, uint32 nt_err set_message(outbuf,18,0,True); - if(nt_error != 0) { + if (NT_STATUS_V(nt_error)) { ERROR_NT(nt_error); } @@ -937,7 +937,7 @@ static int do_nt_transact_create_pipe( connection_struct *conn, DEBUG(5,("do_nt_transact_create_pipe: open name = %s\n", fname)); /* Send the required number of replies */ - send_nt_replies(inbuf, outbuf, bufsize, 0, params, 69, *ppdata, 0); + send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, params, 69, *ppdata, 0); return -1; } @@ -1353,7 +1353,7 @@ static int call_nt_transact_create(connection_struct *conn, DEBUG(5,("call_nt_transact_create: open name = %s\n", fname)); /* Send the required number of replies */ - send_nt_replies(inbuf, outbuf, bufsize, 0, params, 69, *ppdata, 0); + send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, params, 69, *ppdata, 0); return -1; } @@ -1450,7 +1450,7 @@ static int call_nt_transact_rename(connection_struct *conn, /* * Rename was successful. */ - send_nt_replies(inbuf, outbuf, bufsize, 0, NULL, 0, NULL, 0); + send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, NULL, 0, NULL, 0); DEBUG(3,("nt transact rename from = %s, to = %s succeeded.\n", fsp->fsp_name, new_name)); @@ -1570,7 +1570,7 @@ security descriptor.\n")); talloc_destroy(mem_ctx); - send_nt_replies(inbuf, outbuf, bufsize, 0, params, 4, data, (int)sd_size); + send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, params, 4, data, (int)sd_size); return -1; } @@ -1609,7 +1609,7 @@ static int call_nt_transact_set_security_desc(connection_struct *conn, if (!set_sd( fsp, data, total_data_count, security_info_sent, &error_class, &error_code)) return ERROR_DOS(error_class, error_code); - send_nt_replies(inbuf, outbuf, bufsize, 0, NULL, 0, NULL, 0); + send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, NULL, 0, NULL, 0); return -1; } diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 236bb48ce9..f1a83c27f0 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -487,7 +487,7 @@ static int session_trust_account(connection_struct *conn, char *inbuf, char *out if (!last_challenge(user_info.chal)) { DEBUG(1,("smb_password_ok: no challenge done - password failed\n")); - return NT_STATUS_LOGON_FAILURE; + return ERROR_NT(NT_STATUS_LOGON_FAILURE); } pdb_init_sam(&sam_trust_acct); @@ -789,9 +789,11 @@ int reply_sesssetup_and_X(connection_struct *conn, char *inbuf,char *outbuf,int add_session_user(user); if (!guest) { - valid_password = (pass_check_smb(user, domain, - (unsigned char *)smb_apasswd, smb_apasslen, - (unsigned char *)smb_ntpasswd, smb_ntpasslen) == NT_STATUS_NOPROBLEMO); + valid_password = NT_STATUS_IS_OK(pass_check_smb(user, domain, + (unsigned char *)smb_apasswd, + smb_apasslen, + (unsigned char *)smb_ntpasswd, + smb_ntpasslen)); /* The true branch will be executed if (1) the NT password failed (or was not tried), and @@ -2086,7 +2088,7 @@ int reply_lockread(connection_struct *conn, char *inbuf,char *outbuf, int length status = do_lock(fsp, conn, SVAL(inbuf,smb_pid), (SMB_BIG_UINT)numtoread, (SMB_BIG_UINT)startpos, WRITE_LOCK); - if (status != NT_STATUS_NOPROBLEMO) { + if (NT_STATUS_V(status)) { if (lp_blocking_locks(SNUM(conn))) { /* * A blocking lock was requested. Package up @@ -2407,7 +2409,7 @@ int reply_writeunlock(connection_struct *conn, char *inbuf,char *outbuf, status = do_unlock(fsp, conn, SVAL(inbuf,smb_pid), (SMB_BIG_UINT)numtowrite, (SMB_BIG_UINT)startpos); - if (status != NT_STATUS_NOPROBLEMO) { + if (NT_STATUS_V(status)) { END_PROFILE(SMBwriteunlock); return ERROR_NT(status); } @@ -2885,8 +2887,8 @@ int reply_lock(connection_struct *conn, fsp->fd, fsp->fnum, (double)offset, (double)count)); status = do_lock(fsp, conn, SVAL(inbuf,smb_pid), count, offset, WRITE_LOCK); - if (status != NT_STATUS_NOPROBLEMO) { - if (status != NT_STATUS_NOPROBLEMO && lp_blocking_locks(SNUM(conn))) { + if (NT_STATUS_V(status)) { + if (lp_blocking_locks(SNUM(conn))) { /* * A blocking lock was requested. Package up * this smb into a queued request and push it @@ -2924,7 +2926,7 @@ int reply_unlock(connection_struct *conn, char *inbuf,char *outbuf, int size, offset = (SMB_BIG_UINT)IVAL(inbuf,smb_vwv3); status = do_unlock(fsp, conn, SVAL(inbuf,smb_pid), count, offset); - if (status != NT_STATUS_NOPROBLEMO) { + if (NT_STATUS_V(status)) { END_PROFILE(SMBunlock); return ERROR_NT(status); } @@ -4232,7 +4234,7 @@ no oplock granted on this file (%s).\n", fsp->fnum, fsp->fsp_name)); (double)offset, (double)count, (unsigned int)lock_pid, fsp->fsp_name )); status = do_unlock(fsp,conn,lock_pid,count,offset); - if (status != NT_STATUS_NOPROBLEMO) { + if (NT_STATUS_V(status)) { END_PROFILE(SMBlockingX); return ERROR_NT(status); } @@ -4265,7 +4267,7 @@ no oplock granted on this file (%s).\n", fsp->fnum, fsp->fsp_name)); status = do_lock(fsp,conn,lock_pid, count,offset, ((locktype & 1) ? READ_LOCK : WRITE_LOCK)); - if (status != NT_STATUS_NOPROBLEMO) { + if (NT_STATUS_V(status)) { if ((lock_timeout != 0) && lp_blocking_locks(SNUM(conn))) { /* * A blocking lock was requested. Package up |