#include "rfc1738.h"
#include "util.h"
-#define EDUI_PROGRAM_NAME "ext_edirectory_userip_acl"
-#define EDUI_PROGRAM_VERSION "2.1"
+#define EDUI_PROGRAM_NAME "ext_edirectory_userip_acl"
+#define EDUI_PROGRAM_VERSION "2.1"
/* System includes */
#ifndef _GNU_SOURCE
#endif
#ifdef HELPER_INPUT_BUFFER
-#define EDUI_MAXLEN HELPER_INPUT_BUFFER
+#define EDUI_MAXLEN HELPER_INPUT_BUFFER
#else
-#define EDUI_MAXLEN 4096 /* Modified to improve performance, unless HELPER_INPUT_BUFFER exists */
+#define EDUI_MAXLEN 4096 /* Modified to improve performance, unless HELPER_INPUT_BUFFER exists */
#endif
/* ldap compile options */
#endif
/* conf_t - status flags */
-#define EDUI_MODE_INIT 0x01
-#define EDUI_MODE_DEBUG 0x02 /* Replace with Squid's debug system */
-#define EDUI_MODE_TLS 0x04
-#define EDUI_MODE_IPV4 0x08
-#define EDUI_MODE_IPV6 0x10
-#define EDUI_MODE_GROUP 0x20 /* Group is REQUIRED */
-#define EDUI_MODE_PERSIST 0x40 /* Persistent LDAP connections */
-#define EDUI_MODE_KILL 0x80
+#define EDUI_MODE_INIT 0x01
+#define EDUI_MODE_DEBUG 0x02 /* Replace with Squid's debug system */
+#define EDUI_MODE_TLS 0x04
+#define EDUI_MODE_IPV4 0x08
+#define EDUI_MODE_IPV6 0x10
+#define EDUI_MODE_GROUP 0x20 /* Group is REQUIRED */
+#define EDUI_MODE_PERSIST 0x40 /* Persistent LDAP connections */
+#define EDUI_MODE_KILL 0x80
/* conf_t - Program configuration struct typedef */
typedef struct {
char attrib[EDUI_MAXLEN];
char dn[EDUI_MAXLEN];
char passwd[EDUI_MAXLEN];
- char search_filter[EDUI_MAXLEN]; /* Base search_filter that gets copied to edui_ldap_t */
+ char search_filter[EDUI_MAXLEN]; /* Base search_filter that gets copied to edui_ldap_t */
int ver;
int scope;
int port;
char host[EDUI_MAXLEN];
char dn[EDUI_MAXLEN];
char passwd[EDUI_MAXLEN];
- char search_filter[EDUI_MAXLEN]; /* search_group gets appended here by GroupLDAP */
- char search_ip[EDUI_MAXLEN]; /* Could be IPv4 or IPv6, set by ConvertIP */
+ char search_filter[EDUI_MAXLEN]; /* search_group gets appended here by GroupLDAP */
+ char search_ip[EDUI_MAXLEN]; /* Could be IPv4 or IPv6, set by ConvertIP */
char userid[EDUI_MAXLEN]; /* Resulting userid */
unsigned int status;
unsigned int port;
- unsigned long type; /* Type of bind */
+ unsigned long type; /* Type of bind */
int ver;
int scope;
- int err; /* LDAP error code */
+ int err; /* LDAP error code */
time_t idle_time;
int num_ent; /* Number of entry's found via search */
int num_val; /* Number of value's found via getval */
l->port = 0;
l->scope = -1;
l->type = 0;
- l->err = -1; /* Set error to LDAP_SUCCESS by default */
+ l->err = -1; /* Set error to LDAP_SUCCESS by default */
l->ver = 0;
l->idle_time = 0;
- l->num_ent = 0; /* Number of entries in l->lm */
- l->num_val = 0; /* Number of entries in l->val */
+ l->num_ent = 0; /* Number of entries in l->lm */
+ l->num_val = 0; /* Number of entries in l->val */
/* Set default settings from conf */
if (edui_conf.basedn[0] != '\0')
OpenLDAP(edui_ldap_t *l, char *h, unsigned int p)
{
if ((l == NULL) || (h == NULL)) return LDAP_ERR_NULL;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized, or might be in use */
- if (l->status & LDAP_OPEN_S) return LDAP_ERR_OPEN; /* Already open */
- if (l->status & LDAP_BIND_S) return LDAP_ERR_BIND; /* Already bound */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized, or might be in use */
+ if (l->status & LDAP_OPEN_S) return LDAP_ERR_OPEN; /* Already open */
+ if (l->status & LDAP_BIND_S) return LDAP_ERR_BIND; /* Already bound */
xstrncpy(l->host, h, sizeof(l->host));
if (p > 0)
l->port = p;
else
- l->port = LDAP_PORT; /* Default is port 389 */
+ l->port = LDAP_PORT; /* Default is port 389 */
#ifdef NETSCAPE_SSL
if (l->port == LDAPS_PORT)
- l->status |= (LDAP_SSL_S | LDAP_TLS_S); /* SSL Port: 636 */
+ l->status |= (LDAP_SSL_S | LDAP_TLS_S); /* SSL Port: 636 */
#endif
#ifdef USE_LDAP_INIT
#endif
if (l->lp == NULL) {
l->err = LDAP_CONNECT_ERROR;
- return LDAP_ERR_CONNECT; /* Unable to connect */
+ return LDAP_ERR_CONNECT; /* Unable to connect */
} else {
/* set status */
// l->status &= ~(LDAP_INIT_S);
int s;
if (l == NULL) return LDAP_ERR_NULL;
if (l->lp == NULL) return LDAP_ERR_NULL;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Connection not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Connection not open */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Connection not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Connection not open */
if (l->lm != NULL) {
ldap_msgfree(l->lm);
if (s == LDAP_SUCCESS) {
l->status = LDAP_INIT_S;
l->idle_time = 0;
- l->err = s; /* Set LDAP error code */
+ l->err = s; /* Set LDAP error code */
return LDAP_ERR_SUCCESS;
} else {
- l->err = s; /* Set LDAP error code */
+ l->err = s; /* Set LDAP error code */
return LDAP_ERR_FAILED;
}
}
if (l == NULL) return LDAP_ERR_NULL;
if ((v > 3) || (v < 1)) return LDAP_ERR_PARAM;
if (l->lp == NULL) return LDAP_ERR_POINTER;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
- if (l->status & LDAP_BIND_S) return LDAP_ERR_BIND; /* Already bound */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
+ if (l->status & LDAP_BIND_S) return LDAP_ERR_BIND; /* Already bound */
/* set version */
x = ldap_set_option(l->lp, LDAP_OPT_PROTOCOL_VERSION, &v);
if (x == LDAP_SUCCESS) {
l->ver = v;
- l->err = x; /* Set LDAP error code */
+ l->err = x; /* Set LDAP error code */
return LDAP_ERR_SUCCESS;
} else {
- l->err = x; /* Set LDAP error code */
+ l->err = x; /* Set LDAP error code */
return LDAP_ERR_FAILED;
}
}
{
int s;
if (l == NULL) return LDAP_ERR_NULL;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
- if (l->status & LDAP_BIND_S) return LDAP_ERR_BIND; /* Already bound */
- if (l->lp == NULL) return LDAP_ERR_POINTER; /* Error */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
+ if (l->status & LDAP_BIND_S) return LDAP_ERR_BIND; /* Already bound */
+ if (l->lp == NULL) return LDAP_ERR_POINTER; /* Error */
/* Copy details - dn and pw CAN be NULL for anonymous and/or TLS */
if (dn != NULL) {
break;
#endif
#ifdef LDAP_AUTH_TLS
- case LDAP_AUTH_TLS: /* Added for chicken switch to TLS-enabled without using SSL */
+ case LDAP_AUTH_TLS: /* Added for chicken switch to TLS-enabled without using SSL */
l->type = t;
break;
#endif
default:
l->type = LDAP_AUTH_NONE;
- break; /* Default to anonymous bind */
+ break; /* Default to anonymous bind */
}
/* Bind */
#endif
s = ldap_bind_s(l->lp, l->dn, l->passwd, l->type);
if (s == LDAP_SUCCESS) {
- l->status |= LDAP_BIND_S; /* Success */
- l->err = s; /* Set LDAP error code */
+ l->status |= LDAP_BIND_S; /* Success */
+ l->err = s; /* Set LDAP error code */
return LDAP_ERR_SUCCESS;
} else {
- l->err = s; /* Set LDAP error code */
+ l->err = s; /* Set LDAP error code */
return LDAP_ERR_FAILED;
}
}
void *y, *z;
size_t s;
long x;
- int i, j, t, swi; /* IPv6 "::" cut over toggle */
+ int i, j, t, swi; /* IPv6 "::" cut over toggle */
if (l == NULL) return LDAP_ERR_NULL;
if (ip == NULL) return LDAP_ERR_PARAM;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
- if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not bound */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
+ if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not bound */
y = memchr((void *)ip, ':', EDUI_MAXLEN);
z = memchr((void *)ip, '.', EDUI_MAXLEN);
*(obj) = '\0';
/* StringSplit() will zero out bufa & obj at each call */
memset(l->search_ip, '\0', sizeof(l->search_ip));
- xstrncpy(bufa, ip, sizeof(bufa)); /* To avoid segfaults, use bufa instead of ip */
+ xstrncpy(bufa, ip, sizeof(bufa)); /* To avoid segfaults, use bufa instead of ip */
swi = 0;
if (l->status & LDAP_IPV6_S) {
/* Search for :: in string */
/* bufa starts with a ::, so just copy and clear */
xstrncpy(bufb, bufa, sizeof(bufb));
*(bufa) = '\0';
- ++swi; /* Indicates that there is a bufb */
+ ++swi; /* Indicates that there is a bufb */
} else if ((bufa[0] == ':') && (bufa[1] != ':')) {
/* bufa starts with a :, a typo so just fill in a ':', cat and clear */
bufb[0] = ':';
strncat(bufb, bufa, strlen(bufa));
*(bufa) = '\0';
- ++swi; /* Indicates that there is a bufb */
+ ++swi; /* Indicates that there is a bufb */
} else {
p = strstr(bufa, "::");
if (p != NULL) {
memcpy(bufb, p, i);
*p = '\0';
bufb[i] = '\0';
- ++swi; /* Indicates that there is a bufb */
+ ++swi; /* Indicates that there is a bufb */
}
}
}
errno = 0;
x = strtol(obj, (char **)NULL, 10);
if (((x < 0) || (x > 255)) || ((errno != 0) && (x == 0)) || ((obj[0] != '0') && (x == 0)))
- return LDAP_ERR_OOB; /* Out of bounds -- Invalid address */
+ return LDAP_ERR_OOB; /* Out of bounds -- Invalid address */
memset(hexc, '\0', sizeof(hexc));
int hlen = snprintf(hexc, sizeof(hexc), "%02X", (int)x);
strncat(l->search_ip, hexc, hlen);
} else
- break; /* reached end of octet */
+ break; /* reached end of octet */
} else if (l->status & LDAP_IPV6_S) {
/* Break down IPv6 address */
if (swi > 1)
- t = StringSplit(bufb, ':', obj, sizeof(obj)); /* After "::" */
+ t = StringSplit(bufb, ':', obj, sizeof(obj)); /* After "::" */
else
- t = StringSplit(bufa, ':', obj, sizeof(obj)); /* Before "::" */
+ t = StringSplit(bufa, ':', obj, sizeof(obj)); /* Before "::" */
/* Convert octet by size (t) - and fill 0's */
- switch (t) { /* IPv6 is already in HEX, copy contents */
+ switch (t) { /* IPv6 is already in HEX, copy contents */
case 4:
hexc[0] = (char) toupper((int)obj[0]);
i = (int)hexc[0];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[1] = (char) toupper((int)obj[1]);
i = (int)hexc[1];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[2] = '\0';
strncat(l->search_ip, hexc, 2);
hexc[0] = (char) toupper((int)obj[2]);
i = (int)hexc[0];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[1] = (char) toupper((int)obj[3]);
i = (int)hexc[1];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[2] = '\0';
strncat(l->search_ip, hexc, 2);
break;
hexc[1] = (char) toupper((int)obj[0]);
i = (int)hexc[1];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[2] = '\0';
strncat(l->search_ip, hexc, 2);
hexc[0] = (char) toupper((int)obj[1]);
i = (int)hexc[0];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[1] = (char) toupper((int)obj[2]);
i = (int)hexc[1];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[2] = '\0';
strncat(l->search_ip, hexc, 2);
break;
hexc[0] = (char) toupper((int)obj[0]);
i = (int)hexc[0];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[1] = (char) toupper((int)obj[1]);
i = (int)hexc[1];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[2] = '\0';
strncat(l->search_ip, hexc, 2);
break;
hexc[1] = (char) toupper((int)obj[0]);
i = (int)hexc[1];
if (!isxdigit(i))
- return LDAP_ERR_OOB; /* Out of bounds */
+ return LDAP_ERR_OOB; /* Out of bounds */
hexc[2] = '\0';
strncat(l->search_ip, hexc, 2);
break;
if (bufb[i] == ':')
++j;
}
- --j; /* Preceding "::" doesn't count */
- t = 8 - (strlen(l->search_ip) / 4) - j; /* Remainder */
+ --j; /* Preceding "::" doesn't count */
+ t = 8 - (strlen(l->search_ip) / 4) - j; /* Remainder */
if (t > 0) {
for (i = 0; i < t; ++i)
strncat(l->search_ip, "0000", 4);
int swi;
char bufa[EDUI_MAXLEN], bufb[EDUI_MAXLEN], bufc[EDUI_MAXLEN], bufd[EDUI_MAXLEN], bufg[EDUI_MAXLEN];
if (l == NULL) return LDAP_ERR_NULL;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
- if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not Bound */
- if (l->search_ip[0] == '\0') return LDAP_ERR_DATA; /* Search IP is required */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
+ if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not Bound */
+ if (l->search_ip[0] == '\0') return LDAP_ERR_DATA; /* Search IP is required */
/* Zero out if not already */
memset(bufa, '\0', sizeof(bufa));
int s;
char ft[EDUI_MAXLEN];
if (l == NULL) return LDAP_ERR_NULL;
- if ((scope < 0) || (filter == NULL)) return LDAP_ERR_PARAM; /* If attrs is NULL, then all attrs will return */
+ if ((scope < 0) || (filter == NULL)) return LDAP_ERR_PARAM; /* If attrs is NULL, then all attrs will return */
if (l->lp == NULL) return LDAP_ERR_POINTER;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
- if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not bound */
- if (l->status & LDAP_SEARCH_S) return LDAP_ERR_SEARCHED; /* Already searching */
- if (l->basedn[0] == '\0') return LDAP_ERR_DATA; /* We require a basedn */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
+ if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not bound */
+ if (l->status & LDAP_SEARCH_S) return LDAP_ERR_SEARCHED; /* Already searching */
+ if (l->basedn[0] == '\0') return LDAP_ERR_DATA; /* We require a basedn */
if (l->lm != NULL)
- ldap_msgfree(l->lm); /* Make sure l->lm is empty */
+ ldap_msgfree(l->lm); /* Make sure l->lm is empty */
xstrncpy(ft, filter, sizeof(ft));
break;
}
if (s == LDAP_SUCCESS) {
- l->status |= (LDAP_SEARCH_S); /* Mark as searched */
+ l->status |= (LDAP_SEARCH_S); /* Mark as searched */
l->err = s;
- l->idle_time = 0; /* Connection in use, reset idle timer */
- l->num_ent = ldap_count_entries(l->lp, l->lm); /* Counted */
+ l->idle_time = 0; /* Connection in use, reset idle timer */
+ l->num_ent = ldap_count_entries(l->lp, l->lm); /* Counted */
return LDAP_ERR_SUCCESS;
} else {
l->err = s;
LDAPMessage *ent;
if (l == NULL) return LDAP_ERR_NULL;
if (l->lp == NULL) return LDAP_ERR_POINTER;
- if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
- if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
- if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not bound */
- if (!(l->status & LDAP_SEARCH_S)) return LDAP_ERR_NOT_SEARCHED; /* Not searched */
+ if (!(l->status & LDAP_INIT_S)) return LDAP_ERR_INIT; /* Not initalized */
+ if (!(l->status & LDAP_OPEN_S)) return LDAP_ERR_OPEN; /* Not open */
+ if (!(l->status & LDAP_BIND_S)) return LDAP_ERR_BIND; /* Not bound */
+ if (!(l->status & LDAP_SEARCH_S)) return LDAP_ERR_NOT_SEARCHED; /* Not searched */
if (l->num_ent <= 0) {
debug("l->num_ent: %d\n", l->num_ent);
- return LDAP_ERR_DATA; /* No entries found */
+ return LDAP_ERR_DATA; /* No entries found */
}
if (l->val != NULL)
- ldap_value_free_len(l->val); /* Clear data before populating */
+ ldap_value_free_len(l->val); /* Clear data before populating */
l->num_val = 0;
if (l->status & LDAP_VAL_S)
- l->status &= ~(LDAP_VAL_S); /* Clear VAL bit */
+ l->status &= ~(LDAP_VAL_S); /* Clear VAL bit */
if (edui_conf.attrib[0] == '\0')
- xstrncpy(edui_conf.attrib, "cn", sizeof(edui_conf.attrib)); /* Make sure edui_conf.attrib is set */
+ xstrncpy(edui_conf.attrib, "cn", sizeof(edui_conf.attrib)); /* Make sure edui_conf.attrib is set */
/* Sift through entries */
struct berval **ber = NULL;
for (ent = ldap_first_entry(l->lp, l->lm); ent != NULL; ent = ldap_next_entry(l->lp, ent)) {
l->val = ldap_get_values_len(l->lp, ent, "networkAddress");
- ber = ldap_get_values_len(l->lp, ent, edui_conf.attrib); /* edui_conf.attrib is the <userid> mapping */
+ ber = ldap_get_values_len(l->lp, ent, edui_conf.attrib); /* edui_conf.attrib is the <userid> mapping */
if (l->val != NULL) {
- x = ldap_count_values_len(l->val); /* We got x values ... */
+ x = ldap_count_values_len(l->val); /* We got x values ... */
l->num_val = x;
if (x > 0) {
/* Display all values */
memcpy(bufa, l->val[i]->bv_val, j);
z = BinarySplit(bufa, j, '#', bufb, sizeof(bufb));
/* BINARY DEBUGGING *
- local_printfx("value[%" PRIuSIZE "]: BinarySplit(", (size_t) i);
- for (k = 0; k < z; ++k) {
- c = (int) bufb[k];
- if (c < 0)
- c = c + 256;
- local_printfx("%02X", c);
- }
- local_printfx(", ");
- for (k = 0; k < (j - z - 1); ++k) {
- c = (int) bufa[k];
- if (c < 0)
- c = c + 256;
- local_printfx("%02X", c);
- }
- local_printfx("): %" PRIuSIZE "\n", (size_t) z);
+ local_printfx("value[%" PRIuSIZE "]: BinarySplit(", (size_t) i);
+ for (k = 0; k < z; ++k) {
+ c = (int) bufb[k];
+ if (c < 0)
+ c = c + 256;
+ local_printfx("%02X", c);
+ }
+ local_printfx(", ");
+ for (k = 0; k < (j - z - 1); ++k) {
+ c = (int) bufa[k];
+ if (c < 0)
+ c = c + 256;
+ local_printfx("%02X", c);
+ }
+ local_printfx("): %" PRIuSIZE "\n", (size_t) z);
* BINARY DEBUGGING */
z = j - z - 1;
j = atoi(bufb);
/* IPv4 address (eDirectory 8.7 and below) */
/* bufa is the address, just compare it */
if (!(l->status & LDAP_IPV4_S) || (l->status & LDAP_IPV6_S))
- break; /* Not looking for IPv4 */
+ break; /* Not looking for IPv4 */
for (k = 0; k < z; ++k) {
c = (int) bufa[k];
if (c < 0)
l->num_val = 0;
l->err = LDAP_SUCCESS;
l->status &= ~(LDAP_SEARCH_S);
- return LDAP_ERR_SUCCESS; /* We got our userid */
+ return LDAP_ERR_SUCCESS; /* We got our userid */
}
/* Not matched, continue */
} else if ((j == 8) || (j == 9)) {
/* IPv4 (UDP/TCP) address (eDirectory 8.8 and higher) */
/* bufa + 2 is the address (skip 2 digit port) */
if (!(l->status & LDAP_IPV4_S) || (l->status & LDAP_IPV6_S))
- break; /* Not looking for IPv4 */
+ break; /* Not looking for IPv4 */
for (k = 2; k < z; ++k) {
c = (int) bufa[k];
if (c < 0)
l->num_val = 0;
l->err = LDAP_SUCCESS;
l->status &= ~(LDAP_SEARCH_S);
- return LDAP_ERR_SUCCESS; /* We got our userid */
+ return LDAP_ERR_SUCCESS; /* We got our userid */
}
/* Not matched, continue */
} else if ((j == 10) || (j == 11)) {
/* IPv6 (UDP/TCP) address (eDirectory 8.8 and higher) */
/* bufa + 2 is the address (skip 2 digit port) */
if (!(l->status & LDAP_IPV6_S))
- break; /* Not looking for IPv6 */
+ break; /* Not looking for IPv6 */
for (k = 2; k < z; ++k) {
c = (int) bufa[k];
if (c < 0)
l->num_val = 0;
l->err = LDAP_SUCCESS;
l->status &= ~(LDAP_SEARCH_S);
- return LDAP_ERR_SUCCESS; /* We got our userid */
+ return LDAP_ERR_SUCCESS; /* We got our userid */
}
/* Not matched, continue */
}
-// else {
+// else {
/* Others are unsupported */
// }
}
l->num_val = 0;
l->err = LDAP_NO_SUCH_OBJECT;
l->status &= ~(LDAP_SEARCH_S);
- return LDAP_ERR_NOTFOUND; /* Not found ... Sorry :) */
+ return LDAP_ERR_NOTFOUND; /* Not found ... Sorry :) */
}
/*
return 1;
case 'd':
if (!(edui_conf.mode & EDUI_MODE_DEBUG))
- edui_conf.mode |= EDUI_MODE_DEBUG; /* Don't set mode more than once */
- debug_enabled = 1; /* Official Squid-3 Debug Mode */
+ edui_conf.mode |= EDUI_MODE_DEBUG; /* Don't set mode more than once */
+ debug_enabled = 1; /* Official Squid-3 Debug Mode */
break;
case '4':
if (!(edui_conf.mode & EDUI_MODE_IPV4) || !(edui_conf.mode & EDUI_MODE_IPV6))
- edui_conf.mode |= EDUI_MODE_IPV4; /* Don't set mode more than once */
+ edui_conf.mode |= EDUI_MODE_IPV4; /* Don't set mode more than once */
break;
case '6':
if (!(edui_conf.mode & EDUI_MODE_IPV4) || !(edui_conf.mode & EDUI_MODE_IPV6))
- edui_conf.mode |= EDUI_MODE_IPV6; /* Don't set mode more than once */
+ edui_conf.mode |= EDUI_MODE_IPV6; /* Don't set mode more than once */
break;
case 'Z':
if (!(edui_conf.mode & EDUI_MODE_TLS))
- edui_conf.mode |= EDUI_MODE_TLS; /* Don't set mode more than once */
+ edui_conf.mode |= EDUI_MODE_TLS; /* Don't set mode more than once */
break;
case 'P':
if (!(edui_conf.mode & EDUI_MODE_PERSIST))
- edui_conf.mode |= EDUI_MODE_PERSIST; /* Don't set mode more than once */
+ edui_conf.mode |= EDUI_MODE_PERSIST; /* Don't set mode more than once */
break;
case 'v':
- ++i; /* Set LDAP version */
+ ++i; /* Set LDAP version */
if (argv[i] != NULL) {
edui_conf.ver = atoi(argv[i]);
if (edui_conf.ver < 1)
}
break;
case 't':
- ++i; /* Set Persistent timeout */
+ ++i; /* Set Persistent timeout */
if (argv[i] != NULL) {
edui_conf.persist_timeout = atoi(argv[i]);
if (edui_conf.persist_timeout < 0)
}
break;
case 'b':
- ++i; /* Set Base DN */
+ ++i; /* Set Base DN */
if (argv[i] != NULL)
xstrncpy(edui_conf.basedn, argv[i], sizeof(edui_conf.basedn));
else {
}
break;
case 'H':
- ++i; /* Set Hostname */
+ ++i; /* Set Hostname */
if (argv[i] != NULL)
xstrncpy(edui_conf.host, argv[i], sizeof(edui_conf.host));
else {
}
break;
case 'p':
- ++i; /* Set port */
+ ++i; /* Set port */
if (argv[i] != NULL)
edui_conf.port = atoi(argv[i]);
else {
}
break;
case 'D':
- ++i; /* Set Bind DN */
+ ++i; /* Set Bind DN */
if (argv[i] != NULL)
xstrncpy(edui_conf.dn, argv[i], sizeof(edui_conf.dn));
else {
}
break;
case 'W':
- ++i; /* Set Bind PWD */
+ ++i; /* Set Bind PWD */
if (argv[i] != NULL)
xstrncpy(edui_conf.passwd, argv[i], sizeof(edui_conf.passwd));
else {
}
break;
case 'F':
- ++i; /* Set Search Filter */
+ ++i; /* Set Search Filter */
if (argv[i] != NULL)
xstrncpy(edui_conf.search_filter, argv[i], sizeof(edui_conf.search_filter));
else {
break;
case 'G':
if (!(edui_conf.mode & EDUI_MODE_GROUP))
- edui_conf.mode |= EDUI_MODE_GROUP; /* Don't set mode more than once */
+ edui_conf.mode |= EDUI_MODE_GROUP; /* Don't set mode more than once */
break;
case 's':
- ++i; /* Set Scope Level */
+ ++i; /* Set Scope Level */
if (argv[i] != NULL) {
if (!strncmp(argv[i], "base", 4))
edui_conf.scope = 0;
else if (!strncmp(argv[i], "sub", 4))
edui_conf.scope = 2;
else
- edui_conf.scope = 1; /* Default is 'one' */
+ edui_conf.scope = 1; /* Default is 'one' */
} else {
local_printfx("No parameters given for 's'.\n");
DisplayUsage();
}
break;
case 'u':
- ++i; /* Set Search Attribute */
+ ++i; /* Set Search Attribute */
if (argv[i] != NULL) {
xstrncpy(edui_conf.attrib, argv[i], sizeof(edui_conf.attrib));
} else {
return 1;
}
break;
- case '-': /* We got a second '-' ... ignore */
+ case '-': /* We got a second '-' ... ignore */
break;
default:
local_printfx("Invalid parameter - '%c'.\n", argv[i][j]);
}
/* Set predefined required paremeters if none are given, localhost:LDAP_PORT, etc */
- if (edui_conf.host[0] == '\0') /* Default to localhost */
+ if (edui_conf.host[0] == '\0') /* Default to localhost */
xstrncpy(edui_conf.host, "localhost", sizeof(edui_conf.host));
if (edui_conf.port < 0)
- edui_conf.port = LDAP_PORT; /* Default: LDAP_PORT */
+ edui_conf.port = LDAP_PORT; /* Default: LDAP_PORT */
if ((edui_conf.mode & EDUI_MODE_IPV4) && (edui_conf.mode & EDUI_MODE_IPV6))
- edui_conf.mode &= ~(EDUI_MODE_IPV6); /* Default to IPv4 */
+ edui_conf.mode &= ~(EDUI_MODE_IPV6); /* Default to IPv4 */
if (edui_conf.ver < 0)
edui_conf.ver = 2;
if (!(edui_conf.mode & EDUI_MODE_TLS))
- edui_conf.mode |= EDUI_MODE_TLS; /* eDirectory requires TLS mode */
+ edui_conf.mode |= EDUI_MODE_TLS; /* eDirectory requires TLS mode */
if ((edui_conf.mode & EDUI_MODE_TLS) && (edui_conf.ver < 3))
- edui_conf.ver = 3; /* TLS requires version 3 */
+ edui_conf.ver = 3; /* TLS requires version 3 */
if (edui_conf.persist_timeout < 0)
- edui_conf.persist_timeout = 600; /* Default: 600 seconds (10 minutes) */
+ edui_conf.persist_timeout = 600; /* Default: 600 seconds (10 minutes) */
if (edui_conf.scope < 0)
- edui_conf.scope = 1; /* Default: one */
+ edui_conf.scope = 1; /* Default: one */
if (edui_conf.search_filter[0] == '\0')
xstrncpy(edui_conf.search_filter, "(&(objectclass=User)(networkAddress=*))", sizeof(edui_conf.search_filter));
if (edui_conf.attrib[0] == '\0')
if (!(edui_ldap.status & LDAP_INIT_S)) {
InitLDAP(&edui_ldap);
debug("InitLDAP() -> %s\n", ErrLDAP(LDAP_ERR_SUCCESS));
- if (edui_conf.mode & EDUI_MODE_PERSIST) /* Setup persistant mode */
+ if (edui_conf.mode & EDUI_MODE_PERSIST) /* Setup persistant mode */
edui_ldap.status |= LDAP_PERSIST_S;
}
if ((edui_ldap.status & LDAP_IDLE_S) && (edui_elap > 0)) {
local_printfx("ERR message=\"(SearchIPLDAP: %s)\"\n", ErrLDAP(x));
} else {
debug("SearchIPLDAP(-, %s) -> %s\n", edui_ldap.userid, ErrLDAP(x));
- local_printfx("OK user=%s\n", edui_ldap.userid); /* Got userid --> OK user=<userid> */
+ local_printfx("OK user=%s\n", edui_ldap.userid); /* Got userid --> OK user=<userid> */
}
}
/* Clear for next query */
local_printfx("ERR message=\"(SearchIPLDAP: %s)\"\n", ErrLDAP(x));
} else {
debug("SearchIPLDAP(-, %s) -> %s\n", edui_ldap.userid, ErrLDAP(x));
- local_printfx("OK user=%s\n", edui_ldap.userid); /* Got a userid --> OK user=<userid> */
+ local_printfx("OK user=%s\n", edui_ldap.userid); /* Got a userid --> OK user=<userid> */
}
}
}
x = MainSafe(argc, argv);
return x;
}
+