From fb1e3e7b767a2c9e2394f74d3b946003539b2c8f Mon Sep 17 00:00:00 2001 From: Nalin Dahyabhai Date: Nov 25 2009 16:42:29 +0000 Subject: - read the server URI from /etc/ipa/default.conf, per guidance from rcritten - be able to take a full-blown URI as a command-line option, too --- diff --git a/src/certmonger-ipa-submit.8.in b/src/certmonger-ipa-submit.8.in index 8dd3676..5556cf9 100644 --- a/src/certmonger-ipa-submit.8.in +++ b/src/certmonger-ipa-submit.8.in @@ -4,7 +4,7 @@ ipa-submit .SH SYNOPSIS -ipa-submit [-h serverHost] [-c cafile] [-C capath] +ipa-submit [-h serverHost] [-H serverURI] [-c cafile] [-C capath] [-t keytab] [-k submitterPrincipal] [-P principalOfRequest] [csrfile] .SH DESCRIPTION @@ -22,7 +22,11 @@ issued. This setting is required by IPA and must always be specified. .TP \fB\-h\fR serverHost Submit the request to the IPA server running on the named host. The default is -to read the name of the host from \fB/etc/ipa/ipa.conf\fR. +to read the location of the host from \fB/etc/ipa/default.conf\fR. +.TP +\fB\-H\fR serverURI +Submit the request to the IPA server at the specified location. The default is +to read the location of the host from \fB/etc/ipa/default.conf\fR. .TP \fB\-c\fR cafile The server's certificate was issued by the CA whose certificate is in the named diff --git a/src/ipa.c b/src/ipa.c index 30a3848..458ba13 100644 --- a/src/ipa.c +++ b/src/ipa.c @@ -40,7 +40,7 @@ int main(int argc, char **argv) { - int i, c, ret; + int i, c, ret, host_is_uri = 0; const char *host = NULL, *cainfo = NULL, *capath = NULL; const char *ktname = NULL, *kpname = NULL; char *csr, *p, *q, uri[LINE_MAX], *s, *reqprinc = NULL, *ipaconfig; @@ -52,10 +52,15 @@ main(int argc, char **argv) reqprinc[strcspn(reqprinc, "\r\n")] = '\0'; } - while ((c = getopt(argc, argv, "h:C:c:t:k:P:")) != -1) { + while ((c = getopt(argc, argv, "h:H:C:c:t:k:P:")) != -1) { switch (c) { case 'h': host = optarg; + host_is_uri = 0; + break; + case 'H': + host = optarg; + host_is_uri = 1; break; case 'C': capath = optarg; @@ -75,6 +80,7 @@ main(int argc, char **argv) default: fprintf(stderr, "Usage: %s [-h serverHost] " + "[-H serverUri] " "[-c cafile] " "[-C capath] " "[-t keytab] " @@ -92,14 +98,23 @@ main(int argc, char **argv) cainfo = "/etc/ipa/ca.crt"; } if (host == NULL) { - ipaconfig = read_config_file("/etc/ipa/ipa.conf"); + ipaconfig = read_config_file("/etc/ipa/default.conf"); if (ipaconfig != NULL) { - host = get_ipa_server(ipaconfig); + host = get_config_entry(ipaconfig, + "global", + "xmlrpc_uri"); + host_is_uri = 1; } } if ((reqprinc == NULL) || (host == NULL)) { if (host == NULL) { - printf(_("Unable to determine hostname of CA.\n")); + if (host_is_uri) { + printf(_("Unable to determine location of " + "CA's XMLRPC server.\n")); + } else { + printf(_("Unable to determine hostname of " + "CA.\n")); + } } if (reqprinc == NULL) { printf(_("Unable to determine principal name for " @@ -107,6 +122,7 @@ main(int argc, char **argv) } fprintf(stderr, "Usage: %s [-h serverHost] " + "[-H serverUri] " "[-c cafile] " "[-C capath] " "[-t keytab] " @@ -130,6 +146,7 @@ main(int argc, char **argv) printf(_("Unable to read signing request.\n")); fprintf(stderr, "Usage: %s [-h serverHost] " + "[-H serverUri] " "[-c cafile] " "[-C capath] " "[-t keytab] " @@ -164,7 +181,11 @@ main(int argc, char **argv) } /* Initialize for XML-RPC. */ - snprintf(uri, sizeof(uri), "https://%s/ipa/xml", host); + if (host_is_uri) { + snprintf(uri, sizeof(uri), "%s", host); + } else { + snprintf(uri, sizeof(uri), "https://%s/ipa/xml", host); + } ctx = cm_submit_x_init(NULL, uri, "cert_request", cainfo, capath, 1); if (ctx == NULL) { fprintf(stderr, "Error setting up for XMLRPC.\n");