0

Background: I'm running a redmine server with the redmine DMSF plugin, which provides full text search using xapian. Redmine is running on Passenger, hosted by Nginx. The Passenger process is running as user "redmine" and group "nginx". Apparmor is disabled for Passenger and Nginx.

The redmine log indicates that the xapian index cannot be found:

REDMAIN_XAPIAN ERROR: Xapian database is not properly set, initiated or it's corrupted.
DatabaseOpeningError: Couldn't stat '/var/tmp/dmsf-index/english'

And an strace on the running passenger process shows the following:

[pid  1013] stat("/var/tmp/dmsf-index/english", 0x7fa3bd112f00) = -1 ENOENT (No such file or directory)
[pid  1013] write(8, "REDMAIN_XAPIAN ERROR: Xapian dat"..., 88) = 88
[pid  1013] write(8, "DatabaseOpeningError: Couldn't s"..., 66) = 66

A file listing as root:

775# ls -ahl /var/tmp/dmsf-index/english/
total 340K
drwxr-x--- 2 redmine nginx 4.0K Sep  5 13:04 .
drwxr-x--- 3 redmine nginx 4.0K Sep  5 13:04 ..
-rw-r----- 1 redmine nginx    0 Sep  5 14:00 flintlock
-rw-r----- 1 redmine nginx   28 Sep  5 13:04 iamchert
-rw-r----- 1 redmine nginx   13 Sep  5 13:04 position.baseA
-rw-r----- 1 redmine nginx   16 Sep  5 13:04 position.baseB
-rw-r----- 1 redmine nginx  80K Sep  5 13:04 position.DB
-rw-r----- 1 redmine nginx   13 Sep  5 13:04 postlist.baseA
-rw-r----- 1 redmine nginx   17 Sep  5 13:04 postlist.baseB
-rw-r----- 1 redmine nginx 176K Sep  5 13:04 postlist.DB
-rw-r----- 1 redmine nginx   13 Sep  5 13:04 record.baseA
-rw-r----- 1 redmine nginx   14 Sep  5 13:04 record.baseB
-rw-r----- 1 redmine nginx 8.0K Sep  5 13:04 record.DB
-rw-r----- 1 redmine nginx   13 Sep  5 13:04 termlist.baseA
-rw-r----- 1 redmine nginx   14 Sep  5 13:04 termlist.baseB
-rw-r----- 1 redmine nginx  32K Sep  5 13:04 termlist.DB

And several commands run as user "redmine" and group "nginx" via sudo -i:

redmine@redmine:/var/tmp/dmsf-index/english$ pwd
/var/tmp/dmsf-index/english
redmine@redmine:/var/tmp/dmsf-index/english$ file .
.: directory
redmine@redmine:/var/tmp/dmsf-index/english$ ls
flintlock  iamchert  position.baseA  position.baseB  position.DB  postlist.baseA  postlist.baseB  postlist.DB  record.baseA  record.baseB  record.DB  termlist.baseA  termlist.baseB  termlist.DB
redmine@redmine:/var/tmp/dmsf-index/english$ file record.DB 
record.DB: data
redmine@redmine:/var/tmp/dmsf-index/english$ whoami
redmine
redmine@redmine:/var/tmp/dmsf-index/english$

As far as I can tell there are no permission errors (usually indicated with EACCES). I have read that NFS or CIFS can return ENOENT under obscure circumstances, but this is a local ext4 partition mounted at /

I have even tried setting the permissions for dmsf-index recursively as 777, but I get the same error.

So my question is, why can't Passenger/Redmine find the directory, while a shell running as the same user can?

  • Is the application running in a chroot? – Kusalananda Sep 5 '17 at 12:33
  • No it is not running in a chroot. – Ianvdl Sep 5 '17 at 13:02
  • What distribution are you running? Is a security framework such as SELinux active? Does anything appear in the system logs or in the nginx logs? – Gilles 'SO- stop being evil' Sep 5 '17 at 22:18
  • @Gilles I've solved the problem, but for future reference: I'm running Ubuntu 16.04, SELinux is disabled, Apparmor is enabled but currently disabled for Passenger and Nginx. Nothing useful showed in the logs. – Ianvdl Sep 6 '17 at 8:02
2

So it turns out Kusalananda was on the right track regarding a chroot.

The nginx systemd unit file on this machine sets PrivateTmp=true, which according to the documentation does the following:

Takes a boolean argument. If true, sets up a new file system namespace for the executed processes and mounts private /tmp and /var/tmp directories inside it that is not shared by processes outside of the namespace. This is useful to secure access to temporary files of the process, but makes sharing between processes via /tmp or /var/tmp impossible.

Toggling this option to false fixes the problem.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.