Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/emby: ensure plugins are writeable #46959

Merged
merged 1 commit into from Sep 23, 2018

Conversation

worldofpeace
Copy link
Contributor

Emby manages plugins at /var/lib/emby/${dataDir}/plugins like this.
When an upgrade occurs the plugins are already there and it just overwrites them.
However it can't because they aren't writeable. This causes an exception during runtime.

A very simple solution for now is to just make them writeable after we know the dataDir exists.
(definitely after an upgrade)

I've testing in a vm a couple times by simulating an upgrade and I no longer see the exception @numinit reported.

Motivation for this change
System.UnauthorizedAccessException: Access to the path "/nix/store/nfmvvn6jv5b29q8a1m8pz2mmx4y3fjfn-emby-3.5.2.0/bin/plugins/Emby.Server.CinemaMode.dll" or "/var/lib/emby/ProgramData-Server/plugins/Emby.Server.CinemaMode.dll" is denied.
  at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) [0x00192] in <2bf5cbaa96234d758393ee9c32a4b268>:0
  at Emby.Server.Implementations.ApplicationHost.CopyPlugins (System.String source, System.String target) [0x0008f] in <ea7199aea78e429a84e168a1e154646a>:0
  at Emby.Server.Implementations.ApplicationHost.GetPluginAssemblies () [0x00023] in <ea7199aea78e429a84e168a1e154646a>:0
  at Emby.Server.Implementations.ApplicationHost.GetComposablePartAssemblies () [0x00000] in <ea7199aea78e429a84e168a1e154646a>:0
  at Emby.Server.Implementations.ApplicationHost.DiscoverTypes () [0x00015] in <ea7199aea78e429a84e168a1e154646a>:0
  at Emby.Server.Implementations.ApplicationHost.Init () [0x0009b] in <ea7199aea78e429a84e168a1e154646a>:0
  at MediaBrowser.Server.Mono.MainClass.RunApplication (Emby.Server.Implementations.ServerApplicationPaths appPaths, MediaBrowser.Model.Logging.ILogManager logManager, Emby.Server.Implementations.StartupOptions options) [0x000c2] in <674f05e6c9e14fbaa7955ba5ed6025ed>:0
  at MediaBrowser.Server.Mono.MainClass.Main (System.String[] args) [0x0009c] in <674f05e6c9e14fbaa7955ba5ed6025ed>:0
System.UnauthorizedAccessException
  at System.IO.File.Copy (System.String sourceFileName, System.String destFileName, System.Boolean overwrite) [0x00192] in <2bf5cbaa96234d758393ee9c32a4b268>:0
  at Emby.Server.Implementations.ApplicationHost.CopyPlugins (System.String source, System.String target) [0x0008f] in <ea7199aea78e429a84e168a1e154646a>:0
  at Emby.Server.Implementations.ApplicationHost.GetPluginAssemblies () [0x00023] in <ea7199aea78e429a84e168a1e154646a>:0
  at Emby.Server.Implementations.ApplicationHost.GetComposablePartAssemblies () [0x00000] in <ea7199aea78e429a84e168a1e154646a>:0
  at Emby.Server.Implementations.ApplicationHost.DiscoverTypes () [0x00015] in <ea7199aea78e429a84e168a1e154646a>:0
  at Emby.Server.Implementations.ApplicationHost.Init () [0x0009b] in <ea7199aea78e429a84e168a1e154646a>:0
  at MediaBrowser.Server.Mono.MainClass.RunApplication (Emby.Server.Implementations.ServerApplicationPaths appPaths, MediaBrowser.Model.Logging.ILogManager logManager, Emby.Server.Implementations.StartupOptions options) [0x000c2] in <674f05e6c9e14fbaa7955ba5ed6025ed>:0
  at MediaBrowser.Server.Mono.MainClass.Main (System.String[] args) [0x0009c] in <674f05e6c9e14fbaa7955ba5ed6025ed>:0
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Fits CONTRIBUTING.md.

@Mic92
Copy link
Member

Mic92 commented Sep 20, 2018

Do you know why plugins are not writeable in the first place? Why does emby not set the permissions correctly itself? Does it copy files from the nix store?

@worldofpeace
Copy link
Contributor Author

It copies the files from the nix store.

@Mic92
Copy link
Member

Mic92 commented Sep 20, 2018

Ok. Could you ask upstream to make them writeable after copying them?

@Mic92
Copy link
Member

Mic92 commented Sep 20, 2018

Depending how long they take to fix this, we can merge this.

@worldofpeace
Copy link
Contributor Author

Sure thing.

@Mic92
Copy link
Member

Mic92 commented Sep 20, 2018

My blind fix would be something like:

File.SetAttributes(targetFile,
    File.GetAttributes(targetFile) & ~FileAttributes.ReadOnly);

@worldofpeace
Copy link
Contributor Author

@Mic92 I opened an issue ✨

@srhb srhb merged commit 7ac9e75 into NixOS:master Sep 23, 2018
@worldofpeace worldofpeace deleted the emby/correct-permission branch September 23, 2018 18:35
@minijackson minijackson mentioned this pull request Apr 18, 2019
10 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants