nwrap: simplify nwrap_add_hname_alias
authorMichael Adam <obnox@samba.org>
Mon, 9 Nov 2015 16:36:07 +0000 (17:36 +0100)
committerMichael Adam <obnox@samba.org>
Mon, 11 Jan 2016 11:25:29 +0000 (12:25 +0100)
This always uses the provided h_name_a alias name.
No need to fall back to the fqdn name from the entry.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
lib/nss_wrapper/nss_wrapper.c

index ccb219c6c52310ece603e3cd1ecdd60a09126df4..821c50f0d37efeba72df65a9ea51fcb020e24ee6 100644 (file)
@@ -2594,32 +2594,30 @@ static void nwrap_add_hname_add_to_existing(struct nwrap_entdata *const ed,
        }
 }
 
-static bool nwrap_add_hname_alias(const char *const h_name_a,
+static bool nwrap_add_hname_alias(char *const h_name_a,
                                  struct nwrap_entdata *const ed)
 {
-       /* One of argument 'h_hame_a' are "optional" */
-       char *const h_name = (char *const) ((h_name_a == NULL) ? ed->ht.h_name : h_name_a);
        ENTRY e;
        ENTRY *p;
 
        /* Maybe it's little bit late ... */
        assert(ed != NULL);
-       assert(h_name != NULL);
+       assert(h_name_a != NULL);
 
-       e.key = h_name;
+       e.key = h_name_a;
        e.data = NULL;
        NWRAP_LOG(NWRAP_LOG_DEBUG, "Searching name: %s", e.key);
        p = hsearch(e, FIND);
        if (p == NULL) {
-               NWRAP_LOG(NWRAP_LOG_DEBUG, "Name %s not found. Adding...", h_name);
+               NWRAP_LOG(NWRAP_LOG_DEBUG, "Name %s not found. Adding...", h_name_a);
                /* Just add alias and don't mess with metadata */
-               nwrap_add_hname_add_new(h_name, ed);
+               nwrap_add_hname_add_new(h_name_a, ed);
        } else {
                /* Element found. Add them to end of list */
                struct nwrap_entdata *ed_dst = (struct nwrap_entdata *)p->data;
 
                assert(p->data != NULL);
-               NWRAP_LOG(NWRAP_LOG_DEBUG, "Name %s found. Add record to list.", h_name);
+               NWRAP_LOG(NWRAP_LOG_DEBUG, "Name %s found. Add record to list.", h_name_a);
                nwrap_add_hname_add_to_existing(ed, ed_dst);
        }