16cd6a6acSopenharmony_ci/* 26cd6a6acSopenharmony_ci * Author: Mary Garvin <mgarvin@tresys.com> 36cd6a6acSopenharmony_ci * 46cd6a6acSopenharmony_ci * Copyright (C) 2007-2008 Tresys Technology, LLC 56cd6a6acSopenharmony_ci * 66cd6a6acSopenharmony_ci * This library is free software; you can redistribute it and/or 76cd6a6acSopenharmony_ci * modify it under the terms of the GNU Lesser General Public 86cd6a6acSopenharmony_ci * License as published by the Free Software Foundation; either 96cd6a6acSopenharmony_ci * version 2.1 of the License, or (at your option) any later version. 106cd6a6acSopenharmony_ci * 116cd6a6acSopenharmony_ci * This library is distributed in the hope that it will be useful, 126cd6a6acSopenharmony_ci * but WITHOUT ANY WARRANTY; without even the implied warranty of 136cd6a6acSopenharmony_ci * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 146cd6a6acSopenharmony_ci * Lesser General Public License for more details. 156cd6a6acSopenharmony_ci * 166cd6a6acSopenharmony_ci * You should have received a copy of the GNU Lesser General Public 176cd6a6acSopenharmony_ci * License along with this library; if not, write to the Free Software 186cd6a6acSopenharmony_ci * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 196cd6a6acSopenharmony_ci */ 206cd6a6acSopenharmony_ci 216cd6a6acSopenharmony_ci#ifndef __TEST_DOWNGRADE_H__ 226cd6a6acSopenharmony_ci#define __TEST_DOWNGRADE_H__ 236cd6a6acSopenharmony_ci 246cd6a6acSopenharmony_ci#include <CUnit/Basic.h> 256cd6a6acSopenharmony_ci#include <sepol/policydb/policydb.h> 266cd6a6acSopenharmony_ci 276cd6a6acSopenharmony_ci/* 286cd6a6acSopenharmony_ci * Function Name: downgrade_test_init 296cd6a6acSopenharmony_ci * 306cd6a6acSopenharmony_ci * Input: None 316cd6a6acSopenharmony_ci * 326cd6a6acSopenharmony_ci * Output: None 336cd6a6acSopenharmony_ci * 346cd6a6acSopenharmony_ci * Description: Initialize the policydb (policy data base structure) 356cd6a6acSopenharmony_ci */ 366cd6a6acSopenharmony_ciint downgrade_test_init(void); 376cd6a6acSopenharmony_ci 386cd6a6acSopenharmony_ci/* 396cd6a6acSopenharmony_ci * Function Name: downgrade_test_cleanup 406cd6a6acSopenharmony_ci * 416cd6a6acSopenharmony_ci * Input: None 426cd6a6acSopenharmony_ci * 436cd6a6acSopenharmony_ci * Output: None 446cd6a6acSopenharmony_ci * 456cd6a6acSopenharmony_ci * Description: Destroys policydb structure 466cd6a6acSopenharmony_ci */ 476cd6a6acSopenharmony_ciint downgrade_test_cleanup(void); 486cd6a6acSopenharmony_ci 496cd6a6acSopenharmony_ci/* 506cd6a6acSopenharmony_ci * Function Name: downgrade_add_tests 516cd6a6acSopenharmony_ci * 526cd6a6acSopenharmony_ci * Input: CU_pSuite 536cd6a6acSopenharmony_ci * 546cd6a6acSopenharmony_ci * Output: Returns 0 upon success. Upon failure, a CUnit testing error 556cd6a6acSopenharmony_ci * value is returned 566cd6a6acSopenharmony_ci * 576cd6a6acSopenharmony_ci * Description: Add the given downgrade tests to the downgrade suite. 586cd6a6acSopenharmony_ci */ 596cd6a6acSopenharmony_ciint downgrade_add_tests(CU_pSuite suite); 606cd6a6acSopenharmony_ci 616cd6a6acSopenharmony_ci/* 626cd6a6acSopenharmony_ci * Function Name: test_downgrade_possible 636cd6a6acSopenharmony_ci * 646cd6a6acSopenharmony_ci * Input: None 656cd6a6acSopenharmony_ci * 666cd6a6acSopenharmony_ci * Output: None 676cd6a6acSopenharmony_ci * 686cd6a6acSopenharmony_ci * Description: Tests the backward compatibility of MLS and Non-MLS binary 696cd6a6acSopenharmony_ci * policy versions. 706cd6a6acSopenharmony_ci */ 716cd6a6acSopenharmony_civoid test_downgrade(void); 726cd6a6acSopenharmony_ci 736cd6a6acSopenharmony_ci/* 746cd6a6acSopenharmony_ci * Function Name: do_downgrade_test 756cd6a6acSopenharmony_ci * 766cd6a6acSopenharmony_ci * Input: int that represents a 0 for Non-MLS policy and a 776cd6a6acSopenharmony_ci * 1 for MLS policy downgrade testing 786cd6a6acSopenharmony_ci * 796cd6a6acSopenharmony_ci * Output: (int) 0 on success, negative number upon failure 806cd6a6acSopenharmony_ci * 816cd6a6acSopenharmony_ci * Description: This function handles the downgrade testing. A binary policy 826cd6a6acSopenharmony_ci * is read into the policydb structure, the policy version is 836cd6a6acSopenharmony_ci * decreased by a specific amount, written back out and then read 846cd6a6acSopenharmony_ci * back in again. The process is iterative until the minimum 856cd6a6acSopenharmony_ci * policy version is reached. 866cd6a6acSopenharmony_ci */ 876cd6a6acSopenharmony_ciint do_downgrade_test(int mls); 886cd6a6acSopenharmony_ci 896cd6a6acSopenharmony_ci/* 906cd6a6acSopenharmony_ci * Function Name: read_binary_policy 916cd6a6acSopenharmony_ci * 926cd6a6acSopenharmony_ci * Input: char * which is the path to the file containing the binary policy 936cd6a6acSopenharmony_ci * 946cd6a6acSopenharmony_ci * Output: Returns 0 upon success. Upon failure, -1 is returned. 956cd6a6acSopenharmony_ci * Possible failures are, filename with given path does not exist, 966cd6a6acSopenharmony_ci * a failure to open the file, or a failure from prolicydb_read 976cd6a6acSopenharmony_ci * function call. 986cd6a6acSopenharmony_ci * 996cd6a6acSopenharmony_ci * Description: Get a filename, open file and read in the binary policy 1006cd6a6acSopenharmony_ci * into the policydb structure. 1016cd6a6acSopenharmony_ci */ 1026cd6a6acSopenharmony_ciint read_binary_policy(const char *path, policydb_t *); 1036cd6a6acSopenharmony_ci 1046cd6a6acSopenharmony_ci/* 1056cd6a6acSopenharmony_ci * Function Name: write_binary_policy 1066cd6a6acSopenharmony_ci * 1076cd6a6acSopenharmony_ci * Input: char * which is the path to the file containing the binary policy 1086cd6a6acSopenharmony_ci * 1096cd6a6acSopenharmony_ci * Output: Returns 0 upon success. Upon failure, -1 is returned. 1106cd6a6acSopenharmony_ci * Possible failures are, filename with given path does not exist, 1116cd6a6acSopenharmony_ci * a failure to open the file, or a failure from prolicydb_read 1126cd6a6acSopenharmony_ci * function call. 1136cd6a6acSopenharmony_ci * 1146cd6a6acSopenharmony_ci * Description: Get a filename, open file and read in the binary policy 1156cd6a6acSopenharmony_ci * into the policydb structure. 1166cd6a6acSopenharmony_ci */ 1176cd6a6acSopenharmony_ciint write_binary_policy(const char *path, policydb_t *); 1186cd6a6acSopenharmony_ci 1196cd6a6acSopenharmony_ci#endif 120