Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions backend/src/routes/updates.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,19 +267,20 @@ pub async fn install_update(

tracing::info!("Running as root: {}", is_root);

// Build command - use nohup and setsid to detach from parent process
// Build command - use sudo nohup to detach from parent process
// This ensures the update continues even when the backend service is stopped
// sudoers entry: csf-core ALL=(ALL) NOPASSWD: /bin/bash /opt/csf-core/scripts/update.sh*
// sudoers entry: csf-core ALL=(ALL) NOPASSWD: /usr/bin/nohup /bin/bash /opt/csf-core/scripts/update.sh*
let mut command = if is_root {
// Running as root, execute script directly with nohup
let mut cmd = Command::new("nohup");
cmd.arg("/bin/bash");
cmd.arg(&script_path_clone);
cmd
} else {
// Running as csf-core user - use sudo with nohup
let mut cmd = Command::new("nohup");
cmd.arg("sudo");
// Running as csf-core user - use sudo nohup (not nohup sudo!)
// This matches the sudoers entry exactly
let mut cmd = Command::new("sudo");
cmd.arg("/usr/bin/nohup");
cmd.arg("/bin/bash");
cmd.arg(&script_path_clone);
cmd
Expand Down
1 change: 0 additions & 1 deletion csf-core.sudoers
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
csf-core ALL=(ALL) NOPASSWD: /bin/bash /opt/csf-core/scripts/update.sh*
csf-core ALL=(ALL) NOPASSWD: /usr/bin/bash /opt/csf-core/scripts/update.sh*
csf-core ALL=(ALL) NOPASSWD: /usr/bin/nohup /bin/bash /opt/csf-core/scripts/update.sh*
csf-core ALL=(ALL) NOPASSWD: /usr/bin/nohup sudo /bin/bash /opt/csf-core/scripts/update.sh*
csf-core ALL=(ALL) NOPASSWD: /usr/bin/nohup /usr/bin/bash /opt/csf-core/scripts/update.sh*
csf-core ALL=(ALL) NOPASSWD: /bin/systemctl daemon-reload
csf-core ALL=(ALL) NOPASSWD: /bin/systemctl start csf-core.service
Expand Down
Loading