This file is indexed.

/usr/share/perl5/Net/Appliance/Session/Transport.pm is in libnet-appliance-session-perl 4.131260-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
package Net::Appliance::Session::Transport;
{
  $Net::Appliance::Session::Transport::VERSION = '4.131260';
}

{
    package # hide from pause
        Net::Appliance::Session::Transport::ConnectOptions;
    use Moo;
    use MooX::Types::MooseLike::Base qw(Str);

    has username => (
        is => 'ro',
        isa => Str,
        required => 0,
        predicate => 1,
    );

    has password => (
        is => 'ro',
        isa => Str,
        required => 0,
        predicate => 1,
    );

    has privileged_password => (
        is => 'ro',
        isa => Str,
        required => 0,
        predicate => 1,
    );
}

use Moo::Role;

sub connect {
    my $self = shift;
    my $options = Net::Appliance::Session::Transport::ConnectOptions->new(@_);

    foreach my $slot (qw/ username password privileged_password /) {
        my $has = 'has_' . $slot;
        my $set = 'set_' . $slot;
        $self->$set($options->$slot) if $options->$has;
    }

    if ($self->nci->transport->is_win32 and $self->has_password) {
        $self->set_password($self->get_password . $self->nci->transport->ors);
    }

    # SSH transport takes a username if we have one
    $self->nci->transport->connect_options->username($self->get_username)
        if $self->has_username
           and $self->nci->transport->connect_options->can('username');

    # poke remote device (whether logging in or not)
    $self->find_prompt($self->wake_up);

    # optionally, log in to the remote host
    if ($self->do_login and not $self->prompt_looks_like('generic')) {

        if ($self->nci->phrasebook->has_prompt('user')
            and $self->prompt_looks_like('user')) {
            die 'a set username is required to connect to this host'
                if not $self->has_username;

            $self->cmd($self->get_username, { match => 'pass' });
        }

        die 'a set password is required to connect to this host'
            if not $self->has_password;

        # support for serial console servers where, after loggin in to the
        # server, the console is asleep and needs waking up to show its prompt
        $self->say($self->get_password);
        $self->find_prompt($self->wake_up);
    }

    $self->prompt_looks_like('generic')
        or die 'login failed to remote host - prompt does not match';

    $self->close_called(0);
    $self->logged_in(1);

    $self->in_privileged_mode( $self->do_privileged_mode ? 0 : 1 );
    $self->in_configure_mode( $self->do_configure_mode ? 0 : 1 );

    # disable paging... this is undone in our close() method
    $self->disable_paging if $self->do_paging;

    return $self;
}

sub close {
    my $self = shift;

    # protect against death spiral (rt.cpan #53796)
    return if $self->close_called;
    $self->close_called(1);

    if ($self->nci->transport->connect_ready) {
        $self->end_configure
            if $self->do_configure_mode and $self->in_configure_mode;
        $self->end_privileged
            if $self->do_privileged_mode and $self->in_privileged_mode;

        # re-enable paging
        $self->enable_paging if $self->do_paging;

        # issue disconnect macro if the phrasebook has one
        if ($self->nci->phrasebook->has_macro('disconnect')) {
            eval { $self->macro('disconnect') };
            # this should die as there's no returned prompt (NCI pump() fails)
        }

        $self->nci->transport->disconnect;
        # there is no longer a transport
    }

    $self->logged_in(0);
}

1;