Bug 973764 - When utility exits with error, it should give as detailed error message as possible
Summary: When utility exits with error, it should give as detailed error message as po...
Status: CLOSED WONTFIX
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: ipa (Show other bugs)
(Show other bugs)
Version: 7.1
Hardware: Unspecified Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Martin Kosek
QA Contact: Namita Soman
URL:
Whiteboard:
Keywords:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2013-06-12 16:17 UTC by Martin Kosek
Modified: 2016-01-29 13:12 UTC (History)
2 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-01-29 13:12:00 UTC
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

Description Martin Kosek 2013-06-12 16:17:14 UTC
This bug is created as a clone of upstream ticket:
https://fedorahosted.org/freeipa/ticket/3689

I did run

{{{
ipa-getkeytab -s server.example.com -p HTTP/broker.example.net -k /var/www/openshift/broker/httpd/conf.d/http.keytab
}}}

and the call failed with exit status 11 and message

{{{
Failed to add key to the keytab
}}}

I took me some time (this being a scripted operation) that the directory to which I wanted to put the keytab did not exist.

Looking at the code, it does

{{{
                krberr = krb5_kt_add_entry(krbctx, kt, &kt_entry);
                if (krberr) {
                        fprintf(stderr,
                                _("Failed to add key to the keytab\n"));
                        exit (11);
                }
}}}

Alexander suggests that it should be possible to get some more detailed error message about the cause of the problem from the krb5* library using krb5_get_error_message. I tried to apply the following patch

{{{
--- ipa-getkeytab.c.orig	2012-10-12 10:05:55.000000000 -0400
+++ ipa-getkeytab.c	2013-06-05 06:53:15.378200294 -0400
@@ -604,8 +604,10 @@
 
 		krberr = krb5_kt_add_entry(krbctx, kt, &kt_entry);
 		if (krberr) {
+                        const char * krberr_str = krb5_get_error_message(krbctx, krberr);
 			fprintf(stderr,
-                                _("Failed to add key to the keytab\n"));
+                                _("Failed to add key to the keytab: %s\n"), krberr_str);
+			krb5_free_error_message(krbctx, krberr_str);
 			exit (11);
 		}
 	}
}}}

(noto sure how critical it is to call the free if we are about to exit) and the error message is

{{{
Failed to add key to the keytab: Key table file '/var/www/openshift/broker/httpd/conf.dx/http.keytab' not found
}}}

It might not be exactly the 'Directory does not exist' but at least it points to the existence of the file as the source of the problem.

Could all ocurences of

{{{
if (error_code_that_ve_got_from_kr5_call) {
  fprintf(stderr, _("some fixed string\n"));
  exit(somevalue);
}
}}}

be replaced with code which would also call krb5_get_error_message and printed it out?

Comment 1 Martin Kosek 2016-01-29 13:12:00 UTC
Thank you taking your time and submitting this request for Red Hat Enterprise Linux. Unfortunately, this bug was not given a priority and was deferred both in the upstream project and in Red Hat Enterprise Linux.

Given that we are unable to fulfill this request in following Red Hat Enterprise Linux releases, I am closing the Bugzilla as WONTFIX. To request that Red Hat re-considers the decision, please re-open the Bugzilla via appropriate support channels and provide additional business and/or technical details about its importance to you.

Note that you can still track this request or even contribute patches in the referred upstream Trac ticket.


Note You need to log in before you can comment on or make changes to this bug.