mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-25 06:52:13 +00:00
forwarder: Make explicit root check
Rather than generating a potentially misleading error message if the socket bind fails, perform an explicit check for `root` for Hybrid VSOCK. Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
parent
e377578e08
commit
b67fa9e450
@ -85,11 +85,16 @@ fn start_hybrid_vsock(
|
||||
socket_path: &str,
|
||||
dump_only: bool,
|
||||
) -> Result<()> {
|
||||
let effective = nix::unistd::Uid::effective();
|
||||
|
||||
if !effective.is_root() {
|
||||
return Err(anyhow!("You need to be root"));
|
||||
}
|
||||
|
||||
// Remove the socket if it already exists
|
||||
let _ = std::fs::remove_file(socket_path);
|
||||
|
||||
let listener =
|
||||
UnixListener::bind(socket_path).map_err(|e| anyhow!("You need to be root: {:?}", e))?;
|
||||
let listener = UnixListener::bind(socket_path)?;
|
||||
|
||||
debug!(logger, "Waiting for connections";
|
||||
"vsock-type" => "hybrid",
|
||||
|
Loading…
Reference in New Issue
Block a user