From 329d326a0bb018d013572cb1ad71c8049e26f2f1 Mon Sep 17 00:00:00 2001 From: Chris O'Neil Date: Tue, 19 Mar 2024 19:52:42 +0000 Subject: [PATCH] chore: run `safenodemand` service as root Creating a user for running the `safenodemand` service doesn't make as much sense because the user must have root access. We can leave it up to the user to create an account and set it up for passwordless sudo, then provide an optional `--user` argument. For now we don't have this, and just go with root. --- sn_node_manager/src/cmd/daemon.rs | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/sn_node_manager/src/cmd/daemon.rs b/sn_node_manager/src/cmd/daemon.rs index 50f0551621..f660f9d720 100644 --- a/sn_node_manager/src/cmd/daemon.rs +++ b/sn_node_manager/src/cmd/daemon.rs @@ -15,10 +15,7 @@ use crate::{ }; use color_eyre::{eyre::eyre, Result}; use sn_releases::{ReleaseType, SafeReleaseRepoActions}; -use sn_service_management::{ - control::{ServiceControl, ServiceController}, - DaemonService, NodeRegistry, -}; +use sn_service_management::{control::ServiceController, DaemonService, NodeRegistry}; use std::{net::Ipv4Addr, path::PathBuf}; pub async fn add( @@ -40,10 +37,6 @@ pub async fn add( println!("================================================="); } - let service_user = "safe"; - let service_manager = ServiceController {}; - service_manager.create_service_user(service_user)?; - let mut node_registry = NodeRegistry::load(&config::get_node_registry_path()?)?; let release_repo = ::default_config(); @@ -60,6 +53,10 @@ pub async fn add( .await? }; + // At the moment we don't have the option to provide a user for running the service. Since + // `safenodemand` requires manipulation of services, the user running it must either be root or + // have root access. For now we will just use the `root` user. The user option gets ignored on + // Windows anyway, so there shouldn't be a cross-platform issue here. add_daemon( AddDaemonServiceOptions { address, @@ -67,7 +64,7 @@ pub async fn add( daemon_install_bin_path: config::get_daemon_install_path(), daemon_src_bin_path, port, - user: service_user.to_string(), + user: "root".to_string(), version, }, &mut node_registry,