svn commit: samba r20719 - in branches/SAMBA_3_0_24/source:
printing smbd
jra at samba.org
jra at samba.org
Fri Jan 12 23:49:54 GMT 2007
Author: jra
Date: 2007-01-12 23:49:53 +0000 (Fri, 12 Jan 2007)
New Revision: 20719
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=20719
Log:
Sync up the changes in the fileserver code between SAMBA_3_0.
copy now returns NTSTATUS, part of close does the same.
Jeremy.
Modified:
branches/SAMBA_3_0_24/source/printing/nt_printing.c
branches/SAMBA_3_0_24/source/smbd/close.c
branches/SAMBA_3_0_24/source/smbd/nttrans.c
branches/SAMBA_3_0_24/source/smbd/process.c
branches/SAMBA_3_0_24/source/smbd/reply.c
Changeset:
Modified: branches/SAMBA_3_0_24/source/printing/nt_printing.c
===================================================================
--- branches/SAMBA_3_0_24/source/printing/nt_printing.c 2007-01-12 23:47:16 UTC (rev 20718)
+++ branches/SAMBA_3_0_24/source/printing/nt_printing.c 2007-01-12 23:49:53 UTC (rev 20719)
@@ -1743,7 +1743,6 @@
SMB_STRUCT_STAT st;
int ver = 0;
int i;
- int err;
memset(inbuf, '\0', sizeof(inbuf));
memset(outbuf, '\0', sizeof(outbuf));
@@ -1823,8 +1822,8 @@
slprintf(old_name, sizeof(old_name)-1, "%s/%s", new_dir, driver->driverpath);
if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
driver_unix_convert(new_name, conn, NULL, &st);
- if ( !copy_file(new_name, old_name, conn, OPENX_FILE_EXISTS_TRUNCATE|
- OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False, &err) ) {
+ if ( !NT_STATUS_IS_OK(copy_file(new_name, old_name, conn, OPENX_FILE_EXISTS_TRUNCATE|
+ OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
new_name, old_name));
*perr = WERR_ACCESS_DENIED;
@@ -1839,8 +1838,8 @@
slprintf(old_name, sizeof(old_name)-1, "%s/%s", new_dir, driver->datafile);
if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
driver_unix_convert(new_name, conn, NULL, &st);
- if ( !copy_file(new_name, old_name, conn, OPENX_FILE_EXISTS_TRUNCATE|
- OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False, &err) ) {
+ if ( !NT_STATUS_IS_OK(copy_file(new_name, old_name, conn, OPENX_FILE_EXISTS_TRUNCATE|
+ OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
new_name, old_name));
*perr = WERR_ACCESS_DENIED;
@@ -1857,8 +1856,8 @@
slprintf(old_name, sizeof(old_name)-1, "%s/%s", new_dir, driver->configfile);
if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
driver_unix_convert(new_name, conn, NULL, &st);
- if ( !copy_file(new_name, old_name, conn, OPENX_FILE_EXISTS_TRUNCATE|
- OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False, &err) ) {
+ if ( !NT_STATUS_IS_OK(copy_file(new_name, old_name, conn, OPENX_FILE_EXISTS_TRUNCATE|
+ OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
new_name, old_name));
*perr = WERR_ACCESS_DENIED;
@@ -1876,8 +1875,8 @@
slprintf(old_name, sizeof(old_name)-1, "%s/%s", new_dir, driver->helpfile);
if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
driver_unix_convert(new_name, conn, NULL, &st);
- if ( !copy_file(new_name, old_name, conn, OPENX_FILE_EXISTS_TRUNCATE|
- OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False, &err) ) {
+ if ( !NT_STATUS_IS_OK(copy_file(new_name, old_name, conn, OPENX_FILE_EXISTS_TRUNCATE|
+ OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
new_name, old_name));
*perr = WERR_ACCESS_DENIED;
@@ -1904,9 +1903,9 @@
slprintf(old_name, sizeof(old_name)-1, "%s/%s", new_dir, driver->dependentfiles[i]);
if (ver != -1 && (ver=file_version_is_newer(conn, new_name, old_name)) > 0) {
driver_unix_convert(new_name, conn, NULL, &st);
- if ( !copy_file(new_name, old_name, conn,
+ if ( !NT_STATUS_IS_OK(copy_file(new_name, old_name, conn,
OPENX_FILE_EXISTS_TRUNCATE|
- OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False, &err) ) {
+ OPENX_FILE_CREATE_IF_NOT_EXIST, 0, False))) {
DEBUG(0,("move_driver_to_download_area: Unable to rename [%s] to [%s]\n",
new_name, old_name));
*perr = WERR_ACCESS_DENIED;
Modified: branches/SAMBA_3_0_24/source/smbd/close.c
===================================================================
--- branches/SAMBA_3_0_24/source/smbd/close.c 2007-01-12 23:47:16 UTC (rev 20718)
+++ branches/SAMBA_3_0_24/source/smbd/close.c 2007-01-12 23:49:53 UTC (rev 20719)
@@ -144,12 +144,14 @@
Deal with removing a share mode on last close.
****************************************************************************/
-static int close_remove_share_mode(files_struct *fsp, enum file_close_type close_type)
+static NTSTATUS close_remove_share_mode(files_struct *fsp,
+ enum file_close_type close_type)
{
connection_struct *conn = fsp->conn;
BOOL delete_file = False;
struct share_mode_lock *lck;
SMB_STRUCT_STAT sbuf;
+ NTSTATUS status = NT_STATUS_OK;
/*
* Lock the share entries, and determine if we should delete
@@ -162,7 +164,7 @@
if (lck == NULL) {
DEBUG(0, ("close_remove_share_mode: Could not get share mode "
"lock for file %s\n", fsp->fsp_name));
- return EINVAL;
+ return NT_STATUS_INVALID_PARAMETER;
}
if (!del_share_mode(lck, fsp)) {
@@ -197,7 +199,7 @@
|| !delete_file
|| (lck->delete_token == NULL)) {
TALLOC_FREE(lck);
- return 0;
+ return NT_STATUS_OK;
}
/*
@@ -227,6 +229,9 @@
DEBUG(5,("close_remove_share_mode: file %s. Delete on close "
"was set and stat failed with error %s\n",
fsp->fsp_name, strerror(errno) ));
+ /*
+ * Don't save the errno here, we ignore this error
+ */
goto done;
}
@@ -239,6 +244,9 @@
fsp->fsp_name,
(unsigned int)fsp->dev, (double)fsp->inode,
(unsigned int)sbuf.st_dev, (double)sbuf.st_ino ));
+ /*
+ * Don't save the errno here, we ignore this error
+ */
goto done;
}
@@ -254,9 +262,13 @@
DEBUG(5,("close_remove_share_mode: file %s. Delete on close "
"was set and unlink failed with error %s\n",
fsp->fsp_name, strerror(errno) ));
+
+ status = map_nt_error_from_unix(errno);
goto done;
}
+ status = NT_STATUS_FILE_DELETED;
+
done:
/* unbecome user. */
pop_sec_ctx();
@@ -264,7 +276,7 @@
process_pending_change_notify_queue((time_t)0);
TALLOC_FREE(lck);
- return 0;
+ return status;
}
/****************************************************************************
@@ -444,7 +456,8 @@
process_pending_change_notify_queue((time_t)0);
} else {
TALLOC_FREE(lck);
- remove_pending_change_notify_requests_by_fid(fsp, NT_STATUS_CANCELLED);
+ remove_pending_change_notify_requests_by_fid(
+ fsp, NT_STATUS_OK);
}
/*
Modified: branches/SAMBA_3_0_24/source/smbd/nttrans.c
===================================================================
--- branches/SAMBA_3_0_24/source/smbd/nttrans.c 2007-01-12 23:47:16 UTC (rev 20718)
+++ branches/SAMBA_3_0_24/source/smbd/nttrans.c 2007-01-12 23:49:53 UTC (rev 20719)
@@ -1784,10 +1784,15 @@
don't allow a directory to be opened.
****************************************************************************/
-static int call_nt_transact_notify_change(connection_struct *conn, char *inbuf, char *outbuf, int length, int bufsize,
- uint16 **ppsetup, uint32 setup_count,
- char **ppparams, uint32 parameter_count,
- char **ppdata, uint32 data_count, uint32 max_data_count)
+static int call_nt_transact_notify_change(connection_struct *conn, char *inbuf,
+ char *outbuf, int length,
+ int bufsize,
+ uint16 **ppsetup, uint32 setup_count,
+ char **ppparams,
+ uint32 parameter_count,
+ char **ppdata, uint32 data_count,
+ uint32 max_data_count,
+ uint32 max_param_count)
{
uint16 *setup = *ppsetup;
files_struct *fsp;
@@ -2734,11 +2739,13 @@
case NT_TRANSACT_NOTIFY_CHANGE:
{
START_PROFILE_NESTED(NT_transact_notify_change);
- outsize = call_nt_transact_notify_change(conn, inbuf, outbuf,
- size, bufsize,
- &state->setup, state->setup_count,
- &state->param, state->total_param,
- &state->data, state->total_data, state->max_data_return);
+ outsize = call_nt_transact_notify_change(
+ conn, inbuf, outbuf, size, bufsize,
+ &state->setup, state->setup_count,
+ &state->param, state->total_param,
+ &state->data, state->total_data,
+ state->max_data_return,
+ state->max_param_return);
END_PROFILE_NESTED(NT_transact_notify_change);
break;
}
Modified: branches/SAMBA_3_0_24/source/smbd/process.c
===================================================================
--- branches/SAMBA_3_0_24/source/smbd/process.c 2007-01-12 23:47:16 UTC (rev 20718)
+++ branches/SAMBA_3_0_24/source/smbd/process.c 2007-01-12 23:49:53 UTC (rev 20719)
@@ -514,6 +514,19 @@
*/
goto again;
}
+
+ if ((change_notify_fd() >= 0) && FD_ISSET(change_notify_fd(), &fds)) {
+
+ process_pending_change_notify_queue((time_t)0);
+
+ /*
+ * Same comment as for oplock processing applies here. We
+ * might have done I/O on the client socket.
+ */
+
+ goto again;
+ }
+
return receive_smb(smbd_server_fd(), buffer, 0);
}
@@ -1112,7 +1125,7 @@
common_flags2 &= ~v;
}
-void construct_reply_common(char *inbuf,char *outbuf)
+void construct_reply_common(const char *inbuf, char *outbuf)
{
set_message(outbuf,0,0,False);
Modified: branches/SAMBA_3_0_24/source/smbd/reply.c
===================================================================
--- branches/SAMBA_3_0_24/source/smbd/reply.c 2007-01-12 23:47:16 UTC (rev 20718)
+++ branches/SAMBA_3_0_24/source/smbd/reply.c 2007-01-12 23:49:53 UTC (rev 20719)
@@ -3,7 +3,7 @@
Main SMB reply routines
Copyright (C) Andrew Tridgell 1992-1998
Copyright (C) Andrew Bartlett 2001
- Copyright (C) Jeremy Allison 1992-2004.
+ Copyright (C) Jeremy Allison 1992-2007.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -761,7 +761,6 @@
{
pstring fname;
int outsize = 0;
- BOOL ok=False;
int mode;
time_t mtime;
SMB_STRUCT_STAT sbuf;
@@ -794,6 +793,11 @@
return ERROR_NT(NT_STATUS_ACCESS_DENIED);
}
+ if (!check_name(fname,conn)) {
+ END_PROFILE(SMBsetatr);
+ return UNIXERROR(ERRDOS, ERRnoaccess);
+ }
+
mode = SVAL(inbuf,smb_vwv0);
mtime = srv_make_unix_date3(inbuf+smb_vwv1);
@@ -803,17 +807,13 @@
else
mode &= ~aDIR;
- if (check_name(fname,conn)) {
- ok = (file_set_dosmode(conn,fname,mode,&sbuf,False) == 0);
+ if (file_set_dosmode(conn,fname,mode,&sbuf,False) != 0) {
+ END_PROFILE(SMBsetatr);
+ return UNIXERROR(ERRDOS, ERRnoaccess);
}
- } else {
- ok = True;
}
- if (ok)
- ok = set_filetime(conn,fname,mtime);
-
- if (!ok) {
+ if (!set_filetime(conn,fname,mtime)) {
END_PROFILE(SMBsetatr);
return UNIXERROR(ERRDOS, ERRnoaccess);
}
@@ -4448,8 +4448,12 @@
Copy a file as part of a reply_copy.
******************************************************************/
-BOOL copy_file(char *src,char *dest1,connection_struct *conn, int ofun,
- int count,BOOL target_is_directory, int *err_ret)
+/*
+ * TODO: check error codes on all callers
+ */
+
+NTSTATUS copy_file(char *src, char *dest1,connection_struct *conn, int ofun,
+ int count, BOOL target_is_directory)
{
SMB_STRUCT_STAT src_sbuf, sbuf2;
SMB_OFF_T ret=-1;
@@ -4458,9 +4462,8 @@
uint32 dosattrs;
uint32 new_create_disposition;
NTSTATUS status;
+ int close_err;
- *err_ret = 0;
-
pstrcpy(dest,dest1);
if (target_is_directory) {
char *p = strrchr_m(src,'/');
@@ -4474,7 +4477,7 @@
}
if (!vfs_file_exist(conn,src,&src_sbuf)) {
- return(False);
+ return NT_STATUS_OBJECT_NAME_NOT_FOUND;
}
if (!target_is_directory && count) {
@@ -4482,7 +4485,7 @@
} else {
if (!map_open_params_to_ntcreate(dest1,0,ofun,
NULL, NULL, &new_create_disposition, NULL)) {
- return(False);
+ return NT_STATUS_INVALID_PARAMETER;
}
}
@@ -4496,7 +4499,7 @@
NULL, &fsp1);
if (!NT_STATUS_IS_OK(status)) {
- return(False);
+ return status;
}
dosattrs = dos_mode(conn, src, &src_sbuf);
@@ -4515,7 +4518,7 @@
if (!NT_STATUS_IS_OK(status)) {
close_file(fsp1,ERROR_CLOSE);
- return(False);
+ return status;
}
if ((ofun&3) == 1) {
@@ -4544,9 +4547,17 @@
* Thus we don't look at the error return from the
* close of fsp1.
*/
- *err_ret = close_file(fsp2,NORMAL_CLOSE);
+ close_err = close_file(fsp2,NORMAL_CLOSE);
- return(ret == (SMB_OFF_T)src_sbuf.st_size);
+ if (close_err != 0) {
+ return map_nt_error_from_unix(close_err);
+ }
+
+ if (ret != (SMB_OFF_T)src_sbuf.st_size) {
+ return NT_STATUS_DISK_FULL;
+ }
+
+ return NT_STATUS_OK;
}
/****************************************************************************
@@ -4659,13 +4670,14 @@
if (!has_wild) {
pstrcat(directory,"/");
pstrcat(directory,mask);
- if (resolve_wildcards(directory,newname) &&
- copy_file(directory,newname,conn,ofun, count,target_is_directory,&err))
+ if (resolve_wildcards(directory,newname)
+ && NT_STATUS_IS_OK(status = copy_file(
+ directory,newname,conn,ofun,
+ count,target_is_directory)))
count++;
- if(!count && err) {
- errno = err;
+ if(!count && !NT_STATUS_IS_OK(status)) {
END_PROFILE(SMBcopy);
- return(UNIXERROR(ERRHRD,ERRgeneral));
+ return ERROR_NT(status);
}
if (!count) {
exists = vfs_file_exist(conn,directory,NULL);
@@ -4698,9 +4710,10 @@
error = ERRnoaccess;
slprintf(fname,sizeof(fname)-1, "%s/%s",directory,dname);
pstrcpy(destname,newname);
- if (resolve_wildcards(fname,destname) &&
- copy_file(fname,destname,conn,ofun,
- count,target_is_directory,&err))
+ if (resolve_wildcards(fname,destname)
+ && NT_STATUS_IS_OK(status = copy_file(
+ fname,destname,conn,ofun,
+ count,target_is_directory)))
count++;
DEBUG(3,("reply_copy : doing copy on %s -> %s\n",fname,destname));
}
More information about the samba-cvs
mailing list