From f16615485adca54ecf4b51997cc54284d7353edc Mon Sep 17 00:00:00 2001 From: William Brown Date: Mar 04 2019 01:42:04 +0000 Subject: Ticket 50230 - improve ioerror msg when not root/dirsrv Bug Description: When not running as root or dirsrv, improve the clarity of the error messages as the previous messages were misleading. Fix Description: Improve the exception handling and messages. https://pagure.io/389-ds-base/issue/50230 Author: William Brown Review by: mhonek --- diff --git a/src/lib389/cli/dsctl b/src/lib389/cli/dsctl index 8061b04..ed8fc8f 100755 --- a/src/lib389/cli/dsctl +++ b/src/lib389/cli/dsctl @@ -103,11 +103,16 @@ if __name__ == '__main__': signal.signal(signal.SIGINT, signal_handler) try: insts = inst.list(serverid=args.instance) - except PermissionError: - log.error("Unable to access instance information. Are you running as root or dirsrv?") + except (PermissionError, IOError) as e: + log.error("Unable to access instance information. Are you running as the correct user? (usually dirsrv or root)") + log.error("Error: %s" % str(e)) + sys.exit(1) + except Exception as e: + log.error("Error: %s" % str(e)) sys.exit(1) if len(insts) != 1: - log.error("No such instance '%s': this may be a permission issue." % args.instance) + log.error("No such instance '%s'" % args.instance) + log.error("Unable to access instance information. Are you running as the correct user? (usually dirsrv or root)") sys.exit(1) inst.allocate(insts[0])