How to set permissions and ownership correctly for the downloads

General support for problems installing or using Deluge
Cas_vt
Member
Member
Posts: 15
Joined: Fri Mar 12, 2021 2:51 pm

How to set permissions and ownership correctly for the downloads

Postby Cas_vt » Sat Apr 03, 2021 12:51 pm

Hey there,

I have problems with the permissions and ownerships of the files that are downloaded by deluge.

The problem is that when the files are downloaded (download folder is /home/cas/Downloads, so downloads folder of a different user but it is able to download to it fine), Sonarr and Radarr aren't able to process the downloaded file and plex can't add the movie or series to it's library because it doesn't have the permissions.

Code: Select all

# /etc/systemd/system/deluged.service
[Unit]
Description=Deluge Bittorrent Client Daemon
Documentation=man:deluged
After=network-online.target

[Service]
Type=simple
UMask=000
User=debian-deluged
Group=debian-deluged

ExecStart=/usr/bin/deluged -d

Restart=on-failure

# Time to wait before forcefully stopped.
TimeoutStopSec=300

[Install]
WantedBy=multi-user.target




# /etc/systemd/system/deluge-web.service
[Unit]
Description=Deluge Bittorrent Client Web Interface
Documentation=man:deluge-web
After=network-online.target deluged.service
Wants=deluged.service

[Service]
Type=simple
UMask=000
User=debian-deluged
Group=debian-deluged

ExecStart=/usr/bin/deluge-web -d

Restart=on-failure

[Install]
WantedBy=multi-user.target

After some testing, I got the following information:

Code: Select all

[1]Radarr finds and adds the movie Deadpool to deluge; it downloads fine.

[2]When deluge is done downloading, this is the permissions for the file:
'Downloads/Deadpool (2016) [1080p] [YTS.AG]':
total 1728216
-rw-rw-rw- 1 debian-deluged debian-deluged     105827 apr  3 14:10  WWW.YTS.AG.jpg
-rw-rw-rw- 1 debian-deluged debian-deluged 1769571535 apr  3 14:21 'Deadpool.2016.1080p.BluRay.x264-[YTS.AG].mp4'

[3]Doing the following DIDN'T make radarr process the completed download aka it didn't work:
sudo chown -R cas:cas Downloads/*
'Downloads/Deadpool (2016) [1080p] [YTS.AG]':
total 1728216
-rw-rw-rw- 1 cas cas     105827 apr  3 14:10  WWW.YTS.AG.jpg
-rw-rw-rw- 1 cas cas 1769571535 apr  3 14:21 'Deadpool.2016.1080p.BluRay.x264-[YTS.AG].mp4'

[4]Doing the following DIDN't work:
sudo chown -R cas:debian-deluged Downloads/*
'Downloads/Deadpool (2016) [1080p] [YTS.AG]':
total 1728216
-rw-rw-rw- 1 cas debian-deluged     105827 apr  3 14:10  WWW.YTS.AG.jpg
-rw-rw-rw- 1 cas debian-deluged 1769571535 apr  3 14:21 'Deadpool.2016.1080p.BluRay.x264-[YTS.AG].mp4'


I tried chmod/chown 0777, 0666, cas:cas, cas:debian-deluged, root:root but nothing works. Including multiple combinations of chmod and chown, though I don't think chmod is the problem.

The users "plex", "sonarr", "debian-deluged" and "cas" are all in the group "debian-deluged", if I've set it up correctly though users, groups and permissions are by far not my speciality.

Do you have any idea where to start for making this work?

shamael
Compulsive Poster
Compulsive Poster
Posts: 638
Joined: Sat Oct 08, 2016 9:28 am

Re: How to set permissions and ownership correctly for the downloads

Postby shamael » Mon Apr 05, 2021 9:15 am

hi,

What is you add the executable permission to the group debian-deluged with all the plex etc. users already in?

Cas_vt
Member
Member
Posts: 15
Joined: Fri Mar 12, 2021 2:51 pm

Re: How to set permissions and ownership correctly for the downloads

Postby Cas_vt » Tue Apr 06, 2021 12:09 pm

The strange thing is, that when I set the downloaded files to chmod -R 666, I can't access them, but when I set all the files to chmod -R 777, I CAN access them. Which is strange. Because accessing a folder requires read, but the difference is executable... Why? That doesn't make sense. In this case, executable desides if I can access a folder. That doesn't make sense.

Code: Select all

cas@Waveserver:~/Downloads$ ls -l
total 8
drw-rw-rw- 2 cas cas 4096 apr  3 14:09 'Deadpool (2016) [1080p] [YTS.AG]'
drw-rw-rw- 2 cas cas 4096 apr  2 21:30 '[TorrentCouch.com].Arrow.S06.Complete.720p.BRRip.x264.[7.5GB].[MP4].[Season.6.Full]'
cas@Waveserver:~/Downloads$ cd Deadpool\ \(2016\)\ \[1080p\]\ \[YTS.AG\]/
-bash: cd: Deadpool (2016) [1080p] [YTS.AG]/: Permission denied
cas@Waveserver:~/Downloads$ sudo chmod -R 777 *
cas@Waveserver:~/Downloads$ ls -l
total 8
drwxrwxrwx 2 cas cas 4096 apr  3 14:09 'Deadpool (2016) [1080p] [YTS.AG]'
drwxrwxrwx 2 cas cas 4096 apr  2 21:30 '[TorrentCouch.com].Arrow.S06.Complete.720p.BRRip.x264.[7.5GB].[MP4].[Season.6.Full]'
cas@Waveserver:~/Downloads$ cd Deadpool\ \(2016\)\ \[1080p\]\ \[YTS.AG\]/
cas@Waveserver:~/Downloads/Deadpool (2016) [1080p] [YTS.AG]$ ls -l
total 1728216
-rwxrwxrwx 1 cas cas 1769571535 apr  3 14:21 'Deadpool.2016.1080p.BluRay.x264-[YTS.AG].mp4'
-rwxrwxrwx 1 cas cas     105827 apr  3 14:10  WWW.YTS.AG.jpg

**It's now 30 minutes later**

Okay, I figured it out. For radarr to process the downloaded file, the following command needs to be executed first:

Code: Select all

sudo chown -R cas:cas /home/cas/Downloads/* && sudo chmod -R 777 /home/cas/Downloads/*
After that, radarr processes the file. This needs to happen right after the file is completed downloading. This can be done using "Execute" plugin.

My question is how do I install the execute plugin? Everywhere on google, they say "[1] Download the plugin egg [2] Import it to deluge". But where can I download the plugin egg. I can't find it anywhere!

mhertz
Compulsive Poster
Compulsive Poster
Posts: 1093
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to set permissions and ownership correctly for the downloads

Postby mhertz » Tue Apr 06, 2021 1:47 pm

Shamael is much better than me with permissions and whatnot, but anyway, I would just quickly add that execute plugin is built-in/included by default, and can be enabled from preferences menu. Also, and pereffered I would assume, is umask definition in the service files, there's a default value in there which could be changed to e.g 000 for "777" I believe, which probably isn't recommended often, but if you need have it like that to work. little more info in the deluge documentation on the systemd service setup page about other umask example numbers and there meaning:
Umask for deluged downloaded files
The umask in the service file can be modified to determine access to files downloaded by deluged (also applies to logging files). Some useful access values are detailed as follows:

000 - full access for all users and groups.

007 - only user and group that deluged is running as (e.g. deluge) with no access from any other accounts.

002 - user and group deluged is running as with read-only for all other accounts.

022 - user deluged is running as with read-only for all other accounts.

The service for deluged must be stopped and started instead of just restarted after changes.

Source: https://deluge.readthedocs.io/en/latest ... rvice.html

Cas_vt
Member
Member
Posts: 15
Joined: Fri Mar 12, 2021 2:51 pm

Re: How to set permissions and ownership correctly for the downloads

Postby Cas_vt » Tue Apr 06, 2021 2:15 pm

I already have Umask set to 000. But I also need to run chown so why not run chmod too, to ensure right permissions? But there's a new problem. The "execute" plugin works, but the command doesn't. I've set it up to run "sudo chmod -R 777 /home/cas/Downloads/*" and also "sudo chown -R cas:cas /home/cas/Downloads/*" when download is complete. But that requires sudo ofcourse and deluge is being run under "debian-deluged", not "root". Is there a way to make this work?

mhertz
Compulsive Poster
Compulsive Poster
Posts: 1093
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to set permissions and ownership correctly for the downloads

Postby mhertz » Tue Apr 06, 2021 6:21 pm

Sorry, I don't really know what would be recommended here. It could be done, but e.g. defining sudo access for your deluge user's unrestricted account, if even possible as no login access, would negate any advantage in using such in first place i'm thinking.

It would be best to fix this without these workarounds, but sadly I know nothing about sonar etc, and as said not that big into permissions except need-to-know standard basis.

Possibly if wanna persue this, you could in your script do something along the lines of:

Code: Select all

yes <ROOT-PASSWORD> | su -c 'chmod -R 777 "$3/$2" && chown -R cas: "$3/$2"'

Not good having your password laying around in plain-text, but I don't know other ways, that wouldn't make the unrestircted debian-deluged "restricted and in which case you might as well avoid all these issues alltogether with simply changing 'debain-deluged' to instead 'cas' in your systemd files and run as own user, i'm guessing.


Return to “Support”

Who is online

Users browsing this forum: No registered users and 9 guests