From 18af18b35b72834284e079d79fae45a3d642676f Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 17 Mar 2014 19:21:35 +0100 Subject: More progress.. Warning: Contains very ugly temporary hack for uidNumber<->objectSid mapping ;) --- server.c | 39 +++------------------------------------ 1 file changed, 3 insertions(+), 36 deletions(-) (limited to 'server.c') diff --git a/server.c b/server.c index b303e67..91f5703 100644 --- a/server.c +++ b/server.c @@ -21,7 +21,6 @@ #define MSGID_BIND 1 typedef struct { - size_t aliasLen; size_t baseLen; char ip[4]; time_t lastLookup; @@ -29,7 +28,6 @@ typedef struct { char bind[BINDLEN]; char password[PWLEN]; char base[BASELEN]; - char alias[ALIASLEN]; epoll_server_t con; } server_t; @@ -77,59 +75,28 @@ void server_setBase(const char *server, const char *base) entry->base[entry->baseLen] = '\0'; } -void server_setAlias(const char *server, const char *alias) -{ - server_t *entry = server_create(server); - if (entry == NULL) return; - if (snprintf(entry->alias, ALIASLEN, "%s", alias) >= ALIASLEN) printf("Warning: SearchBase Alias for %s is too long.\n", server); - entry->aliasLen = normalize_dn(entry->alias, entry->alias, min(strlen(entry->alias), ALIASLEN - 1)); - entry->alias[entry->aliasLen] = '\0'; -} - void server_initServers() { int i; printf("%d servers configured.\n", serverCount); for (i = 0; i < serverCount; ++i) { - printf("%s:\n Bind: %s\n Base: %s\n Proxy Alias: %s\n", servers[i].addr, servers[i].bind, servers[i].base, servers[i].alias); + printf("%s:\n Bind: %s\n Base: %s\n", servers[i].addr, servers[i].bind, servers[i].base); server_ensureConnected(i); } } // What the proxy calls -int server_aliasToBase(struct string *in, struct string *out) -{ - int i; - char buffer[TMPLEN]; - const size_t searchLen = normalize_dn(buffer, in->s, min(in->l, TMPLEN - 1)); - buffer[searchLen] = '\0'; - // Now buffer contains the normalized wanted alias. Try to find a match in the server list - for (i = 0; i < serverCount; ++i) { - if (searchLen < servers[i].aliasLen) continue; - if (strcmp(servers[i].alias, buffer + (searchLen - servers[i].aliasLen)) == 0) { - // Found, handle - tmpbuffer_format(out, "%.*s%s", (int)(searchLen - servers[i].aliasLen), buffer, servers[i].base); - return i; - } - } - return -1; -} - -int server_baseToAlias(struct string *in, struct string *out) +int server_getFromBase(struct string *in) { int i; char buffer[TMPLEN]; const size_t searchLen = normalize_dn(buffer, in->s, min(in->l, TMPLEN - 1)); buffer[searchLen] = '\0'; - // Now buffer contains the normalized wanted base. Try to find a match in the server list + // Now buffer contains the normalized wanted bind/domain/whatev. Try to find a match in the server list for (i = 0; i < serverCount; ++i) { - printf("Comparing %s (%s) to %s\n", buffer, buffer + (searchLen - servers[i].baseLen), servers[i].base); if (searchLen < servers[i].baseLen) continue; if (strcmp(servers[i].base, buffer + (searchLen - servers[i].baseLen)) == 0) { - // Found, handle - tmpbuffer_format(out, "%.*s%s", (int)(searchLen - servers[i].baseLen), buffer, servers[i].alias); - printf("Match, returning %s\n", out->s); return i; } } -- cgit v1.2.3-55-g7522