Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion systemdhook.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -319,6 +331,7 @@ int main(int argc, char *argv[])
goto out;
}

success:
ret = 0;
out:
yajl_tree_free(node);
Expand Down