FAQ-OMatic
view release on metacpan or search on metacpan
lib/FAQ/OMatic/Auth.pm view on Meta::CPAN
# these functions manipulate a file that maps IDs to
# (ID,password,...) tuples. (... = future expansion)
# Right now it's a flat file, but maybe someday it should be a
# dbm file if anyone ever has zillions of authorized posters.
# given an ($id,$password,...) array, writes it into idfile
sub writeIDfile {
my ($id,$password,@rest) = @_;
my $lockf = FAQ::OMatic::lockFile("idfile");
FAQ::OMatic::gripe('error', "idfile is locked.") if (not $lockf);
if (not open(IDFILE, "<$FAQ::OMatic::Config::metaDir/idfile")) {
FAQ::OMatic::unlockFile($lockf);
FAQ::OMatic::gripe('abort', "FAQ::OMatic::Auth::writeIDfile: Couldn't "
."read $FAQ::OMatic::Config::metaDir/idfile because $!");
return;
}
# read id mappings in
my %idmap;
lib/FAQ/OMatic/Auth.pm view on Meta::CPAN
# given an id, returns an array starting ($id,$password,...)
sub readIDfile {
my $id = shift || ''; # key to lookup on
my $dontHideVersion = shift || '';
# keep regular lookups from seeing version number
# record. (smacks of a hack, but this is Perl!)
return undef if (($id eq 'version') and (not $dontHideVersion));
my $lockf = FAQ::OMatic::lockFile("idfile");
FAQ::OMatic::gripe('error', "idfile is locked.") if (not $lockf);
if (not open(IDFILE, "<$FAQ::OMatic::Config::metaDir/idfile")) {
FAQ::OMatic::unlockFile($lockf);
FAQ::OMatic::gripe('abort', "FAQ::OMatic::Auth::readIDfile: Couldn't "
."read $FAQ::OMatic::Config::metaDir/idfile because $!");
return undef;
}
my ($idf,$passf,@restf);
while (defined($_=<IDFILE>)) {
( run in 0.572 second using v1.01-cache-2.11-cpan-49f99fa48dc )