Scan automatically - Permission denied

Hello,

I’ve an issue with the Update my library automatically option.
When I add some files into my Movies folder (located on my NAS, where the Plex server is running), it does not update the library, same for TV shows, but for another library (called “Formation”) it’s working.

When I check the box, I get some error on the log file :

Apr 28, 2018 17:00:58.804 [0xec3ffb40] INFO - Refreshing paths because of preference change
Apr 28, 2018 17:00:58.804 [0xec3ffb40] INFO - Refreshing paths watched by LibraryUpdateManager
Apr 28, 2018 17:00:58.806 [0xec3ffb40] DEBUG - LibraryUpdateManager will start watching /volume1/video/Film
Apr 28, 2018 17:00:58.806 [0xec3ffb40] DEBUG - LibraryUpdateManager will start watching /volume1/video/Formation Photographe accompli
Apr 28, 2018 17:00:58.807 [0xec3ffb40] DEBUG - LibraryUpdateManager will start watching /volume1/video/Series
Apr 28, 2018 17:00:58.807 [0xec3ffb40] DEBUG - [Notify] Initializing.
Apr 28, 2018 17:00:58.807 [0xf0f35b40] ERROR - [Notify] Failed to add watch for /volume1/video/Film (13: Permission denied)
Apr 28, 2018 17:00:58.809 [0xf17ffb40] DEBUG - Completed: [192.168.1.28:60437] 200 PUT /:/prefs?FSEventLibraryUpdatesEnabled=1 (5 live) TLS GZIP 6ms 268 bytes (pipelined: 1)
Apr 28, 2018 17:00:58.826 [0xf0f35b40] ERROR - [Notify] Failed to add watch for /volume1/video/Film/21.Jump.Street.2012.FRENCH.BDRip.XviD-NERD (13: Permission denied)
[...]
Apr 28, 2018 17:00:59.023 [0xf0f35b40] DEBUG - [Notify] Now watching /volume1/video/Formation Photographe accompli
Apr 28, 2018 17:00:59.114 [0xf0f35b40] DEBUG - [Notify] Now watching /volume1/video/Formation Photographe accompli/Sublimez vos photos
Apr 28, 2018 17:00:59.208 [0xf0f35b40] DEBUG - [Notify] Now watching /volume1/video/Formation Photographe accompli/Revelez votre ame
Apr 28, 2018 17:00:59.208 [0xf0f35b40] ERROR - [Notify] Failed to add watch for /volume1/video/Series (13: Permission denied)
Apr 28, 2018 17:00:59.208 [0xf0f35b40] DEBUG - [Notify] Now watching /volume1/video/Series/90210
[...]

But I can’t figure out why there is some different behavior on this two folder for example :
/volume1/video/Film
/volume1/video/Formation Photographe accompli

ash-4.3# ls -l /volume1/video/
total 39008
drwxrwsrwx  1 Rian users     2536 Nov 14 08:39 Armin Van Buuren
drwxrwxrwx+ 1 root root       374 Mar 31 06:57 @eaDir
d---------+ 1 Rian users    48748 Apr 28 17:23 Film
d---------+ 1 Rian users     2272 Apr 28 17:23 Formation Photographe accompli
d---------+ 1 Rian users      350 Apr  1 16:24 Series
----------+ 1 Rian users 39842382 Apr 15 13:01 test.mp4
-rwxrwxrwx  1 Rian users    98304 Jan 26  2014 Thumbs.db
d---------+ 1 Rian users      512 Mar 18 15:29 Vidéo photographe accompli
ash-4.3# stat /volume1/video/Film/
File: ‘/volume1/video/Film/’
Size: 48748     	Blocks: 0          IO Block: 4096   directory
Device: 27h/39d	Inode: 371         Links: 1
Access: (0000/d---------)  Uid: ( 1026/    Rian)   Gid: (  100/   users)
Access: 2018-04-28 17:23:15.960659707 +0200
Modify: 2018-04-28 17:23:23.157593785 +0200
Change: 2018-04-28 17:23:23.157593785 +0200
Birth: -
ash-4.3# stat /volume1/video/Formation\ Photographe\ accompli/
File: ‘/volume1/video/Formation Photographe accompli/’
Size: 2272      	Blocks: 0          IO Block: 4096   directory
Device: 27h/39d	Inode: 11197       Links: 1
Access: (0000/d---------)  Uid: ( 1026/    Rian)   Gid: (  100/   users)
Access: 2018-04-28 17:23:44.337399789 +0200
Modify: 2018-04-28 17:23:44.005402829 +0200
Change: 2018-04-28 17:23:44.005402829 +0200
Birth: -

Permissions on Synology are done with ACLs unless you manually override them with permission bits at the file system level.

This line: d---------+ 1 Rian users 350 Apr 1 16:24 Series shows me the directory is still using ACLs (the +)
You will notice Thumbs.db is using standard permission bits.

You may do one of two things:

  1. Go into File Station and (re)set permissions in the videos share to allow either a. user plex to read or b. everyone to read.
  2. Override permanently at the file system level by using permission bits and a combination of the persistence bits (setuid, setgid, or perms)

Plex is already permit for “read/write” on the video share.
But I’ve done now just to make sure, is check the box “Apply to this folded, sub folders etc ..”. And I’ve uncheck/check the scan option, I still have the permission denied error.

FYI, here’s the ACL for these folders :
ash-4.3# synoacltool -get /volume1/video/
ACL version: 1
Archive: has_ACL,is_support_ACL
Owner: [root(user)]
---------------------
[0] user:kodi:allow:rwxpdDaARWc–:fd-- (level:0)
[1] group:administrators:allow:rwxpdDaARWc–:fd-- (level:0)
[2] user:plex:allow:rwxpdDaARWc–:fd-- (level:0)
ash-4.3# synoacltool -get /volume1/video/Film/
ACL version: 1
Archive: is_inherit,is_support_ACL
Owner: [Rian(user)]
---------------------
[0] user:kodi:allow:rwxpdDaARWc–:fd-- (level:1)
[1] group:administrators:allow:rwxpdDaARWc–:fd-- (level:1)
[2] user:plex:allow:rwxpdDaARWc–:fd-- (level:1)
ash-4.3# synoacltool -get /volume1/video/Formation\ Photographe\ accompli/
ACL version: 1
Archive: is_inherit,is_support_ACL
Owner: [Rian(user)]
---------------------
[0] user:kodi:allow:rwxpdDaARWc–:fd-- (level:1)
[1] group:administrators:allow:rwxpdDaARWc–:fd-- (level:1)
[2] user:plex:allow:rwxpdDaARWc–:fd-- (level:1)

As a simple check to make certain the ACL is not corrupted in the Synology database, would you consider:

sudo -su root
find /volume1/video -type d -exec chmod 775 {} \;
find /volume1/video -type f -exec chmod 664 {} \;

This gives owner (your username) permission as well as those in your group permission.

Should this not be to your liking, you can reset back to 000 and al

-OR-

Reapplying ACLs via the command line? (edit path as appropriate)

 synoacltool -add /volume1/video/ user:plex:allow:rwxpdDaARWcCo:fd--

I have reapplying ACL like you said :

synoacltool -add /volume1/video/Series/Workingirls/ user:plex:allow:rwxpdDaARWcCo:fd--
ACL version: 1
Archive: is_inherit,has_ACL,is_support_ACL
Owner: [Rian(user)]
---------------------
	 [0] user:plex:allow:rwxpdDaARWcCo:fd--  (level:0)
	 [1] user:kodi:allow:rwxpdDaARWc--:fd--  (level:2)
	 [2] group:administrators:allow:rwxpdDaARWc--:fd--  (level:2)
	 [3] user:plex:allow:rwxpdDaARWc--:fd--  (level:2)

But I still have the issue :

Apr 28, 2018 18:44:18.307 [0xda223b40] DEBUG - [Notify] Now watching /volume1/video/Series/Westworld
Apr 28, 2018 18:44:18.308 [0xda223b40] ERROR - [Notify] Failed to add watch for /volume1/video/Series/Workingirls (13: Permission denied)

It seems that permission is exactly the same. I’ve check on sinology interface and there is no differences

That is better .

Please count the number of directories you have.

find /volume1/video -type d -print | wc -l

Repeat this for all media directories.

If the number is > 8192, we need to increase the default kernel size (Linux default = 8192).

The parameter we will increase is fs.inotify.max_user_watches in /etc/sysctl.conf and raise it to something more reasonable like 32768

I don’t know why it’s better because I still have the issue but I trust you :slight_smile:

Here’s the number :

ash-4.3# find /volume1/video/Film/ -type d -print | wc -l
86
ash-4.3# find /volume1/video/Series/ -type d -print | wc -l
449
ash-4.3# find /volume1/video/Formation\ Photographe\ accompli/ -type d -print | wc -l
5
ash-4.3# find /volume1/video -type d -print | wc -l
550

The number is small.

And the value is to the default :

ash-4.3# cat /etc/sysctl.conf
kernel.panic = 3
net.core.somaxconn = 65535
net.ipv4.tcp_tw_reuse  = 1

That’s not making sense.

If you are willing, bypass the ACLs entirely with the hard permission bits I have shown above. (recursive chmod).
Time to get angry at Synology again (this sometimes happens)

Is it easy to rollback to ACL system ?
I’m just scared of changing things like that.

Yes.

Setting file/directory permissions back to 000 (as they currently are listed)

The Synology chmod command has built in help if needed.

admin@moesern:~$ chmod --help
Usage: chmod [OPTION]... MODE[,MODE]... FILE...
  or:  chmod [OPTION]... OCTAL-MODE FILE...
  or:  chmod [OPTION]... --reference=RFILE FILE...
Change the mode of each FILE to MODE.
With --reference, change the mode of each FILE to that of RFILE.

  -c, --changes          like verbose but report only when a change is made
  -f, --silent, --quiet  suppress most error messages
  -v, --verbose          output a diagnostic for every file processed
      --no-preserve-root  do not treat '/' specially (the default)
      --preserve-root    fail to operate recursively on '/'
      --reference=RFILE  use RFILE's mode instead of MODE values
  -R, --recursive        change files and directories recursively
      --help     display this help and exit
      --version  output version information and exit

Each MODE is of the form '[ugoa]*([-+=]([rwxXst]*|[ugo]))+|[-+=][0-7]+'.

  -k                     force keep the file in acl mode even if linux perm 
                         is given. the mode NNN will be tranformed to ACLs 
                         700 = u:<user of file>:allow:MRWX:fd 
                         060 = g:<group of file>:allow:MRW:fd
                         003 = a::allow:MWX:fd
SYNOACL Operations:
  [-+]a <ACL[,ACL...]>       add/remove specific ACEs
  -a# <index[,index...]>     remove the ACEs with spcific indices
  =a# <index[,index...]> ACL replace specific ACEs with the given ACL

ACL Format:
  <Object Type>:<Object name>:<Access type>:<Permissions>:<Inheritance>

  Object:      user(u),group(g),everyone(a),owner(o),
               authenticated_user(l),system(s)
               Object name can be empty if object type is not user/group
  Access:      allow/deny
  Permission:  rwxpdDaARWcCo, MRWX, F
               MR = raRc, MW = wpDAW, MX = x, F=rwxpdDaARWcCo
  Inheritance: fdin; Can be empty, default: fd

*Notice: SYNOACL operations will do normalization first, which means
         duplicated ACEs in ACL will be removed and ACEs with same object, 
         same access type and same inheritance will be merged.

GNU coreutils online help: <http://www.gnu.org/software/coreutils/>
Full documentation at: <http://www.gnu.org/software/coreutils/chmod>
or available locally via: info '(coreutils) chmod invocation'
admin@moesern:~$ 

Here’s what I’ve done :

ash-4.3# find /volume1/video/Series/Workingirls -type d -exec chmod 775 {} \;
ash-4.3# find /volume1/video/Series/Workingirls -type f -exec chmod 664 {} \;
ash-4.3# ls -l /volume1/video/Series/
total 0
d-----S---+ 1 Rian users  348 May 30  2017 90210
d---------+ 1 Rian users   18 Dec 14 21:37 Agents of SHIELD
[...]
d-----S---+ 1 Rian users 1504 May 30  2017 Westworld
drwxrwxr-x  1 Rian users 3880 May 30  2017 Workingirls
ash-4.3# tail -f "Plex Media Server.log"
[...]
Apr 28, 2018 19:48:15.487 [0xda223b40] DEBUG - [Notify] Now watching /volume1/video/Series/Westworld
Apr 28, 2018 19:48:15.488 [0xda223b40] DEBUG - [Notify] Now watching /volume1/video/Series/Workingirls
[...]

So changing to the basic permission fixed the issue.

So I tried to restore ACL for this directory, and I can’t :

ash-4.3# find /volume1/video/Series/Workingirls -type d -exec chmod 000 {} \;
ash-4.3# find /volume1/video/Series/Workingirls -type f -exec chmod 000 {} \;
ash-4.3# ls -l /volume1/video/Series/
total 0
d-----S---+ 1 Rian users  348 May 30  2017 90210
d---------+ 1 Rian users   18 Dec 14 21:37 Agents of SHIELD
[...]
d-----S---+ 1 Rian users 1504 May 30  2017 Westworld
d---------  1 Rian users 3880 May 30  2017 Workingirls

So I restore the ACL from Syno interface. I’ve just open the permission of the video share, and check the box to apply it to subfolders, it works :

ash-4.3# ls -l /volume1/video/Series/
total 0
d-----S---+ 1 Rian users  348 May 30  2017 90210
d---------+ 1 Rian users   18 Dec 14 21:37 Agents of SHIELD
[...]
d-----S---+ 1 Rian users 1504 May 30  2017 Westworld
d---------+ 1 Rian users 3880 May 30  2017 Workingirls

I tried to relaunch the “scan automatically” and the issue is fixed with ACL too :slight_smile:

So for summarized :

  1. Change permission :

    ash-4.3# find /volume1/video/Film -type d -exec chmod 775 {} ;
    ash-4.3# find /volume1/video/Film -type f -exec chmod 664 {} ;

  2. On the Synology Interface, right click on the video folder located in File Station. Go to Permission tab, and just check the box “…subfolder…”

  3. Save. It will apply ACL on each subfolder of video, so Film too.

  4. Disable / Enable the Plex option Update my library automatically

Done !