Is your feature improvement request related to a problem? Please describe.
The custom restart command (defined in the system.toml file), always assumes that sudo needs to be used when calling the custom command. When using a container setup, this is generally not the case as certain privileged functions are available to a non-root user (e.g. restarting the container when using s6-overlay is allowed by a non root user.)
Ideally sudo should be an optional dependency, and only called if it is actually installed.
Below shows a snippet of the log entry when sudo is not installed and the restart manager tries to execute the script (notice it doesn't actually say that sudo is missing, but it was definitely caused by the missing sudo as shown in the rust snippet following the example).
tedge-agent | 2023-07-25T19:56:47.185282174Z ERROR tedge_agent::restart_manager::actor: No such file or directory (os error 2)
The rust source code shows the problem with the reliance on sudo, and it blindly uses it without any prior checks if it exists or not.
let mut command = Command::new(SUDO);
command.args(system_config.system.reboot);
vec.push(command);
Ok(vec)
Describe the solution you'd like
Only use sudo to run specific commands if it is installed. If sudo isn't installed just try running the command without it, and pass the error reason back to the user.
Is your feature improvement request related to a problem? Please describe.
The custom restart command (defined in the
system.toml
file), always assumes thatsudo
needs to be used when calling the custom command. When using a container setup, this is generally not the case as certain privileged functions are available to a non-root user (e.g. restarting the container when using s6-overlay is allowed by a non root user.)Ideally
sudo
should be an optional dependency, and only called if it is actually installed.Below shows a snippet of the log entry when sudo is not installed and the restart manager tries to execute the script (notice it doesn't actually say that sudo is missing, but it was definitely caused by the missing sudo as shown in the rust snippet following the example).
The rust source code shows the problem with the reliance on
sudo
, and it blindly uses it without any prior checks if it exists or not.File: crates/core/tedge_agent/src/restart_manager/actor.rs
Describe the solution you'd like
sudo
isn't installed just try running the command without it, and pass the error reason back to the user.Describe alternatives you've considered
Additional context