This file is indexed.

/usr/share/perl5/CPANPLUS/Shell/Default/Plugins/Remote.pm is in libcpanplus-perl 0.9144-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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
package CPANPLUS::Shell::Default::Plugins::Remote;

use strict;

use Module::Load;
use Params::Check               qw[check];
use CPANPLUS::Error             qw[error msg];
use Locale::Maketext::Simple    Class => 'CPANPLUS', Style => 'gettext';

use vars qw[$VERSION];
$VERSION = "0.9144";

=head1 NAME

CPANPLUS::Shell::Default::Plugins::Remote - connect to a remote CPANPLUS

=head1 SYNOPSIS

    CPAN Terminal> /connect localhost 1337 --user=foo --pass=bar
    ...
    CPAN Terminal@localhost> /disconnect

=head1 DESCRIPTION

This is a C<CPANPLUS::Shell::Default> plugin that allows you to connect
to a machine running an instance of C<CPANPLUS::Daemon>, allowing remote
usage of the C<CPANPLUS Shell>.

A sample session, updating all modules on a remote machine, might look
like this:

    CPAN Terminal> /connect --user=my_user --pass=secret localhost 1337

    Connection accepted

    Successfully connected to 'localhost' on port '11337'

    Note that no output will appear until a command has completed
    -- this may take a while


    CPAN Terminal@localhost> o; i *

    [....]

    CPAN Terminal@localhost> /disconnect

    CPAN Terminal>

=cut

### store the original prompt here, so we can restore it on disconnect
my $Saved_Prompt;

sub plugins { ( connect => 'connect', disconnect => 'disconnect' ) }

sub connect {
    my $class   = shift;
    my $shell   = shift;
    my $cb      = shift;
    my $cmd     = shift;
    my $input   = shift || '';
    my $opts    = shift || {};
    my $conf = $cb->configure_object;

    my $user; my $pass;
    {   local $Params::Check::ALLOW_UNKNOWN = 1;

        my $tmpl = {
            user => { default   => 'cpanpd',    store => \$user },
            pass => { required  => 1,           store => \$pass },
        };

         check( $tmpl, $opts ) or return;
    }

    my @parts = split /\s+/, $input;
    my $host = shift @parts || 'localhost';
    my $port = shift @parts || '1337';

    load IO::Socket;

    my $remote = IO::Socket::INET->new(
                        Proto       => "tcp",
                        PeerAddr    => $host,
                        PeerPort    => $port,
                    ) or (
                        error( loc( "Cannot connect to port '%1' ".
                                    "on host '%2'", $port, $host ) ),
                        return
                    );

    my $con = {
        connection  => $remote,
        username    => $user,
        password    => $pass,
    };

    ### store the connection
    $shell->remote( $con );

    my($status,$buffer) = $shell->__send_remote_command(
                            "VERSION=$CPANPLUS::Shell::Default::VERSION");

    if( $status ) {
        print "\n$buffer\n\n";

        print loc(  "Successfully connected to '%1' on port '%2'",
                    $host, $port );
        print "\n\n";
        print loc(  "Note that no output will appear until a command ".
                    "has completed\n-- this may take a while" );
        print "\n\n";

        ### save the original prompt
        $Saved_Prompt = $shell->prompt;

        $shell->prompt( $shell->brand .'@'. $host .':'. $port .'> ' );

    } else {
        print "\n$buffer\n\n";

        print loc(  "Failed to connect to '%1' on port '%2'",
                    $host, $port );
        print "\n\n";

        $shell->remote( undef );
    }
}

sub disconnect {
    my $class   = shift;
    my $shell   = shift;

    print "\n", ( $shell->remote
                    ? loc( "Disconnecting from remote host" )
                    : loc( "Not connected to remote host" )
            ), "\n\n";

    $shell->remote( undef );
    $shell->prompt( $Saved_Prompt );
}

sub connect_help {
    return loc(
            "    /connect [HOST PORT]   # Connect to the remote machine,\n" .
            "                           # defaults taken from your config\n" .
            "        --user=USER        # Optional username\n" .
            "        --pass=PASS        # Optional password" );
}

sub disconnect_help {
    return loc(
            "    /disconnect            # Disconnect from the remote server" );
}

1;

=pod

=head1 BUG REPORTS

Please report bugs or other issues to E<lt>bug-cpanplus@rt.cpan.org<gt>.

=head1 AUTHOR

This module by Jos Boumans E<lt>kane@cpan.orgE<gt>.

=head1 COPYRIGHT

The CPAN++ interface (of which this module is a part of) is copyright (c)
2001 - 2007, Jos Boumans E<lt>kane@cpan.orgE<gt>. All rights reserved.

This library is free software; you may redistribute and/or modify it
under the same terms as Perl itself.

=head1 SEE ALSO

L<CPANPLUS::Shell::Default>, L<CPANPLUS::Shell>, L<cpanp>

=cut

# Local variables:
# c-indentation-style: bsd
# c-basic-offset: 4
# indent-tabs-mode: nil
# End:
# vim: expandtab shiftwidth=4: