Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question, possible feature request concerning SSHFS user/group #24

Open
wildernessfamily opened this issue Oct 26, 2023 · 1 comment
Open

Comments

@wildernessfamily
Copy link

Hi,
I've been using iNotifyScan for some time. It works flawlessly. It's amazing! I switched from using SAMBA to SSHFS. I don't want all my users (family members) using the same SSH key for user www-data. Example, lets say my SSH username is david123. When I create the SSHFS mount to my NextCloud files and I transfer files they are written as user david123 and group david123. iNotifyScan picks up the files and adds them to NextCloud database but in I can't access them in NextCloud UI. I get permission denied due to the user/group naming.
When using iNotifyScan, is there a possibility to be able to update the user/group of all of the scanned files for any and all users to www-data:www-data during the scan?

Thank you for your time and hard work creating iNotifyScan. Very much appreciated!

@Blaok
Copy link
Owner

Blaok commented Oct 28, 2023

Hi,

I'm very glad that you find this project useful :)

Regarding your feature request, let me first confirm if I understand it correctly:

  1. You have a server running Nextcloud as user www-data; the same server also serves files as user david123 via SSH;
  2. Files uploaded via SSH/SSHFS is not accessible by www-data because they have user/group david123. Therefore, the Nextcloud web server cannot access them;
  3. Your solution is to run nextcloud-inotifyscan as root so that it not only adds files to the Nextcloud database, but also updates the user and group so that the web server can access them as www-data.

I think this is a valid and probably very common use case, but I wouldn't recommend your solution, for two reasons: 1) updating user/group is not intended usage of nextcloud-inotifyscan, especially given the fact that it requires privileges, and 2) there is a simpler and (arguably) better solution. In fact, I have exactly the same use cases and have been using the following solution for years, but never was able to document it anywhere. This might be a good time to do it. The idea is to attack the fact that

Files uploaded via SSH/SSHFS is not accessible by www-data because they have user/group david123.

This is doable using ACL to make new files and directories inherit group from their parent directory. Step-by-step example:

  1. Select or create a group whose members are sharing (read & write) accesses, e.g., family;
  2. Add users to the group, e.g., usermod -a -G family www-data; usermod -a -G family david123;
  3. Change the group of files that you intend to share, e.g., chgrp family -R /path/to/shared/dir/;
  4. Make the files writable by the group, e.g., chmod g+w /path/to/shared/dir/;
  5. Make new files/directories inherit the group, e.g., chmod g+s /path/to/shared/dir/;
  6. Make new files/directories inherit the mode so that new files/directories remain writable by the group, e.g., setfacl -dm g::rwx /path/to/shared/dir/.

New files and directories under /path/to/shared/dir/ will now have group family even if they are created by the www-data user via Nextcloud or by the david123 user via SSH. Both users are able to read & write files owned by group family, too. New subdirectories will inherit the same property. Existing files and directories will need to be updated in a similar way as /path/to/shared/dir/, possibly with the help of find -type d/f -exec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants