summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2007-07-30 10:23:26 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:29:02 -0500
commit4392d47b34720d2dcd8ee47bd14a71bf1eab2c86 (patch)
tree2087732a93398dea7efe2b0de2cef090151a5524 /source3
parent09b3d2525249fd832b7d46a19921a87a13b71407 (diff)
downloadsamba-4392d47b34720d2dcd8ee47bd14a71bf1eab2c86.tar.gz
samba-4392d47b34720d2dcd8ee47bd14a71bf1eab2c86.tar.bz2
samba-4392d47b34720d2dcd8ee47bd14a71bf1eab2c86.zip
r24078: Add reply_unixerror
(This used to be commit 10ac991750e9476299d39ac6f763d1638ff8c619)
Diffstat (limited to 'source3')
-rw-r--r--source3/include/smb_macros.h1
-rw-r--r--source3/smbd/error.c30
2 files changed, 31 insertions, 0 deletions
diff --git a/source3/include/smb_macros.h b/source3/include/smb_macros.h
index a47eff2f64..15789a938a 100644
--- a/source3/include/smb_macros.h
+++ b/source3/include/smb_macros.h
@@ -172,6 +172,7 @@
#define reply_nterror(req,status) reply_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__)
/* this is how errors are generated */
#define UNIXERROR(defclass,deferror) unix_error_packet(inbuf,outbuf,defclass,deferror,NT_STATUS_OK,__LINE__,__FILE__)
diff --git a/source3/smbd/error.c b/source3/smbd/error.c
index d00c61487a..023e1b7dcc 100644
--- a/source3/smbd/error.c
+++ b/source3/smbd/error.c
@@ -157,3 +157,33 @@ void reply_both_error(struct smb_request *req, uint8 eclass, uint32 ecode,
error_packet_set((char *)req->outbuf, eclass, ecode, status,
line, file);
}
+
+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);
+}