Index: [Article Count Order] [Thread]

Date:  Wed, 8 Feb 2006 01:33:24 +0100
From:  Michael Stauber <bq (at mark) solarspeed.net>
Subject:  [coba-e:04042] Re: cgiemail enable-owner-bounce
To:  coba-e (at mark) bluequartz.org
Message-Id:  <200602080133.24595.bq (at mark) solarspeed.net>
In-Reply-To:  <20060207220002.GB47091 (at mark) xs4all.nl>
References:  <20060205131914.GA70308 (at mark) xs4all.nl> <20060207220002.GB47091 (at mark) xs4all.nl>
X-Mail-Count: 04042

Hi Maurice,

> Is there a call to get the full mailaddress (from p.e. the virtusertable)
> when I know the username?

Quick, dirty and inefficient, but it does the trick:

---------------------------------------------------------------------------------------------------------
#!/usr/bin/perl

$username="OURUSERNAME"; #<-- we assume this user exists
$path = "~" . $username;
$cwd = (`cd $path ;pwd`);
print "$cwd  \n";
if ($cwd =~ /^\/home\/.sites\/(.*)\/(.*)\/.users\/(.*)\/(.*)/i) {
                $sitenumber       =       $2;
}
@two = (`ls -l /home/sites/`);
foreach $line (@two) {
        if ($line =~ /^lrwxrwxrwx(.*)[0-9}[0-9]:[0-9][0-9] (.*) -> ..
\/.sites\/(.*)\/$sitenumber/i) {
                $domain = $2;
        }
}
$email-address = "$username\@$domain\n";
print "$email-address\n";
---------------------------------------------------------------------------------------------------------

From Perl and as unprivileged user you cannot read /etc/mail/virtusertable.db 
on BQ, as that file is owned by user "smmsp" and has 640 permissions. Even if 
you could read the .db, you'll need DB::File to decode it and get at the 
stored values. 

The textfile /etc/mail/virtusertable has more relaxed permissions and it's 
possible to read it as unprivileged user. However, if you parse it for a 
username it might also return all aliases that are associated with that 
username and then it gets messy.

-- 

With best regards,

Michael Stauber