clinton-hall / nzbToMedia

Provides NZB and Torrent postprocessing To CouchPotatoServer, SickBeard/SickRage, HeadPhones, Mylar and Gamez
GNU General Public License v3.0
674 stars 176 forks source link

unable to access '/root/.config/git/ignore': Permission denied #1867

Closed phybersplice closed 7 months ago

phybersplice commented 2 years ago

Hi

I'm using a docker that I've forked from linuxserver.io and modified myself to include your scripts + git, ffmpeg, etc...

Here's the git link to my dockerfile. Everything is working quite well - just trying to do some log cleanup, and the one entry in particular is this one when it does a git check for an update: warning: unable to access '/root/.config/git/ignore': Permission denied

Any idea on how to fix that? Thanks!

Thu Dec 02 2021 20:53:36 | nzbToRadarr: [20:53:36] [INFO]::MAIN: Auto-detected SECTION:Radarr
-- | --
INFO | Thu Dec 02 2021 20:53:35 | nzbToRadarr: [20:53:35] [INFO]::MAIN: Script triggered from NZBGet Version 21.2-testing-r2333.
INFO | Thu Dec 02 2021 20:53:35 | nzbToRadarr: [20:53:35] [INFO]::MAIN: #########################################################
INFO | Thu Dec 02 2021 20:53:35 | nzbToRadarr: [20:53:35] [INFO]::MAIN: ## ..::[nzbToMedia.py]::.. ##
INFO | Thu Dec 02 2021 20:53:35 | nzbToRadarr: [20:53:35] [INFO]::MAIN: #########################################################
INFO | Thu Dec 02 2021 20:53:35 | nzbToRadarr: [20:53:35] [INFO]::MAIN: nzbToMedia Version:f9dde62762f7ad4fa6a5bfca892af7263a28a3e3 Branch:master (Linux 4.4.180+)
INFO | Thu Dec 02 2021 20:53:35 | nzbToRadarr: [20:53:35] [INFO]::MAIN: No update needed
INFO | Thu Dec 02 2021 20:53:35 | nzbToRadarr: [20:53:35] [INFO]::MAIN: Checking if git needs an update
INFO | Thu Dec 02 2021 20:53:35 | nzbToRadarr: [20:53:35] [INFO]::MAIN: Checking database structure...
INFO | Thu Dec 02 2021 20:53:34 | nzbToRadarr: [20:53:35] [INFO]::MAIN: Python v3.9 will reach end of life in 1403 days.
INFO | Thu Dec 02 2021 20:53:25 | nzbToRadarr: warning: unable to access '/root/.config/git/ignore': Permission denied
clinton-hall commented 2 years ago

this suggests to me that the user that installed nzbToMedia (i.e. the user that runs the docker install script and therefore the git clone is different to the user that NZBGet runs as (which is the user that nzbToMedia runs as).

phybersplice commented 2 years ago

this suggests to me that the user that installed nzbToMedia (i.e. the user that runs the docker install script and therefore the git clone is different to the user that NZBGet runs as (which is the user that nzbToMedia runs as).

Thanks for getting back to me. I used this guide to create a restricted docker user on the Synology 1821+

clinton-hall commented 2 years ago

ok... What I don't know is what user actually "installs" the docker and creates the git clone.

Basically, if you were to look at the permissions for {Docker_path}/root/.config/git/ignore this should tell you who has write permissions. That should be the same user that runs NZBget (restricted docker user).

Sorry, but when it comes to this, I don't have a great knowledge of Docker, and Syno is the one NAS I've had very little experience with...

phybersplice commented 2 years ago

ok... What I don't know is what user actually "installs" the docker and creates the git clone.

Basically, if you were to look at the permissions for {Docker_path}/root/.config/git/ignore this should tell you who has write permissions. That should be the same user that runs NZBget (restricted docker user).

Sorry, but when it comes to this, I don't have a great knowledge of Docker, and Syno is the one NAS I've had very little experience with...

I'm learning as well ... it's kind of fun. But this gives me an idea to inspect a few things... so thanks for the help! Been using your scripts for years!!!

Edit: looks like when Docker creates the folders and files within the container, its root:root

phybersplice commented 2 years ago

I must be doing something wrong somewhere. The script is calling this /root folder but when I check what's in it, I get this - no sign of docker-path/root/.config

ash-4.4# pwd
/volume1/@docker/btrfs/subvolumes/1ec957a8e72ad087723edfc2c15cf028b1c204819d35dab3807ad595c2b20962/root

ash-4.4# ls -ltra
total 4
-rw-r--r-- 1 root root 209 Nov 28 22:28 .wget-hsts
drwx------ 1 root root  20 Nov 28 22:28 .
drwxr-xr-x 1 root root 192 Nov 28 22:40 ..
ash-4.4# 
clinton-hall commented 2 years ago

ah... I just noticed this isn't actually part of the git check for nzbToMedia... that actually works, and the error comes before that.

It looks as though NZBGet is passing that as the Present Directory when the script runs. But this location doesn't exist and that is why the error is logged?

out of curiosity. have you restarted the Docker, or the NAS since you installed and set up NZBGet?

phybersplice commented 2 years ago

ah... I just noticed this isn't actually part of the git check for nzbToMedia... that actually works, and the error comes before that.

It looks as though NZBGet is passing that as the Present Directory when the script runs. But this location doesn't exist and that is why the error is logged?

out of curiosity. have you restarted the Docker, or the NAS since you installed and set up NZBGet?

Yes, I've restarted the NAS (1821+) which in turn restarts the docker Containers I run.

I would agree with you about it not existing. I linked to the wrong dockerfile and repo (I have two). I've edited the correct one.

netty0 commented 2 years ago

I've been living with this same error for a year or so now. I use docker as well on Armbian. Not syno

It looks as though NZBGet is passing that as the Present Directory when the script runs. But this location doesn't exist and that is why the error is logged?

I have indeed found this file to not exist in the docker itself. The user account and permission are all set accordingly. If you know of a way to get rid of this error on Docker setups, I would love to know. Thanks

neo-neo1 commented 2 years ago

I too have this error for months. The file simply does not exist. I guess it's the Docker tax nzbtomedia charges us for using Docker. The nzbget container does not run as root by default, not sure if it's supposed to check /root to begin with?

clinton-hall commented 2 years ago

is anyone able to do a test with Lines 730 and 733 commented out. i.e. https://github.com/clinton-hall/nzbToMedia/blob/master/nzbToMedia.py#L730-L733 change from

import cleanup

eol.check()
cleanup.clean(cleanup.FOLDER_STRUCTURE)

to

#import cleanup

eol.check()
#cleanup.clean(cleanup.FOLDER_STRUCTURE)

the cleanup is the only part that is initialized before the Python Version check, so I just want to confirm that this is what is causing the issue. the changes above should stop the error (if it is the Cleanup that is responsible) and I can then start trying to find a permanent fix for this.

phybersplice commented 2 years ago

is anyone able to do a test with Lines 730 and 733 commented out. i.e. https://github.com/clinton-hall/nzbToMedia/blob/master/nzbToMedia.py#L730-L733 change from

import cleanup

eol.check()
cleanup.clean(cleanup.FOLDER_STRUCTURE)

to

#import cleanup

eol.check()
#cleanup.clean(cleanup.FOLDER_STRUCTURE)

the cleanup is the only part that is initialized before the Python Version check, so I just want to confirm that this is what is causing the issue. the changes above should stop the error (if it is the Cleanup that is responsible) and I can then start trying to find a permanent fix for this.

I've done the commenting out just now

phybersplice commented 2 years ago

@clinton-hall Sorry it took me a while to report back. The commenting seems to have worked.
The error does not show up anymore.

MattPark commented 8 months ago

I've had this warning for a couple of years. Despite git being installed in the container the, file/folder it's looking for just doesn't exist. cleanup.py just shells out to git clean which is looking for your global ignore file to check before it cleans and if you don't have one it tosses a warning.

In my nzbget container, there is no global file setup in root either.

So looks like you can just add --quiet flag to suppress the warnings. Or what may be a "better" approach is -x flag which possibly avoids checking the global ignore file. You do have -x on some of the functions in cleanup.py but some are missing.

MattPark commented 8 months ago

yeah ok that fixed it. I'll do a PR

clinton-hall commented 8 months ago

thanks. Have merged into nightly branch.