diff options
author | Simon Rettberg | 2016-02-19 10:12:50 +0100 |
---|---|---|
committer | Simon Rettberg | 2016-02-19 10:12:50 +0100 |
commit | e27569e63c64c92447edc7e6827b121f87e01a87 (patch) | |
tree | 3fa25bcc8d5d58163e448684a655f44709fc41fc | |
parent | Remove debug messages (diff) | |
download | ldadp-e27569e63c64c92447edc7e6827b121f87e01a87.tar.gz ldadp-e27569e63c64c92447edc7e6827b121f87e01a87.tar.xz ldadp-e27569e63c64c92447edc7e6827b121f87e01a87.zip |
Configurable name of homeDirectory attribute
-rw-r--r-- | ldadp.c | 2 | ||||
-rw-r--r-- | proxy.c | 9 | ||||
-rw-r--r-- | server.c | 14 | ||||
-rw-r--r-- | server.h | 2 | ||||
-rw-r--r-- | types.h | 2 |
5 files changed, 27 insertions, 2 deletions
@@ -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) { @@ -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)) { @@ -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); @@ -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); @@ -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; |