Skip to content

Commit

Permalink
s4/scripting/bin: Add NT_STATUS_OK to list of definitions
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Andrew Bartlett <[email protected]>
  • Loading branch information
jsutton24 authored and abartlet committed Jun 14, 2023
1 parent 7c66cd4 commit efb85e3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion libcli/util/nterr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
2 changes: 0 additions & 2 deletions libcli/util/ntstatus.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 10 additions & 1 deletion source4/scripting/bin/gen_ntstatus.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit efb85e3

Please sign in to comment.