allow setting args and current_dir
and this is as far as we will get
This commit is contained in:
@@ -45,6 +45,10 @@ pub struct TerminalConfig {
|
||||
pub enabled: bool,
|
||||
#[serde(default = "default_terminal_shell")]
|
||||
pub shell: PathBuf,
|
||||
#[serde(default)]
|
||||
pub args: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub current_dir: Option<PathBuf>,
|
||||
#[serde(default = "default_terminal_max_sessions")]
|
||||
pub max_sessions: usize,
|
||||
}
|
||||
@@ -54,6 +58,8 @@ impl Default for TerminalConfig {
|
||||
Self {
|
||||
enabled: false,
|
||||
shell: default_terminal_shell(),
|
||||
args: Vec::new(),
|
||||
current_dir: None,
|
||||
max_sessions: default_terminal_max_sessions(),
|
||||
}
|
||||
}
|
||||
@@ -249,6 +255,8 @@ mod tests {
|
||||
terminal: TerminalConfig {
|
||||
enabled: true,
|
||||
shell: "/bin/sh".into(),
|
||||
args: vec!["-l".into()],
|
||||
current_dir: Some("/tmp".into()),
|
||||
max_sessions: 2,
|
||||
},
|
||||
};
|
||||
@@ -284,4 +292,24 @@ agent_token = "secret"
|
||||
);
|
||||
assert_eq!(config.terminal, TerminalConfig::default());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn existing_terminal_config_defaults_optional_command_fields() {
|
||||
let config: AgentConfig = toml::from_str(
|
||||
r#"
|
||||
server_url = "https://example.com"
|
||||
agent_id = "agent-1"
|
||||
agent_token = "secret"
|
||||
|
||||
[terminal]
|
||||
enabled = true
|
||||
shell = "/bin/sh"
|
||||
max_sessions = 2
|
||||
"#,
|
||||
)
|
||||
.expect("existing terminal config should parse");
|
||||
|
||||
assert!(config.terminal.args.is_empty());
|
||||
assert!(config.terminal.current_dir.is_none());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +154,8 @@ mod tests {
|
||||
terminal: crate::config::TerminalConfig {
|
||||
enabled: true,
|
||||
shell: "/bin/ash".into(),
|
||||
args: vec!["-l".into()],
|
||||
current_dir: Some("/root".into()),
|
||||
max_sessions: 2,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -215,6 +215,8 @@ async fn run_terminal(
|
||||
) -> Result<()> {
|
||||
let terminal = match wakey::wakey_linux::terminal::TerminalPty::spawn(
|
||||
Path::new(&config.terminal.shell),
|
||||
&config.terminal.args,
|
||||
config.terminal.current_dir.as_deref(),
|
||||
rows,
|
||||
cols,
|
||||
) {
|
||||
@@ -225,7 +227,13 @@ async fn run_terminal(
|
||||
};
|
||||
let (mut reader, mut writer, mut child) = terminal.into_parts();
|
||||
let process_group = child.id();
|
||||
info!(terminal_id = %terminal_id, shell = %config.terminal.shell.display(), "terminal PTY ready");
|
||||
info!(
|
||||
terminal_id = %terminal_id,
|
||||
program = %config.terminal.shell.display(),
|
||||
args = ?config.terminal.args,
|
||||
current_dir = ?config.terminal.current_dir,
|
||||
"terminal PTY ready"
|
||||
);
|
||||
|
||||
let (relay_input_tx, mut relay_input_rx) = mpsc::channel(RELAY_INPUT_QUEUE);
|
||||
let mut relay_output: Option<mpsc::Sender<Message>> = None;
|
||||
|
||||
Reference in New Issue
Block a user