Skip to content

Commit

Permalink
chore: run safenodemand service as root
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jacderida committed Mar 19, 2024
1 parent 0c67b54 commit 329d326
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions sn_node_manager/src/cmd/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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 = <dyn SafeReleaseRepoActions>::default_config();

Expand All @@ -60,14 +53,18 @@ 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,
env_variables,
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,
Expand Down

0 comments on commit 329d326

Please sign in to comment.