| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
#ifndef _SELABEL_INTERNAL_H_ |
| 9 |
#define _SELABEL_INTERNAL_H_ |
| 10 |
|
| 11 |
#include <stdlib.h> |
| 12 |
#include <stdarg.h> |
| 13 |
#include <stdio.h> |
| 14 |
#include <selinux/selinux.h> |
| 15 |
#include <selinux/label.h> |
| 16 |
#include "dso.h" |
| 17 |
#include "sha1.h" |
| 18 |
|
| 19 |
#if defined(ANDROID) || defined(__APPLE__) |
| 20 |
|
| 21 |
#define fgets_unlocked(buf, size, fp) fgets(buf, size, fp) |
| 22 |
#endif |
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
int selabel_file_init(struct selabel_handle *rec, |
| 28 |
const struct selinux_opt *opts, |
| 29 |
unsigned nopts) hidden; |
| 30 |
int selabel_media_init(struct selabel_handle *rec, |
| 31 |
const struct selinux_opt *opts, |
| 32 |
unsigned nopts) hidden; |
| 33 |
int selabel_x_init(struct selabel_handle *rec, |
| 34 |
const struct selinux_opt *opts, |
| 35 |
unsigned nopts) hidden; |
| 36 |
int selabel_db_init(struct selabel_handle *rec, |
| 37 |
const struct selinux_opt *opts, |
| 38 |
unsigned nopts) hidden; |
| 39 |
int selabel_property_init(struct selabel_handle *rec, |
| 40 |
const struct selinux_opt *opts, |
| 41 |
unsigned nopts) hidden; |
| 42 |
int selabel_service_init(struct selabel_handle *rec, |
| 43 |
const struct selinux_opt *opts, |
| 44 |
unsigned nopts) hidden; |
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
#define DIGEST_SPECFILE_SIZE SHA1_HASH_SIZE |
| 57 |
#define DIGEST_FILES_MAX 8 |
| 58 |
struct selabel_digest { |
| 59 |
unsigned char *digest; |
| 60 |
unsigned char *hashbuf; |
| 61 |
size_t hashbuf_size; |
| 62 |
size_t specfile_cnt; |
| 63 |
char **specfile_list; |
| 64 |
}; |
| 65 |
|
| 66 |
extern int digest_add_specfile(struct selabel_digest *digest, FILE *fp, |
| 67 |
char *from_addr, |
| 68 |
size_t buf_len, |
| 69 |
const char *path); |
| 70 |
extern void digest_gen_hash(struct selabel_digest *digest); |
| 71 |
|
| 72 |
struct selabel_lookup_rec { |
| 73 |
char * ctx_raw; |
| 74 |
char * ctx_trans; |
| 75 |
int validated; |
| 76 |
unsigned lineno; |
| 77 |
}; |
| 78 |
|
| 79 |
struct selabel_handle { |
| 80 |
|
| 81 |
unsigned int backend; |
| 82 |
int validating; |
| 83 |
|
| 84 |
|
| 85 |
struct selabel_lookup_rec *(*func_lookup) (struct selabel_handle *h, |
| 86 |
const char *key, int type); |
| 87 |
void (*func_close) (struct selabel_handle *h); |
| 88 |
void (*func_stats) (struct selabel_handle *h); |
| 89 |
bool (*func_partial_match) (struct selabel_handle *h, const char *key); |
| 90 |
bool (*func_hash_all_partial_matches) (struct selabel_handle *h, |
| 91 |
const char *key, uint8_t *digest); |
| 92 |
struct selabel_lookup_rec *(*func_lookup_best_match) |
| 93 |
(struct selabel_handle *h, |
| 94 |
const char *key, |
| 95 |
const char **aliases, |
| 96 |
int type); |
| 97 |
enum selabel_cmp_result (*func_cmp)(struct selabel_handle *h1, |
| 98 |
struct selabel_handle *h2); |
| 99 |
|
| 100 |
|
| 101 |
void *data; |
| 102 |
|
| 103 |
|
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
size_t spec_files_len; |
| 108 |
char **spec_files; |
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
struct selabel_digest *digest; |
| 113 |
}; |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
extern int |
| 119 |
selabel_validate(struct selabel_handle *rec, |
| 120 |
struct selabel_lookup_rec *contexts) hidden; |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
extern int myprintf_compat; |
| 126 |
extern void __attribute__ ((format(printf, 1, 2))) |
| 127 |
(*myprintf) (const char *fmt, ...) hidden; |
| 128 |
|
| 129 |
#define COMPAT_LOG(type, fmt...) if (myprintf_compat) \ |
| 130 |
myprintf(fmt); \ |
| 131 |
else \ |
| 132 |
selinux_log(type, fmt); |
| 133 |
|
| 134 |
extern int |
| 135 |
compat_validate(struct selabel_handle *rec, |
| 136 |
struct selabel_lookup_rec *contexts, |
| 137 |
const char *path, unsigned lineno) hidden; |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
extern int read_spec_entries(char *line_buf, const char **errbuf, int num_args, ...); |
| 144 |
|
| 145 |
#endif |