From a75d430a71015c888350406190a5ab797e54a22c Mon Sep 17 00:00:00 2001 From: "lpsolit%gmail.com" Date: Wed, 4 Dec 2013 17:08:35 +0000 Subject: [PATCH] Bug 940466: Do a separate "cvs login" before committing changes feedback=myk git-svn-id: svn://10.0.0.236/trunk@265131 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/doctor/Doctor/File.pm | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/mozilla/webtools/doctor/Doctor/File.pm b/mozilla/webtools/doctor/Doctor/File.pm index 6205ef6f96b..a37591d27f1 100644 --- a/mozilla/webtools/doctor/Doctor/File.pm +++ b/mozilla/webtools/doctor/Doctor/File.pm @@ -10,6 +10,8 @@ use Doctor qw(:DEFAULT %CONFIG); use Doctor::Error; use File::Temp qw(tempfile); +use IPC::Open3; +use Symbol; # doesn't import "diff" to prevent conflicts with our own use Text::Diff (); @@ -353,12 +355,22 @@ sub commit { # of the file instead of its full spec. my $spec = $self->version eq "new" ? $self->name : $self->spec; - my $cvsroot = ":pserver:$username"; - # Only include the password if one is given. - if ($password) { - $cvsroot .= ":$password"; + my $cvsroot = ":pserver:$username\@$CONFIG{WRITE_CVS_SERVER}"; + # Log out the current user, just in case this hasn't been done before. + Doctor::system_capture("cvs", "-d", $cvsroot, "logout"); + + my ($err, $out, $in) = (gensym); + my $pid = open3($in, $out, $err, "cvs", "-d", $cvsroot, "login") + or die "couldn't log in: $!"; + $password ||= ""; + print $in "$password\n"; + waitpid($pid, 0); + + my $e = <$err>; + if ($e =~ /failed/) { + ThrowUserError("Couldn't authenticate user '$username'", "Authentication failed", + "cvs login", undef, $e); } - $cvsroot .= "\@$CONFIG{WRITE_CVS_SERVER}"; my @args = ("-d", $cvsroot, "commit", "-m", $comment, $spec); @@ -367,6 +379,8 @@ sub commit { chdir $self->tempdir; -e $spec or die "couldn't find $spec: $!"; my ($rv, $output, $errors) = Doctor::system_capture("cvs", @args); + # Log out the current user, so that his credentials aren't reused. + Doctor::system_capture("cvs", "-d", $cvsroot, "logout"); chdir $olddir; return ($rv, $output, $errors);