smberr.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. Unix SMB/Netbios implementation.
  3. Version 1.9.
  4. Copyright (C) Andrew Tridgell 1998
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. */
  17. #define NO_SYSLOG
  18. #include "includes.h"
  19. extern int DEBUGLEVEL;
  20. /* error code stuff - put together by Merik Karman
  21. merik@blackadder.dsh.oz.au */
  22. typedef struct
  23. {
  24. const char *name;
  25. int code;
  26. const char *message;
  27. } err_code_struct;
  28. /* Dos Error Messages */
  29. static err_code_struct const dos_msgs[] = {
  30. {"ERRbadfunc",1,"Invalid function."},
  31. {"ERRbadfile",2,"File not found."},
  32. {"ERRbadpath",3,"Directory invalid."},
  33. {"ERRnofids",4,"No file descriptors available"},
  34. {"ERRnoaccess",5,"Access denied."},
  35. {"ERRbadfid",6,"Invalid file handle."},
  36. {"ERRbadmcb",7,"Memory control blocks destroyed."},
  37. {"ERRnomem",8,"Insufficient server memory to perform the requested function."},
  38. {"ERRbadmem",9,"Invalid memory block address."},
  39. {"ERRbadenv",10,"Invalid environment."},
  40. {"ERRbadformat",11,"Invalid format."},
  41. {"ERRbadaccess",12,"Invalid open mode."},
  42. {"ERRbaddata",13,"Invalid data."},
  43. {"ERR",14,"reserved."},
  44. {"ERRbaddrive",15,"Invalid drive specified."},
  45. {"ERRremcd",16,"A Delete Directory request attempted to remove the server's current directory."},
  46. {"ERRdiffdevice",17,"Not same device."},
  47. {"ERRnofiles",18,"A File Search command can find no more files matching the specified criteria."},
  48. {"ERRbadshare",32,"The sharing mode specified for an Open conflicts with existing FIDs on the file."},
  49. {"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
  50. {"ERRunsup", 50, "The operation is unsupported"},
  51. {"ERRnosuchshare", 67, "You specified an invalid share name"},
  52. {"ERRfilexists",80,"The file named in a Create Directory, Make New File or Link request already exists."},
  53. {"ERRbadpipe",230,"Pipe invalid."},
  54. {"ERRpipebusy",231,"All instances of the requested pipe are busy."},
  55. {"ERRpipeclosing",232,"Pipe close in progress."},
  56. {"ERRnotconnected",233,"No process on other end of pipe."},
  57. {"ERRmoredata",234,"There is more data to be returned."},
  58. {"ERRinvgroup",2455,"Invalid workgroup (try the -W option)"},
  59. {NULL,-1,NULL}};
  60. /* Server Error Messages */
  61. static err_code_struct const server_msgs[] = {
  62. {"ERRerror",1,"Non-specific error code."},
  63. {"ERRbadpw",2,"Bad password - name/password pair in a Tree Connect or Session Setup are invalid."},
  64. {"ERRbadtype",3,"reserved."},
  65. {"ERRaccess",4,"The requester does not have the necessary access rights within the specified context for the requested function. The context is defined by the TID or the UID."},
  66. {"ERRinvnid",5,"The tree ID (TID) specified in a command was invalid."},
  67. {"ERRinvnetname",6,"Invalid network name in tree connect."},
  68. {"ERRinvdevice",7,"Invalid device - printer request made to non-printer connection or non-printer request made to printer connection."},
  69. {"ERRqfull",49,"Print queue full (files) -- returned by open print file."},
  70. {"ERRqtoobig",50,"Print queue full -- no space."},
  71. {"ERRqeof",51,"EOF on print queue dump."},
  72. {"ERRinvpfid",52,"Invalid print file FID."},
  73. {"ERRsmbcmd",64,"The server did not recognize the command received."},
  74. {"ERRsrverror",65,"The server encountered an internal error, e.g., system file unavailable."},
  75. {"ERRfilespecs",67,"The file handle (FID) and pathname parameters contained an invalid combination of values."},
  76. {"ERRreserved",68,"reserved."},
  77. {"ERRbadpermits",69,"The access permissions specified for a file or directory are not a valid combination. The server cannot set the requested attribute."},
  78. {"ERRreserved",70,"reserved."},
  79. {"ERRsetattrmode",71,"The attribute mode in the Set File Attribute request is invalid."},
  80. {"ERRpaused",81,"Server is paused."},
  81. {"ERRmsgoff",82,"Not receiving messages."},
  82. {"ERRnoroom",83,"No room to buffer message."},
  83. {"ERRrmuns",87,"Too many remote user names."},
  84. {"ERRtimeout",88,"Operation timed out."},
  85. {"ERRnoresource",89,"No resources currently available for request."},
  86. {"ERRtoomanyuids",90,"Too many UIDs active on this session."},
  87. {"ERRbaduid",91,"The UID is not known as a valid ID on this session."},
  88. {"ERRusempx",250,"Temp unable to support Raw, use MPX mode."},
  89. {"ERRusestd",251,"Temp unable to support Raw, use standard read/write."},
  90. {"ERRcontmpx",252,"Continue in MPX mode."},
  91. {"ERRreserved",253,"reserved."},
  92. {"ERRreserved",254,"reserved."},
  93. {"ERRnosupport",0xFFFF,"Function not supported."},
  94. {NULL,-1,NULL}};
  95. /* Hard Error Messages */
  96. static err_code_struct const hard_msgs[] = {
  97. {"ERRnowrite",19,"Attempt to write on write-protected diskette."},
  98. {"ERRbadunit",20,"Unknown unit."},
  99. {"ERRnotready",21,"Drive not ready."},
  100. {"ERRbadcmd",22,"Unknown command."},
  101. {"ERRdata",23,"Data error (CRC)."},
  102. {"ERRbadreq",24,"Bad request structure length."},
  103. {"ERRseek",25 ,"Seek error."},
  104. {"ERRbadmedia",26,"Unknown media type."},
  105. {"ERRbadsector",27,"Sector not found."},
  106. {"ERRnopaper",28,"Printer out of paper."},
  107. {"ERRwrite",29,"Write fault."},
  108. {"ERRread",30,"Read fault."},
  109. {"ERRgeneral",31,"General failure."},
  110. {"ERRbadshare",32,"An open conflicts with an existing open."},
  111. {"ERRlock",33,"A Lock request conflicted with an existing lock or specified an invalid mode, or an Unlock requested attempted to remove a lock held by another process."},
  112. {"ERRwrongdisk",34,"The wrong disk was found in a drive."},
  113. {"ERRFCBUnavail",35,"No FCBs are available to process request."},
  114. {"ERRsharebufexc",36,"A sharing buffer has been exceeded."},
  115. {NULL,-1,NULL}};
  116. struct
  117. {
  118. int code;
  119. const char *class;
  120. err_code_struct const *err_msgs;
  121. } const err_classes [] = {
  122. {0,"SUCCESS",NULL},
  123. {0x01,"ERRDOS",dos_msgs},
  124. {0x02,"ERRSRV",server_msgs},
  125. {0x03,"ERRHRD",hard_msgs},
  126. {0x04,"ERRXOS",NULL},
  127. {0xE1,"ERRRMX1",NULL},
  128. {0xE2,"ERRRMX2",NULL},
  129. {0xE3,"ERRRMX3",NULL},
  130. {0xFF,"ERRCMD",NULL},
  131. {-1,NULL,NULL}};
  132. /****************************************************************************
  133. return a SMB error string from a SMB buffer
  134. ****************************************************************************/
  135. char *smb_errstr(char *inbuf)
  136. {
  137. static pstring ret;
  138. int class = CVAL(inbuf,smb_rcls);
  139. int num = SVAL(inbuf,smb_err);
  140. int i,j;
  141. for (i=0;err_classes[i].class;i++)
  142. if (err_classes[i].code == class)
  143. {
  144. if (err_classes[i].err_msgs)
  145. {
  146. const err_code_struct *err = err_classes[i].err_msgs;
  147. for (j=0;err[j].name;j++)
  148. if (num == err[j].code)
  149. {
  150. if (DEBUGLEVEL > 0)
  151. slprintf(ret, sizeof(ret) - 1, "%s - %s (%s)",err_classes[i].class,
  152. err[j].name,err[j].message);
  153. else
  154. slprintf(ret, sizeof(ret) - 1, "%s - %s",err_classes[i].class,err[j].name);
  155. return ret;
  156. }
  157. }
  158. slprintf(ret, sizeof(ret) - 1, "%s - %d",err_classes[i].class,num);
  159. return ret;
  160. }
  161. slprintf(ret, sizeof(ret) - 1, "Error: Unknown error (%d,%d)",class,num);
  162. return(ret);
  163. }