mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
ipa-join: select {JSON,XML}-RPC at build time
Related: https://pagure.io/freeipa/issue/7966 Reviewed-By: Christian Heimes <cheimes@redhat.com> Reviewed-By: Rob Crittenden <rcritten@redhat.com> Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
parent
62503e4fd0
commit
f6940772dd
@ -34,12 +34,15 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <sys/wait.h>
|
||||
#include <curl/curl.h>
|
||||
#include <jansson.h>
|
||||
#include <limits.h>
|
||||
|
||||
#ifdef WITH_IPA_JOIN_XML
|
||||
#include "xmlrpc-c/base.h"
|
||||
#include "xmlrpc-c/client.h"
|
||||
#else
|
||||
#include <curl/curl.h>
|
||||
#include <jansson.h>
|
||||
#endif
|
||||
|
||||
#include "ipa-client-common.h"
|
||||
#include "ipa_ldap.h"
|
||||
@ -54,11 +57,19 @@ char * read_config_file(const char *filename);
|
||||
char * get_config_entry(char * data, const char *section, const char *key);
|
||||
|
||||
static int debug = 0;
|
||||
static int use_json = 0;
|
||||
|
||||
#define ASPRINTF(strp, fmt...) \
|
||||
if (asprintf(strp, fmt) == -1) { \
|
||||
if (!quiet) \
|
||||
fprintf(stderr, _("Out of memory!\n")); \
|
||||
rval = 3; \
|
||||
goto cleanup; \
|
||||
}
|
||||
|
||||
/*
|
||||
* Translate some IPA exceptions into specific errors in this context.
|
||||
*/
|
||||
#ifdef WITH_IPA_JOIN_XML
|
||||
static int
|
||||
handle_fault(xmlrpc_env * const envP) {
|
||||
if (envP->fault_occurred) {
|
||||
@ -74,6 +85,7 @@ handle_fault(xmlrpc_env * const envP) {
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Get the IPA server from the configuration file.
|
||||
* The caller is responsible for freeing this value
|
||||
@ -127,6 +139,7 @@ static int check_perms(const char *keytab)
|
||||
*
|
||||
* The caller is responsible for freeing the return value.
|
||||
*/
|
||||
#ifdef WITH_IPA_JOIN_XML
|
||||
char *
|
||||
set_user_agent(const char *ipaserver) {
|
||||
int ret;
|
||||
@ -198,6 +211,7 @@ callRPC(char * user_agent,
|
||||
xmlrpc_client_destroy(clientP);
|
||||
free((void*)clientparms.transportparmsP);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* The caller is responsible for unbinding the connection if ld is not NULL */
|
||||
static LDAP *
|
||||
@ -482,6 +496,7 @@ done:
|
||||
return rval;
|
||||
}
|
||||
|
||||
#ifdef WITH_IPA_JOIN_XML
|
||||
static int
|
||||
join_krb5_xmlrpc(const char *ipaserver, char *hostname, char **hostdn, const char **princ, int force, int quiet) {
|
||||
xmlrpc_env env;
|
||||
@ -616,6 +631,8 @@ cleanup_xmlrpc:
|
||||
return rval;
|
||||
}
|
||||
|
||||
#else // ifdef WITH_IPA_JOIN_XML
|
||||
|
||||
static inline struct curl_slist *
|
||||
curl_slist_append_log(struct curl_slist *list, char *string, int quiet) {
|
||||
list = curl_slist_append(list, string);
|
||||
@ -635,14 +652,6 @@ curl_slist_append_log(struct curl_slist *list, char *string, int quiet) {
|
||||
goto cleanup; \
|
||||
}
|
||||
|
||||
#define ASPRINTF(strp, fmt...) \
|
||||
if (asprintf(strp, fmt) == -1) { \
|
||||
if (!quiet) \
|
||||
fprintf(stderr, _("Out of memory!\n")); \
|
||||
rval = 3; \
|
||||
goto cleanup; \
|
||||
}
|
||||
|
||||
size_t
|
||||
jsonrpc_handle_response(char *ptr, size_t size, size_t nmemb, void *userdata) {
|
||||
size_t realsize = size * nmemb;
|
||||
@ -1008,7 +1017,9 @@ cleanup:
|
||||
|
||||
return rval;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef WITH_IPA_JOIN_XML
|
||||
static int
|
||||
xmlrpc_unenroll_host(const char *ipaserver, const char *host, int quiet)
|
||||
{
|
||||
@ -1098,6 +1109,7 @@ cleanup:
|
||||
|
||||
return rval;
|
||||
}
|
||||
#endif
|
||||
|
||||
static int
|
||||
join(const char *server, const char *hostname, const char *bindpw, const char *basedn, const char *keytab, int force, int quiet)
|
||||
@ -1174,10 +1186,11 @@ join(const char *server, const char *hostname, const char *bindpw, const char *b
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
if (!use_json)
|
||||
rval = join_krb5_xmlrpc(ipaserver, host, &hostdn, &princ, force, quiet);
|
||||
else
|
||||
rval = join_krb5_jsonrpc(ipaserver, host, &hostdn, &princ, force, quiet);
|
||||
#ifdef WITH_IPA_JOIN_XML
|
||||
rval = join_krb5_xmlrpc(ipaserver, host, &hostdn, &princ, force, quiet);
|
||||
#else
|
||||
rval = join_krb5_jsonrpc(ipaserver, host, &hostdn, &princ, force, quiet);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (rval) goto cleanup;
|
||||
@ -1403,10 +1416,11 @@ unenroll_host(const char *server, const char *hostname, const char *ktname, int
|
||||
ccache = NULL;
|
||||
putenv("KRB5CCNAME=MEMORY:ipa-join");
|
||||
|
||||
if (use_json)
|
||||
rval = jsonrpc_unenroll_host(ipaserver, host, quiet);
|
||||
else
|
||||
rval = xmlrpc_unenroll_host(ipaserver, host, quiet);
|
||||
#ifdef WITH_IPA_JOIN_XML
|
||||
rval = xmlrpc_unenroll_host(ipaserver, host, quiet);
|
||||
#else
|
||||
rval = jsonrpc_unenroll_host(ipaserver, host, quiet);
|
||||
#endif
|
||||
|
||||
cleanup:
|
||||
if (host)
|
||||
@ -1468,8 +1482,6 @@ main(int argc, const char **argv) {
|
||||
_("LDAP password (if not using Kerberos)"), _("password") },
|
||||
{ "basedn", 'b', POPT_ARG_STRING, &basedn, 0,
|
||||
_("LDAP basedn"), _("basedn") },
|
||||
{ "jsonrpc", 'j', POPT_ARG_NONE, &use_json, 0,
|
||||
_("Use a JSON-RPC call instead of XML-RPC"), NULL },
|
||||
POPT_AUTOHELP
|
||||
POPT_TABLEEND
|
||||
};
|
||||
|
39
configure.ac
39
configure.ac
@ -51,6 +51,14 @@ AC_ARG_WITH([ipatests],
|
||||
[with_ipatests=yes])
|
||||
AM_CONDITIONAL([WITH_IPATESTS], [test x"$with_ipatests" = xyes])
|
||||
|
||||
AC_ARG_WITH([ipa_join_xml],
|
||||
[AC_HELP_STRING([--with-ipa-join-xml], [Use XML-RPC support in ipa-join])],
|
||||
[with_ipa_join_xml=${withval}],
|
||||
[with_ipa_join_xml=no])
|
||||
AS_IF([test x"$with_ipa_join_xml" = xyes], [AC_DEFINE([WITH_IPA_JOIN_XML], [1],
|
||||
[ipa-join uses XML-RPC])])
|
||||
AM_CONDITIONAL([WITH_IPA_JOIN_XML], [test x"$with_ipa_join_xml" = xyes])
|
||||
|
||||
AM_CONDITIONAL([HAVE_GCC], [test "$ac_cv_prog_gcc" = yes])
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
@ -164,26 +172,17 @@ PKG_CHECK_MODULES([SASL], [libsasl2])
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl - Check for XMLRPC-C
|
||||
dnl ---------------------------------------------------------------------------
|
||||
PKG_CHECK_MODULES([XMLRPC], [xmlrpc xmlrpc_client xmlrpc_util], [],
|
||||
[try_xmlrpc_fallback=true])
|
||||
if test x"$try_xmlrpc_fallback" = xtrue; then
|
||||
XMLRPC_LIBS=
|
||||
AC_CHECK_HEADER([xmlrpc-c/base.h], [],
|
||||
[AC_MSG_ERROR([xmlrpc-c/base.h not found])])
|
||||
|
||||
AC_CHECK_LIB([xmlrpc_client], [xmlrpc_client_init2],
|
||||
[XMLRPC_LIBS="-lxmlrpc -lxmlrpc_client -lxmlrpc_util"])
|
||||
if test "x$XMLRPC_LIBS" = "x" ; then
|
||||
AC_MSG_ERROR([xmlrpc-c not found])
|
||||
fi
|
||||
AC_SUBST(XMLRPC_LIBS)
|
||||
fi
|
||||
AS_IF([test x"$with_ipa_join_xml" = xyes], [
|
||||
PKG_CHECK_MODULES([XMLRPC], [xmlrpc xmlrpc_client xmlrpc_util])
|
||||
])
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl - Check for jansson and libcurl for ipa-join
|
||||
dnl ---------------------------------------------------------------------------
|
||||
PKG_CHECK_MODULES([JANSSON], [jansson])
|
||||
PKG_CHECK_MODULES([LIBCURL], [libcurl])
|
||||
AS_IF([test x"$with_ipa_join_xml" = xno], [
|
||||
PKG_CHECK_MODULES([JANSSON], [jansson])
|
||||
PKG_CHECK_MODULES([LIBCURL], [libcurl])
|
||||
])
|
||||
|
||||
dnl ---------------------------------------------------------------------------
|
||||
dnl - Check for libintl
|
||||
@ -684,3 +683,11 @@ AM_COND_IF([WITH_IPATESTS], [
|
||||
echo "\
|
||||
with ipatests: no"
|
||||
])
|
||||
AM_COND_IF([WITH_IPA_JOIN_XML], [
|
||||
echo "\
|
||||
ipa-join RPC mode: XML-RPC"
|
||||
], [
|
||||
echo "\
|
||||
ipa-join RPC mode: JSON-RPC"
|
||||
])
|
||||
|
||||
|
@ -28,6 +28,13 @@
|
||||
%global with_ipatests_option --without-ipatests
|
||||
%endif
|
||||
|
||||
# Use XML-RPC with ipa-join
|
||||
%if 0%{?with_ipa_join_xml}
|
||||
%global with_ipa_join_xml_option --with-ipa-join-xml
|
||||
%else
|
||||
%global with_ipa_join_xml_option --without-ipa-join-xml
|
||||
%endif
|
||||
|
||||
# lint is not executed during rpmbuild
|
||||
# %%global with_lint 1
|
||||
%if 0%{?with_lint}
|
||||
@ -165,10 +172,13 @@ BuildRequires: openldap-devel
|
||||
# DAL version change may cause code crash or memory leaks, it is better to fail early.
|
||||
BuildRequires: krb5-kdb-version = %{krb5_kdb_version}
|
||||
BuildRequires: krb5-devel >= %{krb5_version}
|
||||
%if 0%{?with_ipa_join_xml}
|
||||
# 1.27.4: xmlrpc_curl_xportparms.gssapi_delegation
|
||||
BuildRequires: xmlrpc-c-devel >= 1.27.4
|
||||
%else
|
||||
BuildRequires: libcurl-devel
|
||||
BuildRequires: jansson-devel
|
||||
%endif
|
||||
BuildRequires: popt-devel
|
||||
BuildRequires: gcc
|
||||
BuildRequires: make
|
||||
@ -548,8 +558,11 @@ Requires: hostname
|
||||
Requires: initscripts
|
||||
%endif
|
||||
Requires: libcurl >= 7.21.7-2
|
||||
%if 0%{?with_ipa_join_xml}
|
||||
Requires: xmlrpc-c >= 1.27.4
|
||||
%else
|
||||
Requires: jansson
|
||||
%endif
|
||||
Requires: sssd-ipa >= %{sssd_version}
|
||||
Requires: certmonger >= %{certmonger_version}
|
||||
Requires: nss-tools >= %{nss_version}
|
||||
@ -819,6 +832,7 @@ autoreconf -ivf
|
||||
%configure --with-vendor-suffix=-%{release} \
|
||||
%{enable_server_option} \
|
||||
%{with_ipatests_option} \
|
||||
%{with_ipa_join_xml_option} \
|
||||
%{linter_options}
|
||||
|
||||
# run build in default dir
|
||||
|
Loading…
Reference in New Issue
Block a user