310-remove_error_strings.patch 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. --- a/libcli/util/doserr.c
  2. +++ b/libcli/util/doserr.c
  3. @@ -28,6 +28,7 @@ struct werror_code_struct {
  4. static const struct werror_code_struct dos_errs[] =
  5. {
  6. +#ifdef VERBOSE_ERROR
  7. { "WERR_OK", WERR_OK },
  8. { "WERR_BADFILE", WERR_BADFILE },
  9. { "WERR_ACCESS_DENIED", WERR_ACCESS_DENIED },
  10. @@ -2668,6 +2669,7 @@ static const struct werror_code_struct d
  11. { "WERR_AMBIGUOUS_SYSTEM_DEVICE", WERR_AMBIGUOUS_SYSTEM_DEVICE },
  12. { "WERR_SYSTEM_DEVICE_NOT_FOUND", WERR_SYSTEM_DEVICE_NOT_FOUND },
  13. /* END GENERATED-WIN32-ERROR-CODES */
  14. +#endif
  15. { NULL, W_ERROR(0) }
  16. };
  17. @@ -2684,12 +2686,14 @@ const char *win_errstr(WERROR werror)
  18. static char msg[40];
  19. int idx = 0;
  20. +#ifdef VERBOSE_ERROR
  21. while (dos_errs[idx].dos_errstr != NULL) {
  22. if (W_ERROR_V(dos_errs[idx].werror) ==
  23. W_ERROR_V(werror))
  24. return dos_errs[idx].dos_errstr;
  25. idx++;
  26. }
  27. +#endif
  28. slprintf(msg, sizeof(msg), "DOS code 0x%08x", W_ERROR_V(werror));
  29. @@ -2702,6 +2706,7 @@ struct werror_str_struct {
  30. };
  31. const struct werror_str_struct dos_err_strs[] = {
  32. +#ifdef VERBOSE_ERROR
  33. { WERR_OK, "Success" },
  34. { WERR_ACCESS_DENIED, "Access is denied" },
  35. { WERR_INVALID_PARAM, "Invalid parameter" },
  36. @@ -5324,6 +5329,7 @@ const struct werror_str_struct dos_err_s
  37. { WERR_AMBIGUOUS_SYSTEM_DEVICE, "The requested system device cannot be identified due to multiple indistinguishable devices potentially matching the identification criteria." },
  38. { WERR_SYSTEM_DEVICE_NOT_FOUND, "The requested system device cannot be found." },
  39. /* END GENERATED-WIN32-ERROR-CODES-DESC */
  40. +#endif
  41. };
  42. @@ -5334,6 +5340,7 @@ const struct werror_str_struct dos_err_s
  43. const char *get_friendly_werror_msg(WERROR werror)
  44. {
  45. +#ifdef VERBOSE_ERROR
  46. int i = 0;
  47. for (i = 0; i < ARRAY_SIZE(dos_err_strs); i++) {
  48. @@ -5342,6 +5349,7 @@ const char *get_friendly_werror_msg(WERR
  49. return dos_err_strs[i].friendly_errstr;
  50. }
  51. }
  52. +#endif
  53. return win_errstr(werror);
  54. }
  55. --- a/librpc/ndr/libndr.h
  56. +++ b/librpc/ndr/libndr.h
  57. @@ -663,4 +663,20 @@ _PUBLIC_ enum ndr_err_code ndr_push_enum
  58. _PUBLIC_ void ndr_print_bool(struct ndr_print *ndr, const char *name, const bool b);
  59. +#ifndef VERBOSE_ERROR
  60. +#define ndr_print_bool(...) do {} while (0)
  61. +#define ndr_print_struct(...) do {} while (0)
  62. +#define ndr_print_null(...) do {} while (0)
  63. +#define ndr_print_enum(...) do {} while (0)
  64. +#define ndr_print_bitmap_flag(...) do {} while (0)
  65. +#define ndr_print_ptr(...) do {} while (0)
  66. +#define ndr_print_union(...) do {} while (0)
  67. +#define ndr_print_bad_level(...) do {} while (0)
  68. +#define ndr_print_array_uint8(...) do {} while (0)
  69. +#define ndr_print_string_array(...) do {} while (0)
  70. +#define ndr_print_string_array(...) do {} while (0)
  71. +#define ndr_print_NTSTATUS(...) do {} while (0)
  72. +#define ndr_print_WERROR(...) do {} while (0)
  73. +#endif
  74. +
  75. #endif /* __LIBNDR_H__ */
  76. --- a/librpc/ndr/ndr_basic.c
  77. +++ b/librpc/ndr/ndr_basic.c
  78. @@ -31,6 +31,19 @@
  79. #define NDR_SIVAL(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVAL(ndr->data,ofs,v); } else SIVAL(ndr->data,ofs,v); } while (0)
  80. #define NDR_SIVALS(ndr, ofs, v) do { if (NDR_BE(ndr)) { RSIVALS(ndr->data,ofs,v); } else SIVALS(ndr->data,ofs,v); } while (0)
  81. +#undef ndr_print_bool
  82. +#undef ndr_print_struct
  83. +#undef ndr_print_null
  84. +#undef ndr_print_enum
  85. +#undef ndr_print_bitmap_flag
  86. +#undef ndr_print_ptr
  87. +#undef ndr_print_union
  88. +#undef ndr_print_bad_level
  89. +#undef ndr_print_array_uint8
  90. +#undef ndr_print_string_array
  91. +#undef ndr_print_string_array
  92. +#undef ndr_print_NTSTATUS
  93. +#undef ndr_print_WERROR
  94. /*
  95. check for data leaks from the server by looking for non-zero pad bytes
  96. --- a/librpc/ndr/ndr_string.c
  97. +++ b/librpc/ndr/ndr_string.c
  98. @@ -588,6 +588,7 @@ _PUBLIC_ enum ndr_err_code ndr_push_stri
  99. return NDR_ERR_SUCCESS;
  100. }
  101. +#undef ndr_print_string_array
  102. _PUBLIC_ void ndr_print_string_array(struct ndr_print *ndr, const char *name, const char **a)
  103. {
  104. uint32_t count;
  105. --- a/librpc/rpc/dcerpc_error.c
  106. +++ b/librpc/rpc/dcerpc_error.c
  107. @@ -31,6 +31,7 @@ struct dcerpc_fault_table {
  108. static const struct dcerpc_fault_table dcerpc_faults[] =
  109. {
  110. #define _FAULT_STR(x) { #x , x }
  111. +#ifdef VERBOSE_ERROR
  112. _FAULT_STR(DCERPC_NCA_S_COMM_FAILURE),
  113. _FAULT_STR(DCERPC_NCA_S_OP_RNG_ERROR),
  114. _FAULT_STR(DCERPC_NCA_S_UNKNOWN_IF),
  115. @@ -78,6 +79,7 @@ static const struct dcerpc_fault_table d
  116. _FAULT_STR(DCERPC_NCA_S_FAULT_CODESET_CONV_ERROR),
  117. _FAULT_STR(DCERPC_NCA_S_FAULT_OBJECT_NOT_FOUND),
  118. _FAULT_STR(DCERPC_NCA_S_FAULT_NO_CLIENT_STUB),
  119. +#endif
  120. { NULL, 0 }
  121. #undef _FAULT_STR
  122. };
  123. @@ -87,12 +89,14 @@ _PUBLIC_ const char *dcerpc_errstr(TALLO
  124. int idx = 0;
  125. WERROR werr = W_ERROR(fault_code);
  126. +#ifdef VERBOSE_ERROR
  127. while (dcerpc_faults[idx].errstr != NULL) {
  128. if (dcerpc_faults[idx].faultcode == fault_code) {
  129. return dcerpc_faults[idx].errstr;
  130. }
  131. idx++;
  132. }
  133. +#endif
  134. return win_errstr(werr);
  135. }
  136. --- a/source3/libsmb/nterr.c
  137. +++ b/source3/libsmb/nterr.c
  138. @@ -702,6 +702,7 @@ const char *nt_errstr(NTSTATUS nt_code)
  139. NT_STATUS_DOS_CODE(nt_code));
  140. }
  141. +#ifdef VERBOSE_ERROR
  142. while (nt_errs[idx].nt_errstr != NULL) {
  143. if (NT_STATUS_V(nt_errs[idx].nt_errcode) ==
  144. NT_STATUS_V(nt_code)) {
  145. @@ -709,6 +710,7 @@ const char *nt_errstr(NTSTATUS nt_code)
  146. }
  147. idx++;
  148. }
  149. +#endif
  150. result = talloc_asprintf(talloc_tos(), "NT code 0x%08x",
  151. NT_STATUS_V(nt_code));
  152. @@ -724,12 +726,14 @@ const char *get_friendly_nt_error_msg(NT
  153. {
  154. int idx = 0;
  155. +#ifdef VERBOSE_ERROR
  156. while (nt_err_desc[idx].nt_errstr != NULL) {
  157. if (NT_STATUS_V(nt_err_desc[idx].nt_errcode) == NT_STATUS_V(nt_code)) {
  158. return nt_err_desc[idx].nt_errstr;
  159. }
  160. idx++;
  161. }
  162. +#endif
  163. /* fall back to NT_STATUS_XXX string */
  164. @@ -745,6 +749,7 @@ const char *get_nt_error_c_code(NTSTATUS
  165. char *result;
  166. int idx = 0;
  167. +#ifdef VERBOSE_ERROR
  168. while (nt_errs[idx].nt_errstr != NULL) {
  169. if (NT_STATUS_V(nt_errs[idx].nt_errcode) ==
  170. NT_STATUS_V(nt_code)) {
  171. @@ -752,6 +757,7 @@ const char *get_nt_error_c_code(NTSTATUS
  172. }
  173. idx++;
  174. }
  175. +#endif
  176. result = talloc_asprintf(talloc_tos(), "NT_STATUS(0x%08x)",
  177. NT_STATUS_V(nt_code));
  178. @@ -767,12 +773,14 @@ NTSTATUS nt_status_string_to_code(const
  179. {
  180. int idx = 0;
  181. +#ifdef VERBOSE_ERROR
  182. while (nt_errs[idx].nt_errstr != NULL) {
  183. if (strcasecmp(nt_errs[idx].nt_errstr, nt_status_str) == 0) {
  184. return nt_errs[idx].nt_errcode;
  185. }
  186. idx++;
  187. }
  188. +#endif
  189. return NT_STATUS_UNSUCCESSFUL;
  190. }
  191. --- a/lib/tdb/common/tdb_private.h
  192. +++ b/lib/tdb/common/tdb_private.h
  193. @@ -69,7 +69,11 @@ typedef uint32_t tdb_off_t;
  194. /* NB assumes there is a local variable called "tdb" that is the
  195. * current context, also takes doubly-parenthesized print-style
  196. * argument. */
  197. +#ifdef VERBOSE_DEBUG
  198. #define TDB_LOG(x) tdb->log.log_fn x
  199. +#else
  200. +#define TDB_LOG(x) do {} while(0)
  201. +#endif
  202. #ifdef TDB_TRACE
  203. void tdb_trace(struct tdb_context *tdb, const char *op);
  204. --- a/source3/script/mkbuildoptions.awk
  205. +++ b/source3/script/mkbuildoptions.awk
  206. @@ -55,7 +55,7 @@ BEGIN {
  207. print "****************************************************************************/";
  208. print "void build_options(bool screen)";
  209. print "{";
  210. - print " if ((DEBUGLEVEL < 4) && (!screen)) {";
  211. + print " if ((DEBUGLEVEL < 4) || (!screen)) {";
  212. print " return;";
  213. print " }";
  214. print "";
  215. --- a/source3/script/mkbuildoptions-waf.awk
  216. +++ b/source3/script/mkbuildoptions-waf.awk
  217. @@ -55,7 +55,7 @@ BEGIN {
  218. print "****************************************************************************/";
  219. print "void build_options(bool screen)";
  220. print "{";
  221. - print " if ((DEBUGLEVEL < 4) && (!screen)) {";
  222. + print " if ((DEBUGLEVEL < 4) || (!screen)) {";
  223. print " return;";
  224. print " }";
  225. print "";
  226. --- a/source3/rpc_client/cli_pipe.c
  227. +++ b/source3/rpc_client/cli_pipe.c
  228. @@ -445,7 +445,6 @@ static NTSTATUS cli_pipe_validate_curren
  229. rpccli_pipe_txt(talloc_tos(), cli),
  230. pkt->ptype, expected_pkt_type,
  231. nt_errstr(ret)));
  232. - NDR_PRINT_DEBUG(ncacn_packet, pkt);
  233. return ret;
  234. }
  235. @@ -466,7 +465,6 @@ static NTSTATUS cli_pipe_validate_curren
  236. rpccli_pipe_txt(talloc_tos(), cli),
  237. pkt->ptype, expected_pkt_type,
  238. nt_errstr(ret)));
  239. - NDR_PRINT_DEBUG(ncacn_packet, pkt);
  240. return ret;
  241. }
  242. @@ -486,7 +484,6 @@ static NTSTATUS cli_pipe_validate_curren
  243. rpccli_pipe_txt(talloc_tos(), cli),
  244. pkt->ptype, expected_pkt_type,
  245. nt_errstr(ret)));
  246. - NDR_PRINT_DEBUG(ncacn_packet, pkt);
  247. return ret;
  248. }
  249. @@ -508,7 +505,6 @@ static NTSTATUS cli_pipe_validate_curren
  250. rpccli_pipe_txt(talloc_tos(), cli),
  251. pkt->ptype, expected_pkt_type,
  252. nt_errstr(ret)));
  253. - NDR_PRINT_DEBUG(ncacn_packet, pkt);
  254. return ret;
  255. }
  256. @@ -526,7 +522,6 @@ static NTSTATUS cli_pipe_validate_curren
  257. rpccli_pipe_txt(talloc_tos(), cli),
  258. pkt->ptype, expected_pkt_type,
  259. nt_errstr(ret)));
  260. - NDR_PRINT_DEBUG(ncacn_packet, pkt);
  261. return ret;
  262. }
  263. @@ -570,7 +565,6 @@ static NTSTATUS cli_pipe_validate_curren
  264. rpccli_pipe_txt(talloc_tos(), cli),
  265. pkt->ptype, expected_pkt_type,
  266. nt_errstr(ret)));
  267. - NDR_PRINT_DEBUG(ncacn_packet, pkt);
  268. return ret;
  269. }
  270. --- a/source3/rpc_server/srv_pipe.c
  271. +++ b/source3/rpc_server/srv_pipe.c
  272. @@ -996,7 +996,6 @@ static bool api_pipe_bind_req(struct pip
  273. if (!NT_STATUS_IS_OK(status)) {
  274. DEBUG(1, ("api_pipe_bind_req: invalid pdu: %s\n",
  275. nt_errstr(status)));
  276. - NDR_PRINT_DEBUG(ncacn_packet, pkt);
  277. goto err_exit;
  278. }
  279. @@ -1330,7 +1329,6 @@ bool api_pipe_bind_auth3(struct pipes_st
  280. if (!NT_STATUS_IS_OK(status)) {
  281. DEBUG(1, ("api_pipe_bind_auth3: invalid pdu: %s\n",
  282. nt_errstr(status)));
  283. - NDR_PRINT_DEBUG(ncacn_packet, pkt);
  284. goto err;
  285. }
  286. @@ -1488,7 +1486,6 @@ static bool api_pipe_alter_context(struc
  287. if (!NT_STATUS_IS_OK(status)) {
  288. DEBUG(1, ("api_pipe_alter_context: invalid pdu: %s\n",
  289. nt_errstr(status)));
  290. - NDR_PRINT_DEBUG(ncacn_packet, pkt);
  291. goto err_exit;
  292. }
  293. @@ -2062,7 +2059,6 @@ static bool process_request_pdu(struct p
  294. if (!NT_STATUS_IS_OK(status)) {
  295. DEBUG(1, ("process_request_pdu: invalid pdu: %s\n",
  296. nt_errstr(status)));
  297. - NDR_PRINT_DEBUG(ncacn_packet, pkt);
  298. set_incoming_fault(p);
  299. return false;
  300. }