Bug 10038 - Enhance 'net' command to exit with mapped error codes.
Summary: Enhance 'net' command to exit with mapped error codes.
Status: NEW
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: Tools (show other bugs)
Version: unspecified
Hardware: All All
: P5 enhancement (vote)
Target Milestone: ---
Assignee: Andrew Bartlett
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-07-19 12:29 UTC by ravindra (mail address dead)
Modified: 2018-10-09 06:32 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description ravindra (mail address dead) 2013-07-19 12:29:42 UTC
In order to trap exact NT_STATUS error code of a 'net' command from inside a process, it is beneficial to make 'net' command exit with a mapping error code instead of just returning status.

Currently 'net' command emits detailed error code but this is done either to a debug log file or to the stdout depending on the configuration.
In order to get this specific NT_STATUS error code one has to parse the file or the stdout, looking for a specific string like "Failed to join.." etc.
This  becomes clumsy or break in case the error string changed later.

It would be good if we make 'net' command exit with specific mapped error codes so that programs using 'net' can capture error condition in a better way in a SIGCHLD handler.
Comment 1 Amit Kumar 2018-10-09 06:32:04 UTC
(In reply to ravindra from comment #0)

Have you tested on latest samba-4.7.1-9.el7_5.x86_64

# net ads join -U <> -d 10
password: Entered wrong password
Failed to join domain: failed to lookup DC info for domain 'ATEST' over rpc: The attempted logon is invalid. This is either due to a bad username or authentication information.
return code = -1