Resolving permissions problems
This How-To is about finding and resolving permission issues where PMS cannot read the file(s) due to a problem somewhere in the path.
While the process is straight forward (perform ls -la for each directory in the pathname to the file), the process is time consuming and somewhat tedious.
This HowTo provides a basic script which you can use (change from read-test to write-test if needed) and find where user plex loses its permission to get to a specific file.
Consider the case of file: /tmp/a/b/c/d/e.mp4
The process
Step 1 - Temporarily make user plex a viable shell user account
Step 2 - Copy the text below to a file (making it a script)
I’ve named this “can-read”
#!/bin/sh
if [ "$1" = "" ]; then
echo usage: $0 path-to-check
exit 1
fi
Dir="$1"
while [ "$Dir" != "" ]
do
if [ -r "$Dir" ]; then
echo READ: \"$Dir\"
else
echo FAIL: \"$Dir\"
fi
NewDir="$(dirname "$Dir")"
if [ "$NewDir" = "$Dir" ]; then
Dir=""
else
Dir="$NewDir"
fi
done
Copy the script and change the -r test to -w to test for write access
Step 3
After making it executable, start testing pathnames with :
su -s /bin/sh plex can-read /path/to/file.ext
Example
Check read permissions for `/tmp/a/b/c/d/e.mp4
# su -s /bin/sh plex ./can-read /tmp/a/b/c/d/e.mp4
FAIL: "/tmp/a/b/c/d/e.mp4"
FAIL: "/tmp/a/b/c/d"
FAIL: "/tmp/a/b/c"
READ: "/tmp/a/b"
READ: "/tmp/a"
READ: "/tmp"
READ: "/"
#
Notice the fail point?
Checking permissions using ls -la finds the permissions problem.
# cd /tmp/a/b
# ls -la
total 0
drwxr-xr-x. 3 chuck chuck 60 Mar 28 03:13 ./
drwxr-xr-x. 3 chuck chuck 60 Mar 28 03:13 ../
drwx------. 3 chuck chuck 60 Mar 28 03:13 c/
#
Step 4 - Fixing the problem
We observe that, at /tmp/a/b , directory c does not permit anyone except the owner to access it.
We correct this by fixing the permissions chmod 755 /tmp/a/b/c
One last verification confirms everything is now correct.
# su -s /bin/sh plex ./can-read /tmp/a/b/c/d/e.mp4
READ: "/tmp/a/b/c/d/e.mp4"
READ: "/tmp/a/b/c/d"
READ: "/tmp/a/b/c"
READ: "/tmp/a/b"
READ: "/tmp/a"
READ: "/tmp"
READ: "/"
#
User plex will now be able to access everything from c down.