On Pi3 with Stretch, apache is calling an wsgi script that should access a file on an external drive. Here's the apache error log:

 mod_wsgi (pid=7963): Failed to exec Python script file '/usr/share/doc/mercurial-common/examples/hgweb.wsgi'.
 mod_wsgi (pid=7963): Exception occurred processing WSGI script '/usr/share/doc/mercurial-common/examples/hgweb.wsgi'.
 Traceback (most recent call last):
   File "/usr/share/doc/mercurial-common/examples/hgweb.wsgi", line 18, in <module>
     application = hgweb(config)
   File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/__init__.py", line 40, in hgweb
     return hgwebdir_mod.hgwebdir(config, baseui=baseui)
   File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/hgwebdir_mod.py", line 123, in __init__
   File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/hgwebdir_mod.py", line 160, in refresh
     repos = findrepos(paths)
   File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/hgwebdir_mod.py", line 65, in findrepos
     repos.extend(urlrepos(prefix, roothead, paths))
   File "/usr/lib/python2.7/dist-packages/mercurial/hgweb/hgwebdir_mod.py", line 77, in urlrepos
     for path in paths:
   File "/usr/lib/python2.7/dist-packages/mercurial/scmutil.py", line 715, in walkrepos
     adddir(seen_dirs, path)
   File "/usr/lib/python2.7/dist-packages/mercurial/scmutil.py", line 702, in adddir
     dirstat = os.stat(dirname)
 OSError: [Errno 13] Permission denied: '/media/pi/data/repositories-HG'

I supposed that is wsgi script is using apache credentials : www-data user.

Using this kind of command:

 sudo -u www-data test -r /media/pi/data/repositories-HG; echo $?

I was able to determine that www-data was able to access /media but not the following directories. Based on this post, I added www-data to "disk" group but nothing changed.

The drive was auto-mounted. I also tried to force mounting but the result is the same. Here's the fstab file:

proc            /proc           proc    defaults          0       0
PARTUUID=d9265b4a-01  /boot           vfat    defaults          0       2
PARTUUID=d9265b4a-02  /               ext4    defaults,noatime  0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that

/dev/sda /media/pi/data ext4 defaults,nofail 0  0

All files in repositories-HG belongs to www-data.www-data:

pi@piJud:/media/pi/data $ l
total 44K
drwxr-xr-x   8 root     www-data 4,0K janv.  2 18:18 .
drwxr-x---+  3 root     root     4,0K mars  13 17:48 ..
drwxrwxr-x  59 www-data www-data 4,0K févr. 25 16:35 repositories-HG

Why is this behaviour?

What should I do?

  • Either mount the external disk with uid=www-data,gid=www-data or add www-data to the pi group. – Dougie Mar 14 at 5:00
  • Thanks, can you explain why adding www-data to pi group should do the trick? – Julien Mar 14 at 7:55
  • Because you need owner or group access. – Dougie Mar 14 at 21:07

Your Answer

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

Browse other questions tagged or ask your own question.