-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

As Stephen noted in a recent post[1], the check for a local non-legacy
domain should be done with checking if provider == local, not by
comparing the domain name. The attached patch fixes this in the tools.

        Jakub

[1] https://www.redhat.com/archives/freeipa-devel/2009-July/msg00336.html

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkpxz0gACgkQHsardTLnvCUmfQCgp++wmosCFlQvoCb5syFzRu1R
HpoAoOVZxwA1tYKBNVd+REhqfOyQmPDW
=Xql7
-----END PGP SIGNATURE-----
>From 96d6dc26a463917867f8352856e88d34733c2a2f Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhro...@redhat.com>
Date: Thu, 30 Jul 2009 12:02:29 +0200
Subject: [PATCH] Correct check for local domain in tools

When looking for the local domain in the tools, do so by looking
on provider value, not domain name. Also removes one redundant lookup
of local domain.
---
 server/tools/sss_usermod.c |   12 ------------
 server/tools/tools_util.c  |    4 ++--
 2 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/server/tools/sss_usermod.c b/server/tools/sss_usermod.c
index 65e9497..879c8d8 100644
--- a/server/tools/sss_usermod.c
+++ b/server/tools/sss_usermod.c
@@ -553,18 +553,6 @@ int main(int argc, const char **argv)
                   "Could not add attribute to changeset\n");
     }
 
-
-    /* arguments processed, go on to actual work */
-    for (dom = ctx->domains; dom; dom = dom->next) {
-        if (strcasecmp(dom->name, "LOCAL") == 0) break;
-    }
-    if (dom == NULL) {
-        ERROR("Could not get LOCAL domain info\n");
-        ret = EXIT_FAILURE;
-        goto fini;
-    }
-    data->domain = dom;
-
     req = sysdb_transaction_send(ctx, ctx->ev, ctx->sysdb);
     if (!req) {
         DEBUG(1, ("Could not start transaction (%d)[%s]\n", ret, strerror(ret)));
diff --git a/server/tools/tools_util.c b/server/tools/tools_util.c
index 0d3220e..b580300 100644
--- a/server/tools/tools_util.c
+++ b/server/tools/tools_util.c
@@ -81,7 +81,7 @@ enum id_domain find_domain_for_id(struct tools_ctx *ctx,
             if (id < dom->id_min || id > dom->id_max) {
                 continue;
             } else {
-                if (strcasecmp(dom->name, "LOCAL") == 0) {
+                if (strcasecmp(dom->provider, "local") == 0) {
                     *dom_ret = dom;
                     return ID_IN_LOCAL;
                 } else if (is_domain_local_legacy(ctx, dom) == 0) {
@@ -100,7 +100,7 @@ enum id_domain find_domain_for_id(struct tools_ctx *ctx,
     } else {
         /* No ID specified, find LOCAL */
         for (dom = ctx->domains; dom; dom = dom->next) {
-            if (strcasecmp(dom->name, "LOCAL") == 0) {
+            if (strcasecmp(dom->provider, "local") == 0) {
                 *dom_ret = dom;
                 return ID_IN_LOCAL;
             }
-- 
1.6.2.5


_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to