File: test-downgrade.h

package info (click to toggle)
android-platform-external-libselinux 10.0.0%2Br36-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 34,176 kB
  • sloc: ansic: 147,112; python: 25,790; makefile: 1,930; yacc: 1,389; sh: 1,206; lex: 452; xml: 180
file content (119 lines) | stat: -rw-r--r-- 3,440 bytes parent folder | download | duplicates (10)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
 * Author: Mary Garvin <mgarvin@tresys.com>
 *
 * Copyright (C) 2007-2008 Tresys Technology, LLC
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License as published by the Free Software Foundation; either
 *  version 2.1 of the License, or (at your option) any later version.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

#ifndef __TEST_DOWNGRADE_H__
#define __TEST_DOWNGRADE_H__

#include <CUnit/Basic.h>
#include <sepol/policydb/policydb.h>

/*
 * Function Name:  downgrade_test_init
 * 
 * Input: None
 * 
 * Output: None
 * 
 * Description: Initialize the policydb (policy data base structure)
 */
int downgrade_test_init(void);

/*
 * Function Name:  downgrade_test_cleanup
 * 
 * Input: None
 * 
 * Output: None
 * 
 * Description: Destroys policydb structure
 */
int downgrade_test_cleanup(void);

/*
 * Function Name: downgrade_add_tests
 * 
 * Input: CU_pSuite
 * 
 * Output: Returns 0 upon success.  Upon failure, a CUnit testing error
 *	   value is returned
 * 
 * Description:  Add the given downgrade tests to the downgrade suite.
 */
int downgrade_add_tests(CU_pSuite suite);

/*
 * Function Name: test_downgrade_possible
 * 
 * Input: None
 * 
 * Output: None
 * 
 * Description: Tests the backward compatability of MLS and Non-MLS binary
 *		policy versions. 
 */
void test_downgrade(void);

/*
 * Function Name:  do_downgrade_test
 * 
 * Input: int that represents a 0 for Non-MLS policy and a 
 * 		 1 for MLS policy downgrade testing
 * 
 * Output: (int) 0 on success, negative number upon failure
 * 
 * Description: This function handles the downgrade testing.  A binary policy
 *		is read into the policydb structure, the policy version is
 *		decreased by a specific amount, written back out and then read
 *		back in again. The process is iterative until the minimum
 *		policy version is reached. 
 */
int do_downgrade_test(int mls);

/*
 * Function Name: read_binary_policy
 * 
 * Input: char * which is the path to the file containing the binary policy
 * 
 * Output: Returns 0 upon success.  Upon failure, -1 is returned.
 *	   Possible failures are, filename with given path does not exist,
 *	   a failure to open the file, or a failure from prolicydb_read
 *	   function call.
 * 
 * Description: Get a filename, open file and read in the binary policy
 *		into the policydb structure.
 */
int read_binary_policy(const char *path, policydb_t *);

/*
 * Function Name: write_binary_policy
 * 
 * Input: char * which is the path to the file containing the binary policy
 * 
 * Output: Returns 0 upon success.  Upon failure, -1 is returned.
 *	   Possible failures are, filename with given path does not exist,
 *	   a failure to open the file, or a failure from prolicydb_read
 *	   function call.
 * 
 * Description: Get a filename, open file and read in the binary policy
 *		into the policydb structure.
 */
int write_binary_policy(const char *path, policydb_t *);

#endif