1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
/*
* Copyright 2019 Tresys Technology, LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <check.h>
#include <string.h>
#include <stdlib.h>
#include "test_utils.h"
struct av_rule_data * make_example_av_rule(void) {
// allow foo_t { bar_t baz_t }:file { read write getattr };
struct av_rule_data *av_rule_data = malloc(sizeof(struct av_rule_data));
av_rule_data->flavor = AV_RULE_ALLOW;
av_rule_data->sources = calloc(1,sizeof(struct string_list));
ck_assert_ptr_nonnull(av_rule_data->sources);
av_rule_data->sources->string = strdup(EXAMPLE_TYPE_1);
ck_assert_ptr_nonnull(av_rule_data->sources->string);
av_rule_data->sources->next = NULL;
av_rule_data->targets = calloc(1,sizeof(struct string_list));
ck_assert_ptr_nonnull(av_rule_data->targets);
av_rule_data->targets->string = strdup(EXAMPLE_TYPE_2);
ck_assert_ptr_nonnull(av_rule_data->targets->string);
av_rule_data->targets->next = calloc(1,sizeof(struct string_list));
ck_assert_ptr_nonnull(av_rule_data->targets->next);
av_rule_data->targets->next->string = strdup(EXAMPLE_TYPE_3);
ck_assert_ptr_nonnull(av_rule_data->targets->next->string);
av_rule_data->targets->next->next = NULL;
av_rule_data->object_classes = calloc(1,sizeof(struct string_list));
ck_assert_ptr_nonnull(av_rule_data->object_classes);
av_rule_data->object_classes->string = strdup("file");
ck_assert_ptr_nonnull(av_rule_data->object_classes->string);
av_rule_data->object_classes->next = NULL;
av_rule_data->perms = calloc(1,sizeof(struct string_list));
ck_assert_ptr_nonnull(av_rule_data->perms);
av_rule_data->perms->string = strdup("read");
ck_assert_ptr_nonnull(av_rule_data->perms->string);
av_rule_data->perms->next = calloc(1,sizeof(struct string_list));
ck_assert_ptr_nonnull(av_rule_data->perms->next);
av_rule_data->perms->next->string = strdup("write");
ck_assert_ptr_nonnull(av_rule_data->perms->next->string);
av_rule_data->perms->next->next = calloc(1,sizeof(struct string_list));
ck_assert_ptr_nonnull(av_rule_data->perms->next->next);
av_rule_data->perms->next->next->string = strdup("getattr");
ck_assert_ptr_nonnull(av_rule_data->perms->next->next->string);
av_rule_data->perms->next->next->next = NULL;
return av_rule_data;
}
|