Article View: news.software.nntp
Article #69115Problems with MySQL auth and inn 2.4.1
From: Sebastian Damm
Date: Thu, 13 May 2004 10:53
Date: Thu, 13 May 2004 10:53
152 lines
5580 bytes
5580 bytes
Hello
(I wrote this posting already to the inn-workers list, but since I haven't
received neither a Subscription confirmation nor a copy of my own mail,
I'll try my question here)
I'm trying to get my MySQL auth perl Script working with inn. I'm already
trying for days and have no clue where the problem is.
I configured my innd with
#v+
./configure --with-perl --enable-largefiles --with-news-master=newsmaster\
--with-gnu-ld --with-python --with-log-dir=/var/log/inn \
--with-run-dir=/var/run/news
#v-
Now I have a MySQL database and a table with the columns username,
password and news. When news = 1 the User is allowed to use the
newsserver.
In my readers.conf there is an auth part
#v+
auth "jeder" {
perl_auth: "authdb_hook.pl"
# auth: "authdb_standalone.pl"
}
#v-
I've tried both versions, running authdb_$version.pl as a standalone
program with the auth: in the readers.conf and using perl_auth and then
just using the authenticate() function in the perl script.
I read the README pages for external authentication programs and perl auth
hooks and I think I did everything right, but when I start the perl hook
program I just get "bad auth" twice, the "standalone version" doesn't
print out any problems, exits with 0 and still tells me a "bad auth".
OK, here's my perl script for using perl_auth:
#v+
#!/usr/bin/perl -w
use strict;
use DBI;
sub authenticate
{
my $backend = 'mysql';
my $dbname = 'usermnagement';
my $dbhost = 'localhost';
my $dbport = '3306';
my $dbuser = 'news';
my $dbpass = 'password';
my $dbh = DBI->connect("dbi:$backend:$dbname;$dbhost;$dbport", "$dbuser", "$dbpass") || die "Can't connect to MySQL-Server:$DBI::errstr\n";
my $username='user1';
my $password='pass1';
my $getuser="SELECT username FROM users WHERE username='$username' AND password=PASSWORD('$password') AND news='1'";
my $sth = $dbh->prepare($getuser) || die "Can't prepare SELECT: $DBI::errstr\n";
my $querynum = $sth->execute || die "Can't query: $DBI::errstr\n";
my @returnarray;
if ($querynum == 1)
{
$returnarray[0]='281';
$returnarray[1]='';
return @returnarray;
exit 0;
}
else
{
$returnarray[0]='502';
$returnarray[1]='Get out!';
return @returnarray;
exit 1;
}
$sth->finish;
$dbh->disconnect;
}
#v-
Can someone tell me what I do wrong? As you can see I haven't even used
the Hash %attributes that it has access to according to hook-perl in the
doc directory of the sources. I think the script doesn't even get started,
because when I let the script print something out to STDERR I don't get
anything in the news.notice file (with the standalone version I do get
some messages so I know at least that the script is being run).
The standalone program does not much different:
#v+
#!/usr/bin/perl -w
use strict;
use DBI;
authenticate();
sub authenticate
{
my $backend = 'mysql';
my $dbname = 'usermanagement';
my $dbhost = 'localhost';
my $dbport = '3306';
my $dbuser = 'news';
my $dbpass = 'password';
my $dbh = DBI->connect("dbi:$backend:$dbname;$dbhost;$dbport", "$dbuser", "$dbpass") || die "Can't connect to MySQL-Server:$DBI::errstr\n";
my $username='user1';
my $password='pass1';
my $getuser="SELECT username FROM users WHERE username='$username' AND password=PASSWORD('$password') AND news='1'";
my $sth = $dbh->prepare($getuser) || die "Can't prepare SELECT:$DBI::errstr\n";
my $querynum = $sth->execute || die "Can't query: $DBI::errstr\n";
if ($querynum == 1)
{
# print "user:user1\r";
exit 0;
}
else
{
print STDERR localtime(time).": Authentication failed for user ".$username."\n";
exit 1;
}
$sth->finish;
$dbh->disconnect;
}
#v-
Unfortunately I don't speak Perl that well but when I run the second
version from the shell it returns with returncode 0 and without any output
#v+
news@newsserver:~/bin/auth/passwd> ./authdb_standalone.pl
news@newsserver:~/bin/auth/passwd> echo $?
0
news@newsserver:~/bin/auth/passwd>
#v-
I really have no idea what to try anymore, and I haven't found a perl
program for doing MySQL authentication on the net, I only read about one
that Daniel Marsh has written and apparently also posted here, but no
archive has it anymore... :( So if someone has that script still lying
around somewhere, could you send it to me?
Any help would be appreciated.
Sebastian Damm
--
Sebastian Damm ........................................ slim.post@gmx.de
Technical Details
Message-ID:
<slrnca6kst.la6.slim.post@gibsmir.csn.tu-chemnitz.de>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!number1.nntp.dca.giganews.com!internal1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news.tu-chemnitz.de!not-for-mailShow Full Headers
Complete Article Headers
Message-ID: <slrnca6kst.la6.slim.post@gibsmir.csn.tu-chemnitz.de> Subject: Problems with MySQL auth and inn 2.4.1 Date: Thu, 13 May 2004 10:53:17 +0000 From: Sebastian Damm <slim.post@gmx.de> Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!illumos!news.pugleaf.net!.TX!archive.pugleaf.net!archive.newsdeef.eu!mbox2nntp-news.software.nntp.20140818.mbox.gz!number1.nntp.dca.giganews.com!internal1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!news.tu-chemnitz.de!not-for-mail Newsgroups: news.software.nntp Organization: Chemnitz University of Technology Lines: 152 NNTP-Posting-Host: gibsmir.csn.tu-chemnitz.de X-Trace: anderson.hrz.tu-chemnitz.de 1084445597 18824 134.109.96.139 (13 May X-Complaints-To: abuse@tu-chemnitz.de NNTP-Posting-Date: Thu, 13 May 2004 10:53:17 +0000 (UTC) User-Agent: slrn/0.9.8.0 (Linux)