Net-SSH-Any

 view release on metacpan or  search on metacpan

lib/Net/SSH/Any/Backend/Net_SSH2.pm  view on Meta::CPAN

        if ($windows) {
            $any->_load_module('Win32') or return;
            my $appdata = Win32::GetFolderPath(Win32::CSIDL_APPDATA());
            unless (defined $appdata) {
                $any->_set_error(SSHA_CONNECTION_ERROR, "unable to determine directory for user application data");
                return;
            }
            $config_dir = File::Spec->join($appdata, 'libnet-ssh-any-perl');
        }
        else {
            my $home = (getpwuid $>)[7];
            $home = $ENV{HOME} unless defined $home;
            unless (defined $home) {
                $any->_set_error(SSHA_CONNECTION_ERROR, "unable to determine user home directory");
                return;
            }
            $config_dir = File::Spec->join($home, '.ssh');
        }
        unless (-d $config_dir or mkdir $config_dir, 0700) {
            $any->_set_error(SSHA_CONNECTION_ERROR, "unable to create directory '$config_dir': $^E");
            return;

lib/Net/SSH/Any/Backend/Net_SSH2.pm  view on Meta::CPAN

    }
    unless ($socket and $ssh2->connect($socket)) {
        return $any->_set_error(SSHA_CONNECTION_ERROR, "Unable to connect to remote host");
    }
    $debug and $debug & 1024 and _debug 'COMP_SC: ' . $ssh2->method('COMP_SC') . ' COMP_CS: ' .$ssh2->method('COMP_CS');

    __check_host_key($any) or return;

    my %aa;
    $aa{username} = _first_defined($be_opts->{user},
                                   eval { (getpwuid $<)[0] },
                                   eval { getlogin() });
    $aa{password} = $be_opts->{password} if defined $be_opts->{password};
    $aa{passphrase} = $be_opts->{passphrase} if defined $be_opts->{passphrase};
    if (defined (my $private = $be_opts->{key_path})) {
        unless (-f $private) {
            $any->_set_error(SSHA_CONNECTION_ERROR, "Private key '$private' does not exist on file system");
            return;
        }
        my $public = $private.".pub";
        unless (-f $public) {

lib/Net/SSH/Any/OS/POSIX.pm  view on Meta::CPAN

                    }
                }
            }
        }
    }
    ()
}

sub find_user_dirs {
    my $any = shift;
    my $home = (getpwuid $<)[7];
    my @dirs;
    for my $name (@_) {
        my $posix_name = (ref $name ? $name->{POSIX} : $name);
        if (defined $posix_name and
            defined $home) {
            push @dirs, join('/', $home, $posix_name)
        }
    }
    grep -d $_, @dirs;
}

lib/Net/SSH/Any/OS/POSIX.pm  view on Meta::CPAN

        $flags |= Fcntl::FD_CLOEXEC();
    }
    fcntl($file, Fcntl::F_SETFL(), $flags);
    1;
}

my $unique_ix = 0;

sub create_secret_file {
    my ($any, $name, $data) = @_;
    my $home = (getpwuid $<)[7];
    unless (defined $home) {
        $any->_os_set_error(SSHA_LOCAL_IO_ERROR, "Unable to determine user home directory: $!");
        return;
    }
    my $base = File::Spec->rel2abs('.libssh-net-any-perl', $home);
    mkdir $base, 0700 unless -d $base;
    unless (do { local $!; -d $base }) {
        $any->_or_set_error(SSHA_LOCAL_IO_ERROR, "Unable to create private directory $base: $!");
        return;
    }

lib/Net/SSH/Any/OS/_Base.pm  view on Meta::CPAN

    my @data = grep { defined and length } _array_or_scalar_to_list $data;
    if (@data and not $in) {
        croak "remote input channel is not defined but data is available for sending"
    }
    \@data
}

sub current_user {
    my $any = shift;
    local ($SIG{__DIE__}, $@);
    eval { (getpwuid $<)[0] } // eval { getlogin() }
}

sub interactive_login {
    my ($any, $pty, $proc) = @_;
    my $opts = $any->{be_opts}; # FIXME. This shouldn't be here!
    my $user = $opts->{user};
    my $password = $opts->{password};
    my $password_prompt = $opts->{password_prompt};
    my $asks_username_at_login = $opts->{asks_username_at_login};



( run in 0.392 second using v1.01-cache-2.11-cpan-8d75d55dd25 )