Cannot access external drive from webserver

Moderators: odroid, mdrjr

Cannot access external drive from webserver

Unread postby Respectech » Tue Oct 07, 2014 6:44 am

I know this isn't technically an ODROID issue, so feel free to tell me to "take a hike". ;-) But, if you have any ideas, I'd really appreciate them.

I'm using lighttpd (lightweight webserver) on an ODROID-U3 running the latest version of Ubuntu, and I'm trying to access files on an external drive.

My lighttpd www directory is at /var/www. I have symlinked the following file in that directory:

Code: Select all
lrwxrwxrwx 1 root root 27 oct 6 14:20 video -> /media/odroid/1TB/smoothcam


When I try accessing that directory from lighttpd using CGI, I get:

Code: Select all
** Access error: cannot open: video/ reason: 13 **


If I try accessing that symlink with any other user (not within lighttpd), I can access it fine.

Here is a listing of video/:

Code: Select all
drwxrwxrwx 1 www-data www-data 4096 oct 6 13:40 smoothcam1


I've added www-data (the user that lighttpd server runs under) to the "root" and "odroid" groups as those can access that directory just fine. I cannot figure out how to execute a process as the user "www-data", so I can't try to recreate that. Here's the id of user "www-data" on my system:

Code: Select all
uid=33(www-data) gid=33(www-data) groups=33(www-data),0(root),1001(odroid)


Any ideas what I'm doing wrong?
Respectech
 
Posts: 279
Joined: Wed Nov 13, 2013 9:20 am
Location: California
languages_spoken: English, German, some Ukrainian, some Spanish
ODROIDs: All the ODROIDs!!

Well, the ones released since the U2.

Re: Cannot access external drive from webserver

Unread postby mdrjr » Tue Oct 07, 2014 10:24 am

I think you have to manually mount your disk instead of letting auto-mounter do it...
It will be probably better...
mdrjr
Site Admin
 
Posts: 11695
Joined: Fri Feb 22, 2013 11:34 pm
Location: Brazil
languages_spoken: english, portuguese
ODROIDs: -

Re: Cannot access external drive from webserver

Unread postby Respectech » Wed Oct 08, 2014 12:03 am

I have a line in /etc/fstab to specify the mount. I've tried umount and mount to manually mount it, but nothing changes. Here's my line from fstab:

Code: Select all
/dev/sda1    /media/odroid/1TB    ntfs    defaults,uid=1000,gid=1000,umask=000    0    2


Any other ideas?
Respectech
 
Posts: 279
Joined: Wed Nov 13, 2013 9:20 am
Location: California
languages_spoken: English, German, some Ukrainian, some Spanish
ODROIDs: All the ODROIDs!!

Well, the ones released since the U2.

Re: Cannot access external drive from webserver

Unread postby meveric » Wed Oct 08, 2014 5:10 am

Respectech wrote:I have a line in /etc/fstab to specify the mount. I've tried umount and mount to manually mount it, but nothing changes. Here's my line from fstab:

Code: Select all
/dev/sda1    /media/odroid/1TB    ntfs    defaults,uid=1000,gid=1000,umask=000    0    2


Any other ideas?

i think if you mount it for gid und uid 1000 it's mounted for the first user in the system which should be the user "odroid"... so that won't help with accessing for www-data...
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.
User avatar
meveric
 
Posts: 9476
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go

Re: Cannot access external drive from webserver

Unread postby Respectech » Wed Oct 08, 2014 5:19 am

I also tried mounting it for uid www-data and gid www-data, but that made no difference. Plus, I have a different U3 running the same configuration and it works fine there with uid and gid 1000.
Respectech
 
Posts: 279
Joined: Wed Nov 13, 2013 9:20 am
Location: California
languages_spoken: English, German, some Ukrainian, some Spanish
ODROIDs: All the ODROIDs!!

Well, the ones released since the U2.

Re: Cannot access external drive from webserver

Unread postby Respectech » Fri Oct 10, 2014 3:48 am

For test purposes, I tried cloning the eMMC from my older U3 that can read/write from the Lighttpd (webserver) process from/to the external NTFS-formatted disk drive and mounted the cloned card on the new U3. It works!

So there is definitely nothing wrong with the hardware, and it is possible for Lighttpd running as www-data:www-data to read/write from/to an external NTFS-formatted disk drive mounted via /etc/fstab with the following parameters:

Code: Select all
/dev/sda1    /media/odroid/video    ntfs    defaults,uid=1000,gid=1000,umask=000    0    2


The system that was cloned is running ntfs-3g.

Very curious why I can't get it to work with a newer image of Ubuntu for the U3.
Respectech
 
Posts: 279
Joined: Wed Nov 13, 2013 9:20 am
Location: California
languages_spoken: English, German, some Ukrainian, some Spanish
ODROIDs: All the ODROIDs!!

Well, the ones released since the U2.

Re: Cannot access external drive from webserver

Unread postby Respectech » Fri Oct 10, 2014 4:06 am

For clarification, the old U3 was running Xubuntu 13.10 (works as I hoped) while the new U3 was running Lubuntu 14.04.1 LTS.
Respectech
 
Posts: 279
Joined: Wed Nov 13, 2013 9:20 am
Location: California
languages_spoken: English, German, some Ukrainian, some Spanish
ODROIDs: All the ODROIDs!!

Well, the ones released since the U2.

Re: Cannot access external drive from webserver

Unread postby LiquidAcid » Fri Oct 10, 2014 6:58 am

My guess is that this is a problem with the symlink. By default webservers don't follow symlinks, and I don't think lighthttpd is an exception. In general you shouldn't change this behaviour, since it can create huge security issues.

I would just directly mount the NTFS volume in /var/www/, or if you want to keep the position in /media, just create an additional bind mount.
LiquidAcid
 
Posts: 1080
Joined: Fri Oct 11, 2013 11:07 pm
languages_spoken: english
ODROIDs: X2

Re: Cannot access external drive from webserver

Unread postby Respectech » Fri Oct 10, 2014 8:05 am

Thanks! I'll give that a try.

However, it still doesn't explain why it worked with the same setup on Xubuntu 13.10 but not on Lubuntu 14.04.1 LTS.
Respectech
 
Posts: 279
Joined: Wed Nov 13, 2013 9:20 am
Location: California
languages_spoken: English, German, some Ukrainian, some Spanish
ODROIDs: All the ODROIDs!!

Well, the ones released since the U2.

Re: Cannot access external drive from webserver

Unread postby Respectech » Fri Oct 10, 2014 8:46 am

@LiquidAcid: You're a genius! Mounting it as /var/www/video works! Must be some slight difference in the security mechanisms between Xubuntu 13.10 and Lubuntu 14.04.1 LTS.
Respectech
 
Posts: 279
Joined: Wed Nov 13, 2013 9:20 am
Location: California
languages_spoken: English, German, some Ukrainian, some Spanish
ODROIDs: All the ODROIDs!!

Well, the ones released since the U2.


Return to Ubuntu

Who is online

Users browsing this forum: Bing [Bot] and 5 guests