aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Burrows <neil.burrows@nvable.com>2020-06-22 10:13:28 +0100
committerNeil Burrows <neil.burrows@nvable.com>2020-06-22 10:13:28 +0100
commitc20400fa40d88329b1187aed84ead66e8cae4dde (patch)
tree68f9785d9b8aaad9956defdc36a18cd23c05f7c1
parentc3349038c4270c65caa46b148ef6802f083e5e19 (diff)
Prevent system plugins from being uninstalled
-rw-r--r--Emby.Server.Implementations/Updates/InstallationManager.cs6
-rw-r--r--MediaBrowser.Common/Plugins/BasePlugin.cs9
-rw-r--r--MediaBrowser.Common/Plugins/IPlugin.cs5
-rw-r--r--MediaBrowser.Model/Plugins/PluginInfo.cs6
4 files changed, 25 insertions, 1 deletions
diff --git a/Emby.Server.Implementations/Updates/InstallationManager.cs b/Emby.Server.Implementations/Updates/InstallationManager.cs
index 80326fddf..0e912dfe9 100644
--- a/Emby.Server.Implementations/Updates/InstallationManager.cs
+++ b/Emby.Server.Implementations/Updates/InstallationManager.cs
@@ -402,6 +402,12 @@ namespace Emby.Server.Implementations.Updates
/// <param name="plugin">The plugin.</param>
public void UninstallPlugin(IPlugin plugin)
{
+ if (!plugin.CanUninstall)
+ {
+ _logger.LogInformation("Attempt to delete non removable plugin {0}", plugin.Name);
+ return;
+ }
+
plugin.OnUninstalling();
// Remove it the quick way for now
diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs
index 9e4a360c3..aab07c1fb 100644
--- a/MediaBrowser.Common/Plugins/BasePlugin.cs
+++ b/MediaBrowser.Common/Plugins/BasePlugin.cs
@@ -2,6 +2,7 @@
using System;
using System.IO;
+using System.Reflection;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Model.Plugins;
using MediaBrowser.Model.Serialization;
@@ -50,6 +51,11 @@ namespace MediaBrowser.Common.Plugins
public string DataFolderPath { get; private set; }
/// <summary>
+ /// Gets a value indicating whether the plugin can be uninstalled.
+ /// </summary>
+ public bool CanUninstall => !Path.GetDirectoryName(AssemblyFilePath).Equals(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), StringComparison.InvariantCulture);
+
+ /// <summary>
/// Gets the plugin info.
/// </summary>
/// <returns>PluginInfo.</returns>
@@ -60,7 +66,8 @@ namespace MediaBrowser.Common.Plugins
Name = Name,
Version = Version.ToString(),
Description = Description,
- Id = Id.ToString()
+ Id = Id.ToString(),
+ CanUninstall = CanUninstall
};
return info;
diff --git a/MediaBrowser.Common/Plugins/IPlugin.cs b/MediaBrowser.Common/Plugins/IPlugin.cs
index d34820961..7bd37d210 100644
--- a/MediaBrowser.Common/Plugins/IPlugin.cs
+++ b/MediaBrowser.Common/Plugins/IPlugin.cs
@@ -41,6 +41,11 @@ namespace MediaBrowser.Common.Plugins
string AssemblyFilePath { get; }
/// <summary>
+ /// Gets a value indicating whether the plugin can be uninstalled.
+ /// </summary>
+ bool CanUninstall { get; }
+
+ /// <summary>
/// Gets the full path to the data folder, where the plugin can store any miscellaneous files needed.
/// </summary>
/// <value>The data folder path.</value>
diff --git a/MediaBrowser.Model/Plugins/PluginInfo.cs b/MediaBrowser.Model/Plugins/PluginInfo.cs
index c13f1a89f..dd215192f 100644
--- a/MediaBrowser.Model/Plugins/PluginInfo.cs
+++ b/MediaBrowser.Model/Plugins/PluginInfo.cs
@@ -35,6 +35,12 @@ namespace MediaBrowser.Model.Plugins
/// </summary>
/// <value>The unique id.</value>
public string Id { get; set; }
+
+ /// <summary>
+ /// Gets or sets a value indicating whether the plugin can be uninstalled.
+ /// </summary>
+ public bool CanUninstall { get; set; }
+
/// <summary>
/// Gets or sets the image URL.
/// </summary>