blob: 02dbe73623aab5117e933a32b002ddd0b2beeb6a [file] [log] [blame]
Joshua Brindle13cd4c82008-08-19 15:30:36 -04001/*
2 * This file describes the internal interface used by the labeler
3 * for calling the user-supplied memory allocation, validation,
4 * and locking routine.
5 *
6 * Author : Eamon Walsh <ewalsh@epoch.ncsc.mil>
7 */
8#ifndef _SELABEL_INTERNAL_H_
9#define _SELABEL_INTERNAL_H_
10
11#include <stdlib.h>
12#include <stdarg.h>
13#include <selinux/selinux.h>
14#include <selinux/label.h>
15#include "dso.h"
16
17/*
18 * Installed backends
19 */
20int selabel_file_init(struct selabel_handle *rec, struct selinux_opt *opts,
21 unsigned nopts) hidden;
22int selabel_media_init(struct selabel_handle *rec, struct selinux_opt *opts,
23 unsigned nopts) hidden;
24int selabel_x_init(struct selabel_handle *rec, struct selinux_opt *opts,
25 unsigned nopts) hidden;
Eamon Walsh70aeeb92010-03-15 18:38:35 -040026int selabel_db_init(struct selabel_handle *rec,
27 struct selinux_opt *opts, unsigned nopts) hidden;
Joshua Brindle13cd4c82008-08-19 15:30:36 -040028
29/*
30 * Labeling internal structures
31 */
Eamon Walsha00fd942010-12-02 19:21:10 -050032struct selabel_sub {
33 char *src;
34 int slen;
35 char *dst;
36 struct selabel_sub *next;
37};
38
Richard Haines441cf2e2011-04-18 16:41:40 +010039extern struct selabel_sub *selabel_subs_init(const char *path,
40 struct selabel_sub *list);
41
Joshua Brindle13cd4c82008-08-19 15:30:36 -040042struct selabel_lookup_rec {
43 security_context_t ctx_raw;
44 security_context_t ctx_trans;
45 int validated;
46};
47
48struct selabel_handle {
49 /* arguments that were passed to selabel_open */
50 unsigned int backend;
51 int validating;
52
53 /* labeling operations */
54 struct selabel_lookup_rec *(*func_lookup) (struct selabel_handle *h,
55 const char *key, int type);
56 void (*func_close) (struct selabel_handle *h);
57 void (*func_stats) (struct selabel_handle *h);
58
59 /* supports backend-specific state information */
60 void *data;
Eamon Walsha00fd942010-12-02 19:21:10 -050061
62 /* substitution support */
63 struct selabel_sub *subs;
Joshua Brindle13cd4c82008-08-19 15:30:36 -040064};
65
66/*
67 * Validation function
68 */
69extern int
70selabel_validate(struct selabel_handle *rec,
71 struct selabel_lookup_rec *contexts) hidden;
72
73/*
74 * Compatibility support
75 */
76extern int myprintf_compat;
77extern void __attribute__ ((format(printf, 1, 2)))
78(*myprintf) (const char *fmt,...);
79
80#define COMPAT_LOG(type, fmt...) if (myprintf_compat) \
81 myprintf(fmt); \
82 else \
83 selinux_log(type, fmt);
84
85extern int
86compat_validate(struct selabel_handle *rec,
87 struct selabel_lookup_rec *contexts,
88 const char *path, unsigned lineno) hidden;
89
90#endif /* _SELABEL_INTERNAL_H_ */