From: Joseph Sutton Date: Fri, 26 May 2023 03:14:22 +0000 (+1200) Subject: s4/scripting/bin: Add NT_STATUS_OK to list of definitions X-Git-Tag: talloc-2.4.1~392 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=efb85e3d6dd976deb89a46089a5556b846c478d9;p=thirdparty%2Fsamba.git s4/scripting/bin: Add NT_STATUS_OK to list of definitions Add NT_STATUS_OK to our pre-generated list of status codes. Ensure it goes first in the list to ensure that code that previously found this error code in ‘special_errs’ maintains the same behaviour by falling back to ‘nt_errs’. This makes NT_STATUS_OK available to Python code using the ‘ntstatus’ module. Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- diff --git a/libcli/util/nterr.c b/libcli/util/nterr.c index 3bca6da1b55..0a57a8fd28e 100644 --- a/libcli/util/nterr.c +++ b/libcli/util/nterr.c @@ -45,7 +45,6 @@ typedef struct * same table as the other ones. */ static const nt_err_code_struct special_errs[] = { - { "NT_STATUS_OK", NT_STATUS_OK }, { "STATUS_NO_MORE_FILES", STATUS_NO_MORE_FILES }, { "STATUS_INVALID_EA_NAME", STATUS_INVALID_EA_NAME }, { "STATUS_BUFFER_OVERFLOW", STATUS_BUFFER_OVERFLOW }, diff --git a/libcli/util/ntstatus.h b/libcli/util/ntstatus.h index 2aaee5dcc4d..9a1d1fd855a 100644 --- a/libcli/util/ntstatus.h +++ b/libcli/util/ntstatus.h @@ -51,8 +51,6 @@ typedef uint32_t NTSTATUS; #define NT_STATUS_SMB_NO_PREAUTH_INTEGRITY_HASH_OVERLAP NT_STATUS(0xC05D0000) /* Other error codes that aren't in the list we use */ -#define NT_STATUS_OK NT_STATUS_SUCCESS - #define STATUS_MORE_ENTRIES NT_STATUS_MORE_ENTRIES #define STATUS_BUFFER_OVERFLOW NT_STATUS_BUFFER_OVERFLOW #define STATUS_NO_MORE_FILES NT_STATUS_NO_MORE_FILES diff --git a/source4/scripting/bin/gen_ntstatus.py b/source4/scripting/bin/gen_ntstatus.py index 09aa4f36620..bf0f01640b0 100755 --- a/source4/scripting/bin/gen_ntstatus.py +++ b/source4/scripting/bin/gen_ntstatus.py @@ -22,7 +22,7 @@ # import sys, io -from gen_error_common import parseErrorDescriptions +from gen_error_common import ErrorDef, parseErrorDescriptions def generateHeaderFile(out_file, errors): out_file.write("/*\n") @@ -129,6 +129,15 @@ def main (): with io.open(input_file, "rt", encoding='utf8') as file_contents: errors = parseErrorDescriptions(file_contents, False, transformErrorName) + # NT_STATUS_OK is a synonym of NT_STATUS_SUCCESS, and is very widely used + # throughout Samba. It must go first in the list to ensure that to ensure + # that code that previously found this error code in ‘special_errs’ + # maintains the same behaviour by falling back to ‘nt_errs’. + ok_status = ErrorDef() + ok_status.err_code = 0 + ok_status.err_define = 'NT_STATUS_OK' + errors.insert(0, ok_status) + print("writing new header file: %s" % gen_headerfile_name) out_file = io.open(gen_headerfile_name, "wt", encoding='utf8') generateHeaderFile(out_file, errors)