Project

General

Profile

Can't upload files

Added by Darhl Thomason over 4 years ago

I installed Redmine 3.4.13 on CentOS 8, basically following https://linuxconfig.org/how-to-install-redmine-on-redhat-8.

Environment:
  Redmine version                3.4.13.stable
  Ruby version                   2.4.9-p362 (2019-10-02) [x86_64-linux]
  Rails version                  4.2.11.1
  Environment                    production
  Database adapter               PostgreSQL
SCM:
  Subversion                     1.10.2
  Git                            2.18.4
  Filesystem                     
Redmine plugins:
  clipboard_image_paste          1.13
  redmine_agile                  1.5.3
  redmine_importer               1.2.2
  redmine_lightbox2              0.4.5
  redmineup_tags                 2.0.8

Because of the plugins that my team wanted to use, we went with 3.4.x instead of the v4.x that the tutorial uses.

And because I had to downlevel Ruby, I used RVM to install that.

I also added the apache user to the redmine group:

cat /etc/group | grep redmine
wheel:x:10:myusername,redmine
redmine:x:1002:apache
rvm:x:1003:redmine

Right now, the 'Attachments directory writable' and 'Plugin assets directory writable (./public/plugin_assets)' both have red !'s, and I cannot upload any files.

Doesn't make a difference if SELinux is enforcing or disabled, owner on the folders (/opt/redmine/files & /opt/redmine/public/plugin_assets) are set recursively for redmine:redmine, I've even set the permissions to 777 with no change.

This post (https://www.redmine.org/boards/2/topics/58156) seems to indicate that the owner of /opt/redmine/config.ru is what determines what user Passenger runs as, this file is set to redmine:redmine.

Some log exports are:
/var/log/httpd/redmine_access.log:

1.2.3.4 - - [02/Jul/2020:13:15:45 -0700] "GET /projects/picnic/files/new HTTP/2.0" 200 12449 "https://redmine.test/projects/picnic/files" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36" 
1.2.3.4 - - [02/Jul/2020:13:15:49 -0700] "POST /uploads.js?attachment_id=1&filename=3dprinting.jpg&content_type=image%2Fjpeg HTTP/2.0" 500 648 "https://redmine.test/projects/picnic/files/new" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36" 
1.2.3.4 - - [02/Jul/2020:13:15:51 -0700] "POST /projects/picnic/files HTTP/2.0" 200 12515 "https://redmine.test/projects/picnic/files/new" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36" 

/opt/redmine/log/production.log:

Started GET "/projects/picnic/files/new" for 1.2.3.4 at 2020-07-02 13:15:45 -0700
Processing by FilesController#new as HTML
  Parameters: {"project_id"=>"picnic"}
  Current user: myusername (id=5)
  Rendered attachments/_form.html.erb (6.7ms)
  Rendered files/new.html.erb within layouts/base (13.3ms)
  Rendered plugins/redmineup_tags/app/views/tags/_additional_assets.html.erb (0.7ms)
  Rendered plugins/clipboard_image_paste/app/views/clipboard_image_paste/_headers.html.erb (0.9ms)
  Rendered plugins/redmineup_tags/app/views/tags/_select2_transformation_rules.html.erb (0.3ms)
  Rendered plugins/clipboard_image_paste/app/views/clipboard_image_paste/_add_form.html.erb (4.0ms)
Completed 200 OK in 74ms (Views: 53.3ms | ActiveRecord: 6.6ms)
Started POST "/uploads.js?attachment_id=1&filename=3dprinting.jpg&content_type=image%2Fjpeg" for 172.17.41.151 at 2020-07-02 13:15:49 -0700
Processing by AttachmentsController#upload as JS
  Parameters: {"attachment_id"=>"1", "filename"=>"3dprinting.jpg", "content_type"=>"image/jpeg"}
  Current user: myusername (id=5)
Saving attachment '/opt/redmine/files/2020/07/200702131549_3dprinting.jpg' (52974 bytes)
Completed 500 Internal Server Error in 41ms (ActiveRecord: 6.3ms)

Errno::EACCES (Permission denied @ dir_s_mkdir - /opt/redmine/files/2020):
  app/models/attachment.rb:118:in `files_to_final_location'
  app/controllers/attachments_controller.rb:97:in `upload'
  lib/redmine/sudo_mode.rb:63:in `sudo_mode'

Started POST "/projects/picnic/files" for 172.17.41.151 at 2020-07-02 13:15:51 -0700
Processing by FilesController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"XFG4hSLwp0VaJqoQg8WhFqrFgx8KK4F8Sw2I5esFW4wPmb6qheBFXEl2sQOT9xuav3Gx7MdX4EvbahLgimvA+g==", "attachments"=>{"1"=>{"filename"=>"3dprinting.jpg", "description"=>"", "token"=>""}}, "commit"=>"Add", "project_id"=>"picnic"}
  Current user: myusername (id=5)
  Rendered attachments/_form.html.erb (3.5ms)
  Rendered files/new.html.erb within layouts/base (4.7ms)
  Rendered plugins/redmineup_tags/app/views/tags/_additional_assets.html.erb (1.0ms)
  Rendered plugins/clipboard_image_paste/app/views/clipboard_image_paste/_headers.html.erb (0.8ms)
  Rendered plugins/redmineup_tags/app/views/tags/_select2_transformation_rules.html.erb (0.3ms)
  Rendered plugins/clipboard_image_paste/app/views/clipboard_image_paste/_add_form.html.erb (4.7ms)
Completed 200 OK in 61ms (Views: 42.3ms | ActiveRecord: 6.3ms)

I saw a post somewhere that said Passenger runs as 'nobody', but I don't know how to tell or how to check that.

Any thoughts or suggestions are appreciated.

Thanks!


Replies (4)

RE: Can't upload files - Added by Go MAEDA over 4 years ago

Darhl Thomason wrote:

I saw a post somewhere that said Passenger runs as 'nobody', but I don't know how to tell or how to check that.

Passenger runs as 'nobody' if the owner of config/environment.rb (in your environment, /opt/redmine/config/environment.rb) is root. Otherwise, it runs as the same user as the owner of config/environment.rb.

RE: Can't upload files - Added by Darhl Thomason over 4 years ago

Hmm, the environment.rb is owned by the redmine user. The entire structure from /opt/redmine and down is owned by the redmine user, any thoughts on why I cannot write to the 'files' location?

[myuser@myserver config]$ ls -l
total 84
-rw-rw-r--. 1 redmine redmine   219 Dec 20  2019 additional_environment.rb.example
-rw-rw-r--. 1 redmine redmine  3516 Dec 20  2019 application.rb
-rw-rw-r--. 1 redmine redmine   171 Dec 20  2019 boot.rb
-rw-rw-r--. 1 redmine redmine  8791 Jul  1 08:45 configuration.yml
-rw-rw-r--. 1 redmine redmine  8140 Dec 20  2019 configuration.yml.example
-rw-rw-r--. 1 redmine redmine   161 Jun 26 16:24 database.yml
-rw-rw-r--. 1 redmine redmine  1137 Dec 20  2019 database.yml.example
-rw-rw-r--. 1 redmine redmine   586 Dec 20  2019 environment.rb
drwxrwxr-x. 2 redmine redmine  4096 Dec 20  2019 environments
drwxrwxr-x. 2 redmine redmine  4096 Jun 26 16:37 initializers
drwxrwxr-x. 2 redmine redmine  4096 Dec 20  2019 locales
-rw-rw-r--. 1 redmine redmine 17672 Dec 20  2019 routes.rb
-rw-rw-r--. 1 redmine redmine  6277 Dec 20  2019 settings.yml

[myuser@myserver redmine]$ ls -l
total 92
drwxrwxr-x.  6 redmine redmine 4096 Dec 20  2019 app
-rw-rw-r--.  1 redmine redmine  860 Dec 20  2019 appveyor.yml
drwxrwxr-x.  2 redmine redmine 4096 Dec 20  2019 bin
drwxrwxr-x.  5 redmine redmine 4096 Jun 26 16:23 config
-rw-rw-r--.  1 redmine redmine  160 Dec 20  2019 config.ru
-rw-rw-r--.  1 redmine redmine  241 Dec 20  2019 CONTRIBUTING.md
drwxrwxr-x.  3 redmine redmine 4096 Jun 26 16:37 db
drwxrwxr-x.  2 redmine redmine 4096 Dec 20  2019 doc
drwxrwxr-x.  5 redmine redmine 4096 Dec 20  2019 extra
drwxrwxr-x.  2 redmine redmine 4096 Dec 20  2019 files
-rw-rw-r--.  1 redmine redmine 3617 Dec 20  2019 Gemfile
-rw-rw-r--.  1 redmine redmine 5091 Jun 30 20:49 Gemfile.lock
drwxrwxr-x.  7 redmine redmine 4096 Dec 20  2019 lib
drwxrwxr-x.  2 redmine redmine 4096 Jun 26 16:37 log
drwxrwxr-x.  7 redmine redmine 4096 Jun 30 21:08 plugins
drwxrwxr-x.  8 redmine redmine 4096 Jun 26 16:23 public
-rw-rw-r--.  1 redmine redmine  275 Dec 20  2019 Rakefile
-rw-rw-r--.  1 redmine redmine  205 Dec 20  2019 README.rdoc
drwxrwxr-x.  2 redmine redmine 4096 Dec 20  2019 script
drwxrwxr-x. 10 redmine redmine 4096 Dec 20  2019 test
drwxrwxr-x. 10 redmine redmine 4096 Jun 26 16:41 tmp
drwxrwxr-x.  3 redmine redmine 4096 Jun 26 16:27 vendor

RE: Can't upload files - Added by Pavel Potcheptsov about 4 years ago

chmod -R +w /opt/redmine/files

RE: Can't upload files - Added by Darhl Thomason about 4 years ago

The files should not have to be world writable to work, there was something else going on.

I ended up just killing that server and starting over. Actually talked the team that requested it to go with 4.1. That's working great. Still don't know why the 3.4 install was having issues, I know it's not related to the version of Redmine.

    (1-4/4)