diff --git a/install/tools/ipa-nis-manage b/install/tools/ipa-nis-manage index 948aa0046..f70961309 100755 --- a/install/tools/ipa-nis-manage +++ b/install/tools/ipa-nis-manage @@ -47,7 +47,7 @@ nis_config_dn = DN(('cn', 'NIS Server'), ('cn', 'plugins'), ('cn', 'config')) compat_dn = DN(('cn', 'Schema Compatibility'), ('cn', 'plugins'), ('cn', 'config')) def parse_options(): - usage = "%prog [options] \n" + usage = "%prog [options] \n" usage += "%prog [options]\n" parser = OptionParser(usage=usage, formatter=config.IPAFormatter()) @@ -96,8 +96,8 @@ def main(): options, args = parse_options() if len(args) != 1: - sys.exit("You must specify one action, either enable or disable") - elif args[0] != "enable" and args[0] != "disable": + sys.exit("You must specify one action: enable | disable | status") + elif args[0] not in {"enable", "disable", "status"}: sys.exit("Unrecognized action [" + args[0] + "]") standard_logging_setup(None, debug=options.debug) @@ -186,11 +186,25 @@ def main(): print(lde) retval = 1 + elif args[0] == "status": + nis_entry = get_entry(nis_config_dn, conn) + enabled = (nis_entry and + nis_entry.get( + 'nsslapd-pluginenabled', '')[0].lower() == "on") + if enabled: + print("Plugin is enabled") + retval = 0 + else: + print("Plugin is not enabled") + retval = 4 + else: retval = 1 if retval == 0: - print("This setting will not take effect until you restart Directory Server.") + if args[0] in {"enable", "disable"}: + print("This setting will not take effect until you restart " + "Directory Server.") if args[0] == "enable": print("The %s service may need to be started." % servicemsg) diff --git a/install/tools/man/ipa-nis-manage.1 b/install/tools/man/ipa-nis-manage.1 index d60fda788..93278487c 100644 --- a/install/tools/man/ipa-nis-manage.1 +++ b/install/tools/man/ipa-nis-manage.1 @@ -20,13 +20,15 @@ .SH "NAME" ipa\-nis\-manage \- Enables or disables the NIS listener plugin .SH "SYNOPSIS" -ipa\-nis\-manage [options] +ipa\-nis\-manage [options] .SH "DESCRIPTION" Run the command with the \fBenable\fR option to enable the NIS plugin. Run the command with the \fBdisable\fR option to disable the NIS plugin. -In both cases the user will be prompted to provide the Directory Manager's password unless option \fB\-y\fR is used. +Run the command with the \fBstatus\fR option to read status of the NIS plugin. Return code 0 indicates enabled plugin, return code 4 indicates disabled plugin. + +In all cases the user will be prompted to provide the Directory Manager's password unless option \fB\-y\fR is used. Directory Server will need to be restarted after the NIS listener plugin has been enabled. @@ -45,3 +47,5 @@ File containing the Directory Manager password 2 if the plugin is already in the required status (enabled or disabled) 3 if RPC services cannot be enabled. + +4 if status command detected plugin in disabled state.