]> git.sur5r.net Git - openldap/commitdiff
The old mail500 had a method to try to translate the local address
authorJulio Sánchez Fernández <jsanchez@openldap.org>
Thu, 6 Apr 2000 16:16:46 +0000 (16:16 +0000)
committerJulio Sánchez Fernández <jsanchez@openldap.org>
Thu, 6 Apr 2000 16:16:46 +0000 (16:16 +0000)
part into something to check against the cn of entries.  It is
supported again thorugh the selector %s in the search.
Explicitly initialize some pointers in automatic storage.

clients/mail500/main.c

index 6a5c25bde9153d1ef6876792ea83f00a95236372..84bd0b2a1903e2082671d68eec0247c4ec5f4ab2 100644 (file)
@@ -307,15 +307,9 @@ main ( int argc, char **argv )
        for ( i = optind; i < argc; i++ ) {
                char    *s;
                int     type;
-               char    *localpart, *domainpart;
+               char    *localpart = NULL, *domainpart = NULL;
                char    address[1024];
 
-/*  TBC: Make this processing optional */
-/*             for ( j = 0; argv[i][j] != '\0'; j++ ) { */
-/*                     if ( argv[i][j] == '.' || argv[i][j] == '_' ) */
-/*                             argv[i][j] = ' '; */
-/*             } */
-
                type = USER;
                split_address( argv[i], &localpart, &domainpart );
                if ( (s = strrchr( localpart, '-' )) != NULL ) {
@@ -1134,7 +1128,7 @@ entry_engine(
        int     *current_nto = nto;
        Group   *current_group = NULL;
        char    buf[1024];
-       char    *localpart, *domainpart;
+       char    *localpart = NULL, *domainpart = NULL;
        Subst   substs[2];
        int     cur_priority = 0;
        char    *route_to_host = NULL;
@@ -1436,9 +1430,11 @@ do_address(
 )
 {
        struct timeval  timeout;
-       char            *localpart, *domainpart;
+       char            *localpart = NULL, *domainpart = NULL;
+       char            *synthname = NULL;
        int             resolved;
-       Subst   substs[5];
+       int             i;
+       Subst           substs[6];
 
        /*
         * Look up the name in X.500, add the appropriate addresses found
@@ -1453,6 +1449,11 @@ do_address(
         */
 
        split_address( name, &localpart, &domainpart );
+       synthname = strdup( localpart );
+       for ( i = 0; synthname[i] != '\0'; i++ ) {
+               if ( synthname[i] == '.' || synthname[i] == '_' )
+                       synthname[i] = ' ';
+       }
        timeout.tv_sec = MAIL500_TIMEOUT;
        timeout.tv_usec = 0;
        substs[0].sub_char = 'm';
@@ -1463,13 +1464,25 @@ do_address(
        substs[2].sub_value = localpart;
        substs[3].sub_char = 'd';
        substs[3].sub_value = domainpart;
-       substs[4].sub_char = '\0';
-       substs[4].sub_value = NULL;
+       substs[4].sub_char = 's';
+       substs[4].sub_value = synthname;
+       substs[5].sub_char = '\0';
+       substs[5].sub_value = NULL;
 
        resolved = search_bases( NULL, substs, name,
                                 to, nto, togroups, ngroups,
                                 err, nerr, type );
 
+       if ( localpart ) {
+               free( localpart );
+       }
+       if ( domainpart ) {
+               free( domainpart );
+       }
+       if ( synthname ) {
+               free( synthname );
+       }
+
        if ( !resolved ) {
                /* not resolved - bounce with user unknown */
                if ( type == USER ) {