1 #ifndef _SELINUX_ANDROID_H_ 2 #define _SELINUX_ANDROID_H_ 3 4 #include <stdbool.h> 5 #include <sys/types.h> 6 #include <unistd.h> 7 8 #include <selinux/label.h> 9 10 #ifdef __cplusplus 11 extern "C" { 12 #endif 13 14 extern struct selabel_handle* selinux_android_file_context_handle(void); 15 16 extern struct selabel_handle* selinux_android_service_context_handle(void); 17 18 extern struct selabel_handle* selinux_android_hw_service_context_handle(void); 19 20 extern struct selabel_handle* selinux_android_vendor_service_context_handle(void); 21 22 extern struct selabel_handle* selinux_android_keystore2_key_context_handle(void); 23 24 extern void selinux_android_set_sehandle(const struct selabel_handle *hndl); 25 26 extern int selinux_android_load_policy(void); 27 28 extern int selinux_android_load_policy_from_fd(int fd, const char *description); 29 30 extern int selinux_android_setcon(const char *con); 31 32 extern int selinux_android_setcontext(uid_t uid, 33 bool isSystemServer, 34 const char *seinfo, 35 const char *name); 36 37 extern int selinux_android_context_with_level(const char * context, 38 char ** newContext, 39 uid_t userid, 40 uid_t appid); 41 42 extern int selinux_log_callback(int type, const char *fmt, ...) 43 __attribute__ ((format(printf, 2, 3))); 44 45 // API to support legacy usecase where full-treble legacy VNDK vendor needs to use this callback. 46 extern int selinux_vendor_log_callback(int type, const char *fmt, ...) 47 __attribute__ ((format(printf, 2, 3))); 48 49 #define SELINUX_ANDROID_RESTORECON_NOCHANGE 1 50 #define SELINUX_ANDROID_RESTORECON_VERBOSE 2 51 #define SELINUX_ANDROID_RESTORECON_RECURSE 4 52 #define SELINUX_ANDROID_RESTORECON_FORCE 8 53 #define SELINUX_ANDROID_RESTORECON_DATADATA 16 54 #define SELINUX_ANDROID_RESTORECON_SKIPCE 32 55 #define SELINUX_ANDROID_RESTORECON_CROSS_FILESYSTEMS 64 56 #define SELINUX_ANDROID_RESTORECON_SKIP_SEHASH 128 57 extern int selinux_android_restorecon(const char *file, unsigned int flags); 58 59 extern int selinux_android_restorecon_pkgdir(const char *pkgdir, 60 const char *seinfo, 61 uid_t uid, 62 unsigned int flags); 63 64 extern void selinux_android_seapp_context_init(void); 65 66 extern int selinux_android_seapp_context_reload(void); 67 68 #ifdef __cplusplus 69 } 70 #endif 71 #endif 72