On 2/21/07, RICHARD FERNANDEZ <[EMAIL PROTECTED]> wrote:
> Probably rfernandez is not a valid key in the database file. Try this:
>
> tie my %db, 'NDBM_File', 'aliases', O_RDWR, 0644;
>
> while (my ($key, $value) = each %db) {
> print "$key => $value\n";
> }
>
> untie %db;
>
> On my system, this code works with a custom aliases database
> file I created in Perl (aliases.dir and aliases.pag).
> However, I used simple numbers for the values, but a true
> aliases file probably uses binary-packed values.
>
>
> HTH
Thanks Mumia. I had already tried this w/o success.
I removed the O_CREAT switch (per your sample) and started to see "No
such file or directory" when clearly the file was sitting right there. I
also tried providing the path (./aliases). Same error.
Then it occurred to me that maybe I should try the test code on the
"production" box which runs Solaris and perl 5.8.2. My dev box is OBSD
and runs perl 5.8.6.
The test code runs perfectly on the Solaris box! I have no idea what's
going on under the covers. Maybe someone can shed some light on this?
Anyway at least now I know I'm not barking up the wrong tree :)
Oh, and BTW it turns out that the aliases file does not use
binary-packed values as you suggest. It looks to be straight alias =>
address(es) pairs as I expected before the subject came up.
Thanks to all!
richf
Rich,
There is no such thing as a "standard" aliases file. The standard for
sendmail aliases is whatever your sendmail was compiled with. You can
configure sendmail--or whatever you're calling sendmail--at compile
time to use a number of different hashes and/or DBMs. As far as NDBM,
there are at least two different versions of "ndbm" out there--an old
version that duplicates DBM's .dir/.pag scheme and a more recent
version that uses a single .db file. complicating matters, most "ndbm"
implementations aren't really ndbm anyway, they're ndbm emulation
provided by GDBM or BDB.
It sounds to me like your Perl and OpenBSD's newaliases were compiled
against different versions of <ndbm.h>.
If you want to play around with using dbm hashes, just start playing,
and don't worry about the format. (proposed exercise: parse
etc/aliases and converti it to a DBM of your choice).
If you want to manage you aliases, though, manipulate /etc/aliases as
text, and then call your system's newaliases.
HTH,
-- jay
--------------------------------------------------
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential
daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org
values of β will give rise to dom!