diff options
author | Andrew Tridgell <tridge@samba.org> | 2001-09-04 07:13:01 +0000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2001-09-04 07:13:01 +0000 |
commit | 19fea3242cf6234786b6cbb60631e0071f31ff9f (patch) | |
tree | 1de6e79890a80a1e03cf0dce5813513aaf51bc59 /source3/smbd | |
parent | 55cf37488f66eba2826dba08e80dd4ab6df33fc3 (diff) | |
download | samba-19fea3242cf6234786b6cbb60631e0071f31ff9f.tar.gz samba-19fea3242cf6234786b6cbb60631e0071f31ff9f.tar.bz2 samba-19fea3242cf6234786b6cbb60631e0071f31ff9f.zip |
the next stage in the NTSTATUS/WERROR change. smbd and nmbd now compile, but the client code still needs some work
(This used to be commit dcd6e735f709a9231860ceb9682db40ff26c9a66)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/auth.c | 16 | ||||
-rw-r--r-- | source3/smbd/auth_domain.c | 6 | ||||
-rw-r--r-- | source3/smbd/auth_rhosts.c | 4 | ||||
-rw-r--r-- | source3/smbd/auth_server.c | 7 | ||||
-rw-r--r-- | source3/smbd/auth_smbpasswd.c | 8 | ||||
-rw-r--r-- | source3/smbd/auth_unix.c | 4 | ||||
-rw-r--r-- | source3/smbd/auth_util.c | 6 | ||||
-rw-r--r-- | source3/smbd/error.c | 2 | ||||
-rw-r--r-- | source3/smbd/lanman.c | 19 | ||||
-rw-r--r-- | source3/smbd/notify.c | 2 | ||||
-rw-r--r-- | source3/smbd/nttrans.c | 42 | ||||
-rw-r--r-- | source3/smbd/reply.c | 185 |
12 files changed, 143 insertions, 158 deletions
diff --git a/source3/smbd/auth.c b/source3/smbd/auth.c index d6bc8aeadc..b707c38c62 100644 --- a/source3/smbd/auth.c +++ b/source3/smbd/auth.c @@ -68,15 +68,15 @@ NTSTATUS check_password(const auth_usersupplied_info *user_info, return NT_STATUS_LOGON_FAILURE; } - if (nt_status != NT_STATUS_OK) { + if (!NT_STATUS_IS_OK(nt_status)) { nt_status = check_rhosts_security(user_info, server_info); } - if ((lp_security() == SEC_DOMAIN) && (nt_status != NT_STATUS_OK)) { + if ((lp_security() == SEC_DOMAIN) && !NT_STATUS_IS_OK(nt_status)) { nt_status = check_domain_security(user_info, server_info); } - if ((lp_security() == SEC_SERVER) && (nt_status != NT_STATUS_OK)) { + if ((lp_security() == SEC_SERVER) && !NT_STATUS_IS_OK(nt_status)) { nt_status = check_server_security(user_info, server_info); } @@ -84,7 +84,7 @@ NTSTATUS check_password(const auth_usersupplied_info *user_info, smb_user_control(user_info->smb_username.str, nt_status); } - if (nt_status != NT_STATUS_OK) { + if (!NT_STATUS_IS_OK(nt_status)) { if ((user_info->plaintext_password.len > 0) && (!lp_plaintext_to_smbpasswd())) { nt_status = check_unix_security(user_info, server_info); @@ -94,14 +94,14 @@ NTSTATUS check_password(const auth_usersupplied_info *user_info, } } - if ((nt_status == NT_STATUS_OK) && !done_pam) { + if (NT_STATUS_IS_OK(nt_status) && !done_pam) { /* We might not be root if we are an RPC call */ become_root(); nt_status = smb_pam_accountcheck(user_info->smb_username.str); unbecome_root(); } - if (nt_status == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(nt_status)) { DEBUG(5, ("check_password: Password for user %s suceeded\n", user_info->smb_username.str)); } else { DEBUG(3, ("check_password: Password for user %s FAILED with error %s\n", user_info->smb_username.str, get_nt_error_msg(nt_status))); @@ -233,11 +233,11 @@ BOOL password_ok(char *user, char *password, int pwlen) /* The password could be either NTLM or plain LM. Try NTLM first, but fall-through as required. */ - if (pass_check_smb(user, lp_workgroup(), NULL, 0, (unsigned char *)password, pwlen) == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(pass_check_smb(user, lp_workgroup(), NULL, 0, (unsigned char *)password, pwlen))) { return True; } - if (pass_check_smb(user, lp_workgroup(), (unsigned char *)password, pwlen, NULL, 0) == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(pass_check_smb(user, lp_workgroup(), (unsigned char *)password, pwlen, NULL, 0))) { return True; } diff --git a/source3/smbd/auth_domain.c b/source3/smbd/auth_domain.c index d9d7b6fd40..111f0f143c 100644 --- a/source3/smbd/auth_domain.c +++ b/source3/smbd/auth_domain.c @@ -30,10 +30,10 @@ BOOL global_machine_password_needs_changing = False; Check for a valid username and password in security=domain mode. ****************************************************************************/ -uint32 check_domain_security(const auth_usersupplied_info *user_info, - auth_serversupplied_info *server_info) +NTSTATUS check_domain_security(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; char *p, *pserver; unsigned char trust_passwd[16]; time_t last_change_time; diff --git a/source3/smbd/auth_rhosts.c b/source3/smbd/auth_rhosts.c index a4914f2ef1..ffb9212264 100644 --- a/source3/smbd/auth_rhosts.c +++ b/source3/smbd/auth_rhosts.c @@ -168,10 +168,10 @@ BOOL check_hosts_equiv(char *user) Check for a valid .rhosts/hosts.equiv entry for this user ****************************************************************************/ -uint32 check_rhosts_security(const auth_usersupplied_info *user_info, +NTSTATUS check_rhosts_security(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; become_root(); if (check_hosts_equiv(user_info->smb_username.str)) { diff --git a/source3/smbd/auth_server.c b/source3/smbd/auth_server.c index 9636094fa3..b279152f74 100644 --- a/source3/smbd/auth_server.c +++ b/source3/smbd/auth_server.c @@ -113,14 +113,14 @@ struct cli_state *server_cryptkey(void) Validate a password with the password server. ****************************************************************************/ -static uint32 server_validate(const auth_usersupplied_info *user_info, auth_serversupplied_info *server_info) +static NTSTATUS server_validate(const auth_usersupplied_info *user_info, auth_serversupplied_info *server_info) { struct cli_state *cli; static unsigned char badpass[24]; static fstring baduser; static BOOL tested_password_server = False; static BOOL bad_password_server = False; - uint32 nt_status = NT_STATUS_LOGON_FAILURE; + NTSTATUS nt_status = NT_STATUS_LOGON_FAILURE; cli = server_client(); @@ -232,14 +232,13 @@ use this machine as the password server.\n")); Check for a valid username and password in security=server mode. ****************************************************************************/ -uint32 check_server_security(const auth_usersupplied_info *user_info, auth_serversupplied_info *server_info) +NTSTATUS check_server_security(const auth_usersupplied_info *user_info, auth_serversupplied_info *server_info) { if(lp_security() != SEC_SERVER) return NT_STATUS_LOGON_FAILURE; return server_validate(user_info, server_info); - } diff --git a/source3/smbd/auth_smbpasswd.c b/source3/smbd/auth_smbpasswd.c index 5484758167..33b0623643 100644 --- a/source3/smbd/auth_smbpasswd.c +++ b/source3/smbd/auth_smbpasswd.c @@ -109,7 +109,7 @@ static BOOL smb_pwd_check_ntlmv2(const uchar *password, size_t pwd_len, Do a specific test for an smb password being correct, given a smb_password and the lanman and NT responses. ****************************************************************************/ -uint32 smb_password_ok(SAM_ACCOUNT *sampass, const auth_usersupplied_info *user_info, auth_serversupplied_info *server_info) +NTSTATUS smb_password_ok(SAM_ACCOUNT *sampass, const auth_usersupplied_info *user_info, auth_serversupplied_info *server_info) { uint8 *nt_pw, *lm_pw; uint16 acct_ctrl; @@ -202,11 +202,11 @@ SMB hash supplied in the user_info structure return an NT_STATUS constant. ****************************************************************************/ -uint32 check_smbpasswd_security(const auth_usersupplied_info *user_info, auth_serversupplied_info *server_info) +NTSTATUS check_smbpasswd_security(const auth_usersupplied_info *user_info, auth_serversupplied_info *server_info) { SAM_ACCOUNT *sampass=NULL; BOOL ret; - uint32 nt_status; + NTSTATUS nt_status; pdb_init_sam(&sampass); @@ -220,7 +220,7 @@ uint32 check_smbpasswd_security(const auth_usersupplied_info *user_info, auth_se { DEBUG(1,("Couldn't find user '%s' in passdb file.\n", user_info->smb_username.str)); pdb_free_sam(sampass); - return(NT_STATUS_NO_SUCH_USER); + return NT_STATUS_NO_SUCH_USER; } nt_status = smb_password_ok(sampass, user_info, server_info); diff --git a/source3/smbd/auth_unix.c b/source3/smbd/auth_unix.c index fda44fd91c..1708320961 100644 --- a/source3/smbd/auth_unix.c +++ b/source3/smbd/auth_unix.c @@ -68,9 +68,9 @@ check if a username/password is OK assuming the password in PLAIN TEXT ****************************************************************************/ -uint32 check_unix_security(const auth_usersupplied_info *user_info, auth_serversupplied_info *server_info) +NTSTATUS check_unix_security(const auth_usersupplied_info *user_info, auth_serversupplied_info *server_info) { - uint32 nt_status; + NTSTATUS nt_status; become_root(); nt_status = (pass_check(user_info->smb_username.str, user_info->plaintext_password.str, diff --git a/source3/smbd/auth_util.c b/source3/smbd/auth_util.c index 5ccf963889..28f58eb8ae 100644 --- a/source3/smbd/auth_util.c +++ b/source3/smbd/auth_util.c @@ -101,11 +101,11 @@ static int smb_delete_user(char *unix_user) Add and Delete UNIX users on demand, based on NT_STATUS codes. ****************************************************************************/ -void smb_user_control(char *unix_user, uint32 nt_status) +void smb_user_control(char *unix_user, NTSTATUS nt_status) { struct passwd *pwd=NULL; - if(nt_status == NT_STATUS_OK) { + if (NT_STATUS_IS_OK(nt_status)) { /* * User validated ok against Domain controller. * If the admin wants us to try and create a UNIX @@ -127,7 +127,7 @@ void smb_user_control(char *unix_user, uint32 nt_status) smb_create_user(unix_user, pwd->pw_dir); } - } else if (nt_status == NT_STATUS_NO_SUCH_USER) { + } else if (NT_STATUS_V(nt_status) == NT_STATUS_V(NT_STATUS_NO_SUCH_USER)) { /* * User failed to validate ok against Domain controller. * If the failure was "user doesn't exist" and admin diff --git a/source3/smbd/error.c b/source3/smbd/error.c index a74b62de01..6b5a4b27b1 100644 --- a/source3/smbd/error.c +++ b/source3/smbd/error.c @@ -84,7 +84,7 @@ int unix_error_packet(char *outbuf,int def_class,uint32 def_code,int line) } } - return error_packet(outbuf,NT_STATUS(0),eclass,ecode,line); + return error_packet(outbuf,NT_STATUS_OK,eclass,ecode,line); } diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index 21d18fc88c..eb0e7154a2 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -2016,6 +2016,7 @@ static BOOL api_RDosPrintJobDel(connection_struct *conn,uint16 vuid, char *param char *p = skip_string(str2,1); int jobid, errcode; extern struct current_user current_user; + WERROR werr = WERR_OK; jobid = SVAL(p,0); @@ -2036,18 +2037,21 @@ static BOOL api_RDosPrintJobDel(connection_struct *conn,uint16 vuid, char *param switch (function) { case 81: /* delete */ - if (print_job_delete(¤t_user, jobid, &errcode)) + if (print_job_delete(¤t_user, jobid, &werr)) errcode = NERR_Success; break; case 82: /* pause */ - if (print_job_pause(¤t_user, jobid, &errcode)) + if (print_job_pause(¤t_user, jobid, &werr)) errcode = NERR_Success; break; case 83: /* resume */ - if (print_job_resume(¤t_user, jobid, &errcode)) + if (print_job_resume(¤t_user, jobid, &werr)) errcode = NERR_Success; break; } + + if (!W_ERROR_IS_OK(werr)) + errcode = W_ERROR_V(werr); out: SSVAL(*rparam,0,errcode); @@ -2070,6 +2074,7 @@ static BOOL api_WPrintQueueCtrl(connection_struct *conn,uint16 vuid, char *param char *QueueName = skip_string(str2,1); int errcode = NERR_notsupported; int snum; + WERROR werr = WERR_OK; extern struct current_user current_user; /* check it's a supported varient */ @@ -2089,16 +2094,18 @@ static BOOL api_WPrintQueueCtrl(connection_struct *conn,uint16 vuid, char *param switch (function) { case 74: /* Pause queue */ - if (print_queue_pause(¤t_user, snum, &errcode)) errcode = NERR_Success; + if (print_queue_pause(¤t_user, snum, &werr)) errcode = NERR_Success; break; case 75: /* Resume queue */ - if (print_queue_resume(¤t_user, snum, &errcode)) errcode = NERR_Success; + if (print_queue_resume(¤t_user, snum, &werr)) errcode = NERR_Success; break; case 103: /* Purge */ - if (print_queue_purge(¤t_user, snum, &errcode)) errcode = NERR_Success; + if (print_queue_purge(¤t_user, snum, &werr)) errcode = NERR_Success; break; } + if (!W_ERROR_IS_OK(werr)) errcode = W_ERROR_V(werr); + out: SSVAL(*rparam,0,errcode); SSVAL(*rparam,2,0); /* converter word */ diff --git a/source3/smbd/notify.c b/source3/smbd/notify.c index a2a979b776..5aa0b4ad3f 100644 --- a/source3/smbd/notify.c +++ b/source3/smbd/notify.c @@ -47,7 +47,7 @@ static struct change_notify *change_notify_list; /**************************************************************************** Setup the common parts of the return packet and send it. *****************************************************************************/ -static void change_notify_reply_packet(char *inbuf, uint32 error_code) +static void change_notify_reply_packet(char *inbuf, NTSTATUS error_code) { char outbuf[smb_size+38]; diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index 8a70e69365..aee5aa7798 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -1435,37 +1435,35 @@ static int call_nt_transact_rename(connection_struct *conn, int bufsize, char **ppsetup, char **ppparams, char **ppdata) { - char *params = *ppparams; - pstring new_name; - files_struct *fsp = file_fsp(params, 0); - BOOL replace_if_exists = (SVAL(params,2) & RENAME_REPLACE_IF_EXISTS) ? True : False; - int outsize = 0; - - CHECK_FSP(fsp, conn); - srvstr_pull(inbuf, new_name, params+4, sizeof(new_name), -1, STR_TERMINATE); - - outsize = rename_internals(conn, inbuf, outbuf, fsp->fsp_name, - new_name, replace_if_exists); - if(outsize == 0) { - /* - * Rename was successful. - */ - send_nt_replies(inbuf, outbuf, bufsize, NT_STATUS_OK, NULL, 0, NULL, 0); + char *params = *ppparams; + pstring new_name; + files_struct *fsp = file_fsp(params, 0); + BOOL replace_if_exists = (SVAL(params,2) & RENAME_REPLACE_IF_EXISTS) ? True : False; + NTSTATUS status; - DEBUG(3,("nt transact rename from = %s, to = %s succeeded.\n", - fsp->fsp_name, new_name)); + CHECK_FSP(fsp, conn); + srvstr_pull(inbuf, new_name, params+4, sizeof(new_name), -1, STR_TERMINATE); - outsize = -1; + status = rename_internals(conn, fsp->fsp_name, + new_name, replace_if_exists); + if (!NT_STATUS_IS_OK(status)) return ERROR_NT(status); /* + * Rename was successful. + */ + 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)); + + /* * Win2k needs a changenotify request response before it will * update after a rename.. */ - + process_pending_change_notify_queue((time_t)0); - } - return(outsize); + return -1; } diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 8b392e9e0a..73cfd5ac85 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -499,7 +499,7 @@ static int session_trust_account(connection_struct *conn, char *inbuf, char *out return(ERROR_NT(NT_STATUS_LOGON_FAILURE)); } - if (!smb_password_ok(sam_trust_acct, &user_info, &server_info)) { + if (!NT_STATUS_IS_OK(smb_password_ok(sam_trust_acct, &user_info, &server_info))) { DEBUG(0,("session_trust_account: Trust Account %s - password failed\n", user)); pdb_free_sam(sam_trust_acct); return(ERROR_NT(NT_STATUS_LOGON_FAILURE)); @@ -1751,14 +1751,13 @@ static BOOL can_delete(char *fname,connection_struct *conn, int dirtype) code. ****************************************************************************/ -int unlink_internals(connection_struct *conn, char *inbuf,char *outbuf, - int dirtype, char *name) +NTSTATUS unlink_internals(connection_struct *conn, int dirtype, char *name) { pstring directory; pstring mask; char *p; int count=0; - int error = ERRnoaccess; + NTSTATUS error = NT_STATUS_OK; BOOL has_wild; BOOL exists=False; BOOL bad_path = False; @@ -1797,7 +1796,7 @@ int unlink_internals(connection_struct *conn, char *inbuf,char *outbuf, pstrcat(directory,"/"); pstrcat(directory,mask); if (!can_delete(directory,conn,dirtype)) { - return ERROR_NT(NT_STATUS_SHARING_VIOLATION); + return NT_STATUS_SHARING_VIOLATION; } if (vfs_unlink(conn,directory) == 0) { count++; @@ -1817,7 +1816,7 @@ int unlink_internals(connection_struct *conn, char *inbuf,char *outbuf, */ if (dirptr) { - error = ERRbadfile; + error = NT_STATUS_OBJECT_NAME_NOT_FOUND; if (strequal(mask,"????????.???")) pstrcpy(mask,"*"); @@ -1828,7 +1827,7 @@ int unlink_internals(connection_struct *conn, char *inbuf,char *outbuf, if(!mask_match(fname, mask, case_sensitive)) continue; - error = ERRnoaccess; + error = NT_STATUS_ACCESS_DENIED; slprintf(fname,sizeof(fname)-1, "%s/%s",directory,dname); if (!can_delete(fname,conn,dirtype)) continue; if (vfs_unlink(conn,fname) == 0) count++; @@ -1838,19 +1837,11 @@ int unlink_internals(connection_struct *conn, char *inbuf,char *outbuf, } } - if (count == 0) { - if (exists) - return ERROR_DOS(ERRDOS,error); - else { - if((errno == ENOENT) && bad_path) { - unix_ERR_class = ERRDOS; - unix_ERR_code = ERRbadpath; - } - return(UNIXERROR(ERRDOS,error)); - } + if (count == 0 && NT_STATUS_IS_OK(error)) { + error = map_nt_error_from_unix(errno); } - - return 0; + + return error; } /**************************************************************************** @@ -1863,6 +1854,7 @@ int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size int outsize = 0; pstring name; int dirtype; + NTSTATUS status; START_PROFILE(SMBunlink); dirtype = SVAL(inbuf,smb_vwv0); @@ -1873,16 +1865,16 @@ int reply_unlink(connection_struct *conn, char *inbuf,char *outbuf, int dum_size DEBUG(3,("reply_unlink : %s\n",name)); - outsize = unlink_internals(conn, inbuf, outbuf, dirtype, name); - if(outsize == 0) { - /* - * Win2k needs a changenotify request response before it will - * update after a rename.. - */ - process_pending_change_notify_queue((time_t)0); - - outsize = set_message(outbuf,0,0,True); - } + status = unlink_internals(conn, dirtype, name); + if (!NT_STATUS_IS_OK(status)) return ERROR_NT(status); + + /* + * Win2k needs a changenotify request response before it will + * update after a rename.. + */ + process_pending_change_notify_queue((time_t)0); + + outsize = set_message(outbuf,0,0,True); END_PROFILE(SMBunlink); return outsize; @@ -3171,28 +3163,22 @@ int reply_printwrite(connection_struct *conn, char *inbuf,char *outbuf, int dum_ The guts of the mkdir command, split out so it may be called by the NT SMB code. ****************************************************************************/ -int mkdir_internal(connection_struct *conn, char *inbuf, char *outbuf, pstring directory) +NTSTATUS mkdir_internal(connection_struct *conn, pstring directory) { - BOOL bad_path = False; - SMB_STRUCT_STAT sbuf; - int ret= -1; - - unix_convert(directory,conn,0,&bad_path,&sbuf); - - if (check_name(directory, conn)) - ret = vfs_mkdir(conn,directory,unix_mode(conn,aDIR,directory)); - - if (ret < 0) - { - if((errno == ENOENT) && bad_path) - { - unix_ERR_class = ERRDOS; - unix_ERR_code = ERRbadpath; - } - return(UNIXERROR(ERRDOS,ERRnoaccess)); - } - - return ret; + BOOL bad_path = False; + SMB_STRUCT_STAT sbuf; + int ret= -1; + + unix_convert(directory,conn,0,&bad_path,&sbuf); + + if (check_name(directory, conn)) + ret = vfs_mkdir(conn,directory,unix_mode(conn,aDIR,directory)); + + if (ret == -1) { + return map_nt_error_from_unix(errno); + } + + return NT_STATUS_OK; } /**************************************************************************** @@ -3203,13 +3189,15 @@ int reply_mkdir(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, { pstring directory; int outsize; + NTSTATUS status; START_PROFILE(SMBmkdir); srvstr_pull(inbuf, directory, smb_buf(inbuf) + 1, sizeof(directory), -1, STR_TERMINATE); - outsize=mkdir_internal(conn, inbuf, outbuf, directory); - if(outsize == 0) - outsize = set_message(outbuf,0,0,True); + status = mkdir_internal(conn, directory); + if (!NT_STATUS_IS_OK(status)) return ERROR_NT(status); + + outsize = set_message(outbuf,0,0,True); DEBUG( 3, ( "mkdir %s ret=%d\n", directory, outsize ) ); @@ -3478,9 +3466,9 @@ static BOOL can_rename(char *fname,connection_struct *conn) The guts of the rename command, split out so it may be called by the NT SMB code. ****************************************************************************/ -int rename_internals(connection_struct *conn, - char *inbuf, char *outbuf, char *name, - char *newname, BOOL replace_if_exists) +NTSTATUS rename_internals(connection_struct *conn, + char *name, + char *newname, BOOL replace_if_exists) { pstring directory; pstring mask; @@ -3490,7 +3478,7 @@ int rename_internals(connection_struct *conn, BOOL bad_path1 = False; BOOL bad_path2 = False; int count=0; - int error = ERRnoaccess; + NTSTATUS error = NT_STATUS_OK; BOOL exists=False; BOOL rc = True; SMB_STRUCT_STAT sbuf1, sbuf2; @@ -3600,13 +3588,13 @@ int rename_internals(connection_struct *conn, if(resolve_wildcards(directory,newname) && can_rename(directory,conn) && - !conn->vfs_ops.rename(conn,directory,newname)) + conn->vfs_ops.rename(conn,directory,newname) == 0) count++; } else { if (resolve_wildcards(directory,newname) && can_rename(directory,conn) && !vfs_file_exist(conn,newname,NULL) && - !conn->vfs_ops.rename(conn,directory,newname)) + conn->vfs_ops.rename(conn,directory,newname) == 0) count++; } @@ -3616,7 +3604,7 @@ int rename_internals(connection_struct *conn, if (!count) exists = vfs_file_exist(conn,directory,NULL); if (!count && exists && vfs_file_exist(conn,newname,NULL)) { exists = True; - error = ERRrename; + error = NT_STATUS_OBJECT_NAME_COLLISION; } } else { /* @@ -3630,7 +3618,7 @@ int rename_internals(connection_struct *conn, dirptr = OpenDir(conn, directory, True); if (dirptr) { - error = ERRbadfile; + error = NT_STATUS_OBJECT_NAME_NOT_FOUND; if (strequal(mask,"????????.???")) pstrcpy(mask,"*"); @@ -3643,7 +3631,7 @@ int rename_internals(connection_struct *conn, if(!mask_match(fname, mask, case_sensitive)) continue; - error = ERRnoaccess; + error = NT_STATUS_ACCESS_DENIED; slprintf(fname,sizeof(fname)-1,"%s/%s",directory,dname); if (!can_rename(fname,conn)) { DEBUG(6,("rename %s refused\n", fname)); @@ -3660,7 +3648,7 @@ int rename_internals(connection_struct *conn, if (!replace_if_exists && vfs_file_exist(conn,destname, NULL)) { DEBUG(6,("file_exist %s\n", destname)); - error = 183; + error = NT_STATUS_OBJECT_NAME_COLLISION; continue; } @@ -3672,59 +3660,52 @@ int rename_internals(connection_struct *conn, } } - if (count == 0) { - if (exists) - return ERROR_DOS(ERRDOS,error); - else { - if((errno == ENOENT) && (bad_path1 || bad_path2)) { - unix_ERR_class = ERRDOS; - unix_ERR_code = ERRbadpath; - } - return(UNIXERROR(ERRDOS,error)); - } + if (count == 0 && NT_STATUS_IS_OK(error)) { + error = map_nt_error_from_unix(errno); } - return 0; + return error; } /**************************************************************************** Reply to a mv. ****************************************************************************/ -int reply_mv(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, int dum_buffsize) +int reply_mv(connection_struct *conn, char *inbuf,char *outbuf, int dum_size, + int dum_buffsize) { - int outsize = 0; - pstring name; - pstring newname; - char *p; - - START_PROFILE(SMBmv); - - p = smb_buf(inbuf) + 1; - p += srvstr_pull(inbuf, name, p, sizeof(name), -1, STR_TERMINATE); - p++; - p += srvstr_pull(inbuf, newname, p, sizeof(newname), -1, STR_TERMINATE); - - RESOLVE_DFSPATH(name, conn, inbuf, outbuf); - RESOLVE_DFSPATH(newname, conn, inbuf, outbuf); + int outsize = 0; + pstring name; + pstring newname; + char *p; + NTSTATUS status; - DEBUG(3,("reply_mv : %s -> %s\n",name,newname)); + START_PROFILE(SMBmv); - outsize = rename_internals(conn, inbuf, outbuf, name, newname, False); - if(outsize == 0) { + p = smb_buf(inbuf) + 1; + p += srvstr_pull(inbuf, name, p, sizeof(name), -1, STR_TERMINATE); + p++; + p += srvstr_pull(inbuf, newname, p, sizeof(newname), -1, STR_TERMINATE); + + RESOLVE_DFSPATH(name, conn, inbuf, outbuf); + RESOLVE_DFSPATH(newname, conn, inbuf, outbuf); + + DEBUG(3,("reply_mv : %s -> %s\n",name,newname)); + + status = rename_internals(conn, name, newname, False); + if (!NT_STATUS_IS_OK(status)) { + return ERROR_NT(status); + } /* - * Win2k needs a changenotify request response before it will - * update after a rename.. - */ - - process_pending_change_notify_queue((time_t)0); - - outsize = set_message(outbuf,0,0,True); - } + * Win2k needs a changenotify request response before it will + * update after a rename.. + */ + process_pending_change_notify_queue((time_t)0); + outsize = set_message(outbuf,0,0,True); - END_PROFILE(SMBmv); - return(outsize); + END_PROFILE(SMBmv); + return(outsize); } /******************************************************************* |