[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Woes executing SVN from CGI

From: David W. Wilson <wilson.d_at_anseri.com>
Date: 2007-10-11 15:52:57 CEST

>>I tried the

>>obvious, adding --username and --password options to the "svn" command
line,

>>but no luck, same behavior.

>

>Can you post the output from the CGI (in both CLI and CGI) with these

>options added? I assume you've realised that the CLI runs under a

>different user from Apache (normally), so the CGI version can't use

>the cached credentials from the CLI user.

>

>Greg

 

I am of course aware that CGI runs within Apache's environment.

 

Is there a way to specify credentials for CGI scripts?

 

How about "runas"? With its /savecred option? I haven't been able to get
this to work in the CGI environment either.

 

At any rate, here is my script with username and password options set:

 

------------------------------------------------------------------------

# Print HTTP header

print "Content-type: text/plain; charset=iso-8859-1\n\n";

 

# Print environment

print "Environment:\n";

foreach $var (sort(keys(%ENV))) {

    $val = $ENV{$var};

    $val =~ s|\n|\\n|g;

    $val =~ s|"|\\"|g;

    print "${var}=\"${val}\"\n";

}

print "\n";

 

# Command to get the contents of a SVN file on SVN server

my $command = "\"c:/Program Files/CollabNet Subversion Server/svn\" \"cat\"
\"--non-interactive\" \"--username=wilsond\" \"--password=notLikely\"
\"http://subversion/svn/src/project/wilsond/test.txt\"";

 

# Run the command

my $output = `$command 2>&1`;

 

# Print the command and output

print "Command:\n$command\n\nOutput:\n$output\n";

 

# Finish happily

exit 0;

------------------------------------------------------------------------

 

Here is the CLI output:

 

------------------------------------------------------------------------

Content-type: text/plain; charset=iso-8859-1

 

Command:

"c:/Program Files/CollabNet Subversion Server/svn" "cat" "--non-interactive"
"--username=wilsond" "--password=notLikely"
"http://subversion/svn/src/project/wilsond/test.txt"

 

Output:

This is a test.

------------------------------------------------------------------------

 

Here is the CGI output:

 

------------------------------------------------------------------------

Command:

"c:/Program Files/CollabNet Subversion Server/svn" "cat" "--non-interactive"
"--username=wilsond" "--password=notLikely"
"http://subversion/svn/src/project/wilsond/test.txt"

 

Output:

svn: PROPFIND request failed on '/svn/src/project/wilsond/test.txt'

svn: PROPFIND of '/svn/src/project/wilsond/test.txt': 403 Forbidden
(http://subversion)

------------------------------------------------------------------------

 

The SVN server Apache access log is similar as well. For CLI accesses, the
user name is "anseri\\wilsond", while for CGI accesses it is - or "", as in
my first message. The script behavior seems entirely independent of the
--username and --password options. Even if I supply completely fictitious
username and password, the command completes successfully in CLI.

 

I find this in the Subversion documentation:

 

One last word about client authentication behavior: a bit of explanation
about the --username and --password options is needed. Many client
subcommands accept these options; however it is important to understand
using these options does not automatically send credentials to the server.
As discussed earlier, the server "pulls" credentials from the client when it
deems necessary; the client cannot "push" them at will. If a username and/or
password are passed as options, they will only be presented to the server if
the server requests them.

 

... and in this case, the server apparently does not request them.

 

 

 
Received on Thu Oct 11 15:55:55 2007

This is an archived mail posted to the Subversion Users mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.