diff options
author | Simon Rettberg | 2014-03-17 19:21:35 +0100 |
---|---|---|
committer | Simon Rettberg | 2014-03-17 19:21:35 +0100 |
commit | 18af18b35b72834284e079d79fae45a3d642676f (patch) | |
tree | b622d709bb19c06651b4bed884d85aaaae6442df /server.c | |
parent | Lean and mean initial commit (diff) | |
download | ldadp-18af18b35b72834284e079d79fae45a3d642676f.tar.gz ldadp-18af18b35b72834284e079d79fae45a3d642676f.tar.xz ldadp-18af18b35b72834284e079d79fae45a3d642676f.zip |
More progress.. Warning: Contains very ugly temporary hack for uidNumber<->objectSid mapping ;)
Diffstat (limited to 'server.c')
-rw-r--r-- | server.c | 39 |
1 files changed, 3 insertions, 36 deletions
@@ -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; } } |