On Thu, Oct 09, 2003 at 05:52:21PM +0200, Holger Hecht wrote:
> Can I somehow 
> test the authdaemon alone?

Try this (adjust socket path to suit):

#!/usr/bin/perl
use Socket;

$authsock = "/var/sqwebmail/authdaemon/socket";
$authtype = "webmail";

$|=1;
print "Username? ";
$user = <>;
chomp($user);
print "Password? ";
$pass = <>;
chomp($pass);

$astr = "$authtype\nlogin\n$user\n$pass\n";
$astr = "AUTH " . length($astr) . "\n" . $astr;

# See 'man perlipc'
socket(SOCK,PF_UNIX,SOCK_STREAM,0) || die "socket: $!";
connect(SOCK, sockaddr_un($authsock)) || die "connect: $!";
syswrite(SOCK, $astr, length($astr));
$resp = "";
while ($line = <SOCK>, defined($line)) {
  $resp .= $line;
}
close SOCK;
print $resp;

Reply via email to