diff --git a/systemdhook.c b/systemdhook.c index 2f654ab..92d9ecc 100644 --- a/systemdhook.c +++ b/systemdhook.c @@ -304,7 +304,19 @@ int main(int argc, char *argv[]) } char *mount_label = YAJL_GET_STRING(v_mount); - fprintf(stdout, "Mount Label parsed as: %s", mount_label); + const char *cmd_path[] = { "Path", (const char *)0 }; + yajl_val v_cmd = yajl_tree_get(config_node, cmd_path, yajl_t_string); + if (!v_cmd) { + fprintf(stderr, "Path not found in config\n"); + goto out; + } + char *cmd = YAJL_GET_STRING(v_cmd); + + char *cmd_file_name = basename(cmd); + if (strcmp("init", cmd_file_name) && strcmp("systemd", cmd_file_name)) { + fprintf(stdout, "Skipping as container command is %s, not /sbin/init\n", cmd); + goto success; + } if (!strncmp("prestart", argv[1], sizeof("prestart"))) { if (prestart(rootfs, id, target_pid, mount_label) != 0) { @@ -319,6 +331,7 @@ int main(int argc, char *argv[]) goto out; } +success: ret = 0; out: yajl_tree_free(node);