Plex DVR file creation defaults of 644 causing issues

Just getting this setup on my Ubuntu server and I noticed an issue with the permission defaults Plex is using. When Plex DVR records a TV show it creates it with a mask of 644, user can read/modify, all others can read.

Like this:
-rw-r–r-- 1 plex users 4399994676 Oct 4 21:00 The Flash (2014) - S03E01 - Flashpoint.ts

I dislike this default as it makes it impossible to do maintenance on these files/directories manually through Samba as I login with a unique user name (not plex) who is part of the ‘users’ group.

To modify the files/directories I have to login and manually take ownership of the files and reset their permissions to allow group members to modify.

Is there a place the file creation mask can be modified from 644 to 664 to allow members of the group to modify? Alternately can Plex update its code to not prevent group modification?

1 Like

Can you use the stickybit on the recording directory? I don’t recall if that would work. Your other option would be a cronjob that updats the permissions. Or have it modified as part of post processing.

@cyberbrix: Is this the sticky bit you are referring to (from Wikipedia):
When a directory’s sticky bit is set, the filesystem treats the files in such directories in a special way so only the file’s owner, the directory’s owner, or root user can rename or delete the file. Without the sticky bit set, any user with write and execute permissions for the directory can rename or delete contained files, regardless of the file’s owner. Typically this is set on the /tmp directory to prevent ordinary users from deleting or moving other users’ files.

That doesn’t look to be the solution if I understand.

Ideal solution would be that there is some setting I can set through settings in the browser. Or there is a setting in some config file that Plex uses that I can set the appropriate creation mask (like many other similar programs provide). As a last resort I would settle for using a cron job, but I consider that more of a work-around than a solution to the problem.

You might be able to chmod the file using the new “post processing” option.

I did a force group to “media” and added myself as a member. On my Samba server:
[movies]
comment = Movies
path = /mnt/storage/media/movies
guest ok = no
valid users = jdbower, plex
writable = yes
force group = media
browseable = yes

Setting the group is nice, but not enough if the file is being created as 0644.

While you can set the group via Samba, you should also be able to do this at the fs level. You can force the file to be created as any group that plex is a member of, by using sgid on the library root directory. e.g.
sudo chown :media /mnt/storage/media/movies
sudo chmod g+s /mnt/storage/media/movies
sudo adduser plex media

sorry, I ment to say using SGID like @abentley mentioned

In my smb.conf:

[Plex]
path = /srv/plex/Media
read only = no
force user = plex
force group = plex

This way Samba forces the owner and group for any new files to be plex, so Plex always has access to the media. No problems.

What about in /etc/passwd?

plex:x:x:998:131:,umask=0002:/var/lib/plexmediaserver:/bin/false

Obviously set the 0002 to what you would prefer.

I tried using answers from both @abently and @charliebash :

chown -R root:users Unwatched
chmod -R g+s Unwatched
adduser plex users

sudo chfn -o umask=002 plex
=> plex:x:113:119:,umask=002:/var/lib/plexmediaserver:/bin/bash

However, plex still overrides the umask to deny group members write permission. It doesn’t matter if it’s owned by the group users, users don’t have write permissions. Ubuntu’s default permissions give both user and group write permissions, so this looks to be something Plex is overriding specifically.

Here’s the resultant directory created with the above:
drwxr-sr-x 3 plex users 4096 Oct 9 10:13 This Week With George Stephanopoulos (2002)

@Zibnet said:
In my smb.conf:

[Plex]
path = /srv/plex/Media
read only = no
force user = plex
force group = plex

This way Samba forces the owner and group for any new files to be plex, so Plex always has access to the media. No problems.

Thanks for the insight, but Plex isn’t using Samba. It has local access. I don’t use Samba until after the recording.

1 Like

So weird…

drwxrwxrwx 1 1024 users 306 Oct 8 14:02 .
drwxrwxrwx 1 1024 users 22 Sep 26 19:05 …
-rwxrwxrwx 1 1024 users 3.0G Oct 4 19:08 Seven News - 2016-10-04 00_00_00 - Episode 10-04.ts
-rwxrwxrwx 1 1024 users 3.1G Oct 5 19:08 Seven News - 2016-10-05 00_00_00 - Episode 10-05.ts
-rwxrwxrwx 1 1024 users 193M Oct 7 18:42 Seven News - 2016-10-07 00_00_00 - Episode 10-07.ts

I HAD the same problems with NFS shares, but changing the UMASK in /etc/passwd did do the trick.

When you sudo into the plex account, and create a directory, what are the permissions?

@charliebash: Plex intentionally changing the permissions? Here’s what I get by default through the Plex account.

plex@NAS:/media/movies/Movies/Unwatched$ whoami
plex

mkdir test2
ls -la
drwxrwsr-x 2 plex users 4096 Oct 9 17:48 test2

touch test2
ls -la
-rw-rw-r-- 1 plex users 0 Oct 9 17:50 test2

ok, so the useraccount is correct. (setting the correct umask as in /etc/group)

Are you running on a brand name NAS, using third party tools to setup shares etc?

Ubuntu 16.04. Installed Plex from the installation file from Plex’s site. The disks I setup manually.

Sorry man, I can’t replicate this issue. I myself am running:

Linux version 4.4.0-38-generic (buildd@lgw01-58) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.2) ) #57-Ubuntu SMP Tue Sep 6 15:42:33 UTC 2016

Plex adheres to my useraccount rules on my server, the only permissions problems I have had in the past have been due to my own configuration issues.

The only thing I could suggest is to:

  • delete and re-add the acocunts and groups affected by this issue
  • chown -R from the upmost directory tree to the users and groups you require
  • chmod -R as above
  • ensure the umask flag is set in the user account
  • disable samba for the time being while trouble shooting
  • reboot the system

The only thing I can think of is that there is a permissions or ownership problem somewhere up the directory tree to create the issue.

You absolutely should not have to run scripts to change permissions and ownerships, thats going to cause headaches down the line.

I’m at a loss. I’ve set and reset all the permissions back to the disk mount. I’m not sure what I’m missing. From my perspective the gold standard is that the permissions are correct if I ‘su plex’ and create a directory or file as the plex user.

I still think Plex must be changing the permissions.

I also ran into this problem. I wanted to edit .edl files kicked out by my Plex DVR postprocessing as my normal user. The files produced by plex were all 644. For both my user and the plex user, newly created files are 664. As a workaround, I used cron to call this script to fix permissions:
#!/bin/sh
/bin/chmod 664 /Media/Temp/GH_To_Process/
.edl

Having this as a separate script vs putting the command directly in crontab turned out to be the combination that worked for me.

1 Like

That is essentially my work-around, but I was hoping a developer could comment and or fix the actual issue instead of everyone needing a work-around.

I use this in my Perl script:
system(“chown -R root:users $dir”);
system(“chmod -R 777 $dir”);
system(“chmod -R g+s $dir”);

Created a bug post with all the information in another topic and I’m hoping a developer can address it so a work-around isn’t needed.

1 Like

So what’s the status on this? I’m experiencing the exact same problem and it’s pretty clear that Plex needs an option to have it’s default file/directory creation mode changed.

The way it is now, with all files being created as 644 and the only way to alter that mode is using postprocessing scripts, it’s barely usable and/or feels like a cobbled together hack.

Seeing that this issue persists 2 years (!) after being reported does not instill exaggerated optimism tbh…