App-Tel

 view release on metacpan or  search on metacpan

COMMANDS.md  view on Meta::CPAN

    keepass_passwd => $ENV{KEEPASSPASSWORD},

## [Pass] Password Store

This works a bit differently from KeePass and PWSafe support.  It only
requires a safe file and a password.

### pass file

If you set this argument then it will attempt to get the device password out
of the gpg file.  This doesn't need to be a true "pass" password store, it can
be a symmetric encrypted file if you want.  It will just use the first line
from the file as the device password.

If the directory isn't absolute it assumes a password-store and uses
$HOME/.password-store/<dir> as the location.  Alternatively, if you have the
PASSWORD_STORE_DIR environment variable set this will override the default and
it will look in that location for the file.

If you don't include a ".gpg" extension then one is added to the end
automatically.

Examples:

    pass_file => 'router/password.gpg',
    pass_file => 'router_password',         # would change to $HOME/.password-store/router_password.gpg
    pass_file => '/tmp/file.gpg',           # would not be modified

### pass passwd

Specifies the passphrase to decrypt the file

    pass_passwd => 'verysafe',
    pass_passwd => $ENV{SECRET_ENVIRONMENT_VARIABLE},
    pass_passwd => 'KEYRING',

## Storing safe passphrases in the keyring

MANIFEST  view on Meta::CPAN

t/05-passwd.t
t/10-colorize.t
t/10-passwd-crypt-pwsafe.t
t/10-passwd-file-keepass.t
t/10-passwd-keyring.t
t/10-passwd-pass.t
t/conf/test_x
t/fake_routers/eof
t/fake_routers/loopback
t/pass/keepass.kdbx
t/pass/Pass.gpg
t/pass/pwsafe.psafe3
t/rc/fakerouter.rc
t/rc/hostname.rc
t/rc/login_failures.rc
tel_script.spec
xt/eol.t
xt/kwalitee.t
xt/notab.t
xt/perlcritic.t
xt/pod-coverage.t

lib/App/Tel/Passwd/Pass.pm  view on Meta::CPAN


sub new {
    my $proto = shift;
    my $class = ref($proto) || $proto;
    my %args = @_;

    my $self = { debug => $_debug,
                 %args
    };
    $self->{file} = __find_password_store($self->{file});
    $self->{gpg} ||= ($^O=~/(freebsd|openbsd|netbsd|solaris)/) ? '/usr/local/bin/gpg' : '/usr/bin/gpg';

    if (! -x $self->{gpg}) {
        croak "$class: gpg executable not found.";
    }

    if (!defined($self->{file}) || ! -r $self->{file} ) {
        $self->{file} ||= '<undefined>';
        croak "$class: Can't read file $self->{file}";
    }

    $self->{gnupg} = eval {
        load GnuPG::Interface;
        return GnuPG::Interface->new();
    };

    if ($@) {
        croak $@;
    }

    bless( $self, $class );
    $self->{pass} = $self->_run($self->{gpg}, $self->{file}, $self->{passwd});
    return $self;
}

sub _run {
    my ($self, $call, $file, $passphrase) = @_;

    my $gnupg = $self->{gnupg};
    $gnupg->call($call);
    $gnupg->options->no_greeting(1);
    $gnupg->options->quiet(1);

lib/App/Tel/Passwd/Pass.pm  view on Meta::CPAN

    close $status_fh;

    waitpid $pid, 0;  # clean up the finished GnuPG process
    return $plaintext[0];
}

sub __find_password_store {
    my $file = shift;

    return if (!defined($file));
    if ($file !~ /.gpg$/) {
        $file .= '.gpg';
    }
    # if it's an absolute path then treat it as-is.
    return $file if ($file =~ m#^/#);

    if (defined($ENV{PASSWORD_STORE_DIR})) {
        return "$ENV{PASSWORD_STORE_DIR}/$file";
    }

    return "$ENV{HOME}/.password-store/$file";
}

t/10-passwd-pass.t  view on Meta::CPAN

use warnings;
use Test::More;
use Test::Exception;
use Cwd qw ( abs_path );
eval 'use GnuPG::Interface; 1' ## no critic qw(BuiltinFunctions::ProhibitStringyEval)
    or plan skip_all => 'Optional module GnuPG::Interface required';

plan tests => 8;

my $mod = 'Pass';
my $good_file = 't/pass/Pass.gpg';


# for testing we need to use abs_path because the files aren't under the
# $HOME/.password-store directory.

use App::Tel::Passwd;
lives_ok { App::Tel::Passwd::load_module($mod, abs_path($good_file), 'verysafe' ) } "load_module on $mod works";

my $profile = {
    'pass_file' => abs_path($good_file),



( run in 0.947 second using v1.01-cache-2.11-cpan-df04353d9ac )