[tpop3d-discuss] auth-ldap module for tpop3d

Prune prune at lecentre.net
Wed, 06 Feb 2002 14:17:55 +0100


Hi,

The module is finaly done.
Working great....

I just have a problem, regarding the stringmap.c file.
I had a conf line never found by my module.
I added some debug (badly printf) in stringmap.c as follow :


item *stringmap_find(const stringmap S, const char *k) {
    stringmap S2;
    int i;
    if (!S || S->key == NULL) return 0;
    for (S2 = S;;) {
        printf("les attrisbuts stringmap : %s\t%s\n",k,S2->key);         
    // <---------- here
        i = strcmp(k, S2->key);
        if (i == 0) return &(S2->d);
        else if (i < 0) {
            if (S2->l) S2 = S2->l;
            else return NULL;
        } else if (i > 0) {
            if (S2->g) S2 = S2->g;
            else return NULL;
        }
    }
}



Here is the first tpop3D.conf file :

listen-address:         localhost:1110
max-children:           5
timeout-seconds:        10
mailbox:                bsd
auth-mysql-enable:      yes
auth-mysql-mail-group:  6
auth-mysql-username:    cn=manager,dc=lecentre,dc=net
auth-mysql-password:    hidden
auth-ldap-filter-addon: (objectclass=mailrecipient)
auth-ldap-url:          ldap://localhost:600/dc=lecentre,dc=net
auth-ldap-filter:       mail
aaa:                    mail


Here is (part) of the output of the command :     ./tpop3D -d -f 
tpop3d.conf :


su-2.04# ./tpop3d -d -f ./tpop3d.conf
les attrisbuts stringmap : listen-address       listen-address
localhost.my.domain
listening on address 127.0.0.1, port 1110, domain my.domain
les attrisbuts stringmap : max-children listen-address
les attrisbuts stringmap : max-children max-children
les attrisbuts stringmap : append-domain        listen-address
les attrisbuts stringmap : append-domain        auth-mysql-enable
les attrisbuts stringmap : append-domain        auth-ldap-filter-addon
les attrisbuts stringmap : append-domain        auth-ldap-filter
les attrisbuts stringmap : append-domain        aaa
les attrisbuts stringmap : timeout-seconds      listen-address
les attrisbuts stringmap : timeout-seconds      max-children
les attrisbuts stringmap : timeout-seconds      timeout-seconds
les attrisbuts stringmap : auth-pam-enable      listen-address
les attrisbuts stringmap : auth-pam-enable      auth-mysql-enable
les attrisbuts stringmap : auth-pam-enable      auth-mysql-mail-group
les attrisbuts stringmap : auth-pam-enable      auth-mysql-username
les attrisbuts stringmap : auth-mysql-enable    listen-address
les attrisbuts stringmap : auth-mysql-enable    auth-mysql-enable
les attrisbuts stringmap : auth-ldap-url        listen-address
les attrisbuts stringmap : auth-ldap-url        auth-mysql-enable
les attrisbuts stringmap : auth-ldap-url        auth-ldap-filter-addon
les attrisbuts stringmap : auth-ldap-url        auth-ldap-url
auth_ldap_init: url_parse complete : localhost et dc=lecentre,dc=net et 
60000
les attrisbuts stringmap : auth-mysql-username  listen-address
les attrisbuts stringmap : auth-mysql-username
les attrisbuts stringmap : auth-mysql-username  auth-mysql-mail-group
les attrisbuts stringmap : auth-mysql-username  auth-mysql-username
les attrisbuts stringmap : aaa  listen-address
les attrisbuts stringmap : aaa
les attrisbuts stringmap : aaa  auth-mysql-mail-group
auth_mysql_init: filter-attr fail from the conf
les attrisbuts stringmap : auth-mysql-password  listen-address
les attrisbuts stringmap : auth-mysql-password
les attrisbuts stringmap : auth-mysql-password  auth-mysql-mail-group
les attrisbuts stringmap : auth-mysql-password  auth-mysql-username
les attrisbuts stringmap : auth-mysql-password  auth-mysql-password
auth_mysql_init: filter-attr done
les attrisbuts stringmap : auth-ldap-filter-addon       listen-address
les attrisbuts stringmap : auth-ldap-filter-addon
les attrisbuts stringmap : auth-ldap-filter-addon       
auth-mysql-mail-group
auth_ldap_init: connection
auth_ldap_init: connection fini
1 authentication drivers successfully loaded
net_loop: tpop3d version 1.3.5 successfully started








As you can probably see :
-when parsing the conf for directive "aaa", it checks first between 
"listen-address"
- then "" (nothing.... why ? there are no empty lines in the conf file...)
-then "auth-mysql-mail-group"
AND THAT'S ALL !!!!
:)

why ?

I simply tried to order my config file (sort...). then everything goes 
well. (but it checks with every line in the conf each time... not really 
optimized).

Could we concider this a bug ?
I don't really understand the algo used in stringmap_find....

I'm cleanning the code and converting it from the "auth_mysql.c" name to 
"auth_ldap.c". Then it will be released as a patch.
stay tuned.

Cheers,

Prune