The function subversion_fetch_repository is used to fetch subversion logs, but I get an error saying that Subversion needs a password. In the implementation of the Subversion module, access to repositories is dealt with on the level of individual projects, and not on the level of the repository, so there is no easy fix for this. A possible solution could be to add username and password fields in the subversion_repositories table (and of course in the corresponding input forms) that are used for fetching logs. When the variables $repo->username and $repo->password are defined, the beginning of the subversion_fetch_repository function should be something like:

  $start_revision = intval($repo->last_revision);

   $cmd = array(
      escapeshellarg(escapeshellcmd(variable_get('subversion_svn_binary', '/usr/bin/svn'))),
      'log',
      '-r', ($start_revision > 0 ? $start_revision+1 : 0) . ":HEAD",
      '--incremental',
      '--non-interactive',
      '--xml',
      '-v',
      '--username '. $repo->username,
      '--password '. $repo->password,
      '--limit', variable_get('subversion_cron_fetch_amount', 100)
   );

Another possible solution could be that the creator of the Subversion module presumed that the web account (e.g. apache) had access to fetch subversion logs. If so, please let me know; then I can ask my server administrator to fix this.

Comments

halkeye’s picture

Status: Postponed (maintainer needs more info) » Fixed

I just put up a new fix, see if that fixes things.
I don't have non anon read repos myself so must have missed that one.

leop’s picture

Status: Fixed » Closed (duplicate)

I'm afraid your fix is not going to work. The problem is that you define Subversion authorization on the level of individual projects, while the functions that are used for retrieving information from the repository work on the level of an entire repository. Since in the Subversion module there are no user and password fields for a repository (you probably assume anonymous read access for repositories), those functions don't work. Your solution is:

 if ($project->need_auth) {
     # login using owner's login and password
     $cmd = array_merge($cmd, array(
       '--username', escapeshellarg($project->auth_username),
       '--password', escapeshellarg($project->auth_password),
     ));
   }

But in all cases (subversion_cat, subversion_fetch_repository, subversion_get_diff and subversion_ls) the variable $project is not defined. That is because all these functions operate on the level of the repository, not on the level of a project. azbok's proposal for fixing this (http://drupal.org/node/198639) , is unfortunately also not correct. The problem there is that the username and password from the first project that is fetched from the database with the corresponding repository are used. Any usernames and passwords for other projects are discarded in that way.

The real solution to this is to implement authentication on the level of the repository, or to rewrite all functions to the level of individual projects. I think the latter is the best solution, but it is more complicated.

I think we need to continue this discussion at: http://drupal.org/node/198639, so I marked this one as duplicate.