Skip to content

Commit 256b076

Browse files
author
yummyMax
committed
change socket path
Some containerd test use shim.SocketAddress directly. So for Goshim-compatible socket path Signed-off-by: yummyMax <[email protected]>
1 parent a6b4286 commit 256b076

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

crates/shim/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ path = "examples/windows_log_reader.rs"
3737
containerd-shim-protos = { path = "../shim-protos", version = "0.7.2" }
3838
go-flag = "0.1.0"
3939
lazy_static = "1.4.0"
40+
sha2 = "0.10.2"
4041
libc.workspace = true
4142
log = { workspace = true, features = ["std", "kv_unstable" ] }
4243
nix = { workspace = true, features = [

crates/shim/src/lib.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@
1616

1717
#![cfg_attr(feature = "docs", doc = include_str!("../README.md"))]
1818

19-
use std::{collections::hash_map::DefaultHasher, fs::File, hash::Hasher, path::PathBuf};
19+
use std::{fs::File, path::PathBuf};
2020
#[cfg(unix)]
2121
use std::{
2222
os::unix::{io::RawFd, net::UnixListener},
2323
path::Path,
2424
};
25+
use sha2::{Sha256,Digest};
2526

2627
pub use containerd_shim_protos as protos;
2728
#[cfg(unix)]
@@ -173,17 +174,15 @@ pub fn socket_address(socket_path: &str, namespace: &str, id: &str) -> String {
173174
.join(id)
174175
.display()
175176
.to_string();
176-
177177
let hash = {
178-
let mut hasher = DefaultHasher::new();
179-
hasher.write(path.as_bytes());
180-
hasher.finish()
178+
let mut hasher = Sha256::new();
179+
hasher.update(path);
180+
hasher.finalize()
181181
};
182-
183182
if cfg!(unix) {
184-
format!("unix://{}/{:x}.sock", SOCKET_ROOT, hash)
183+
format!("unix://{}/s/{:x}", SOCKET_ROOT, hash)
185184
} else if cfg!(windows) {
186-
format!(r"\\.\pipe\containerd-shim-{}-pipe", hash)
185+
format!(r"\\.\pipe\containerd-shim-{:x}-pipe", hash)
187186
} else {
188187
panic!("unsupported platform")
189188
}

0 commit comments

Comments
 (0)