I've written a webpage that lets me remotely mount an encfs encrypted folder, which is then accessible via WebDAV. It's basically just a password form with a mount / unmount button, which tries to mount / unmount a predefined encfs encrypted drive with the password supplied via the form. Basically a internet accessible wrapper to
encfs --stdinpass /encfs/drive/encrypted/ /var/www/unencrypted
This works as intended, as in I can mount / unmount the encrypted drive and I can see / read the unencrypted data via WebDAV.
But there is something strange going on: The unencrypted view of the folder is ONLY accessible via WebDAV.
If I run sudo -u www-data ls -la /var/www (www-data is the user running the webserver and therefore also the user mounting the drive, I've confirmed this with htop) or as any other user, I see the mounting point (in the example above this would be /var/www/unencrypted) as a regular folder, not like a typical encfs folder, which should normally look something like this:
drwxr-xr-x 5 www-data www-data 4096 Feb 1 02:25 .
drwxr-xr-x 15 root root 4096 Jan 31 11:46 ..
d????????? ? ? ? ? ? unencrypted
but actually it looks like that:
drwxr-xr-x 5 www-data www-data 4096 Feb 1 02:25 .
drwxr-xr-x 15 root root 4096 Jan 31 11:46 ..
drwxr-xr-x 2 www-data www-data 4096 Jan 31 21:47 unencrypted
just like a normal folder (which is reported as being empty, although the same folder has data in it when accessing it via WebDAV).
Also there is no entry in /etc/mtab indicating that the encfs drive was ever mounted. For all intents and purposes, it looks as if the drive was never mounted, although it in fact definitely is, because I can access it via WebDAV and also the ecnfs process is clearly running, as shown in htop.
How does this happen and how to fix this?
PS: If I run
sudo -u www-data bash -c "echo $(cat /tmp/passwort_file) | encfs --stdinpass /encfs/drive/encrypted/ /var/www/unencrypted"
from the terminal, there is no such behavior. The folder is still accessible via WebDAV, but in this case it also correctly appears in /etc/mtab and is also visible as an encfs drive when using ls -la.