• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Author: Mary Garvin <mgarvin@tresys.com>
3  *
4  * Copyright (C) 2007-2008 Tresys Technology, LLC
5  *
6  *  This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU Lesser General Public
8  *  License as published by the Free Software Foundation; either
9  *  version 2.1 of the License, or (at your option) any later version.
10  *
11  *  This library is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14  *  Lesser General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Lesser General Public
17  *  License along with this library; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19  */
20 
21 #ifndef __TEST_DOWNGRADE_H__
22 #define __TEST_DOWNGRADE_H__
23 
24 #include <CUnit/Basic.h>
25 #include <sepol/policydb/policydb.h>
26 
27 /*
28  * Function Name:  downgrade_test_init
29  *
30  * Input: None
31  *
32  * Output: None
33  *
34  * Description: Initialize the policydb (policy data base structure)
35  */
36 int downgrade_test_init(void);
37 
38 /*
39  * Function Name:  downgrade_test_cleanup
40  *
41  * Input: None
42  *
43  * Output: None
44  *
45  * Description: Destroys policydb structure
46  */
47 int downgrade_test_cleanup(void);
48 
49 /*
50  * Function Name: downgrade_add_tests
51  *
52  * Input: CU_pSuite
53  *
54  * Output: Returns 0 upon success.  Upon failure, a CUnit testing error
55  *	   value is returned
56  *
57  * Description:  Add the given downgrade tests to the downgrade suite.
58  */
59 int downgrade_add_tests(CU_pSuite suite);
60 
61 /*
62  * Function Name: test_downgrade_possible
63  *
64  * Input: None
65  *
66  * Output: None
67  *
68  * Description: Tests the backward compatibility of MLS and Non-MLS binary
69  *		policy versions.
70  */
71 void test_downgrade(void);
72 
73 /*
74  * Function Name:  do_downgrade_test
75  *
76  * Input: int that represents a 0 for Non-MLS policy and a
77  * 		 1 for MLS policy downgrade testing
78  *
79  * Output: (int) 0 on success, negative number upon failure
80  *
81  * Description: This function handles the downgrade testing.  A binary policy
82  *		is read into the policydb structure, the policy version is
83  *		decreased by a specific amount, written back out and then read
84  *		back in again. The process is iterative until the minimum
85  *		policy version is reached.
86  */
87 int do_downgrade_test(int mls);
88 
89 /*
90  * Function Name: read_binary_policy
91  *
92  * Input: char * which is the path to the file containing the binary policy
93  *
94  * Output: Returns 0 upon success.  Upon failure, -1 is returned.
95  *	   Possible failures are, filename with given path does not exist,
96  *	   a failure to open the file, or a failure from prolicydb_read
97  *	   function call.
98  *
99  * Description: Get a filename, open file and read in the binary policy
100  *		into the policydb structure.
101  */
102 int read_binary_policy(const char *path, policydb_t *);
103 
104 /*
105  * Function Name: write_binary_policy
106  *
107  * Input: char * which is the path to the file containing the binary policy
108  *
109  * Output: Returns 0 upon success.  Upon failure, -1 is returned.
110  *	   Possible failures are, filename with given path does not exist,
111  *	   a failure to open the file, or a failure from prolicydb_read
112  *	   function call.
113  *
114  * Description: Get a filename, open file and read in the binary policy
115  *		into the policydb structure.
116  */
117 int write_binary_policy(const char *path, policydb_t *);
118 
119 #endif
120