summaryrefslogtreecommitdiffstats
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2009-07-10 18:23:00 -0700
committerJeremy Allison <jra@samba.org>2009-07-10 18:23:00 -0700
commit2000421c592b672898f85758638be74d8485da1e (patch)
tree9bd5f3a3ad130d855bf2233d39cbbe6c2edf7f95 /source3
parent361aa19e69d4176dd8c30f485cc637cd33308d62 (diff)
downloadsamba-2000421c592b672898f85758638be74d8485da1e.tar.gz
samba-2000421c592b672898f85758638be74d8485da1e.tar.xz
samba-2000421c592b672898f85758638be74d8485da1e.zip
Remove reply_unixerror() - no longer needed. Should make Metze's refactoring a lot easier.
Jeremy.
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/include/smb_macros.h1
-rw-r--r--source3/smbd/error.c30
-rw-r--r--source3/smbd/fileio.c1
-rw-r--r--source3/smbd/pipes.c23
-rw-r--r--source3/smbd/reply.c72
-rw-r--r--source3/smbd/trans2.c37
7 files changed, 79 insertions, 87 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c0f4dc10d87..27b5f45eb07 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -6260,8 +6260,6 @@ void reply_dos_error(struct smb_request *req, uint8 eclass, uint32 ecode,
void reply_both_error(struct smb_request *req, uint8 eclass, uint32 ecode,
NTSTATUS status, int line, const char *file);
void reply_openerror(struct smb_request *req, NTSTATUS status);
-void reply_unix_error(struct smb_request *req, uint8 defclass, uint32 defcode,
- NTSTATUS defstatus, int line, const char *file);
/* The following definitions come from smbd/fake_file.c */
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index 7528883c2d9..10ee78b3943 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -115,7 +115,6 @@
#define reply_force_nterror(req,status) reply_force_nt_error(req,status,__LINE__,__FILE__)
#define reply_doserror(req,eclass,ecode) reply_dos_error(req,eclass,ecode,__LINE__,__FILE__)
#define reply_botherror(req,status,eclass,ecode) reply_both_error(req,eclass,ecode,status,__LINE__,__FILE__)
-#define reply_unixerror(req,defclass,deferror) reply_unix_error(req,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__)
#if 0
/* defined in IDL */
diff --git a/source3/smbd/error.c b/source3/smbd/error.c
index ce22f86414b..874efa2a0b3 100644
--- a/source3/smbd/error.c
+++ b/source3/smbd/error.c
@@ -136,33 +136,3 @@ void reply_openerror(struct smb_request *req, NTSTATUS status)
reply_nterror(req, status);
}
}
-
-void reply_unix_error(struct smb_request *req, uint8 defclass, uint32 defcode,
- NTSTATUS defstatus, int line, const char *file)
-{
- int eclass=defclass;
- int ecode=defcode;
- NTSTATUS ntstatus = defstatus;
- int i=0;
-
- TALLOC_FREE(req->outbuf);
- reply_outbuf(req, 0, 0);
-
- if (errno != 0) {
- DEBUG(3,("unix_error_packet: error string = %s\n",
- strerror(errno)));
-
- while (unix_dos_nt_errmap[i].dos_class != 0) {
- if (unix_dos_nt_errmap[i].unix_error == errno) {
- eclass = unix_dos_nt_errmap[i].dos_class;
- ecode = unix_dos_nt_errmap[i].dos_code;
- ntstatus = unix_dos_nt_errmap[i].nt_error;
- break;
- }
- i++;
- }
- }
-
- error_packet_set((char *)req->outbuf, eclass, ecode, ntstatus,
- line, file);
-}
diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c
index 0c13b845df8..60cef09b3ba 100644
--- a/source3/smbd/fileio.c
+++ b/source3/smbd/fileio.c
@@ -57,6 +57,7 @@ ssize_t read_file(files_struct *fsp,char *data,SMB_OFF_T pos,size_t n)
/* you can't read from print files */
if (fsp->print_file) {
+ errno = EBADF;
return -1;
}
diff --git a/source3/smbd/pipes.c b/source3/smbd/pipes.c
index 7ae74356462..799568d0d5d 100644
--- a/source3/smbd/pipes.c
+++ b/source3/smbd/pipes.c
@@ -203,8 +203,14 @@ static void pipe_write_done(struct tevent_req *subreq)
status = np_write_recv(subreq, &nwritten);
TALLOC_FREE(subreq);
- if ((nwritten == 0 && state->numtowrite != 0) || (nwritten < 0)) {
- reply_unixerror(req, ERRDOS, ERRnoaccess);
+ if (nwritten < 0) {
+ reply_nterror(req, status);
+ goto send;
+ }
+
+ /* Looks bogus to me now. Needs to be removed ? JRA. */
+ if ((nwritten == 0 && state->numtowrite != 0)) {
+ reply_doserror(req, ERRDOS, ERRnoaccess);
goto send;
}
@@ -283,7 +289,7 @@ void reply_pipe_write_and_X(struct smb_request *req)
DEBUG(0,("reply_pipe_write_and_X: start of message "
"set and not enough data sent.(%u)\n",
(unsigned int)state->numtowrite ));
- reply_unixerror(req, ERRDOS, ERRnoaccess);
+ reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
return;
}
@@ -313,8 +319,15 @@ static void pipe_write_andx_done(struct tevent_req *subreq)
status = np_write_recv(subreq, &nwritten);
TALLOC_FREE(subreq);
- if (!NT_STATUS_IS_OK(status) || (nwritten != state->numtowrite)) {
- reply_unixerror(req, ERRDOS,ERRnoaccess);
+
+ if (!NT_STATUS_IS_OK(status)) {
+ reply_nterror(req, status);
+ goto done;
+ }
+
+ /* Looks bogus to me now. Is this error message correct ? JRA. */
+ if (nwritten != state->numtowrite) {
+ reply_doserror(req, ERRDOS,ERRnoaccess);
goto done;
}
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 98ee83ea832..e35c5bc6d62 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1106,7 +1106,7 @@ void reply_getatr(struct smb_request *req)
DEBUG(3,("reply_getatr: stat of %s failed (%s)\n",
smb_fname_str_dbg(smb_fname),
strerror(errno)));
- reply_unixerror(req, ERRDOS,ERRbadfile);
+ reply_nterror(req, map_nt_error_from_unix(errno));
goto out;
}
@@ -1220,7 +1220,7 @@ void reply_setatr(struct smb_request *req)
ft.mtime = convert_time_t_to_timespec(mtime);
status = smb_set_file_time(conn, NULL, smb_fname, &ft, true);
if (!NT_STATUS_IS_OK(status)) {
- reply_unixerror(req, ERRDOS, ERRnoaccess);
+ reply_nterror(req, status);
goto out;
}
@@ -1232,7 +1232,7 @@ void reply_setatr(struct smb_request *req)
if (file_set_dosmode(conn, smb_fname, mode, NULL,
false) != 0) {
- reply_unixerror(req, ERRDOS, ERRnoaccess);
+ reply_nterror(req, map_nt_error_from_unix(errno));
goto out;
}
}
@@ -1258,7 +1258,7 @@ void reply_dskattr(struct smb_request *req)
START_PROFILE(SMBdskattr);
if (get_dfree_info(conn,".",True,&bsize,&dfree,&dsize) == (uint64_t)-1) {
- reply_unixerror(req, ERRHRD, ERRgeneral);
+ reply_nterror(req, map_nt_error_from_unix(errno));
END_PROFILE(SMBdskattr);
return;
}
@@ -2271,7 +2271,7 @@ void reply_ctemp(struct smb_request *req)
tmpfd = mkstemp(smb_fname->base_name);
if (tmpfd == -1) {
- reply_unixerror(req, ERRDOS, ERRnoaccess);
+ reply_nterror(req, map_nt_error_from_unix(errno));
goto out;
}
@@ -3269,7 +3269,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
nread = read_file(fsp,data,startpos,numtoread);
if (nread < 0) {
- reply_unixerror(req, ERRDOS, ERRnoaccess);
+ reply_nterror(req, map_nt_error_from_unix(errno));
END_PROFILE(SMBlockread);
return;
}
@@ -3363,7 +3363,7 @@ Returning short read of maximum allowed for compatibility with Windows 2000.\n",
nread = read_file(fsp,data,startpos,numtoread);
if (nread < 0) {
- reply_unixerror(req, ERRDOS,ERRnoaccess);
+ reply_nterror(req, map_nt_error_from_unix(errno));
goto strict_unlock;
}
@@ -3425,9 +3425,10 @@ static void send_file_readX(connection_struct *conn, struct smb_request *req,
SMB_STRUCT_STAT sbuf;
ssize_t nread = -1;
struct lock_struct lock;
+ int saved_errno = 0;
if(SMB_VFS_FSTAT(fsp, &sbuf) == -1) {
- reply_unixerror(req, ERRDOS, ERRnoaccess);
+ reply_nterror(req, map_nt_error_from_unix(errno));
return;
}
@@ -3565,11 +3566,12 @@ nosendfile_read:
reply_outbuf(req, 12, smb_maxcnt);
nread = read_file(fsp, smb_buf(req->outbuf), startpos, smb_maxcnt);
+ saved_errno = errno;
SMB_VFS_STRICT_UNLOCK(conn, fsp, &lock);
if (nread < 0) {
- reply_unixerror(req, ERRDOS, ERRnoaccess);
+ reply_nterror(req, map_nt_error_from_unix(saved_errno));
return;
}
@@ -3810,7 +3812,7 @@ void reply_writebraw(struct smb_request *req)
(int)nwritten, (int)write_through));
if (nwritten < (ssize_t)numtowrite) {
- reply_unixerror(req, ERRHRD, ERRdiskfull);
+ reply_doserror(req, ERRHRD, ERRdiskfull);
error_to_writebrawerr(req);
goto strict_unlock;
}
@@ -3879,7 +3881,7 @@ void reply_writebraw(struct smb_request *req)
nwritten = write_file(req,fsp,buf+4,startpos+nwritten,numtowrite);
if (nwritten == -1) {
TALLOC_FREE(buf);
- reply_unixerror(req, ERRHRD, ERRdiskfull);
+ reply_nterror(req, map_nt_error_from_unix(errno));
error_to_writebrawerr(req);
goto strict_unlock;
}
@@ -3958,6 +3960,7 @@ void reply_writeunlock(struct smb_request *req)
NTSTATUS status = NT_STATUS_OK;
files_struct *fsp;
struct lock_struct lock;
+ int saved_errno = 0;
START_PROFILE(SMBwriteunlock);
@@ -4003,6 +4006,7 @@ void reply_writeunlock(struct smb_request *req)
nwritten = 0;
} else {
nwritten = write_file(req,fsp,data,startpos,numtowrite);
+ saved_errno = errno;
}
status = sync_file(conn, fsp, False /* write through */);
@@ -4013,8 +4017,13 @@ void reply_writeunlock(struct smb_request *req)
goto strict_unlock;
}
- if(((nwritten < numtowrite) && (numtowrite != 0))||(nwritten < 0)) {
- reply_unixerror(req, ERRHRD, ERRdiskfull);
+ if(nwritten < 0) {
+ reply_nterror(req, map_nt_error_from_unix(saved_errno));
+ goto strict_unlock;
+ }
+
+ if((nwritten < numtowrite) && (numtowrite != 0)) {
+ reply_doserror(req, ERRHRD, ERRdiskfull);
goto strict_unlock;
}
@@ -4065,6 +4074,7 @@ void reply_write(struct smb_request *req)
files_struct *fsp;
struct lock_struct lock;
NTSTATUS status;
+ int saved_errno = 0;
START_PROFILE(SMBwrite);
@@ -4141,8 +4151,13 @@ void reply_write(struct smb_request *req)
goto strict_unlock;
}
- if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0)) {
- reply_unixerror(req, ERRHRD, ERRdiskfull);
+ if(nwritten < 0) {
+ reply_nterror(req, map_nt_error_from_unix(saved_errno));
+ goto strict_unlock;
+ }
+
+ if((nwritten == 0) && (numtowrite != 0)) {
+ reply_doserror(req, ERRHRD, ERRdiskfull);
goto strict_unlock;
}
@@ -4389,8 +4404,13 @@ void reply_write_and_X(struct smb_request *req)
nwritten = write_file(req,fsp,data,startpos,numtowrite);
}
- if(((nwritten == 0) && (numtowrite != 0))||(nwritten < 0)) {
- reply_unixerror(req, ERRHRD, ERRdiskfull);
+ if(nwritten < 0) {
+ reply_nterror(req, map_nt_error_from_unix(errno));
+ goto strict_unlock;
+ }
+
+ if((nwritten == 0) && (numtowrite != 0)) {
+ reply_doserror(req, ERRHRD, ERRdiskfull);
goto strict_unlock;
}
@@ -4484,8 +4504,8 @@ void reply_lseek(struct smb_request *req)
SMB_STRUCT_STAT sbuf;
if(SMB_VFS_FSTAT(fsp, &sbuf) == -1) {
- reply_unixerror(req, ERRDOS,
- ERRnoaccess);
+ reply_nterror(req,
+ map_nt_error_from_unix(errno));
END_PROFILE(SMBlseek);
return;
}
@@ -4497,7 +4517,7 @@ void reply_lseek(struct smb_request *req)
}
if(res == -1) {
- reply_unixerror(req, ERRDOS, ERRnoaccess);
+ reply_nterror(req, map_nt_error_from_unix(errno));
END_PROFILE(SMBlseek);
return;
}
@@ -5197,7 +5217,7 @@ void reply_printwrite(struct smb_request *req)
data = (const char *)req->buf + 3;
if (write_file(req,fsp,data,-1,numtowrite) != numtowrite) {
- reply_unixerror(req, ERRHRD, ERRdiskfull);
+ reply_nterror(req, map_nt_error_from_unix(errno));
END_PROFILE(SMBsplwr);
return;
}
@@ -6756,7 +6776,6 @@ void reply_copy(struct smb_request *req)
const char *p;
int count=0;
int error = ERRnoaccess;
- int err = 0;
int tid2;
int ofun;
int flags;
@@ -7059,13 +7078,6 @@ void reply_copy(struct smb_request *req)
}
if (count == 0) {
- if(err) {
- /* Error on close... */
- errno = err;
- reply_unixerror(req, ERRHRD, ERRgeneral);
- goto out;
- }
-
reply_doserror(req, ERRDOS, error);
goto out;
}
@@ -7833,7 +7845,7 @@ void reply_getattrE(struct smb_request *req)
/* Do an fstat on this file */
if(fsp_stat(fsp, &sbuf)) {
- reply_unixerror(req, ERRDOS, ERRnoaccess);
+ reply_nterror(req, map_nt_error_from_unix(errno));
END_PROFILE(SMBgetattrE);
return;
}
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index 4bf27863bde..6a18f0f7102 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -2697,7 +2697,7 @@ static void call_trans2qfsinfo(connection_struct *conn,
uint64_t dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
data_len = 18;
if (get_dfree_info(conn,".",False,&bsize,&dfree,&dsize) == (uint64_t)-1) {
- reply_unixerror(req, ERRHRD, ERRgeneral);
+ reply_nterror(req, map_nt_error_from_unix(errno));
return;
}
@@ -2818,7 +2818,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)st.st_ex_dev, (u
uint64_t dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
data_len = 24;
if (get_dfree_info(conn,".",False,&bsize,&dfree,&dsize) == (uint64_t)-1) {
- reply_unixerror(req, ERRHRD, ERRgeneral);
+ reply_nterror(req, map_nt_error_from_unix(errno));
return;
}
block_size = lp_block_size(snum);
@@ -2851,7 +2851,7 @@ cBytesSector=%u, cUnitTotal=%u, cUnitAvail=%d\n", (unsigned int)bsize, (unsigned
uint64_t dfree,dsize,bsize,block_size,sectors_per_unit,bytes_per_sector;
data_len = 32;
if (get_dfree_info(conn,".",False,&bsize,&dfree,&dsize) == (uint64_t)-1) {
- reply_unixerror(req, ERRHRD, ERRgeneral);
+ reply_nterror(req, map_nt_error_from_unix(errno));
return;
}
block_size = lp_block_size(snum);
@@ -3992,7 +3992,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
"(%s)\n",
smb_fname_str_dbg(smb_fname),
strerror(errno)));
- reply_unixerror(req,ERRDOS,ERRbadpath);
+ reply_nterror(req,map_nt_error_from_unix(errno));
return;
}
} else if (SMB_VFS_STAT(conn, smb_fname)) {
@@ -4000,7 +4000,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
"SMB_VFS_STAT of %s failed (%s)\n",
smb_fname_str_dbg(smb_fname),
strerror(errno)));
- reply_unixerror(req, ERRDOS, ERRbadpath);
+ reply_nterror(req, map_nt_error_from_unix(errno));
return;
}
@@ -4017,7 +4017,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
if (SMB_VFS_FSTAT(fsp, &smb_fname->st) != 0) {
DEBUG(3, ("fstat of fnum %d failed (%s)\n",
fsp->fnum, strerror(errno)));
- reply_unixerror(req, ERRDOS, ERRbadfid);
+ reply_nterror(req, map_nt_error_from_unix(errno));
return;
}
pos = fsp->fh->position_information;
@@ -4090,8 +4090,8 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
"(%s)\n",
smb_fname_str_dbg(smb_fname_base),
strerror(errno)));
+ reply_nterror(req,map_nt_error_from_unix(errno));
TALLOC_FREE(smb_fname_base);
- reply_unixerror(req,ERRDOS,ERRbadpath);
return;
}
} else {
@@ -4101,8 +4101,8 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
"(%s)\n",
smb_fname_str_dbg(smb_fname_base),
strerror(errno)));
+ reply_nterror(req,map_nt_error_from_unix(errno));
TALLOC_FREE(smb_fname_base);
- reply_unixerror(req,ERRDOS,ERRbadpath);
return;
}
}
@@ -4124,7 +4124,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
"SMB_VFS_LSTAT of %s failed (%s)\n",
smb_fname_str_dbg(smb_fname),
strerror(errno)));
- reply_unixerror(req, ERRDOS, ERRbadpath);
+ reply_nterror(req,map_nt_error_from_unix(errno));
return;
}
@@ -4139,7 +4139,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
"SMB_VFS_STAT of %s failed (%s)\n",
smb_fname_str_dbg(smb_fname),
strerror(errno)));
- reply_unixerror(req, ERRDOS, ERRbadpath);
+ reply_nterror(req,map_nt_error_from_unix(errno));
return;
}
}
@@ -4700,19 +4700,18 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
DEBUG(10,("call_trans2qfilepathinfo: SMB_QUERY_FILE_UNIX_LINK\n"));
#ifdef S_ISLNK
if(!S_ISLNK(sbuf.st_ex_mode)) {
- reply_unixerror(req, ERRSRV,
+ reply_doserror(req, ERRSRV,
ERRbadlink);
return;
}
#else
- reply_unixerror(req, ERRDOS, ERRbadlink);
+ reply_doserror(req, ERRDOS, ERRbadlink);
return;
#endif
len = SMB_VFS_READLINK(conn,fullpathname,
buffer, PATH_MAX);
if (len == -1) {
- reply_unixerror(req, ERRDOS,
- ERRnoaccess);
+ reply_nterror(req, map_nt_error_from_unix(errno));
return;
}
buffer[len] = 0;
@@ -6934,7 +6933,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
"(%s)\n",
smb_fname_str_dbg(smb_fname),
strerror(errno)));
- reply_unixerror(req,ERRDOS,ERRbadpath);
+ reply_nterror(req, map_nt_error_from_unix(errno));
return;
}
} else {
@@ -6943,7 +6942,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
"fileinfo of %s failed (%s)\n",
smb_fname_str_dbg(smb_fname),
strerror(errno)));
- reply_unixerror(req,ERRDOS,ERRbadpath);
+ reply_nterror(req, map_nt_error_from_unix(errno));
return;
}
}
@@ -6962,7 +6961,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
max_data_bytes);
return;
} else {
- reply_unixerror(req, ERRDOS, ERRbadpath);
+ reply_doserror(req, ERRDOS, ERRbadpath);
return;
}
} else {
@@ -6977,7 +6976,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
DEBUG(3,("call_trans2setfilepathinfo: fstat "
"of fnum %d failed (%s)\n", fsp->fnum,
strerror(errno)));
- reply_unixerror(req, ERRDOS, ERRbadfid);
+ reply_nterror(req, map_nt_error_from_unix(errno));
return;
}
}
@@ -7027,7 +7026,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
"%s failed (%s)\n",
smb_fname_str_dbg(smb_fname),
strerror(errno)));
- reply_unixerror(req, ERRDOS, ERRbadpath);
+ reply_nterror(req, map_nt_error_from_unix(errno));
return;
}
}