SABnzbd Applying Permissions When "Permissions for completed downloads" is Blank

Get help with all aspects of SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
DogEyedBoy
Newbie
Newbie
Posts: 3
Joined: December 24th, 2022, 10:18 am

SABnzbd Applying Permissions When "Permissions for completed downloads" is Blank

Post by DogEyedBoy »

SABnzbd 3.7.1 LinuxServer Docker container Synology DSM 7.

SABnzbd is applying permissions to everything (as far as I can tell) even when the "Permissions for completed downloads" option is blank.

Debug log shows:

Code: Select all

2022-12-24 14:54:16,644::DEBUG::[filesystem:604] Applying permissions 0o100666 (octal) to...
(Had to remove the filename as "New users are not allowed to post links".)

It seems like this is unnecessary and it shouldn't be happening?
User avatar
sander
Release Testers
Release Testers
Posts: 8832
Joined: January 22nd, 2008, 2:22 pm

Re: SABnzbd Applying Permissions When "Permissions for completed downloads" is Blank

Post by sander »

On your incomplete directory, right?

Happens on my SAB too, and I have Permissions blank too.

Code: Select all

2022-12-20 18:40:28,236::DEBUG::[filesystem:604] Applying permissions 0o100644 (octal) to /shared_dir/_UNPACK_test_download_1000MB.8/1GB-explanation.txt
2022-12-20 18:40:28,236::DEBUG::[filesystem:604] Applying permissions 0o100644 (octal) to /shared_dir/_UNPACK_test_download_1000MB.8/1GB.bin
Looking at the code, I think this is the reason:

Code: Select all

        # Check if the file has any x-bits, no need to remove them otherwise
        if custom_permissions or current_permissions & UNWANTED_FILE_PERMISSIONS:
            # Mask out the X-bits
            set_chmod(path, current_permissions & ~UNWANTED_FILE_PERMISSIONS, allow_failures)
So ... masking out the x-bits, because downloaded files should not be executable? In other words: Security
DogEyedBoy
Newbie
Newbie
Posts: 3
Joined: December 24th, 2022, 10:18 am

Re: SABnzbd Applying Permissions When "Permissions for completed downloads" is Blank

Post by DogEyedBoy »

Yes, this is happening in the incomplete directory but is obviously carried on through the the final file and destination.
User avatar
sander
Release Testers
Release Testers
Posts: 8832
Joined: January 22nd, 2008, 2:22 pm

Re: SABnzbd Applying Permissions When "Permissions for completed downloads" is Blank

Post by sander »

DogEyedBoy wrote: December 25th, 2022, 1:59 pm Yes, this is happening in the incomplete directory but is obviously carried on through the the final file and destination.
And what is negative effect of that?
DogEyedBoy
Newbie
Newbie
Posts: 3
Joined: December 24th, 2022, 10:18 am

Re: SABnzbd Applying Permissions When "Permissions for completed downloads" is Blank

Post by DogEyedBoy »

It's giving all users read and write access. I have my permissions set-up as I want them within my Synology Shared Folders, I don't need SABnzbd to do anything with permissions.
User avatar
sander
Release Testers
Release Testers
Posts: 8832
Joined: January 22nd, 2008, 2:22 pm

Re: SABnzbd Applying Permissions When "Permissions for completed downloads" is Blank

Post by sander »

DogEyedBoy wrote: December 27th, 2022, 11:13 am It's giving all users read and write access. I have my permissions set-up as I want them within my Synology Shared Folders, I don't need SABnzbd to do anything with permissions.
Oh, really. Brrr.

And indeed on Synology, SAB should not touch at all user rights (AFAIK), because Synology wants to do user rights with ACL.

So ... what do you propose as solution?

Easy to leave that line out when Permission is not set. But what about the x-bit then?
User avatar
jcfp
Release Testers
Release Testers
Posts: 989
Joined: February 7th, 2008, 12:45 pm

Re: SABnzbd Applying Permissions When "Permissions for completed downloads" is Blank

Post by jcfp »

The code stripping the executable and setgid/setuser bits doesn't expand permissions (unless custom permissions are set to that effect), see the relevant function. In the absence of custom permissions, it applies the intersection of the current permissions with the inverse of the unwanted-for-security-reasons stuff. That bitwise operation cannot add anything that wasn't there before; i.e. files only end up world-writable if they were world-writable before the function was applied.
User avatar
sander
Release Testers
Release Testers
Posts: 8832
Joined: January 22nd, 2008, 2:22 pm

Re: SABnzbd Applying Permissions When "Permissions for completed downloads" is Blank

Post by sander »

I tested with two NZBs, and can confirm what jcfp says.

https://raw.githubusercontent.com/sande ... r__400.nzb
https://raw.githubusercontent.com/sande ... on_777.nzb

only look at the bin files, which nicely arrive on my Linux with the orginal permissions set aka kept in place:

-r-------- 1 sander sander 100000000 dec 27 20:18 100MB_r__400.bin
-rw-rw-rw- 1 sander sander 100000000 dec 27 20:18 rwx_all_on_777.bin
User avatar
sander
Release Testers
Release Testers
Posts: 8832
Joined: January 22nd, 2008, 2:22 pm

Re: SABnzbd Applying Permissions When "Permissions for completed downloads" is Blank

Post by sander »

So DogEyedBoy ... can you follow up?
Post Reply