Skip to content

Commit

Permalink
fix(libsinsp): allow reading scap from stdin
Browse files Browse the repository at this point in the history
Signed-off-by: Roberto Scolaro <[email protected]>
  • Loading branch information
therealbobo committed Jan 20, 2025
1 parent cb93f4b commit 696b880
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion userspace/libsinsp/sinsp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -717,8 +717,19 @@ std::string sinsp::generate_gvisor_config(const std::string& socket_path) {
}

int64_t sinsp::get_file_size(const std::string& fname, char* error) {
std::filesystem::path p(fname);
auto s = std::filesystem::status(p);

// scap files can be streamed and the source can be one
// of the following. In that case we return 0 as file size.
if(s.type() == std::filesystem::file_type::character ||
s.type() == std::filesystem::file_type::fifo ||
s.type() == std::filesystem::file_type::socket) {
return 0;
}

std::error_code ec;
auto sz = std::filesystem::file_size(fname, ec);
auto sz = std::filesystem::file_size(p, ec);
if(ec) {
strlcpy(error, ec.message().c_str(), SCAP_LASTERR_SIZE);
return -1;
Expand Down

0 comments on commit 696b880

Please sign in to comment.