ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[linux-2.6.git] / security / selinux / ss / mls.h
1 /*
2  * Multi-level security (MLS) policy operations.
3  *
4  * Author : Stephen Smalley, <sds@epoch.ncsc.mil>
5  */
6 #ifndef _SS_MLS_H_
7 #define _SS_MLS_H_
8
9 #include "context.h"
10 #include "policydb.h"
11
12 #ifdef CONFIG_SECURITY_SELINUX_MLS
13
14 void mls_compute_av(struct context *scontext,
15                     struct context *tcontext,
16                     struct class_datum *tclass,
17                     u32 *allowed);
18
19 int mls_compute_context_len(struct context *context);
20 int mls_sid_to_context(struct context *context, char **scontext);
21 int mls_context_isvalid(struct policydb *p, struct context *c);
22
23 int mls_context_to_sid(char oldc,
24                        char **scontext,
25                        struct context *context);
26
27 int mls_convert_context(struct policydb *oldp,
28                         struct policydb *newp,
29                         struct context *context);
30
31 int mls_compute_sid(struct context *scontext,
32                     struct context *tcontext,
33                     u16 tclass,
34                     u32 specified,
35                     struct context *newcontext);
36
37 int sens_index(void *key, void *datum, void *datap);
38 int cat_index(void *key, void *datum, void *datap);
39 int sens_destroy(void *key, void *datum, void *p);
40 int cat_destroy(void *key, void *datum, void *p);
41 int sens_read(struct policydb *p, struct hashtab *h, void *fp);
42 int cat_read(struct policydb *p, struct hashtab *h, void *fp);
43
44 #define mls_for_user_ranges(user, usercon) { \
45 struct mls_range_list *__ranges; \
46 for (__ranges = user->ranges; __ranges; __ranges = __ranges->next) { \
47 usercon.range = __ranges->range;
48
49 #define mls_end_user_ranges } }
50
51 #define mls_symtab_names  "levels", "categories",
52 #define mls_symtab_sizes  16, 16,
53 #define mls_index_f sens_index, cat_index,
54 #define mls_destroy_f sens_destroy, cat_destroy,
55 #define mls_read_f sens_read, cat_read,
56 #define mls_write_f sens_write, cat_write,
57 #define mls_policydb_index_others(p) printk(", %d levels", p->nlevels);
58
59 #define mls_set_config(config) config |= POLICYDB_CONFIG_MLS
60
61 void mls_user_destroy(struct user_datum *usrdatum);
62 int mls_read_range(struct context *c, void *fp);
63 int mls_read_perm(struct perm_datum *perdatum, void *fp);
64 int mls_read_class(struct class_datum *cladatum,  void *fp);
65 int mls_read_user(struct user_datum *usrdatum, void *fp);
66 int mls_read_nlevels(struct policydb *p, void *fp);
67 int mls_read_trusted(struct policydb *p, void *fp);
68
69 #else
70
71 #define mls_compute_av(scontext, tcontext, tclass_datum, allowed)
72 #define mls_compute_context_len(context) 0
73 #define mls_sid_to_context(context, scontextpp)
74 #define mls_context_isvalid(p, c) 1
75 #define mls_context_to_sid(oldc, context_str, context) 0
76 #define mls_convert_context(oldp, newp, c) 0
77 #define mls_compute_sid(scontext, tcontext, tclass, specified, newcontextp) 0
78 #define mls_for_user_ranges(user, usercon)
79 #define mls_end_user_ranges
80 #define mls_symtab_names
81 #define mls_symtab_sizes
82 #define mls_index_f
83 #define mls_destroy_f
84 #define mls_read_f
85 #define mls_write_f
86 #define mls_policydb_index_others(p)
87 #define mls_set_config(config)
88 #define mls_user_destroy(usrdatum)
89 #define mls_read_range(c, fp) 0
90 #define mls_read_perm(p, fp) 0
91 #define mls_read_class(c, fp) 0
92 #define mls_read_user(u, fp) 0
93 #define mls_read_nlevels(p, fp) 0
94 #define mls_read_trusted(p, fp) 0
95
96 #endif
97
98 #endif  /* _SS_MLS_H */
99