clara-j / media_cleaner

Python script to delete watched content on Emby
31 stars 17 forks source link

Error HttpServer: Error processing request; Access to path denied #2

Closed terrelsa13 closed 4 years ago

terrelsa13 commented 4 years ago

Here is the new issue I am opening as requested.

I am not sure if you are talking linux rwx permissions or the "User-->Profile-->Allow Media Deletion From-->All Libraries" setting on the emby server?

Either way, I have tried running the script from my server as the user I am logged in as and as root. Both have rwx permissions to my media files/folders.

When running the script for the first time to set up the config file, I input my username/password for the emby admin account. I then select a different account as the user to track with. Both accounts have their "User-->Profile-->Allow Media Deletion From-->All Libraries" setting checked.

I see the same issue. https://pastebin.com/raw/nsFvPw35

terrelsa13 commented 4 years ago

@clara-j you were right. It is a permissions issue.

It was deleting the metadata successfully. But not the media. My metadata has a user:group of emby:emby. My media has a user:group of hieroglyph:hieroglyph.

I will have to play around with ACLs to get this working the way I want it to.

terrelsa13 commented 4 years ago

@clara-j Question for you: Are the files deleted by the "admin user" or the "track with user"?

clara-j commented 4 years ago

The delete command is sent using the API of the Admin user you provided. But to be able to delete the actual files on the filesystem, the linux user that the emby server is running under must have permissions on the folder to delete the files.

You can check what user the emby server is running with the ps command, but if the metadata has user/group emby:emby then it is likely emby. So you will need to make sure that the emby user has delete permissions for that folder. You can either modify the folder so that any users can delete, or add emby to the group and make sure the group is able to delete.

I had a similar, if not the same issue, when I first starting developing this since I was using docker and the media folder I mapped with the RO option and deleting from the filesystem failed due to that. When I updated dockers-compose to no longer mount as RO it worked..

terrelsa13 commented 4 years ago

For anyone else who may run into this issue; as @clara-j mentions you will need to add emby to the group that has permissions to delete your media and then make the group permission for that folder rwx. BUT... this will also give any other users in your group rwx permissions allowing them to delete media.

Another option is to specifically give the user emby rwx using an Access Control List.

You only need to do one of the following:

Easy less secure way

add emby to your group (replace yourgroupname with the name of the group that owns your media folder)

usermod -a -G yourgroupname emby

change the permissions of your media folder so anyone in your group can delete media

chmod -R g+rwx /path/to/your/media/folder

Still easy once you learn setfacl and getfacl, but also more secure If you're feeling a little more advanced you can create an ACL to specifically give emby permission to delete media without giving every user added to your group permission to delete media.

setup an access control list giving the user emby permission to delete existing media files

setfacl -m u:emby:rwx -R /path/to/your/media/folder

setup a defualt access contol list giving the user emby permission to delete future media files that will be added

setfacl -d -m u:emby:rwx -R /path/to/your/media/folder
clara-j commented 4 years ago

Thanks for the great explanation. Any issue with me adding this to the README for other users that may have the same problem?

terrelsa13 commented 4 years ago

No issues with that at all.