summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--proxy.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/proxy.c b/proxy.c
index b49946c..e6709a4 100644
--- a/proxy.c
+++ b/proxy.c
@@ -342,19 +342,18 @@ static void request_replaceAttribute(server_t *server, struct string *attribute,
static void response_replacePal(server_t *server, struct PartialAttributeList **pal, attr_t *attr);
static void response_replaceAdl(server_t *server, struct string *type, struct AttributeDescriptionList **adl, attr_t *attr);
static void response_replaceAttribute(server_t *server, struct string *attribute, struct string *value);
-static struct PartialAttributeList* response_filterHomeDir(struct PartialAttributeList *pal);
+static BOOL response_filterHomeDir(struct PartialAttributeList *pal);
static struct PartialAttributeList* response_addPal(struct PartialAttributeList *pal, struct string *attribute, const char *format, ...);
-#define ADDATTR(x,...) do { if (attr->x) last = response_addPal(last, &s_ ## x, __VA_ARGS__); } while (0)
-#define elifDELATTR(x) else if (equals(&(*pal)->type, &s_ ## x)) next = (*pal)->next
+#define ADDATTR(x,...) do { if (attr->x) *pal = response_addPal(*pal, &s_ ## x, __VA_ARGS__); } while (0)
+#define elifDELATTR(x) else if (equals(&(*pal)->type, &s_ ## x)) next = (*pal)->next, del = TRUE
static void response_replacePal(server_t *server, struct PartialAttributeList **pal, attr_t *attr)
{
struct string *username = NULL;
- struct PartialAttributeList *last = NULL;
struct AttributeDescriptionList *lastObjectClass = NULL;
+ struct PartialAttributeList *next = NULL;
while (*pal != NULL) {
- last = *pal;
- struct PartialAttributeList *next = NULL;
+ BOOL del = FALSE;
if (0) { } // Remove fields we don't want from AD
elifDELATTR(gidNumber);
elifDELATTR(gecos);
@@ -364,11 +363,14 @@ static void response_replacePal(server_t *server, struct PartialAttributeList **
else if (equals(&(*pal)->type, &s_homeDirectory)) {
// homeDirectory is set in AD - it can either be a local path (in which case it's useless)
// or a UNC path, which we can easily mount via mount.cifs
- next = response_filterHomeDir(*pal);
- if (next == NULL) attr->homeMount = FALSE;
+ if (response_filterHomeDir(*pal)) {
+ del = TRUE;
+ attr->homeMount = FALSE;
+ next = (*pal)->next;
+ }
}
// Entry should be removed, free structs
- if (next != NULL) {
+ if (del) {
free_ldapadl((*pal)->values);
free(*pal);
*pal = next;
@@ -393,7 +395,7 @@ static void response_replacePal(server_t *server, struct PartialAttributeList **
char *user = tmpbuffer_get();
snprintf(user, TMPLEN, "%.*s", (int)username->l, username->s);
ADDATTR(homeDirectory, "/home/%s", user);
- ADDATTR(gecos, "%.*s,,,", user);
+ ADDATTR(gecos, "%s,,,", user);
if (attr->homeMount && server->homeTemplate[0] != '\0') {
ADDATTR(homeMount, server->homeTemplate, user, user, user, user, user, user);
}
@@ -446,7 +448,7 @@ static void response_replaceAttribute(server_t *server, struct string *attribute
}
}
-static struct PartialAttributeList* response_filterHomeDir(struct PartialAttributeList *pal)
+static BOOL response_filterHomeDir(struct PartialAttributeList *pal)
{
for (struct AttributeDescriptionList *adl = pal->values; adl != NULL; adl = pal->values /* sic */) {
if (adl->a.l > 2 && adl->a.s[0] == '\\' && adl->a.s[1] == '\\') {
@@ -454,12 +456,12 @@ static struct PartialAttributeList* response_filterHomeDir(struct PartialAttribu
free_ldapadl(adl->next);
adl->next = NULL;
pal->type = s_homeMount;
- return NULL;
+ return FALSE;
}
pal->values = adl->next;
free(adl);
}
- return pal->next;
+ return TRUE;
}
static struct PartialAttributeList* response_addPal(struct PartialAttributeList *pal, struct string *attribute, const char *format, ...)
@@ -467,8 +469,7 @@ static struct PartialAttributeList* response_addPal(struct PartialAttributeList
struct PartialAttributeList *next = malloc(sizeof(struct PartialAttributeList));
va_list args;
va_start(args, format);
- pal->next = next;
- next->next = NULL;
+ next->next = pal;
next->type = *attribute;
next->values = malloc(sizeof(struct AttributeDescriptionList));
tmpbuffer_formatva(&next->values->a, format, args);