I'm on CentOS 6.6 and I'm having a strange problem with autofs.

I'm trying to mount an smb share on /var/www/html/mysite/docfolder, so I created a docfolder inside the mysite folder, ran chmod 777 on it, then added:

/var/www/html/mysite/docfolder /etc/auto.docfolder --ghost

in /etc/auto.master . Then i created auto.docfolder under /etc and inside it:

pdf -fstype=cifs,rw,noperm,user=username,pass=password ://myshare/docs

When I run

sudo /sbin/service autofs restart

inside /var/log/messages I can read:

Jun 18 12:19:53 Rtmbssrv automount[30779]: do_mount_autofs_indirect: failed to mount autofs path /var/www/html/mysite/docfolder at /var/www/html/mysite/docfolder
Jun 18 12:19:53 Rtmbssrv automount[30779]: handle_mounts: mount of /var/www/html/mysite/docfolder failed!

So I tried stopping the service and running it manually:

sudo automount -vdf

And the folder got mounted correctly without errors.

Changing the mount folder to: /mnt/docfolder works correctly every time.

What's the difference of running automount instead of launching autofs as service?

Why is the service unable to mount that folder?

Edit: It's a SELinux related problem. I have to keep it enabled, so now the question is: how to give permission to autofs to mount file inside a apache folder, leaving it readable from the apache server?

  • FWIW some services have trouble plainly restarting (for various reasons), but work fine with a stop; wait a bit; start sequence, autofs might be one of them. Also check if when executed as a service it is running with the same args. – Dan Cornilescu Jun 18 '15 at 13:18
  • Args are the same (I double checked it). I also tryed to wait about 5/10 minutes. No way. I think it's a selinux related problem. – Funnydj Jun 18 '15 at 14:00

Found this in my notes, from when I ran into this same thing:

Set SELinux boolean to allow Apache to access CIFS shares:

# setsebool -P httpd_use_cifs on

I think that Derek give the right answer. Anyway I also got that working with:

 sudo mkdir /var/wwww/html/site/pdf
 sudo chmod 755 /var/wwww/html/site/pdf

 #try to change SElinux folder tipe
 sudo chcon -t public_content_rw_t /var/www/html/site/pdf

 #i want that persistent
 sudo semanage fcontext -a -t

 #add this inside fcontext file
 public_content_rw_t "/var/www/html/site/pdf(/.*)?"

 #se if the change is definitive
 restorecon -Rv /var/www/html/site/pdf

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.