gally Posted March 8, 2011 Share Posted March 8, 2011 I wrote a scrit which mounts an external device, makes some backups then umount the device. Everything works ok when I run the script under Eclipse PHP debugger but fails to unmount the device if I run it as localhost. this is the code $umount = '/bin/umount -f '.$drive; .... u_mount($umount, $error=512); .... This is the called function function u_mount($cmd, $error) { $output = array(); $return_var = 0; $return_var = exec($cmd, $output, $return_var); $return_var = $return_var + $error; .... some checks } In both cases (Eclipse and localhost) $return_var is always 0 but in localhost the umount is not executed and the device is still mounted Any idea? Thanks in advance Gally Quote Link to comment Share on other sites More sharing options...
trq Posted March 8, 2011 Share Posted March 8, 2011 You will need to make sure the user your server runs as has permissions to mount. Quote Link to comment Share on other sites More sharing options...
gally Posted March 8, 2011 Author Share Posted March 8, 2011 it has permissions to mount since the mount command works correctly Quote Link to comment Share on other sites More sharing options...
jasonrichardsmith Posted March 8, 2011 Share Posted March 8, 2011 it has permissions to mount since the mount command works correctly Not really. If you can mount stuff, your user name and root can mount that does not mean www-data can mount. Quote Link to comment Share on other sites More sharing options...
jasonrichardsmith Posted March 8, 2011 Share Posted March 8, 2011 Now that I think about it, giving Apache server the right to mount and unmount is sorta dumb. I recommend setting up a cron job. Quote Link to comment Share on other sites More sharing options...
gally Posted March 8, 2011 Author Share Posted March 8, 2011 previous answer: I wasnt clear. My script can mount the device but cant umount it :-) last answer: Can you help me? I really dont know how to do this Quote Link to comment Share on other sites More sharing options...
jasonrichardsmith Posted March 9, 2011 Share Posted March 9, 2011 I am not sure if this will fix your problem or not. I never tried this: usermod -G users www-data Then add the user option to fstab /dev/sda1 /foo/foo ext3 user,noauto,umask=0002 0 0 /foo/foo needs to change to your mount point and ext3 may not be the file system type. And /dev/sda1 may not be your device. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.