MMarco94 / linux-guides

A collection of guides to make the Linux experience easier
MIT License
5 stars 1 forks source link

Syncthing file access and permissions problem #1

Closed aaylnx closed 1 year ago

aaylnx commented 2 years ago

I really like your guide for installing Syncthing on an immutable OS. I'm running Fedora 36 Kinoite. I've adjusted things so that I'm starting up the container like this:

podman run -d \
  --name=syncthing \
  --label io.containers.autoupdate=registry \
  -e PUID=0 \
  -e PGID=0 \
  -p 127.0.0.1:8384:8384 \
  -p 22000:22000/tcp \
  -p 22000:22000/udp \
  -p 21027:21027/udp \
  -v ~/.config/syncthing:/config:Z \
  -v /var/home/aaylnx/synced_shares/personal_cloud:/data1:Z \
  lscr.io/linuxserver/syncthing:latest

The container starts up without a problem, however, the default folder is not "personal_cloud" as indicated above, but ~/.config/syncthing/Sync

When I move items into "Sync" using my normal user, I get a warning from Syncthing about "Failed Items" and that permission is denied.

Any suggestions?

Thank you for your guide!

MMarco94 commented 2 years ago

The container starts up without a problem, however, the default folder is not "personal_cloud" as indicated above, but ~/.config/syncthing/Sync

On Syncthings' web UI (http://127.0.0.1:8384), you need to actually share /data1. That's what's mapped to the personal_cloud folder. What you're seeing is probably the default folder share, which like you mentioned is inside the configuration folder.

When I move items into "Sync" using my normal user, I get a warning from Syncthing about "Failed Items" and that permission is denied.

I don't know. Given how you're starting the container, Syncthing should have the same exact permissions as your "normal user". What's the output of ls -la /var/home/aaylnx/synced_shares_syncthing/personal_cloud (or ls -la ~/.config/syncthing/Sync if you haven't fixed the folder issue yet)?

aaylnx commented 2 years ago

You were correct about selecting /data1 as the shared folder. Once I did that, I was able to sync with my other machines.

However, I still have permission problems (same error as above) when I add or edit files in my syncthing directory.

The output of ls -la /var/home/aaylnx/synced_shares/personal_cloud is

drwxr-xr-x. 1 aaylnx aaylnx    434 Jun 17 20:13 .
drwxrwxr-x. 1 aaylnx aaylnx     28 Jun 17 19:50 ..
drwxr-xr-x. 1 aaylnx aaylnx    266 Jun 17 19:39 Audio
drwxr-xr-x. 1 aaylnx aaylnx    508 Jun 17 19:53 bin
-rw-r--r--. 1 aaylnx aaylnx  30953 Jun 17 10:16 changelog.md
drwxr-xr-x. 1 aaylnx aaylnx    302 Jun 17 19:53 .desktop-obsidian
drwxr-xr-x. 1 aaylnx aaylnx      0 Jun 17 19:39 Desktop-Obsidian-Settings
drwxr-xr-x. 1 aaylnx aaylnx   7576 Jun 17 20:12 Documents
drwxr-xr-x. 1 aaylnx aaylnx     80 Jun 17 19:45 Images
drwxr-xr-x. 1 aaylnx aaylnx    318 Jun 17 19:53 .obsidian
-rw-r--r--. 1 aaylnx aaylnx    369 Jun 17 10:16 PfSense.md
drwxr-xr-x. 1 aaylnx aaylnx      0 Jun 17 19:39 .stfolder
drwxr-xr-x. 1 aaylnx aaylnx      0 Jun 17 19:39 super-productivity
-rw-r--r--. 1 aaylnx aaylnx   2758 Jun 17 10:16 .vault-stats
drwxr-xr-x. 1 aaylnx aaylnx     82 Jun 17 19:57 Video
MMarco94 commented 2 years ago

Permissions seem right. Are the files getting synchronized between your two machines, or is the error preventing that? Is there a more detailed log or error message in the web UI (Actions > Logs)?

aaylnx commented 2 years ago

Yes, permissions have the appearance of being alright.

Let me give an overview of the problem. After setting up ST using podman as your guide directs, I am able to sync all existing files FROM preexisting devices TO the new podman ST instance without any problems. Also, if new files are added to those preexisting devices, they sync over to the new podman container without any problems. However, if I manually add new files to the podman instance, they won't sync over to my other devices, because of errors podman is having.

Checking the logs, as you suggest, I see the following error upon moving a test png into the shared folder found on the podman instance.

2022-06-20 18:54:42 Error while trying to start filesystem watcher for folder "personal_cloud" (zvaee-rdkx7), trying again in 1m0s: lstat /data1/personal_cloud/Images/TPH_568.png: permission denied
2022-06-20 18:54:42 Scanner (folder "personal_cloud" (zvaee-rdkx7), item "Images/TPH_568.png"): scan: lstat /data1/personal_cloud/Images/TPH_568.png: permission denied

This still appears to be a permissions error of some sort, but is it anything specific to the filesystem watcher? I am unsure.

Thanks for your help!

aaylnx commented 2 years ago

Just in case something weird was going on in my system, I've tried this again in a clean setup, in a VM, and I get the same problem. Whenever I add any new files into my shared folder I get the following error.

2022-06-20 21:13:14 Error while trying to start filesystem watcher for folder "syncthing-test" (ttzjz-dqanj), trying again in 1m0s: lstat /data1/test.mp3: permission denied
2022-06-20 21:13:14 Scanner (folder "syncthing-test" (ttzjz-dqanj), item "test.mp3"): scan: lstat /data1/test.mp3: permission denied

This is after setting up with

podman run -d \
  --name=syncthing \
  --label io.containers.autoupdate=registry \
  -e PUID=0 \
  -e PGID=0 \
  -p 127.0.0.1:8384:8384 \
  -p 22000:22000/tcp \
  -p 22000:22000/udp \
  -p 21027:21027/udp \
  -v ~/.config/syncthing:/config:Z \
  -v /var/home/aaylnx/syncthing-test:/data1:Z \
  lscr.io/linuxserver/syncthing:latest

Permissions inside the folder are

drwxrwxr-x. 1 aaylnx aaylnx      34 Jun 20 16:13 .
drwx------. 1 aaylnx aaylnx     510 Jun 20 16:05 ..
drwxr-xr-x. 1 aaylnx aaylnx       0 Jun 20 15:56 .stfolder
-rw-r--r--. 1 aaylnx aaylnx 3416774 Mar  3 08:13 test.mp3

Not sure what the problem is.

MMarco94 commented 1 year ago

Sorry for the long reply, I hope you fixed the problem.

If you haven't, can you try to give your used write access to the folder as well?

MMarco94 commented 1 year ago

I'm gonna mark the issue as closed, since it's been a while (again, sorry about that). If you still have the same issue, feel free to reopen it.