2024-05-18 13:20:54 +00:00
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include "v1_node_runtime_handler_features.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
static v1_node_runtime_handler_features_t *v1_node_runtime_handler_features_create_internal(
|
2024-10-12 03:18:38 +00:00
|
|
|
int recursive_read_only_mounts,
|
|
|
|
|
int user_namespaces
|
2024-05-18 13:20:54 +00:00
|
|
|
) {
|
|
|
|
|
v1_node_runtime_handler_features_t *v1_node_runtime_handler_features_local_var = malloc(sizeof(v1_node_runtime_handler_features_t));
|
|
|
|
|
if (!v1_node_runtime_handler_features_local_var) {
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
v1_node_runtime_handler_features_local_var->recursive_read_only_mounts = recursive_read_only_mounts;
|
2024-10-12 03:18:38 +00:00
|
|
|
v1_node_runtime_handler_features_local_var->user_namespaces = user_namespaces;
|
2024-05-18 13:20:54 +00:00
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
v1_node_runtime_handler_features_local_var->_library_owned = 1;
|
2024-05-18 13:20:54 +00:00
|
|
|
return v1_node_runtime_handler_features_local_var;
|
|
|
|
|
}
|
|
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
__attribute__((deprecated)) v1_node_runtime_handler_features_t *v1_node_runtime_handler_features_create(
|
|
|
|
|
int recursive_read_only_mounts,
|
|
|
|
|
int user_namespaces
|
|
|
|
|
) {
|
|
|
|
|
return v1_node_runtime_handler_features_create_internal (
|
|
|
|
|
recursive_read_only_mounts,
|
|
|
|
|
user_namespaces
|
|
|
|
|
);
|
|
|
|
|
}
|
2024-05-18 13:20:54 +00:00
|
|
|
|
|
|
|
|
void v1_node_runtime_handler_features_free(v1_node_runtime_handler_features_t *v1_node_runtime_handler_features) {
|
|
|
|
|
if(NULL == v1_node_runtime_handler_features){
|
|
|
|
|
return ;
|
|
|
|
|
}
|
2025-02-11 19:36:46 +00:00
|
|
|
if(v1_node_runtime_handler_features->_library_owned != 1){
|
|
|
|
|
fprintf(stderr, "WARNING: %s() does NOT free objects allocated by the user\n", "v1_node_runtime_handler_features_free");
|
|
|
|
|
return ;
|
|
|
|
|
}
|
2024-05-18 13:20:54 +00:00
|
|
|
listEntry_t *listEntry;
|
|
|
|
|
free(v1_node_runtime_handler_features);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cJSON *v1_node_runtime_handler_features_convertToJSON(v1_node_runtime_handler_features_t *v1_node_runtime_handler_features) {
|
|
|
|
|
cJSON *item = cJSON_CreateObject();
|
|
|
|
|
|
|
|
|
|
// v1_node_runtime_handler_features->recursive_read_only_mounts
|
|
|
|
|
if(v1_node_runtime_handler_features->recursive_read_only_mounts) {
|
|
|
|
|
if(cJSON_AddBoolToObject(item, "recursiveReadOnlyMounts", v1_node_runtime_handler_features->recursive_read_only_mounts) == NULL) {
|
|
|
|
|
goto fail; //Bool
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-12 03:18:38 +00:00
|
|
|
|
|
|
|
|
// v1_node_runtime_handler_features->user_namespaces
|
|
|
|
|
if(v1_node_runtime_handler_features->user_namespaces) {
|
|
|
|
|
if(cJSON_AddBoolToObject(item, "userNamespaces", v1_node_runtime_handler_features->user_namespaces) == NULL) {
|
|
|
|
|
goto fail; //Bool
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-18 13:20:54 +00:00
|
|
|
return item;
|
|
|
|
|
fail:
|
|
|
|
|
if (item) {
|
|
|
|
|
cJSON_Delete(item);
|
|
|
|
|
}
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
v1_node_runtime_handler_features_t *v1_node_runtime_handler_features_parseFromJSON(cJSON *v1_node_runtime_handler_featuresJSON){
|
|
|
|
|
|
|
|
|
|
v1_node_runtime_handler_features_t *v1_node_runtime_handler_features_local_var = NULL;
|
|
|
|
|
|
|
|
|
|
// v1_node_runtime_handler_features->recursive_read_only_mounts
|
|
|
|
|
cJSON *recursive_read_only_mounts = cJSON_GetObjectItemCaseSensitive(v1_node_runtime_handler_featuresJSON, "recursiveReadOnlyMounts");
|
2025-02-11 19:36:46 +00:00
|
|
|
if (cJSON_IsNull(recursive_read_only_mounts)) {
|
|
|
|
|
recursive_read_only_mounts = NULL;
|
|
|
|
|
}
|
2024-05-18 13:20:54 +00:00
|
|
|
if (recursive_read_only_mounts) {
|
|
|
|
|
if(!cJSON_IsBool(recursive_read_only_mounts))
|
|
|
|
|
{
|
|
|
|
|
goto end; //Bool
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-10-12 03:18:38 +00:00
|
|
|
// v1_node_runtime_handler_features->user_namespaces
|
|
|
|
|
cJSON *user_namespaces = cJSON_GetObjectItemCaseSensitive(v1_node_runtime_handler_featuresJSON, "userNamespaces");
|
2025-02-11 19:36:46 +00:00
|
|
|
if (cJSON_IsNull(user_namespaces)) {
|
|
|
|
|
user_namespaces = NULL;
|
|
|
|
|
}
|
2024-10-12 03:18:38 +00:00
|
|
|
if (user_namespaces) {
|
|
|
|
|
if(!cJSON_IsBool(user_namespaces))
|
|
|
|
|
{
|
|
|
|
|
goto end; //Bool
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-05-18 13:20:54 +00:00
|
|
|
|
2025-02-11 19:36:46 +00:00
|
|
|
v1_node_runtime_handler_features_local_var = v1_node_runtime_handler_features_create_internal (
|
2024-10-12 03:18:38 +00:00
|
|
|
recursive_read_only_mounts ? recursive_read_only_mounts->valueint : 0,
|
|
|
|
|
user_namespaces ? user_namespaces->valueint : 0
|
2024-05-18 13:20:54 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
return v1_node_runtime_handler_features_local_var;
|
|
|
|
|
end:
|
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
|
|
}
|