Lines Matching +full:is +full:- +full:binary +full:- +full:path
4 * Copyright (C) 2007-2008 Tresys Technology, LLC
6 * This library is free software; you can redistribute it and/or
11 * This library is distributed in the hope that it will be useful,
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #include "test-downgrade.h"
34 #define POLICY_BIN_HI "policies/test-downgrade/policy.hi"
35 #define POLICY_BIN_LO "policies/test-downgrade/policy.lo"
53 return -1; in downgrade_test_init()
100 * Tests the backward compatibility of MLS and Non-MLS binary policy versions.
106 "\nError during downgrade testing of Non-MLS policy\n"); in test_downgrade()
117 * Input: 0 for Non-MLS policy and 1 for MLS policy downgrade testing
122 * A binary policy is read into the policydb structure, the
123 * policy version is decreased by a specific amount, written
124 * back out and then read back in again. The process is
125 * repeated until the minimum policy version is reached.
132 /* Reset policydb for re-use */ in do_downgrade_test()
138 fprintf(stderr, "error reading %spolicy binary\n", mls ? "mls " : ""); in do_downgrade_test()
139 CU_FAIL("Unable to read the binary policy"); in do_downgrade_test()
140 return -1; in do_downgrade_test()
146 for (hi = policydb.policyvers; hi >= POLICYDB_VERSION_MIN; hi--) { in do_downgrade_test()
151 for (lo = hi - 1; lo >= POLICYDB_VERSION_MIN; lo--) { in do_downgrade_test()
156 /* Write out modified binary policy */ in do_downgrade_test()
159 * Error from MLS to pre-MLS is expected due in do_downgrade_test()
160 * to MLS re-implementation in version 19. in do_downgrade_test()
165 …fprintf(stderr, "error writing %spolicy binary, version %d (downgraded from %d)\n", mls ? "mls " :… in do_downgrade_test()
166 CU_FAIL("Failed to write downgraded binary policy"); in do_downgrade_test()
167 return -1; in do_downgrade_test()
174 return -1; in do_downgrade_test()
177 …fprintf(stderr, "error reading %spolicy binary, version %d (downgraded from %d)\n", mls ? "mls " :… in do_downgrade_test()
178 CU_FAIL("Unable to read downgraded binary policy"); in do_downgrade_test()
179 return -1; in do_downgrade_test()
193 * Input: char * which is the path to the file containing the binary policy
195 * Output: Returns 0 upon success. Upon failure, -1 is returned.
196 * Possible failures are, filename with given path does not exist,
200 * Description: Get a filename, open file and read binary policy into policydb
203 int read_binary_policy(const char *path, policydb_t *p) in read_binary_policy() argument
209 /* Open the binary policy file */ in read_binary_policy()
210 if ((in_fp = fopen(path, "rb")) == NULL) { in read_binary_policy()
211 fprintf(stderr, "Unable to open %s: %s\n", path, in read_binary_policy()
213 return -1; in read_binary_policy()
216 /* Read in the binary policy. */ in read_binary_policy()
229 * Input: char * which is the path to the file containing the binary policy
231 * Output: Returns 0 upon success. Upon failure, -1 is returned.
232 * Possible failures are, filename with given path does not exist,
236 * Description: open file and write the binary policy from policydb structure.
238 int write_binary_policy(const char *path, policydb_t *p) in write_binary_policy() argument
249 return -1; in write_binary_policy()
253 /* Open the binary policy file for writing */ in write_binary_policy()
254 if ((out_fp = fopen(path, "w" )) == NULL) { in write_binary_policy()
255 fprintf(stderr, "Unable to open %s: %s\n", path, in write_binary_policy()
258 return -1; in write_binary_policy()
261 /* Write the binary policy */ in write_binary_policy()