diff --git a/src/slic3r/plugin/PluginManager.cpp b/src/slic3r/plugin/PluginManager.cpp index d84f629112..16acfe0eee 100644 --- a/src/slic3r/plugin/PluginManager.cpp +++ b/src/slic3r/plugin/PluginManager.cpp @@ -1145,6 +1145,26 @@ void PluginManager::mark_plugin_install_state_disabled(const std::string& plugin plugin->descriptor.enabled = false; } +void PluginManager::revoke_plugin_permissions(const std::string& plugin_key) +{ + std::lock_guard state_lock(m_install_state_mutex); + + PluginDescriptor descriptor; + if (!try_get_plugin_descriptor(plugin_key, descriptor) || descriptor.plugin_root.empty()) + return; + + const boost::filesystem::path root(descriptor.plugin_root); + PluginInstallState state; + if (!read_install_state(root, state)) { + BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": Failed to read install state for " << plugin_key; + return; + } + + state.permissions = {}; + if (!write_install_state(root, state)) + BOOST_LOG_TRIVIAL(warning) << __FUNCTION__ << ": Failed to revoke permissions for " << plugin_key; +} + // ── Callbacks ─────────────────────────────────────────────────────────────────────────────── void PluginManager::subscribe_on_load_callback(PluginLifecycleCompleteFn fn) @@ -1364,6 +1384,11 @@ bool PluginManager::install_plugin(const boost::filesystem::path& filepath, Plug return false; } + // Every successful install may have replaced executable plugin code. Revoke any permissions + // associated with the previous package so the newly installed version must request them again. + if (!plugin_descriptor.plugin_key.empty()) + revoke_plugin_permissions(plugin_descriptor.plugin_key); + if (!plugin_descriptor.plugin_key.empty()) clear_plugin_error(plugin_descriptor.plugin_key); @@ -1751,6 +1776,7 @@ bool PluginManager::update_cloud_plugin(const std::string& plugin_key, std::stri } clear_plugin_error(plugin_key); + return true; } diff --git a/src/slic3r/plugin/PluginManager.hpp b/src/slic3r/plugin/PluginManager.hpp index 26a02c09ec..f23c552e25 100644 --- a/src/slic3r/plugin/PluginManager.hpp +++ b/src/slic3r/plugin/PluginManager.hpp @@ -254,6 +254,8 @@ private: // Writes the sidecar for a loaded plugin (enabled=true plus the current per-capability flags). void write_loaded_plugin_install_state(const std::string& plugin_key); void mark_plugin_install_state_disabled(const std::string& plugin_key); + // Revoke permissions after a package replacement so the new package must request them again. + void revoke_plugin_permissions(const std::string& plugin_key); bool finalize_cloud_plugin_removal(const PluginDescriptor& plugin, bool keep_local, std::string& error); bool delete_installed_plugin_package(const PluginDescriptor& plugin, std::string& error);