From d6cd5da1b8e43b456dc959c9666824b59a120fde Mon Sep 17 00:00:00 2001 From: Nav Date: Wed, 18 Jan 2023 00:41:23 +0000 Subject: [PATCH] Binned udev rule check in TargetController --- .../TargetControllerComponent.cpp | 36 ------------------- .../TargetControllerComponent.hpp | 7 ---- 2 files changed, 43 deletions(-) diff --git a/src/TargetController/TargetControllerComponent.cpp b/src/TargetController/TargetControllerComponent.cpp index 040be8c3..937fcce3 100644 --- a/src/TargetController/TargetControllerComponent.cpp +++ b/src/TargetController/TargetControllerComponent.cpp @@ -1,13 +1,11 @@ #include "TargetControllerComponent.hpp" -#include #include #include #include #include "Responses/Error.hpp" -#include "src/Helpers/Paths.hpp" #include "src/Helpers/Process.hpp" #include "src/Logger/Logger.hpp" @@ -169,9 +167,6 @@ namespace Bloom::TargetController this->eventListener->setInterruptEventNotifier(&TargetControllerComponent::notifier); EventManager::registerListener(this->eventListener); - // Install Bloom's udev rules if not already installed - TargetControllerComponent::checkUdevRules(); - // Register command handlers this->registerCommandHandler( std::bind(&TargetControllerComponent::handleGetState, this, std::placeholders::_1) @@ -444,37 +439,6 @@ namespace Bloom::TargetController TargetControllerComponent::responsesByCommandIdCv.notify_all(); } - void TargetControllerComponent::checkUdevRules() { - auto bloomRulesPath = std::string("/etc/udev/rules.d/99-bloom.rules"); - auto latestBloomRulesPath = Paths::resourcesDirPath() + "/UDevRules/99-bloom.rules"; - - if (!std::filesystem::exists(bloomRulesPath)) { - Logger::warning("Bloom udev rules missing - attempting installation"); - - // We can only install them if we're running as root - if (!Process::isRunningAsRoot()) { - Logger::error("Bloom udev rules missing - cannot install udev rules without root privileges.\n" - "Running Bloom once with root privileges will allow it to automatically install the udev rules. " - "Alternatively, instructions on manually installing the udev rules can be found " - "here: " + Paths::homeDomainName() + "/docs/getting-started\nBloom may fail to connect to some " - "debug tools until this is resolved."); - return; - } - - if (!std::filesystem::exists(latestBloomRulesPath)) { - // This shouldn't happen, but it can if someone has been messing with the installation files - Logger::error( - "Unable to install Bloom udev rules - \"" + latestBloomRulesPath + "\" does not exist." - ); - return; - } - - std::filesystem::copy(latestBloomRulesPath, bloomRulesPath); - Logger::warning("Bloom udev rules installed - a reconnect of the debug tool may be required " - "before the new udev rules come into effect."); - } - } - void TargetControllerComponent::shutdown() { if (this->getThreadState() == ThreadState::STOPPED) { return; diff --git a/src/TargetController/TargetControllerComponent.hpp b/src/TargetController/TargetControllerComponent.hpp index f753a350..1b2e9ac6 100644 --- a/src/TargetController/TargetControllerComponent.hpp +++ b/src/TargetController/TargetControllerComponent.hpp @@ -234,13 +234,6 @@ namespace Bloom::TargetController */ void registerCommandResponse(Commands::CommandIdType commandId, std::unique_ptr response); - /** - * Installs Bloom's udev rules on user's machine. Rules are copied from build/Distribution/Resources/UdevRules - * to /etc/udev/rules.d/. This method will report an error if Bloom isn't running as root (as root privileges - * are required for writing to files in /etc/udev). - */ - static void checkUdevRules(); - /** * Exit point - must be called before the TargetController thread is terminated. *