Re: [EXIM] dbm alias file

Page principale
Supprimer ce message
Répondre à ce message
Auteur: Peter Radcliffe
Date:  
À: exim-users
Sujet: Re: [EXIM] dbm alias file
Paul Walsh <Paul.Walsh@???> probably said:
> > From:    me [SMTP:me@???]
> > Well thats what I was kinda thinking, when I use exim_dbmbuild it
> > creates a .db file, this I try to open (succesfully) using perl and
> > dbmopen, however no matter what I try it refuses to display the contents
> > let alone modify them. 
>     It may be the version of Perl you're using.   I used the following
> code on one system and it worked fine.  However, when I tried using it on
> another system it didn't.  At first I thought it might have been due to
> different versions of Exim or C Compiler used to build Exim.  I eventually
> noticed that the system which it worked on had Perl 5.003 whereas the other
> had Perl 5.001

>
>     #!/usr/local/bin/perl                 
>     $dbcode=dbmopen(%DB,'aliases',0644); 
>     printf("DB Open code= %d\n",$dbcode); 
>     while ($key,$val)  = each %DB){       
>        printf("%s %s\n",$key,$val);   
>     } 


Not being a perl person, I asked an ex-cow-orker what he did when he wrote
this stuff.

Some snippiets of code from him:

I do't recall exactly what I did to fix it - I think one problem was
] making sure that the key has a trailing NULL:
]    
]    ## key must have trailing NULL
]    if ($key !~ /\x00$/) {
]       $key .= "\x00";
]    }
] 
] The locking stuff looks like this:
] 
]    ## makes no assumptions about the map file.  get it right on your own.
]    my($db) = tie(%db, 'DB_File', $map, O_RDONLY)
]       || die "Cannot open \"$map\": $!\n";
]    my($fd) = $db->fd;
]    open(DB_FH, "+<&=$fd") or die "dup: $!";
]    unless (flock (DB_FH, LOCK_SH | LOCK_NB)) {
]       unless (flock (DB_FH, LOCK_SH)) {
]          die "flock: $!"
]       }  
]    }  
]    my($return) = $db->get($key,$value);
]    flock(DB_FH, LOCK_UN);
]    untie %db;
]    close(DB_FH);


P.

-- 
pir               pir@???      pir@???      pir@???



--
*** Exim information can be found at http://www.exim.org/ ***