Skip to content

Commit 744ef78

Browse files
committed
fix: use json container config file
Signed-off-by: Roberto Scolaro <[email protected]>
1 parent 539ad9e commit 744ef78

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

cmake/modules/container_plugin.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ if(UNIX AND NOT APPLE)
4444

4545
install(
4646
FILES "${CONTAINER_LIBRARY}"
47-
DESTINATION share/plugins
47+
DESTINATION local/share/sysdig/plugins
4848
COMPONENT "${SYSDIG_COMPONENT_NAME}"
4949
)
5050
endif()

userspace/sysdig/csysdig.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ limitations under the License.
2121

2222
#include <stdio.h>
2323
#include <iostream>
24+
#include <fstream>
25+
#include <sstream>
2426
#include <filesystem>
2527
#include <time.h>
2628
#include <signal.h>
@@ -46,8 +48,6 @@ limitations under the License.
4648
#include "utils/sinsp_opener.h"
4749
#include "utils/supported_fields.h"
4850

49-
#include <yaml-cpp/yaml.h>
50-
5151
#ifdef _WIN32
5252
#include "win32/getopt.h"
5353
#include <io.h>
@@ -420,13 +420,13 @@ sysdig_init_res csysdig_init(int argc, char **argv)
420420

421421
// Load container plugin
422422
std::string container_config = R"({"hooks":["create","start"],"engines":{"docker":{"enabled":true,"sockets":["/var/run/docker.sock"]},"podman":{"enabled":true,"sockets":["/run/podman/podman.sock","/run/user/1000/podman/podman.sock"]},"containerd":{"enabled":false,"sockets":["/run/containerd/containerd.sock"]},"cri":{"enabled":true,"sockets":["/run/crio/crio.sock"]},"lxc":{"enabled":false},"libvirt_lxc":{"enabled":false},"bpm":{"enabled":false}}})";
423-
auto container_config_file = "/etc/sysdig/container.yaml";
423+
auto container_config_file = "/etc/sysdig/container.json";
424424
if (std::filesystem::exists(container_config_file))
425425
{
426-
YAML::Node node = YAML::LoadFile(container_config_file);
427-
YAML::Emitter emitter;
428-
emitter << YAML::DoubleQuoted << YAML::Flow << YAML::BeginSeq << node;
429-
container_config = emitter.c_str() + 1;
426+
std::ifstream file(container_config_file);
427+
std::stringstream buffer;
428+
buffer << file.rdbuf();
429+
container_config = buffer.str();
430430
}
431431

432432
plugins.load_plugin(inspector, "container");

userspace/sysdig/sysdig.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ limitations under the License.
2121

2222
#include <stdio.h>
2323
#include <iostream>
24+
#include <fstream>
25+
#include <sstream>
2426
#include <time.h>
2527
#include <signal.h>
2628
#include <fcntl.h>
@@ -54,8 +56,6 @@ limitations under the License.
5456
#include "utils/supported_events.h"
5557
#include "utils/supported_fields.h"
5658

57-
#include <yaml-cpp/yaml.h>
58-
5959
#ifdef _WIN32
6060
#include "win32/getopt.h"
6161
#include <io.h>
@@ -1097,14 +1097,14 @@ sysdig_init_res sysdig_init(int argc, char **argv)
10971097
plugins.read_plugins_from_dirs(inspector.get());
10981098

10991099
// Load container plugin
1100-
std::string container_config = R"({"hooks":["create","start"],"engines":{"docker":{"enabled":true,"sockets":["/var/run/docker.sock"]},"podman":{"enabled":true,"sockets":["/run/podman/podman.sock","/run/user/1000/podman/podman.sock"]},"containerd":{"enabled":false,"sockets":["/run/containerd/containerd.sock"]},"cri":{"enabled":true,"sockets":["/run/crio/crio.sock"]},"lxc":{"enabled":false},"libvirt_lxc":{"enabled":false},"bpm":{"enabled":false}}})";
1101-
auto container_config_file = "/etc/sysdig/container.yaml";
1100+
std::string container_config = R"({"hooks":["create","start"],"engines":{"docker":{"enabled":true,"sockets":["/var/run/docker.sock"]},"podman":{"enabled":true,"sockets":["/run/podman/podman.sock","/run/user/1000/podman/podman.sock"]},"containerd":{"enabled":false,"sockets":["/run/containerd/containerd.sock"]},"cri":{"enabled":true,"sockets":["/run/crio/crio.sock", "/run/containerd/containerd.sock"]},"lxc":{"enabled":false},"libvirt_lxc":{"enabled":false},"bpm":{"enabled":false}}})";
1101+
auto container_config_file = "/etc/sysdig/container.json";
11021102
if (std::filesystem::exists(container_config_file))
11031103
{
1104-
YAML::Node node = YAML::LoadFile(container_config_file);
1105-
YAML::Emitter emitter;
1106-
emitter << YAML::DoubleQuoted << YAML::Flow << YAML::BeginSeq << node;
1107-
container_config = emitter.c_str() + 1;
1104+
std::ifstream file(container_config_file);
1105+
std::stringstream buffer;
1106+
buffer << file.rdbuf();
1107+
container_config = buffer.str();
11081108
}
11091109

11101110
plugins.load_plugin(inspector.get(), "container");

0 commit comments

Comments
 (0)