summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2016-02-19 10:12:50 +0100
committerSimon Rettberg2016-02-19 10:12:50 +0100
commite27569e63c64c92447edc7e6827b121f87e01a87 (patch)
tree3fa25bcc8d5d58163e448684a655f44709fc41fc
parentRemove debug messages (diff)
downloadldadp-e27569e63c64c92447edc7e6827b121f87e01a87.tar.gz
ldadp-e27569e63c64c92447edc7e6827b121f87e01a87.tar.xz
ldadp-e27569e63c64c92447edc7e6827b121f87e01a87.zip
Configurable name of homeDirectory attribute
-rw-r--r--ldadp.c2
-rw-r--r--proxy.c9
-rw-r--r--server.c14
-rw-r--r--server.h2
-rw-r--r--types.h2
5 files changed, 27 insertions, 2 deletions
diff --git a/ldadp.c b/ldadp.c
index 7371af6..6a021b3 100644
--- a/ldadp.c
+++ b/ldadp.c
@@ -125,6 +125,8 @@ static int loadConfig_handler(void *stuff, const char *section, const char *key,
server_setBase(section, value);
} else if (strcmp(key, "home") == 0) {
if (value[0] != '\0') server_setHomeTemplate(section, value);
+ } else if (strcmp(key, "homeattr") == 0) {
+ if (value[0] != '\0') server_setHomeAttribute(section, value);
} else if (strcmp(key, "fingerprint") == 0) {
if (value[0] != '\0') server_setFingerprint(section, value);
} else if (strcmp(key, "cabundle") == 0) {
diff --git a/proxy.c b/proxy.c
index e416055..786c1ed 100644
--- a/proxy.c
+++ b/proxy.c
@@ -452,7 +452,11 @@ static BOOL request_replaceAttribute(server_t *server, struct string *attribute,
fixUnNumeric(value);
////// ###################
} else if (iequals(attribute, &s_homemount)) {
- *attribute = s_homeDirectory;
+ if (server->homeAttr.s == NULL) {
+ *attribute = s_homeDirectory;
+ } else {
+ *attribute = server->homeAttr;
+ }
if (attr != NULL) attr->homeMount = TRUE;
} else if (iequals(attribute, &s_objectclass)) {
if (value == NULL) return TRUE;
@@ -588,7 +592,8 @@ static void response_replacePal(server_t *server, struct PartialAttributeList **
elifDEL(mail);
elifDELATTR(cn, cn);
elifDEL(memberof);
- else if (iequals(&(*pal)->type, &s_homedirectory)) {
+ else if ( (server->homeAttr.s == NULL && iequals(&(*pal)->type, &s_homedirectory))
+ || (server->homeAttr.s != NULL && iequals(&(*pal)->type, &server->homeAttr)) ) {
// 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
if (!response_filterHomeDir(*pal)) {
diff --git a/server.c b/server.c
index 6382b31..13d72c8 100644
--- a/server.c
+++ b/server.c
@@ -12,6 +12,7 @@
#include <errno.h>
#include <socket.h>
#include <fcntl.h>
+#include <ctype.h>
#define AD_PORT 3268
#define AD_PORT_SSL 636
@@ -121,6 +122,19 @@ void server_setHomeTemplate(const char *server, const char *hometemplate)
if (count > 5) printf("WARNING: Too many '%%' in Home Template for %s. Don't forget to replace literal '%%' with '%%%%'\n", server);
}
+void server_setHomeAttribute(const char *server, const char *homeattribute)
+{
+ server_t *entry = server_create(server);
+ if (entry == NULL || entry->sslContext != NULL) return;
+ free((void*)entry->homeAttr.s);
+ entry->homeAttr.l = strlen(homeattribute);
+ char *tmp = strdup(homeattribute);
+ for (size_t i = 0; i < entry->homeAttr.l; ++i) {
+ tmp[i] = tolower(tmp[i]);
+ }
+ entry->homeAttr.s = tmp;
+}
+
void server_setFingerprint(const char *server, const char *fingerprint)
{
server_t *entry = server_create(server);
diff --git a/server.h b/server.h
index f50a491..3d9d73b 100644
--- a/server.h
+++ b/server.h
@@ -18,6 +18,8 @@ void server_setBase(const char *server, const char *base);
void server_setHomeTemplate(const char *server, const char *hometemplate);
+void server_setHomeAttribute(const char *server, const char *homeattribute);
+
void server_setFingerprint(const char *server, const char *fingerprint);
void server_setCaBundle(const char *server, const char *file);
diff --git a/types.h b/types.h
index faa5292..16cf964 100644
--- a/types.h
+++ b/types.h
@@ -1,6 +1,7 @@
#ifndef _TYPES_H_
#define _TYPES_H_
+#include "asn1.h"
#include <stddef.h>
#include <stdint.h>
#include <time.h>
@@ -104,6 +105,7 @@ struct _server_t_ {
char base[BASELEN];
char sid[SIDLEN];
char homeTemplate[MOUNTLEN];
+ struct string homeAttr;
unsigned char fingerprint[FINGERPRINTLEN];
char cabundle[MAXPATH];
BOOL plainLdap;