SOLVED: Arch, Sonarr, NZBGet and file permissions. Want to punch the wall!

Get help, report and discuss bugs.
Post Reply
road hazard
Posts: 13
Joined: 03 Oct 2015, 03:03

SOLVED: Arch, Sonarr, NZBGet and file permissions. Want to punch the wall!

Post by road hazard » 02 Feb 2018, 12:34

Sonarr v2.0.0.5085
Mono v5.4.1
OS: Antergo
NZBGet 19.1

Couldn’t import episode /TV Shows/NCIS.New.Orleans.S04E01.720p.WEB-DL.DD5.1.H.264-tek54m-postbot/69c04ee5440a44f290db6ffe78611952.mkv: Access to the path is denied.

First off, I’m a dumb Linux newbie. I know the solution to my problem is something really stupid I’m overlooking but after a few hours of pounding my head into the freaking wall, I have no idea how to get this working and need to ask for help.

I installed Plex, Sonarr and NZBGet. Everything is setup and configured (program wise). When I add a show in Sonarr, NZBGet downloads it but I get ‘access denied’ when Sonarr attempts to import/rename it.

/TV Shows is owned by my user account and my account is in the group called ‘users’. I can go into that folder and create/rename/delete whatever.

I have issued the commands to add users; plex, nzbget and sonarr to the ‘users’ group. (By my logic, if these users all belong to the same group as my account, they should be able to interact with the files/folders WITHIN that group that other users created, or not?! My brain is fried right now and my kid is busting my chops NON-STOP to play Mario Kart so I’ve been trying to figure this out and get my head straight to post here so please forgive my ramblings.)

When Sonarr tells NZBGet to grab a show, the show is downloaded and placed in /TV Shows but it never gets renamed and placed into the season folder in that directory. When I right click on the NCIS folder that just downloaded, it has a padlock on it and shows that nzbget is the owner. Sonarr is the owner of the NCIS/Season X folder but it’s empty because Sonarr can’t rename/move it in there.

This is a case of me not being able to see the forest for the trees. If all these users belong to the same group, why can’t they all get along and this all just work?!

I think part of my frustration is I’m getting ready to move from Mint to Antergos and I don’t recall having this much difficult getting this same setup working in Mint. Before I do anything, I setup Antergos on a spare PC to make sure I have the flow all working correctly. Which right now, I don’t. :(

With Mint, I think all these run under my user account and I don't have any of these problems. Maybe a simpler solution would be to just run everything under MY account?
Last edited by road hazard on 07 Feb 2018, 20:31, edited 1 time in total.

al3x
Posts: 27
Joined: 24 Aug 2017, 17:13

Re: Arch, Sonarr, NZBGet and file permissions. Want to punch the wall!

Post by al3x » 03 Feb 2018, 15:20

Permissions in linux work like that: You have an owner, a group and then there's "others".

A folder might have these permissions: drwxrwxrwx
That means: d = directory, r = read, w = write, x = execute file or access directory

The first 3 rwx mean: Owner can read, write, execute/access
Next 3 mean: Group can read, write, execute/access
Last 3 mean: Everyone else can read, write, execute/access

So you need to make sure your folder permissions are set properly so every user can access it.

You didn't say what your folder permissions were exactly, but I assume it's something like drwx------ which means only the owner has access. A simple fix would be to give everyone access with something like "chmod 777 [your folder]".

Maybe that's all it needs.

road hazard
Posts: 13
Joined: 03 Oct 2015, 03:03

Re: Arch, Sonarr, NZBGet and file permissions. Want to punch the wall!

Post by road hazard » 03 Feb 2018, 23:35

al3x wrote:
03 Feb 2018, 15:20
Permissions in linux work like that: You have an owner, a group and then there's "others".

A folder might have these permissions: drwxrwxrwx
That means: d = directory, r = read, w = write, x = execute file or access directory

The first 3 rwx mean: Owner can read, write, execute/access
Next 3 mean: Group can read, write, execute/access
Last 3 mean: Everyone else can read, write, execute/access

So you need to make sure your folder permissions are set properly so every user can access it.

You didn't say what your folder permissions were exactly, but I assume it's something like drwx------ which means only the owner has access. A simple fix would be to give everyone access with something like "chmod 777 [your folder]".

Maybe that's all it needs.
This is from the root of my TV Shows folder:

drwxrwxrwx 4 roadhazard users 109 Feb 3 17:56 .
drwxr-xr-x 18 root root 241 Feb 1 18:18 ..
drwxr-xr-x 3 sonarr sonarr 22 Feb 3 17:56 'Modern Family'
drwxr-xr-x 2 nzbget nzbget 50 Feb 3 17:55 Modern.Family.S09E13.blahblah

....so looks like sonarr and nzbget don't have write access. But, I added both those accounts to the 'users' group (same group I'm in) and when I right click on the TV Shows folder, the group, 'users' is listed as: can create and delete files. But something else weird (to a Linux newbie like me).... if I go INTO the Modern Family folder, I can't create anything in there. The folder is owned by sonarr and I added my account to the sonarr group and no dice. Modern.Family.S09etc is owned by NZBGet.

So Sonarr is creating the 'Modern Family/Season X' structure but only it has access to do anything in there. NZBGet is placing the downloaded files into TV Shows folder but due to permission issues, Sonarr can't edit it because it's owned byt nzbget.

Tried the chmod 777 stuff and that worked.........until a new file showed up. Is there a way to PERMANENTLY make a folder 777 (even when NEW files are placed in there down the road)?

I'm really REALLY REALLY starting to wonder if I should just give all accounts root access to eliminate this nightmare. After reading this article on reddit: https://www.reddit.com/r/linux/comments ... the_point/ I think the author makes sense. All these permissions are a nightmare for end users to deal with. I'm not running a web server or massive multi user cloud server. I just want to run Arch on my media server and want everything to just work. (Outside this permission issues, everything does.)

I'm a competent IT person (20+ years of experience......but with only Windows :( ) and I hate Microsoft with a burning passion and am forcing myself to switch to Linux on all home PCs and for the most part, I've had no complaints. But this most recent problem with Arch and permissions issues is driving me to hand out root access like candy. I can see this being a road block for people with NO IT training.

I'll keep plugging away though. I really want to get all this working on Arch.

hugbug
Developer & Admin
Posts: 7418
Joined: 09 Sep 2008, 11:58
Location: Germany

Re: Arch, Sonarr, NZBGet and file permissions. Want to punch the wall!

Post by hugbug » 04 Feb 2018, 00:40

Maybe you should run all programs under the same user account to make things easier for you.
road hazard wrote:
03 Feb 2018, 23:35
so looks like sonarr and nzbget don't have write access. But, I added both those accounts to the 'users' group
There is a thing called "umask", which determines what permissions new files get (if the program which creates them doesn't set permissions explicitly). You can set UMask using system command "umask" and you should do that before launching the programs which create files. In nzbget you can also use option UMask for that.

al3x
Posts: 27
Joined: 24 Aug 2017, 17:13

Re: Arch, Sonarr, NZBGet and file permissions. Want to punch the wall!

Post by al3x » 04 Feb 2018, 04:33

Yeah, as hugbug already wrote, umask is the way to go here.

You could set the umask in nzbget to "002", which means newly created files/folders will get permission rw-rw-r or rwxrwxr-x, resp.

Sonarr has a similar option hidden in settings (turn on advanced settings): Permissions - File chmod mask / Folder chmod mask. This works the opposite of umask, so this should be set to: Files: 0664, Folders: 0775.

Then there's still another problem: Your user accounts don't use group "users" as default. Instead you use the groups "nzbget" and "sonarr". Although you gave both users access to group "users", they're still not the default. So newly created folders and files won't use "users" as group.

To make your new umask settings work those users need to have the same default group. You could change that in linux directly - or you can set the "setgid" access flag for the main folder (e.g. "/TV Shows"). Newly created folders/files will then inherit the group of that main folder which is "users". To set this flag: chmod g+s /TV\ Shows

And you would need to change the permissions of those files/folders already in that directory:
chgrp -R users /TV\ Shows
chmod -R g+w /TV\ Shows

Or - you know, you could just use the same user account for those tools. Hugbug's right, it's far easier :mrgreen:

road hazard
Posts: 13
Joined: 03 Oct 2015, 03:03

Re: Arch, Sonarr, NZBGet and file permissions. Want to punch the wall!

Post by road hazard » 06 Feb 2018, 18:22

al3x wrote:
04 Feb 2018, 04:33
Yeah, as hugbug already wrote, umask is the way to go here.

You could set the umask in nzbget to "002", which means newly created files/folders will get permission rw-rw-r or rwxrwxr-x, resp.

Sonarr has a similar option hidden in settings (turn on advanced settings): Permissions - File chmod mask / Folder chmod mask. This works the opposite of umask, so this should be set to: Files: 0664, Folders: 0775.

Then there's still another problem: Your user accounts don't use group "users" as default. Instead you use the groups "nzbget" and "sonarr". Although you gave both users access to group "users", they're still not the default. So newly created folders and files won't use "users" as group.

To make your new umask settings work those users need to have the same default group. You could change that in linux directly - or you can set the "setgid" access flag for the main folder (e.g. "/TV Shows"). Newly created folders/files will then inherit the group of that main folder which is "users". To set this flag: chmod g+s /TV\ Shows

And you would need to change the permissions of those files/folders already in that directory:
chgrp -R users /TV\ Shows
chmod -R g+w /TV\ Shows

Or - you know, you could just use the same user account for those tools. Hugbug's right, it's far easier :mrgreen:
Was looking at my Mint setup and turns out I am indeed running NZBGet and Sonarr under my account. But with Antergos, I've been having zero luck getting those programs to run under my account. The Arch wiki has steps to do this with NZBGet but the steps they use..... I can't find a directory with Antergos that they reference, which is weird to me since Antergos is based on Arch. I also see that the Arch wiki isn't newbie friendly (at least with my current knowledge of Linux. How they talk about editing files and when they stack commands..... those are stumbling blocks for me.

I can't find any guide on getting Sonarr to run as me. First, I thought it would be as easy as editing the config via their SystemD GUI program (forget the name..... you can go in and start/enable services). But that failed miserably.

Next, in a fit of frustration, I added myself, sonarr and nzbget to the SUDOers file. Rebooted and this removed some roadblocks but files created by NZBGet were STILL locked and Sonarr couldn't rename/import them. (I always thought root accounts could do anything on the system to any file?!)

I think I need to focus on getting those 2 programs running under my user account. I'll also experiment with UMASK.

road hazard
Posts: 13
Joined: 03 Oct 2015, 03:03

Re: Arch, Sonarr, NZBGet and file permissions. Want to punch the wall!

Post by road hazard » 07 Feb 2018, 20:31

Solved my problems. I think everything centered around NZBGet being the main problem!? Just in case somebody else (far into the future) has the same issue, what I did to fix things was:

Don't mess with any Sonarr settings. Leave it running under the 'sonarr' user account. Make sure to add sonarr to the groups 'users' AND 'wheel'!

nzbget:

1) Log into the web console and in the security section/DaemonUsername field, change it to your account (or whatever account you want it to run under, don't leave it running under nzbget.........unless you like banging your head into the wall in frustration like I did and waste your time chasing down permission issues.)

2) Set UMask to 0000

3) Stop NZBGet (if it's running!) and edit /lib/systemd/system/nzbget.service. Change user and group to your account and the group that you're in.

4) Make sure all accounts are added to each others' groups. (add your account to wheel, plex, nzbget, sonarr)...... nzbget to users, plex, sonarr, wheel, etc., etc.

5) Restart the PC (I tried re-enabling the service and manually starting it but that didn't work. I had to reboot my PC at this point.)

Right now, sonarr has NZBGet grab the files, sonarr can rename and import them and plex can see things just fine. Everything is finally working together in perfect harmony!

Side question.......I'm painfully aware of how much Linux LOVES file permissions..... as I switch over to Antergos from Mint, will I need to do anything special to my movies/tv folders? In Windows, when you hook up a new data drive, you sometimes have to take ownership of the folders/files. Will it be the same with switching distros? Will I have to go into the folders (once the mdadm RAID 6 array is assembled) and go into the properties of these folders and do anything?

VeryGimpy
Posts: 1
Joined: 20 Mar 2019, 18:43

Re: SOLVED: Arch, Sonarr, NZBGet and file permissions. Want to punch the wall!

Post by VeryGimpy » 20 Mar 2019, 19:01

I had this or a similar problem and after much hardship i found out that it was caused by unrar restoring file permissions from the rar archive instead of granting access to the user or group. This would happen only in some archives, for some reason.

The solution was to tell unrar to ignore file attributes and permissions during unpack, by adding "unrar x -ai" to setting UnrarCmd in the Unpack section of NZBGet settings. (This should really be the default)

Hope this helps someone end their own permissions nightmare.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests