|
|
927834 |
diff -up ./src/mappers/mail_mapper.c.strip-email-domain ./src/mappers/mail_mapper.c
|
|
|
927834 |
--- ./src/mappers/mail_mapper.c.strip-email-domain 2008-12-31 04:13:39.000000000 -0800
|
|
|
927834 |
+++ ./src/mappers/mail_mapper.c 2017-03-10 18:09:01.608738541 -0800
|
|
|
927834 |
@@ -49,6 +49,7 @@ static int ignorecase = 1;
|
|
|
927834 |
|
|
|
927834 |
/* also check the domain part on email field */
|
|
|
927834 |
static int ignoredomain = 1;
|
|
|
927834 |
+static int stripdomain = 0;
|
|
|
927834 |
static char *hostname = NULL;
|
|
|
927834 |
|
|
|
927834 |
static int debug=0;
|
|
|
927834 |
@@ -81,6 +82,22 @@ static int check_domain(char *domain) {
|
|
|
927834 |
return 0;
|
|
|
927834 |
}
|
|
|
927834 |
|
|
|
927834 |
+static char *mail_strip_email_user(char *email)
|
|
|
927834 |
+{
|
|
|
927834 |
+ char *at;
|
|
|
927834 |
+ char *user = clone_str(email);
|
|
|
927834 |
+
|
|
|
927834 |
+ if (user == NULL) {
|
|
|
927834 |
+ return user;
|
|
|
927834 |
+ }
|
|
|
927834 |
+ at = strchr(email, '@');
|
|
|
927834 |
+
|
|
|
927834 |
+ if (at != NULL) {
|
|
|
927834 |
+ user[at - email] = 0;
|
|
|
927834 |
+ }
|
|
|
927834 |
+ return user;
|
|
|
927834 |
+}
|
|
|
927834 |
+
|
|
|
927834 |
/**
|
|
|
927834 |
* compare previously mapped email against user name
|
|
|
927834 |
*/
|
|
|
927834 |
@@ -112,6 +129,10 @@ static char * mail_mapper_find_user(X509
|
|
|
927834 |
DBG("get_email() failed");
|
|
|
927834 |
return NULL;
|
|
|
927834 |
}
|
|
|
927834 |
+ if (stripdomain) {
|
|
|
927834 |
+ /* strip domain implies we aren't using a map file */
|
|
|
927834 |
+ return mail_strip_email_user(entries[0]);
|
|
|
927834 |
+ }
|
|
|
927834 |
/* TODO: What's on ignoredomain flag ?*/
|
|
|
927834 |
return mapfile_find(mapfile,entries[0],ignorecase);
|
|
|
927834 |
}
|
|
|
927834 |
@@ -176,11 +197,17 @@ mapper_module * mail_mapper_module_init(
|
|
|
927834 |
debug = scconf_get_bool(blk,"debug",0);
|
|
|
927834 |
ignorecase = scconf_get_bool(blk,"ignorecase",ignorecase);
|
|
|
927834 |
ignoredomain = scconf_get_bool(blk,"ignoredomain",ignoredomain);
|
|
|
927834 |
+ stripdomain = scconf_get_bool(blk,"stripdomain",stripdomain);
|
|
|
927834 |
mapfile = scconf_get_str(blk,"mapfile",mapfile);
|
|
|
927834 |
} else {
|
|
|
927834 |
DBG1("No block declaration for mapper '%s'",mapper_name);
|
|
|
927834 |
}
|
|
|
927834 |
set_debug_level(debug);
|
|
|
927834 |
+
|
|
|
927834 |
+ if (stripdomain) {
|
|
|
927834 |
+ /* stripdomain implies ignore domain */
|
|
|
927834 |
+ ignoredomain = 1;
|
|
|
927834 |
+ }
|
|
|
927834 |
/* obtain and store hostname */
|
|
|
927834 |
/* Note: in some systems without nis/yp, getdomainname() call
|
|
|
927834 |
returns NULL. So instead we use gethostname() an match
|