2

Up to now I used this line in /etc/fstab:

/home/ftp_user /home/app_user/mounts/ftp_user  fuse.bindfs  mirror=app_user 0    0

This works. The app_user can access the files of ftp_user like if the files would be his own files.

Now I would like to use inotify. The app_user listens for changes in the bind-mounted directory.

It works if app_user touches a file in /home/app_user/mounts/ftp_user.

But it does not work, if ftp_user touches a file in /home/ftp_user.

Is there way to get this working?

OS: Linux only.

Update: use http if possible

If possible avoid clever inotify solutions. Receiving files via http is often better, since you can validate the files before accepting them. See use http, avoid ftp/sftp/scp/rsync/smb/mail

  • Use ACLs, not FUSE bindfs. There's no need for a bind mount at all. – Michael Hampton Oct 8 '18 at 19:13
  • @MichaelHampton could you please give me a reason. Why are ACLs better than FUSE? What are the benefits? – guettli Dec 11 '19 at 9:44
3
+25

What you are trying to achieve can't be done.
Look at the https://bindfs.org/ and scroll down to "Known issues" section. You will see that

inotify events are not triggered since FUSE doesn’t provide an API for this

You can use inotify to monitor /home/ftp_user, but in this case user who is setting up watch will need to have access to this directory.

| improve this answer | |
  • Maybe there is a solution which does not use FUSE? – guettli Oct 8 '18 at 15:42
  • 2
    You can possibly use ACL and add permissions to user app_user on /home/ftp_user dir and then setup inotify watch directly to /home/ftp_user dir. That of course would require mounting /home file system with ACL option. – Dmitry Zayats Oct 8 '18 at 15:45
  • 1
    Solution which does not use fuse is called ACL - Access Control Lists. Start reading here access.redhat.com/documentation/en-us/red_hat_enterprise_linux/… – Dmitry Zayats Oct 8 '18 at 15:47
1

Doing it the other way round works:

The ftp_user gets the virtual (mounted) directory, and the app_user holds the real directory.

/home/ftp_user /home/app_user/import/ftp_user  fuse.bindfs  mirror=ftp_user 0    0

New files get created in the virtual directory (for example /home/ftp_user/new.txt). This triggers the inotify which runs as user app_user. In this example the file event gets created for /home/app_user/import/ftp_user/new.txt.

| improve this answer | |
  • 1
    This works fantastically for me. I want to trigger resilio-sync running as its own user, but wasn't able to get it to working faster than the standard 10min scan. Doing it reverse here works great for triggering via inotify – tlnagy Dec 11 '19 at 3:50

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.