-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: agent_name added; version upgrade to 0.2.3
- Loading branch information
1 parent
04b8851
commit 75299d2
Showing
17 changed files
with
225 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod get_token; | ||
pub mod get_user_keys; | ||
pub mod save_to_file; | ||
pub mod save_to_file; | ||
pub mod set_name; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
use crate::shared::path::{default_path_agent_control, default_path_to_ossec_conf}; | ||
use crate::shared::sed_command::sed_command; | ||
use anyhow::Result; | ||
use tokio::process::Command; | ||
|
||
/** | ||
Edit the ossef.conf file and add agent_name under client tag. | ||
Then restart the agent to apply the changes. | ||
*/ | ||
pub async fn set_name(name: &str) -> Result<()> { | ||
let machine_id = mid::get(name)?; | ||
let agent_name = format!("{}-{}", name, machine_id); | ||
|
||
let ossec_conf = default_path_to_ossec_conf(); | ||
|
||
let update_cmd = format!(r"s|<agent_name>.*</agent_name>|<agent_name>{}</agent_name>|g", agent_name); | ||
sed_command(&update_cmd, &ossec_conf).await?; | ||
|
||
let control_bin = default_path_agent_control(); | ||
let status = Command::new(control_bin) | ||
.arg("restart") | ||
.status().await?; | ||
|
||
if !status.success() { | ||
error!("Failed to restart agent"); | ||
return Ok(()); | ||
} | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.