Package: redmine
Version: 3.0~20140825-8~deb8u3
Severity: important
Tags: patch

Dear maintainers,

the patch to load all database drivers for the recent update in Jessie
causes some regression when having these instances running as different
users (and thus different owners on files and directories).

Upgrade process itself runs just fine, but starting Redmine from uwsgi for
example causes an error, because the database config of the other instances
cannot be loaded:
  | Tue Jun  7 16:25:54 2016 - *** Operational MODE: preforking ***
  | Tue Jun  7 16:25:54 2016 - *** uWSGI is running in multiple interpreter 
mode ***
  | Tue Jun  7 16:25:54 2016 - spawned uWSGI master process (pid: 2678)
  | Tue Jun  7 16:25:54 2016 - spawned uWSGI worker 1 (pid: 2700, cores: 1)
  | Tue Jun  7 16:25:54 2016 - spawned uWSGI worker 2 (pid: 2701, cores: 1)
  | Tue Jun  7 16:25:54 2016 - /usr/share/redmine/Gemfile:53:in `read':
  |     Permission denied @ rb_sysopen - /etc/redmine/project1/database.yml 
(Errno::EACCES)
  | Tue Jun  7 16:25:54 2016 -      from /usr/share/redmine/Gemfile:53:in 
`block in eval_gemfile'
  | Tue Jun  7 16:25:54 2016 -      from /usr/share/redmine/Gemfile:52:in `each'
  | ...
  | Tue Jun  7 16:25:55 2016 - DAMN ! worker 1 (pid: 2700) died :( trying 
respawn ...
  | Tue Jun  7 16:25:55 2016 - Respawned uWSGI worker 1 (new pid: 2881)
  | Tue Jun  7 16:25:55 2016 - DAMN ! worker 2 (pid: 2701) died :( trying 
respawn ...
  | Tue Jun  7 16:25:55 2016 - Respawned uWSGI worker 2 (new pid: 2882)

The following patch fixes this while still retaining the intended behaviour
on upgrade:
  | --- /usr/share/redmine/Gemfile.orig     2016-06-07 16:54:13.609621700 +0200
  | +++ /usr/share/redmine/Gemfile  2016-06-07 16:53:24.393621700 +0200
  | @@ -50,7 +50,8 @@
  |  Dir['{config,/etc/redmine/*}/database.yml'].select do |f|
  |    File.exists?(f)
  |  end.each do |database_file|
  | -  database_config = YAML::load(ERB.new(IO.read(database_file)).result)
  | +  database_config = YAML::load(ERB.new(IO.read(database_file)).result) \
  | +    rescue YAML::load("production:\n adapter: none")
  |    adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
  |    if adapters.any?
  |      adapters.each do |adapter|
In case of an unreadable file, a faked YAML with no database adapter is
foisted by 'rescue'; thus startup isn't interrupted by an unreadable file.

Thanks for providing Redmine in Debian and thanks for providing
multi-instance support!! :)

-- Adi

PS: here is an example uwsgi config for running redmine (just in case you
    need it for reproducing the issue). To run it that way, you need to
    create an account named 'redmine' (see uid/gid) and install
    uwsgi and uwsgi-plugin-rack-ruby2.1.
    | uwsgi:
    |   plugins: rack
    |   rack: config.ru
    |   env: RAILS_ENV=production
    |   env: X_DEBIAN_SITEID=default
    |   chdir: /usr/share/redmine/
    |   uid: redmine
    |   gid: redmine
    | 
    |   # parameters that depend on the redmine instance
    |   pid: /var/run/uwsgi/app/redmine-default/pid
    |   log: /var/log/redmine/default/production.log
    | 
    |   master: true
    |   lazy-apps: true
    |   memory-report: 1
    |   reload-on-rss: 256
    |   post-buffering: 4096
    |   #default socket is /run/uwsgi/app/redmine-default/socket
    |   chown-socket: www-data
--- /usr/share/redmine/Gemfile.orig	2016-06-07 16:54:13.609621700 +0200
+++ /usr/share/redmine/Gemfile	2016-06-07 16:53:24.393621700 +0200
@@ -50,7 +50,8 @@
 Dir['{config,/etc/redmine/*}/database.yml'].select do |f|
   File.exists?(f)
 end.each do |database_file|
-  database_config = YAML::load(ERB.new(IO.read(database_file)).result)
+  database_config = YAML::load(ERB.new(IO.read(database_file)).result) \
+    rescue YAML::load("production:\n adapter: none")
   adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
   if adapters.any?
     adapters.each do |adapter|

Attachment: signature.asc
Description: Digital signature

Reply via email to