| 1 | # | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # Copyright (c) 2004,2005 Alexander Taler (dissent@0--0.org) | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # All rights reserved. This program is free software; you can redistribute it | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # and/or modify it under the same terms as Perl itself. | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | package VCS::LibCVS::Client::Connection::Pserver; | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 1 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | use IO::Socket::INET; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | VCS::LibCVS::Client::Connection::Pserver - a connection to a cvs pserver | ||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||
| 20 | my $conn = VCS::LibCVS::Client::Connection->new($root); | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | A connection to cvs process on a remote machine using the pserver protocol. | ||||||||||||||||||||||||||||||||||||||||||
| 25 | See VCS::LibCVS::Client::Connection for an explanation of the API. | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | The connection is establised through the network. The default port is the | ||||||||||||||||||||||||||||||||||||||||||
| 28 | standard pserver port, 2401. | ||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||
| 30 | =head1 SUPERCLASS | ||||||||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||||||||
| 32 | VCS::LibCVS::Client::Connection | ||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 37 | # Class constants | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | ▶ | use constant REVISION => '$Header: /cvsroot/libcvs-perl/libcvs-perl/VCS/LibCVS/Client/Connection/Pserver.pm,v 1.7 2005/10/10 12:52:11 dissent Exp $ '; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||||||||||||||||
| 42 | 1 | ▶ | use vars ('@ISA'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | @ISA = ("VCS::LibCVS::Client::Connection"); | |||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # Initializer | ||||||||||||||||||||||||||||||||||||||||||
| 47 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||
| 49 | # register protocols supported by this connection, and authentication functions | ||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | ▶ | sub BEGIN { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 51 | 1 | my $class = "VCS::LibCVS::Client::Connection::Pserver"; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 1 | $VCS::LibCVS::Client::Connection::Protocol_map{"pserver"} = $class; | |||||||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||||||||
| 54 | 1 | push @VCS::LibCVS::Authentication_Functions, \&auth_cvspass; | |||||||||||||||||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 58 | # Class variables | ||||||||||||||||||||||||||||||||||||||||||
| 59 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | =head2 $Admin_Dir_Name scalar string, default "CVS" | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | The name of the sandbox admin directory. | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 1 | ▶ | use vars ('$Search_CvsPass', '$Prompt', '$Store_CvsPass'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 1 | $Search_CvsPass = 1; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | $Prompt = 1; | |||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | $Store_CvsPass = 1; | |||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||
| 73 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 74 | # Private variables | ||||||||||||||||||||||||||||||||||||||||||
| 75 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||
| 77 | # $self->{Root} VCS::LibCVS::Datum::Root object for my repository. | ||||||||||||||||||||||||||||||||||||||||||
| 78 | # $self->{Socket} IO::Socket::INET object for connection to repository. | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 81 | # Class routines | ||||||||||||||||||||||||||||||||||||||||||
| 82 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | =head1 CLASS ROUTINES | ||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||
| 86 | =head2 B<new()> | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | $pserver_connection = VCS::LibCVS::Client::Connection::Ext->new($root) | ||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||
| 90 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||||||||||||
| 92 | =item argument 1 type: VCS::LibCVS::Datum::Root | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | =item return type: VCS::LibCVS::Client::Connection::Pserver | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | Construct a new external CVS connection. | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | my $root = shift; | |||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | my $that = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $that->{Root} = $root; | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | return $that; | |||||||||||||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | =head2 B<auth_cvspass()> | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | An authentication routine which does pserver logins using the ~/.cvspass file. | ||||||||||||||||||||||||||||||||||||||||||
| 114 | By default it will search for the necessary password in ~/.cvspass. If the | ||||||||||||||||||||||||||||||||||||||||||
| 115 | password isn't there (and it's running on a tty) it will prompt for it, and | ||||||||||||||||||||||||||||||||||||||||||
| 116 | write it to the ~/.cvspass file. This behaviour can be customized by several | ||||||||||||||||||||||||||||||||||||||||||
| 117 | variables, described below. | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | This function is loaded into the LibCVS authentication function list, and | ||||||||||||||||||||||||||||||||||||||||||
| 120 | observes the parameters and return values of those functions. See the | ||||||||||||||||||||||||||||||||||||||||||
| 121 | documentation for @VCS::LibCVS::Authentication_Functions for more details. | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | The following configuration parameters are available: | ||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | =item $VCS::LibCVS::Client::Connection::Pserver::Search_CvsPass | ||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | Boolean, whether or not to search the ~/.cvspass file. | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | =item $VCS::LibCVS::Client::Connection::Pserver::Prompt | ||||||||||||||||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||||||||||||||||
| 133 | Boolean, whether or not to prompt for a password. | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | =item $VCS::LibCVS::Client::Connection::Pserver::Store_CvsPass | ||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||
| 137 | Boolean, whether or not to write a prompted password to ~/.cvspass. | ||||||||||||||||||||||||||||||||||||||||||
| 138 | Search_CvsPass and Prompt must also be true for this to happen. | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ▶ | sub auth_cvspass { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
auth_cvspass: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | my ($scheme, $needed, $info) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | return if ($scheme ne "pserver"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | my $scrambled; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | # Search the ~/.cvspass file if requested. | ||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if ($Search_CvsPass) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my $cvspass = VCS::LibCVS::Client::Connection::CvsPass->new(); | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $scrambled = $cvspass->get_password($info->{CVSRoot}); | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||||||||||||||||
| 156 | # Prompt for the password if requested, necessary and on a tty. | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | if ((! defined $scrambled) && ($Prompt) && (-t)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not defined $scrambled and $VCS::LibCVS::Client::Connection::Pserver::Prompt and -t STDIN
not defined $scrambled and $VCS::LibCVS::Client::Connection::Pserver::Prompt
MC/DC0%0/3
not defined $scrambled and $VCS::LibCVS::Client::Connection::Pserver::Prompt and -t STDIN
not defined $scrambled
$VCS::LibCVS::Client::Connection::Pserver::Prompt
-t STDIN
Truth table0%0/4
not(A) and B and C
A= not defined $scrambledB= $VCS::LibCVS::Client::Connection::Pserver::PromptC= -t STDIN
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $password; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | print "CVS pserver is insecure, don't use it\n"; | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | print "CVS pserver password for " . $info->{CVSRoot}->as_string() . ":"; | |||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | system "stty -echo"; chomp($password = <STDIN>); system "stty echo"; | |||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | print "\n"; | |||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | $scrambled = pserver_scramble($password); | |||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | # Write the newly acquired password to the ~/.cvspass file, if requested. | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | if ($Search_CvsPass && $Store_CvsPass) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$VCS::LibCVS::Client::Connection::Pserver::Search_CvsPass and $VCS::LibCVS::Client::Connection::Pserver::Store_CvsPass
MC/DC0%0/2
$VCS::LibCVS::Client::Connection::Pserver::Search_CvsPass and $VCS::LibCVS::Client::Connection::Pserver::Store_CvsPass
$VCS::LibCVS::Client::Connection::Pserver::Search_CvsPass
$VCS::LibCVS::Client::Connection::Pserver::Store_CvsPass
Truth table0%0/3
A and B
A= $VCS::LibCVS::Client::Connection::Pserver::Search_CvsPassB= $VCS::LibCVS::Client::Connection::Pserver::Store_CvsPass
| |||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my $cvspass = VCS::LibCVS::Client::Connection::CvsPass->new(); | |||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $cvspass->store_password($info->{CVSRoot}, $scrambled); | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my %ret = ("scrambled_password" => $scrambled); | |||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | return \%ret; | |||||||||||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 177 | # Private routines | ||||||||||||||||||||||||||||||||||||||||||
| 178 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | # The pserver cipher, copied from cvsclient.info | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 1 | ▶ | use vars ('%pserver_cipher'); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 1 | my %pserver_cipher = | |||||||||||||||||||||||||||||||||||||||||
| 183 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 184 | '0' => 111, 'P' => 125, 'p' => 58, | ||||||||||||||||||||||||||||||||||||||||||
| 185 | '!' => 120, '1' => 52, 'A' => 57, 'Q' => 55, 'a' => 121, 'q' => 113, | ||||||||||||||||||||||||||||||||||||||||||
| 186 | '"' => 53, '2' => 75, 'B' => 83, 'R' => 54, 'b' => 117, 'r' => 32, | ||||||||||||||||||||||||||||||||||||||||||
| 187 | '3' => 119, 'C' => 43, 'S' => 66, 'c' => 104, 's' => 90, | ||||||||||||||||||||||||||||||||||||||||||
| 188 | '4' => 49, 'D' => 46, 'T' => 124, 'd' => 101, 't' => 44, | ||||||||||||||||||||||||||||||||||||||||||
| 189 | '%' => 109, '5' => 34, 'E' => 102, 'U' => 126, 'e' => 100, 'u' => 98, | ||||||||||||||||||||||||||||||||||||||||||
| 190 | '&' => 72, '6' => 82, 'F' => 40, 'V' => 59, 'f' => 69, 'v' => 60, | ||||||||||||||||||||||||||||||||||||||||||
| 191 | '\'' => 108, '7' => 81, 'G' => 89, 'W' => 47, 'g' => 73, 'w' => 51, | ||||||||||||||||||||||||||||||||||||||||||
| 192 | '(' => 70, '8' => 95, 'H' => 38, 'X' => 92, 'h' => 99, 'x' => 33, | ||||||||||||||||||||||||||||||||||||||||||
| 193 | ')' => 64, '9' => 65, 'I' => 103, 'Y' => 71, 'i' => 63, 'y' => 97, | ||||||||||||||||||||||||||||||||||||||||||
| 194 | '*' => 76, ':' => 112, 'J' => 45, 'Z' => 115, 'j' => 94, 'z' => 62, | ||||||||||||||||||||||||||||||||||||||||||
| 195 | '+' => 67, ';' => 86, 'K' => 50, 'k' => 93, | ||||||||||||||||||||||||||||||||||||||||||
| 196 | ',' => 116, '<' => 118, 'L' => 42, 'l' => 39, | ||||||||||||||||||||||||||||||||||||||||||
| 197 | '-' => 74, '=' => 110, 'M' => 123, 'm' => 37, | ||||||||||||||||||||||||||||||||||||||||||
| 198 | '.' => 68, '>' => 122, 'N' => 91, 'n' => 61, | ||||||||||||||||||||||||||||||||||||||||||
| 199 | '/' => 87, '?' => 105, 'O' => 35, '_' => 56, 'o' => 48, | ||||||||||||||||||||||||||||||||||||||||||
| 200 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | # Scramble a password pserver style | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | sub pserver_scramble { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pserver_scramble: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | # Reverse, since chop works from the end | ||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $plain_r = reverse(shift); | |||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | my $scrambled = "A"; | |||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | while ($plain_r) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | $scrambled .= chr($pserver_cipher{chop($plain_r)}); | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | return $scrambled; | |||||||||||||||||||||||||||||||||||||||||
| 214 | } | ||||||||||||||||||||||||||||||||||||||||||
| 215 | |||||||||||||||||||||||||||||||||||||||||||
| 216 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 217 | # Instance routines | ||||||||||||||||||||||||||||||||||||||||||
| 218 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||||||||||||
| 220 | =head1 INSTANCE ROUTINES | ||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||
| 222 | =head2 B<connect()> | ||||||||||||||||||||||||||||||||||||||||||
| 223 | |||||||||||||||||||||||||||||||||||||||||||
| 224 | $client->connect() | ||||||||||||||||||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||||||||||||||||
| 226 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | =item return type: undef | ||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | Connect to a CVS repository via a pserver. This opens the connection to the | ||||||||||||||||||||||||||||||||||||||||||
| 233 | pserver and authenticates, leaving IO::Handles available for talking to the | ||||||||||||||||||||||||||||||||||||||||||
| 234 | server. | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | ▶ | sub connect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | return if $self->connected(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $self->SUPER::connect(); | |||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | # Ask the authentication callbacks for the pserver password | ||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | my %info = ( "CVSRoot" => $self->{Root} ); | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my @needed = ("scrambled_password"); | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my $password; | |||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | foreach my $auth_func (@VCS::LibCVS::Authentication_Functions) { | |||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | my $result = &$auth_func("pserver", \@needed, \%info); | |||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | if (defined $result && defined $result->{"scrambled_password"}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $result and defined $result->{"scrambled_password"}
MC/DC0%0/2
defined $result and defined $result->{"scrambled_password"}
defined $result
defined $result->{"scrambled_password"}
Truth table0%0/3
A and B
A= defined $resultB= defined $result->{"scrambled_password"}
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | $password = $result->{"scrambled_password"}; | |||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | } | ||||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | ▶ | confess "No password for " . $self->{Root}->as_string if ! defined $password; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | # Open the connection to the pserver | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my $host = $self->{Root}->{HostName}; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | ▶ | my $port = $self->{Root}->{Port} || 2401; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'Root'}{'Port'} || 2401
MC/DC0%0/1
$self->{'Root'}{'Port'} || 2401
$self->{'Root'}{'Port'}
Truth table0%0/2
A
A= $self->{'Root'}{'Port'}
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $self->{Socket} = IO::Socket::INET->new(PeerAddr => $host, PeerPort => $port); | |||||||||||||||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||||||||||||||||
| 265 | confess "Could not connect to " . $self->{Root}->as_string | ||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | ▶ | if ! defined $self->{Socket}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | # Do the pserver authentication | ||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $self->{Socket}->print("BEGIN AUTH REQUEST\n"); | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | $self->{Socket}->print($self->{Root}->{RootDir} . "\n"); | |||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | $self->{Socket}->print($self->{Root}->{UserName} . "\n"); | |||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | $self->{Socket}->print($password . "\n"); | |||||||||||||||||||||||||||||||||||||||||
| 273 | 0 | $self->{Socket}->print("END AUTH REQUEST\n"); | |||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | # Check that the authentication succeeded | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $result = $self->{Socket}->getline(); | |||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | if ($result !~ /^I LOVE YOU$/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | my $message = ""; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | ▶ | while ($result !~ /I HATE YOU|^error/) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | $message .= $result; | |||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | $result = $self->{Socket}->getline(); | |||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | $message .= $result; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | confess("Pserver authentication failed: $message"); | |||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | # Use the socket for both reading and writing. | ||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | $self->{SubFromServer} = $self->{Socket}; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $self->{SubToServer} = $self->{Socket}; | |||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | $self->connect_fin(); | |||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | sub disconnect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disconnect: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | return if ! $self->connected(); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $self->SUPER::disconnect(); | |||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | $self->{Socket}->shutdown(2); | |||||||||||||||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||||||||||||||||
| 300 | |||||||||||||||||||||||||||||||||||||||||||
| 301 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 302 | # Private routines | ||||||||||||||||||||||||||||||||||||||||||
| 303 | ############################################################################### | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | VCS::LibCVS::Client | ||||||||||||||||||||||||||||||||||||||||||
| 308 | VCS::LibCVS::Client::Connection | ||||||||||||||||||||||||||||||||||||||||||
| 309 | |||||||||||||||||||||||||||||||||||||||||||
| 310 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||
| 312 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||