Skip to content

Commit

Permalink
Merge commit from fork
Browse files Browse the repository at this point in the history
Fix Credentials leaking in the debug log - 0.8.x
  • Loading branch information
dmulder authored Jan 23, 2025
2 parents 553c632 + 0cf093a commit a5e14f8
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.8.2"
version = "0.8.3"
authors = [
"David Mulder <[email protected]>"
]
Expand Down
14 changes: 13 additions & 1 deletion src/common/src/unix_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,14 +140,26 @@ pub struct HomeDirectoryInfo {
pub aliases: Vec<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Clone)]
pub enum TaskRequest {
HomeDirectory(HomeDirectoryInfo),
LocalGroups(String),
LogonScript(String, String),
KerberosCCache(uid_t, Vec<u8>, Vec<u8>),
}

impl TaskRequest {
/// Get a safe display version of the request, without credentials.
pub fn as_safe_string(&self) -> String {
match self {
TaskRequest::HomeDirectory(info) => format!("HomeDirectory({:?})", info),
TaskRequest::LocalGroups(groups) => format!("LocalGroups({})", groups),
TaskRequest::LogonScript(account_id, _) => format!("LogonScript({}, ...)", account_id),
TaskRequest::KerberosCCache(uid, _, _) => format!("KerberosCCache({}, ...)", uid),
}
}
}

#[derive(Serialize, Deserialize, Debug)]
pub enum TaskResponse {
Success(i32),
Expand Down
7 changes: 5 additions & 2 deletions src/daemon/src/daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,10 @@ impl Encoder<TaskRequest> for TaskCodec {
type Error = io::Error;

fn encode(&mut self, msg: TaskRequest, dst: &mut BytesMut) -> Result<(), Self::Error> {
debug!("Attempting to send request -> {:?} ...", msg);
debug!(
"Attempting to send request -> {:?} ...",
msg.as_safe_string()
);
let data = serde_json::to_vec(&msg).map_err(|e| {
error!("socket encoding error -> {:?}", e);
io::Error::new(io::ErrorKind::Other, "JSON encode error")
Expand Down Expand Up @@ -170,7 +173,7 @@ async fn handle_task_client(
None => return Ok(()),
};

debug!("Sending Task -> {:?}", v.0);
debug!("Sending Task -> {:?}", v.0.as_safe_string());

// Write the req to the socket.
if let Err(_e) = reqs.send(v.0.clone()).await {
Expand Down
8 changes: 6 additions & 2 deletions src/daemon/src/tasks_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,12 @@ async fn handle_tasks(stream: UnixStream, cfg: &HimmelblauConfig) {
return;
}
}
other => {
error!("Error -> {:?}", other);
Some(Err(e)) => {
error!("Error -> {:?}", e);
return;
}
_ => {
error!("Error -> Unexpected response");
return;
}
}
Expand Down

0 comments on commit a5e14f8

Please sign in to comment.