for hg changeset 12866:537d4b6d9a7a

need help for creating/movement array "lip2user" in each code part to loadable settings array from configuration files
in config must contain many rows by 3 fields : ip,ldapdn,resolved

diff -r 537d4b6d9a7a doc/example-config/conf.d/10-mail.conf
--- a/doc/example-config/conf.d/10-mail.conf    Thu Jun 30 08:35:43 2011 +0300
+++ b/doc/example-config/conf.d/10-mail.conf    Tue Jul 05 23:37:03 2011 +0300
@@ -18,6 +18,8 @@
 #   %n - user part in user@domain, same as %u if there's no domain
 #   %d - domain part in user@domain, empty if there's no domain
 #   %h - home directory
+#   %x - ldap dn suffix
+#   %y - dictionary reverse domain name
 #
 # See doc/wiki/Variables.txt for full list. Some examples:
 #
diff -r 537d4b6d9a7a doc/example-config/dovecot-ldap.conf.ext
--- a/doc/example-config/dovecot-ldap.conf.ext  Thu Jun 30 08:35:43 2011 +0300
+++ b/doc/example-config/dovecot-ldap.conf.ext  Tue Jul 05 23:37:03 2011 +0300
@@ -77,8 +77,13 @@
 # only for LDAP binds and another connection is used for user lookups.
 # Otherwise the binding is changed to the default DN before each user lookup.
 #
+#   %x - ldap dn suffix
+#   %y - dictionary reverse domain name
+#
 # For example:
 #   auth_bind_userdn = cn=%u,ou=people,o=org
+#   for domain reverse based mapping:
+#   auth_bind_userdn = cn=%u,ou=people,%x
 #
 #auth_bind_userdn =
 
diff -r 537d4b6d9a7a src/auth/auth-request.c
--- a/src/auth/auth-request.c   Thu Jun 30 08:35:43 2011 +0300
+++ b/src/auth/auth-request.c   Tue Jul 05 23:37:03 2011 +0300
@@ -1556,6 +1556,8 @@
                { '\0', NULL, "login_user" },
                { '\0', NULL, "login_username" },
                { '\0', NULL, "login_domain" },
+               { 'x', NULL, "ldap_dn" },
+               { 'y', NULL, "resolved" },
                { '\0', NULL, NULL }
        };
        struct var_expand_table *tab;
@@ -1609,6 +1611,20 @@
                                                    auth_request);
                }
        }
+       const char *lip2user[][3] = {   
{"127.0.0.1","dc=domain1,dc=tld1","domain1.tld1"},
+                                       
{"127.0.0.2","dc=domain2,dc=tld2","domain2.tld2"},
+                                       
{"127.0.0.3","dc=domain3,dc=tld3","domain3.tld3"},
+                                       
{"127.0.0.4","dc=domain4,dc=tld4","domain4.tld4"}   };
+       int arrsize=sizeof( lip2user ) / sizeof( lip2user[0]);
+       tab[18].value = ""; // default expanded to - emty string
+       tab[19].value = ""; // default expanded to - emty string
+       int i;
+       for(i=0;i<arrsize;i++) {
+           if 
(strcmp(net_ip2addr(&auth_request->local_ip),(lip2user[i][0]))==0) {
+               tab[18].value = lip2user[i][1];
+               tab[19].value = lip2user[i][2];
+           }
+       }
        return tab;
 }
 
diff -r 537d4b6d9a7a src/lib-storage/mail-storage-service.c
--- a/src/lib-storage/mail-storage-service.c    Thu Jun 30 08:35:43 2011 +0300
+++ b/src/lib-storage/mail-storage-service.c    Tue Jul 05 23:37:03 2011 +0300
@@ -529,6 +529,8 @@
                { 'r', NULL, "rip" },
                { 'p', NULL, "pid" },
                { 'i', NULL, "uid" },
+               { 'x', NULL, "ldap_dn" },
+               { 'y', NULL, "resolved" },
                { '\0', NULL, NULL }
        };
        struct var_expand_table *tab;
@@ -545,6 +547,20 @@
        tab[5].value = net_ip2addr(&input->remote_ip);
        tab[6].value = my_pid;
        tab[7].value = dec2str(geteuid());
+       const char *lip2user[][3] = {   
{"127.0.0.1","dc=domain1,dc=tld1","domain1.tld1"},
+                                       
{"127.0.0.2","dc=domain2,dc=tld2","domain2.tld2"},
+                                       
{"127.0.0.3","dc=domain3,dc=tld3","domain3.tld3"},
+                                       
{"127.0.0.4","dc=domain4,dc=tld4","domain4.tld4"}   };
+       int arrsize=sizeof( lip2user ) / sizeof( lip2user[0]);
+       tab[8].value = ""; // default expanded to - emty string
+       tab[9].value = ""; // default expanded to - emty string
+       int i;
+       for(i=0;i<arrsize;i++) {
+           if (strcmp(net_ip2addr(&input->local_ip),(lip2user[i][0]))==0) {
+               tab[8].value = lip2user[i][1];
+               tab[9].value = lip2user[i][2];
+           }
+       }
        return tab;
 }
 
diff -r 537d4b6d9a7a src/lib-storage/mail-user.c
--- a/src/lib-storage/mail-user.c       Thu Jun 30 08:35:43 2011 +0300
+++ b/src/lib-storage/mail-user.c       Tue Jul 05 23:37:03 2011 +0300
@@ -180,6 +180,8 @@
                { 'r', NULL, "rip" },
                { 'p', NULL, "pid" },
                { 'i', NULL, "uid" },
+               { 'x', NULL, "ldap_dn" },
+               { 'y', NULL, "resolved" },
                { '\0', NULL, NULL }
        };
        struct var_expand_table *tab;
@@ -202,6 +204,20 @@
                p_strdup(user->pool, net_ip2addr(user->remote_ip));
        tab[7].value = my_pid;
        tab[8].value = p_strdup(user->pool, dec2str(user->uid));
+       const char *lip2user[][3] = {   
{"127.0.0.1","dc=domain1,dc=tld1","domain1.tld1"},
+                                       
{"127.0.0.2","dc=domain2,dc=tld2","domain2.tld2"},
+                                       
{"127.0.0.3","dc=domain3,dc=tld3","domain3.tld3"},
+                                       
{"127.0.0.4","dc=domain4,dc=tld4","domain4.tld4"}   };
+       int arrsize=sizeof( lip2user ) / sizeof( lip2user[0]);
+       tab[9].value = ""; // default expanded to - emty string
+       tab[10].value = ""; // default expanded to - emty string
+       int i;
+       for(i=0;i<arrsize;i++) {
+           if (strcmp(net_ip2addr(user->local_ip),(lip2user[i][0]))==0) {
+               tab[9].value = lip2user[i][1];
+               tab[10].value = lip2user[i][2];
+           }
+       }
 
        user->var_expand_table = tab;
        return user->var_expand_table;

Reply via email to