Subversion integration problem

Added by Radek Antoniuk over 9 years ago

Hey,

First question:
I'm trying to integrate redmine with external subversion repository reachable via https.
I'm getting the exception in the logs, any ideas:

Processing RepositoriesController#show (for 77.237.9.180 at 2010-03-03 12:44:19) [GET]
  Parameters: {"action"=>"show", "id"=>"testrepo", "controller"=>"repositories"}
Error parsing svn output: #<REXML::ParseException: No close tag for /lists/list>
/usr/lib/ruby/1.8/rexml/parsers/treeparser.rb:28:in `parse'
/usr/lib/ruby/1.8/rexml/document.rb:228:in `build'
/usr/lib/ruby/1.8/rexml/document.rb:43:in `initialize'
/usr/share/redmine/lib/redmine/scm/adapters/subversion_adapter.rb:85:in `new'
/usr/share/redmine/lib/redmine/scm/adapters/subversion_adapter.rb:85
/usr/share/redmine/lib/redmine/scm/adapters/abstract_adapter.rb:193:in `call'
/usr/share/redmine/lib/redmine/scm/adapters/abstract_adapter.rb:193:in `shellout'
/usr/share/redmine/lib/redmine/scm/adapters/abstract_adapter.rb:191:in `popen'
/usr/share/redmine/lib/redmine/scm/adapters/abstract_adapter.rb:191:in `shellout'
/usr/share/redmine/lib/redmine/scm/adapters/abstract_adapter.rb:177:in `shellout'
/usr/share/redmine/lib/redmine/scm/adapters/subversion_adapter.rb:82:in `entries'
/usr/share/redmine/app/models/repository.rb:63:in `entries'
/usr/share/redmine/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:214:in `send'
/usr/share/redmine/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:214:in `method_missing'
/usr/share/redmine/app/controllers/repositories_controller.rb:72:in `show'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/base.rb:1256:in `send'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/base.rb:1256:in `perform_action_without_filters'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/filters.rb:617:in `call_filters'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/filters.rb:610:in `perform_action_without_benchmark'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/lib/ruby/1.8/benchmark.rb:293:in `measure'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in `perform_action_without_rescue'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/rescue.rb:136:in `perform_action'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/base.rb:524:in `send'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/base.rb:524:in `process_without_filters'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/filters.rb:606:in `process_without_session_management_support'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/session_management.rb:134:in `process_without_test'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/test_process.rb:18:in `process'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/base.rb:392:in `process'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:184:in `handle_request'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:112:in `dispatch_unlocked'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:125:in `dispatch'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:124:in `synchronize'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:124:in `dispatch'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:134:in `dispatch_cgi'
/usr/share/redmine/vendor/rails/actionpack/lib/action_controller/dispatcher.rb:41:in `dispatch'
/usr/share/redmine/vendor/rails/railties/lib/fcgi_handler.rb:101:in `process_request'
/usr/share/redmine/vendor/rails/railties/lib/fcgi_handler.rb:151:in `with_signal_handler'
/usr/share/redmine/vendor/rails/railties/lib/fcgi_handler.rb:99:in `process_request'
/usr/share/redmine/vendor/rails/railties/lib/fcgi_handler.rb:76:in `process_each_request'
/usr/lib/ruby/1.8/fcgi.rb:612:in `each_cgi'

...
No close tag for /lists/list
Line:
Position:
Last 80 unconsumed characters:
Output was:
 <?xml version="1.0"?>
<lists>
<list
   path="https://path/to/repo/">
Rendering template within layouts/base
Completed in 1981ms (View: 48, DB: 14) | 500 Internal Server Error

My idea is that maybe this is due to non-trusted CA? but.. any help appreciated ;)

Replies (8)

RE: Subversion integration problem - Added by Felix Schäfer over 9 years ago

I'd wager on the non-trusted CA, as redmine shells out the svn command, which in turns needs to run without interaction. I think it should be enough to log in as the user redmine is run, make an svn info https:// and so on, at which point svn should ask you if you want to trust the CA, where can say permanently.

RE: Subversion integration problem - Added by TEHEK Firefox over 9 years ago

Hi!

I've actually run on the same problem just now.

After spending 2 hours, I've found a solution.

REQUIREMENTS
An access to the server (SSH or physical access).

STEPS
1. login to your server which runs redmine
2. create a folder somewhere in your system that will be used to store svn's config for redmine. I.e. /tmp/redmine-svn (dont forget to give write access to the user which runs Redmine, in Ubuntu apache, it's www-data)
3. issue the following command:

svn --config-dir /tmp/redmine-svn list https://your.repo.address/your/repo/path

4. You will be asked something like this:

Error validating server certificate for 'https://your.repo.address:443':
- The certificate is not issued by a trusted authority. Use the
fingerprint to validate the certificate manually!
Certificate information:
- Hostname: your.repo.address
- Valid: from Fri, 26 Feb 2010 20:58:09 GMT until Sat, 26 Feb 2011 20:58:09 GMT
- Issuer: Internet Widgits Pty Ltd, Some-State, AU
- Fingerprint: fe:0a:38:de:8f:8d:73:85:3c:ce:8c:f6:6b:65:e8:86:9b:b2:30:6a
(R)eject, accept (t)emporarily or accept (p)ermanently? p

Enter p, push enter

5. Open REDMINE_ROOT/lib/redmine/scm/adapters/subversion_adapter.rb

6. Go to line 27 and change

SVN_BIN = "svn"

to

SVN_BIN = "svn --config-dir /tmp/redmine-svn"

Of course, replace "/tmp/redmine-svn" if you used different folder

7. Go drink coffee! =)

EXPLANATION

The problem is exactly as described above by Felix. Since your (and mine) certificate is not trusted, svn asks for action in shell. But since Redmine does svn in --non-interactive form and cannot force svn to accept certificate, we receive an error (or nothing).

svn --config-dir orders svn to store configuration (and accepted and stored certificates) somewhere on your drive.

First, we try doing something manually on svn and prompted to store certificate. After permanently storing certificate it in that config dir, we configure Redmine to use the same dir and thus making it accept the certificate.

If you change certificate, this steppes have to be reapplied, i think.

Cheerz! =^_^=

RE: Subversion integration problem - Added by Henrik Pestano over 9 years ago

Hi, I followed the recommended steps and however I have the same error ... could help me please

RE: Subversion integration problem - Added by Radek Antoniuk over 9 years ago

Hello,

1. Go to /etc/passwd and change /bin/true to /bin/bash for the www-data user
2. check what is the home directory that is set for the www-data user and if the user has write permissions to it
3. su - www-data
4. svn info <repo_url>
5. accept the certificate permanently
6. verify that now it works
7. change back /bin/bash to /bin/true in passwd file

RE: Subversion integration problem - Added by Henrik Pestano over 9 years ago

working perfectly, thank you very much

RE: Subversion integration problem - Added by Kirk Stork over 9 years ago

Hi all,

The above advice all worked fine before the server hosting my repository upgraded their SSL to version 1.0. Now it doesn't work at all. (yes my redmine installation is on OpenSSL 1.0 now also.)

When I try, e.g. the steps by Radek, I no longer get prompted to accept the certificate -- it just fails.

To test, this I monkeyed around with curl.

bash-3.2$ curl https://my.svn.server
curl: (35) error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112)

But when I do

bash-3.2$ curl -3 https://my.svn.server
.. contents arrive

The -3 option to curl tells openssl to use protocol version 3.

I'm wondering if there's a way to tell svn to do the same thing?

Any ideas?

Kirk

RE: Subversion integration problem - Added by Rajith C almost 5 years ago

Hi,

I have followed steps of @ TEHEK Firefox in Windows7 Server PC. Following error occurred. Please help..

An error occurred when trying to access the repository: No such file or directory - "svn --config-dir /tmp/redmine-svn" list --xml "https://xxxxx/svn/redminedemo//"@HEAD --username xxxx --password xxxx --no-auth-cache --non-interactive

Regards,
Rajith

RE: Subversion integration problem - Added by Daniel Scott about 4 years ago

I found, with Redmine v3 that I needed to modify the subversion adapter and put in an explicit config-dir argument.

The complete steps I used were these:

1: Modify Redmine's subversion adapter script

# pico /usr/share/redmine/lib/redmine/scm/adapters/subversion_adapter.rb

Change the line in that file with command line args

from: str << " --no-auth-cache --non-interactive"

to: str << " --config-dir /usr/share/redmine/svn/.subversion --no-auth-cache --non-interactive"

2: Ensure subversion client accepts the self-signed cert permanently

# sudo -u www-data svn --config-dir /usr/share/redmine/svn/.subversion list {your-repository-url}

When prompted, select the option to accept certificate (p)ermanently

To complete the test, enter your subversion credentials when prompted (hit enter at the first username prompt for www-data and it'll ask again for another username). When prompted select "no" to saving your credentials unencrypted (the necessary acceptance of the SSL cert has already been saved by this point). You can verify that by looking inside the /usr/share/redmine/svn/.subversion directory, where you'll find a directory called svn.ssl.server with a new file in it.

Obviously if your copy of redmine runs as a user other than www-data you should sudo using that user instead. Make sure the user you sudo to has the necessary permissions to create an /svn directory inside the redmine directory - otherwise you may not be given the option to (p)ermanently accept the certificate when you run the svn client.

3: Restart Apache

In my case, redmine is running using mod_passenger under apache, so it was necessary to restart apache to pick up the changes to the redmine subversion adapter script (prior to the restart I was still seeing errors in redmine).

# /etc/init.d/apache2 restart

4: Browse to a project's /repository in Redmine

Everything should now be working

(1-8/8)