Plex Media Server on FreeBSD based systems sending 0555 permissions to application data files

Server Version#: 1.21.3.4021

No logs are needed for this. I suspect they are useless anyways.

I’ve been trying to figure out why Plex keeps recreating missing DB files with the “r-xr-xr-x” permission, thus rendering it unable to write to it’s own DBs and files. I thought I bunged up ACLs and my Umasks. Having checked them, no directory is under an ACL, and the umask Plex is using is 022.

Having run a ktrace I found an interesting entry when tracing exactly what the OS is being told to do when the missing DB file handle is created.

Here’s the output:

 11902 Plex Media Server CALL  openat(AT_FDCWD,0x81959c400,0xe01<O_WRONLY|O_CREAT|O_TRUNC|O_EXCL>,0100555<S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH|S_IFREG>)
 11902 Plex Media Server CALL  write(0x7,0x805289580,0x128)
 11902 Plex Media Server CALL  socket(PF_INET,0x1<SOCK_STREAM>,IPPROTO_TCP)
 11902 Plex Media Server NAMI  "/Plex Media Server/Plug-in Support/Databases/tv.plex.providers.epg.cloud-319568ff-dcf9-4816-afba-e3c4cb2611a4-loading.db"

To summarize, the latest version of the Plex Media Server for FreeBSD systems is creating files with 0555 permissions. This is a critical problem and renders Plex unusable when running on a clean install, and breaks other aspects of Plex when it needs to spawn a new DB file only for it to not be able to write to it. This results in PMS hang ups.

This SHOULD be a straightforward fix.

I have no idea how to read the ktrace other than its writing to a file… But I sure don’t see this on my system and I think this would be something that would affect much more folks and not just FreeBSD right?
I mean I would imagine the code is the same for linux to create/write to the file.

In any case I just wipped my db files directly, refresh the guide, and the files are created with wirte access:

-rw-r--r--  1 plex  plex     427008 Feb 11 12:17 tv.plex.providers.epg.cloud-739f700f-3ae7-4ab0-baa5-a36a24cfc314-loading.db
-rw-r--r--  1 plex  plex      32768 Feb 11 12:18 tv.plex.providers.epg.cloud-739f700f-3ae7-4ab0-baa5-a36a24cfc314-loading.db-shm
-rw-r--r--  1 plex  plex    1137112 Feb 11 12:18 tv.plex.providers.epg.cloud-739f700f-3ae7-4ab0-baa5-a36a24cfc314-loading.db-wal
-rw-r--r--  1 plex  plex     336896 Feb 11 12:17 tv.plex.providers.epg.cloud-739f700f-3ae7-4ab0-baa5-a36a24cfc314.db

Same exact permissions if I run su -m plex -c "touch file"
-rw-r--r-- 1 plex plex 0 Feb 11 12:22 file

So I dunno what’s happening on your side but it doesn’t seem widespread or caused by PMS.

What version of the Plex server are you using?

The ktrace doesn’t lie. The directive to create the file with 0555 is coming from Plex. I just ran a touch in that directory as well and the file was created with 0644 permissions. This is looking more and more likely like an issue with the latest Plex releases.

Same version as you, I don’t know how to see from that output that the mode is 0555 but I take your word for it.

Something sounds very odd indeed but again this seems like something that would affect everyone and so far the are no more reports.

I also don’t think the latest version changed much, it’s just a vunl fix.

Caveat: I have not really used FreeBSD… but it seems to have a utility designed for this sort of troubleshooting. What does 'procstat -s ’ return? In all honesty, this really sounds like a process that’s executed before a non-default umask has been set. I’ve ran into this sort of issue where a manual application restart behaves differently than an init script start during boot (enterprise environment on Unix, not Plex.)

I have confirmed that Plex Media Server has a umask of 022

@Cyberpower678 I said this was last version… does it not happen if you rollback? How about a new clean jail?

Btw is this only for the DB files? What about logs?

It does add up to 0555:

S_IRUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH

S_IRUSR = read by user, 400
S_IXUSR = execute by user, 100

And so on for GRP and OTH.


And a counter-report: FreeBSD PlexMediaServer-1.21.3.4021-5a0a3e4b2, working for me. TrueNAS 12.2-U2 system with a 12.2 jail (not a plugin).

I’ve never set up DVR/EPG before on this system.

-rw-r--r--  1 plex  plex    1171456 Feb 11 14:05 tv.plex.providers.epg.cloud-71788236-a3ae-44ff-8a20-f2e07fe83a85.db

What does “FreeBSD based systems” mean? Is this FreeBSD or a variant? Jail? What’s the storage?

Thanks for the explanation Volts, I actually just noticed that before that is ,0100555 not sure if it means the same.

I believe FreeBSD based means FreeNAS / TrueNAS.

FWIW in my case its a jail with icoage (zfs backed storage) on “vanila” FreeBSD 12.2 (jail is still 12.1) and its also working.

1 Like

I haven’t had the time to invest in spawning a clean jail yet. I will try it out again, but it may be a day or two.

The log files are all being created with 0644 permissions.

Yes, I am running TrueNAS, but naturally Plex is running in a vanilla jail.

I wonder…

I believe the empty database file is created by copying from Resources/com.plexapp.plugins.library.db?

Have you changed permissions on that?

I see the same perms there. I wonder if I accidentally bunged them up. Can you share the ls -l output of you PMS binaries folder?

That one is 644.

-rw-r--r--  1 5556  5556  318464 Feb  8 11:40 Resources/com.plexapp.plugins.library.db

There is a log entry when the files are created, it gave me the clue. I actually saw it in ktrace myself - I couldn’t understand how Plex could be asking for different permissions on different systems, and wanted to see what you were seeing. :slight_smile:

Feb 11, 2021 14:28:27.397 [0x80ee71f00] DEBUG - Installing Library Database from ["/path/to/plexmediaserver/Resources/com.plexapp.plugins.library.db"] to ["/path/to/plexdata/Plex Media Server/Plug-in Support/Databases/tv.plex.providers.epg.cloud-2502a832-abb5-408f-9d8e-205cf25072f8.db"]

But those would be installed by the port/pkg a d be the same on others systems… unless your using another method of install/update like a custom script… and somehow messed up permissions.

I actually thought that file was just created on the fly not copied over, nice find maybe it explains the issue.

The first couple bits of that are used for other stuff about the file - the 1 in that position means it’s a “regular” file.

Prepare to be bored, check out st_mode:

stat(2)

I assumed the same!

1 Like

That was totally what was broken. I set all files in there to 0755 and restarted Plex and like magic, all systems go again. Nice find. I must have mangled the perms in that directory somehow.

1 Like