Text::Authinfo - read, query and write authinfo files
Version 0.01
This package should be considered new and untested. Please use at your own risk.
Users should note that authinfo files are without a formal specification. I have referred to resources that claim authority, particularly
http://www.gnu.org/software/emacs/manual/html_node/gnus/NNTP.html
(see "nntp-authinfo-function")
It should be noted that this library supports a subset of files as described here, not arbitrary key/value pairs as hinted at in the description provided by gnu.org.
use Text::Authinfo; my $a = Text::Authinfo->new(); my $read_success = $a->readauthinfo(); print $a->as_string(); my $pw = $a->getauth('machine.example.com','me@example.com','9999'); my $write_success = $a->writeauthinfo();
$authinfofile - the full path of the authinfo file used by default, which points to ~/.authinfo.
FILE - the full filename path for the authinfo file
AUTHINFO - the nested hashrefs denoting the authinfo data. This is of the form:
$a->{AUTHINFO}->{$machine}->{$port}->{$login} = $password;
my $a1 = Text::Authinfo->new(); my $a2 = Text::Authinfo->new('/home/me/.otherauthinfofile');
The constructor has an optional argument that can be used to stipulate an alternative authinfofile to use.
my $read_success = $a->readauthinfo();
Reads the authinfofile data into $a->{AUTHINFO}. Returns 1 for success, 0 otherwise.
$a->{AUTHINFO}
print $a->as_string();
my $write_success1 = $a1->writeauthinfo(); my $write_success2 = $a2->writeauthinfo({'nobackup'=>1});
Writes the contents of $a->{AUTHINFO} into $a->{FILE}, while creating a backup file with the same path as $a->{FILE}, but with '.bak' appended.
$a->{FILE}
Passing a hashref with nobackup set will prevent this behavior.
nobackup
Note! this function will overwrite your existing authinfo file. This can be dangerous! Keep backups.
The file written will have mode 0600 applied.
my $pw = $a->getauth('machine.example.com','me@example.com','9999'); my $pw = $a->getauth('machine.example.com','me@example.com');
This function retrieves your password. The required arguments are determined by the contents of the line for each auth. If a port was mandated, you must pass that in as the third parameter as in the first example above. Otherwise, if the auth line in question did not contain a port, do not pass one in here.
This function returns undef if no match is found.
brad clawsie, <bclawsie at cpan.org>
<bclawsie at cpan.org>
Please report any bugs or feature requests to bug-file-authinfo at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Text-Authinfo. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
bug-file-authinfo at rt.cpan.org
You can find documentation for this module with the perldoc command.
perldoc Text::Authinfo
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Text-Authinfo
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/Text-Authinfo
CPAN Ratings
http://cpanratings.perl.org/d/Text-Authinfo
Search CPAN
http://search.cpan.org/dist/Text-Authinfo/
See the public git repository at:
https://github.com/xylabs/perl-Text-Authinfo
Copyright 2011 brad clawsie.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install Text::Authinfo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Text::Authinfo
CPAN shell
perl -MCPAN -e shell install Text::Authinfo
For more information on module installation, please visit the detailed CPAN module installation guide.