#!/usr/bin/perl -w use strict; sub quotemeta2($) { my $l=shift; $l=quotemeta($l); $l=~s/\\\././g; $l=~s/\\-/-/g; return $l; } my ($pw,$un); $pw="#"; $un="#"; while(<>) { chomp; if(/^ClientAuthname:\s*(.*)[\r\n]+$/i) { $un=quotemeta2($1); } elsif(/^ClientPassword:\s*(.*)[\r\n]+$/i) { $pw=quotemeta2($1); } } open P,"/etc/news/users.lst" || die("Ouverture users.lst : $!\n"); my($grp,$dom,$ok); while(
) { s/#.*//g; if(/\<\<(.*)\>\>/) { $dom=$1; } elsif(/\<(.*)\>/) { $grp=$1; } else { if(/^$un:(..)(.*)[\n\r]*$/) { $ok=(crypt($pw,$1) eq $1.$2); last; } } } close(P); if(!$ok) { print STDERR "auth.pl : user $un pass $pw inconnu.\n"; exit(1); } else { print STDERR "auth.pl : user $grp\@$dom\n"; print "User:$grp\@$dom\n"; exit(0); }