diff options
author | Stephen Gallagher <sgallagh@redhat.com> | 2012-01-13 08:45:27 -0500 |
---|---|---|
committer | Stephen Gallagher <sgallagh@redhat.com> | 2012-01-17 08:32:45 -0500 |
commit | cafcf367f1d41aa7d82c7108747e32918cb93e64 (patch) | |
tree | 418f545d03f0a77605277c7eea2fe38cfb25ba2f /src/providers/ipa | |
parent | 585ffd71e5b97fd9fae396948e1d1360cf6d7b4b (diff) | |
download | sssd-cafcf367f1d41aa7d82c7108747e32918cb93e64.tar.gz sssd-cafcf367f1d41aa7d82c7108747e32918cb93e64.tar.xz sssd-cafcf367f1d41aa7d82c7108747e32918cb93e64.zip |
IPA: Detect nsupdate support for the realm directive
For older platforms, do not add the 'realm' line in
the update message
Diffstat (limited to 'src/providers/ipa')
-rw-r--r-- | src/providers/ipa/ipa_dyndns.c | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/providers/ipa/ipa_dyndns.c b/src/providers/ipa/ipa_dyndns.c index d82236785..561ee5280 100644 --- a/src/providers/ipa/ipa_dyndns.c +++ b/src/providers/ipa/ipa_dyndns.c @@ -365,20 +365,37 @@ static int create_nsupdate_message(struct ipa_nsupdate_ctx *ctx, int ret, i; char *servername = NULL; char *realm; + char *realm_directive; char *zone; char ip_addr[INET6_ADDRSTRLEN]; const char *ip; struct ipa_ipaddress *new_record; + TALLOC_CTX *tmp_ctx; + + tmp_ctx = talloc_new(NULL); + if (!tmp_ctx) return ENOMEM; realm = dp_opt_get_string(ctx->dyndns_ctx->ipa_ctx->basic, IPA_KRB5_REALM); if (!realm) { - return EIO; + ret = EIO; + goto done; + } + +#ifdef HAVE_NSUPDATE_REALM + realm_directive = talloc_asprintf(tmp_ctx, "realm %s\n", realm); +#else + realm_directive = talloc_asprintf(tmp_ctx, ""); +#endif + if (!realm_directive) { + ret = ENOMEM; + goto done; } zone = dp_opt_get_string(ctx->dyndns_ctx->ipa_ctx->basic, IPA_DOMAIN); if (!zone) { - return EIO; + ret = EIO; + goto done; } /* The DNS zone for IPA is the lower-case @@ -392,26 +409,29 @@ static int create_nsupdate_message(struct ipa_nsupdate_ctx *ctx, if (strncmp(ctx->dyndns_ctx->ipa_ctx->service->sdap->uri, "ldap://", 7) != 0) { DEBUG(1, ("Unexpected format of LDAP URI.\n")); - return EIO; + ret = EIO; + goto done; } servername = ctx->dyndns_ctx->ipa_ctx->service->sdap->uri + 7; if (!servername) { - return EIO; + ret = EIO; + goto done; } - DEBUG(9, ("Creating update message for server [%s], realm [%s] " + DEBUG(5, ("Creating update message for server [%s], realm [%s] " "and zone [%s].\n", servername, realm, zone)); /* Add the server, realm and zone headers */ - ctx->update_msg = talloc_asprintf(ctx, "server %s\nrealm %s\nzone %s.\n", - servername, realm, zone); + ctx->update_msg = talloc_asprintf(ctx, "server %s\n%szone %s.\n", + servername, realm_directive, + zone); } else { - DEBUG(9, ("Creating update message for realm [%s] and zone [%s].\n", + DEBUG(5, ("Creating update message for realm [%s] and zone [%s].\n", realm, zone)); /* Add the realm and zone headers */ - ctx->update_msg = talloc_asprintf(ctx, "realm %s\nzone %s.\n", - realm, zone); + ctx->update_msg = talloc_asprintf(ctx, "%szone %s.\n", + realm_directive, zone); } if (ctx->update_msg == NULL) { ret = ENOMEM; @@ -482,6 +502,7 @@ static int create_nsupdate_message(struct ipa_nsupdate_ctx *ctx, ret = EOK; done: + talloc_free(tmp_ctx); return ret; } |