]> git.pld-linux.org Git - packages/checkpolicy.git/blame - checkpolicy-typealias.patch
- really no need to use C99 in this place ;)
[packages/checkpolicy.git] / checkpolicy-typealias.patch
CommitLineData
5aeacf9b
AM
1Index: checkpolicy/policy_parse.y
2===================================================================
3RCS file: /nfshome/pal/CVS/selinux-usr/checkpolicy/policy_parse.y,v
4retrieving revision 1.11
5diff -u -r1.11 policy_parse.y
6--- checkpolicy/policy_parse.y 15 Jan 2004 14:23:02 -0000 1.11
7+++ checkpolicy/policy_parse.y 15 Jan 2004 17:48:45 -0000
8@@ -42,6 +42,7 @@
9 static int define_common_base(void);
10 static int define_av_base(void);
11 static int define_attrib(void);
12+static int define_typealias(void);
13 static int define_type(int alias);
14 static int define_compute_type(int which);
15 static int define_te_avtab(int which);
16@@ -82,6 +83,7 @@
17 %token SID
18 %token ROLE
19 %token ROLES
20+%token TYPEALIAS
21 %token TYPE
22 %token TYPES
23 %token ALIAS
24@@ -240,6 +242,7 @@
25 ;
26 te_decl : attribute_def
27 | type_def
28+ | typealias_def
29 | transition_def
30 | te_avtab_def
31 ;
32@@ -251,6 +254,9 @@
33 | TYPE identifier opt_attr_list ';'
34 {if (define_type(0)) return -1;}
35 ;
36+typealias_def : TYPEALIAS identifier alias_def
37+ {if (define_typealias()) return -1;}
38+ ;
39 opt_attr_list : ',' id_comma_list
40 |
41 ;
42@@ -1479,6 +1485,61 @@
43 return 0;
44 }
45
46+static int define_typealias(void)
47+{
48+ char *id;
763efa69 49+ type_datum_t *t, *aliasdatum;
5aeacf9b
AM
50+ int ret;
51+
52+
53+ if (pass == 2) {
54+ while ((id = queue_remove(id_queue)))
55+ free(id);
56+ return 0;
57+ }
58+
59+ id = (char *) queue_remove(id_queue);
60+ if (!id) {
61+ yyerror("no type name for typealias definition?");
62+ return -1;
63+ }
64+
65+ t = hashtab_search(policydbp->p_types.table, id);
66+ if (!t || t->isattr) {
67+ sprintf(errormsg, "unknown type %s", id);
68+ yyerror(errormsg);
69+ free(id);
70+ return -1;
71+ }
72+
73+ while ((id = queue_remove(id_queue))) {
74+ aliasdatum = (type_datum_t *) malloc(sizeof(type_datum_t));
75+ if (!aliasdatum) {
76+ yyerror("out of memory");
77+ return -1;
78+ }
79+ memset(aliasdatum, 0, sizeof(type_datum_t));
80+ aliasdatum->value = t->value;
81+
82+ ret = hashtab_insert(policydbp->p_types.table,
83+ (hashtab_key_t) id, (hashtab_datum_t) aliasdatum);
84+
85+ if (ret == HASHTAB_PRESENT) {
86+ sprintf(errormsg, "name conflict for type alias %s", id);
87+ yyerror(errormsg);
88+ free(aliasdatum);
89+ free(id);
90+ return -1;
91+ }
92+ if (ret == HASHTAB_OVERFLOW) {
93+ yyerror("hash table overflow");
94+ free(aliasdatum);
95+ free(id);
96+ return -1;
97+ }
98+ }
99+ return 0;
100+}
101
102 static int define_type(int alias)
103 {
104Index: checkpolicy/policy_scan.l
105===================================================================
106RCS file: /nfshome/pal/CVS/selinux-usr/checkpolicy/policy_scan.l,v
107retrieving revision 1.3
108diff -u -r1.3 policy_scan.l
109--- checkpolicy/policy_scan.l 17 Dec 2003 16:52:20 -0000 1.3
110+++ checkpolicy/policy_scan.l 15 Jan 2004 17:33:23 -0000
111@@ -46,6 +46,8 @@
112 roles { return(ROLES); }
113 TYPES |
114 types { return(TYPES); }
115+TYPEALIAS |
116+typealias { return(TYPEALIAS); }
117 TYPE |
118 type { return(TYPE); }
119 ALIAS |
This page took 0.084374 seconds and 4 git commands to generate.