|
Chris PeBenito |
473ea7 |
#ifndef _SELINUX_H_
|
|
Chris PeBenito |
473ea7 |
#define _SELINUX_H_
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
#include <sys/types.h>
|
|
Chris PeBenito |
473ea7 |
#include <stdarg.h>
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
#ifdef __cplusplus
|
|
Chris PeBenito |
473ea7 |
extern "C"
|
|
Chris PeBenito |
473ea7 |
{
|
|
Chris PeBenito |
473ea7 |
#endif
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Return 1 if we are running on a SELinux kernel, or 0 if not or -1 if we get an error. */
|
|
Chris PeBenito |
473ea7 |
extern int is_selinux_enabled(void);
|
|
Chris PeBenito |
473ea7 |
/* Return 1 if we are running on a SELinux MLS kernel, or 0 otherwise. */
|
|
Chris PeBenito |
473ea7 |
extern int is_selinux_mls_enabled(void);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
typedef char* security_context_t;
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Free the memory allocated for a context by any of the below get* calls. */
|
|
Chris PeBenito |
473ea7 |
extern void freecon(security_context_t con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Free the memory allocated for a context array by security_compute_user. */
|
|
Chris PeBenito |
473ea7 |
extern void freeconary(security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Wrappers for the /proc/pid/attr API. */
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Get current context, and set *con to refer to it.
|
|
Chris PeBenito |
473ea7 |
Caller must free via freecon. */
|
|
Chris PeBenito |
473ea7 |
extern int getcon(security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
extern int getcon_raw(security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Set the current security context to con.
|
|
Chris PeBenito |
473ea7 |
Note that use of this function requires that the entire application
|
|
Chris PeBenito |
473ea7 |
be trusted to maintain any desired separation between the old and new
|
|
Chris PeBenito |
473ea7 |
security contexts, unlike exec-based transitions performed via setexeccon.
|
|
Chris PeBenito |
473ea7 |
When possible, decompose your application and use setexeccon()+execve()
|
|
Chris PeBenito |
473ea7 |
instead. Note that the application may lose access to its open descriptors
|
|
Chris PeBenito |
473ea7 |
as a result of a setcon() unless policy allows it to use descriptors opened
|
|
Chris PeBenito |
473ea7 |
by the old context. */
|
|
Chris PeBenito |
473ea7 |
extern int setcon(security_context_t con);
|
|
Chris PeBenito |
473ea7 |
extern int setcon_raw(security_context_t con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Get context of process identified by pid, and
|
|
Chris PeBenito |
473ea7 |
set *con to refer to it. Caller must free via freecon. */
|
|
Chris PeBenito |
473ea7 |
extern int getpidcon(pid_t pid, security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
extern int getpidcon_raw(pid_t pid, security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Get previous context (prior to last exec), and set *con to refer to it.
|
|
Chris PeBenito |
473ea7 |
Caller must free via freecon. */
|
|
Chris PeBenito |
473ea7 |
extern int getprevcon(security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
extern int getprevcon_raw(security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Get exec context, and set *con to refer to it.
|
|
Chris PeBenito |
473ea7 |
Sets *con to NULL if no exec context has been set, i.e. using default.
|
|
Chris PeBenito |
473ea7 |
If non-NULL, caller must free via freecon. */
|
|
Chris PeBenito |
473ea7 |
extern int getexeccon(security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
extern int getexeccon_raw(security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Set exec security context for the next execve.
|
|
Chris PeBenito |
473ea7 |
Call with NULL if you want to reset to the default. */
|
|
Chris PeBenito |
473ea7 |
extern int setexeccon(security_context_t con);
|
|
Chris PeBenito |
473ea7 |
extern int setexeccon_raw(security_context_t con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Get fscreate context, and set *con to refer to it.
|
|
Chris PeBenito |
473ea7 |
Sets *con to NULL if no fs create context has been set, i.e. using default.
|
|
Chris PeBenito |
473ea7 |
If non-NULL, caller must free via freecon. */
|
|
Chris PeBenito |
473ea7 |
extern int getfscreatecon(security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
extern int getfscreatecon_raw(security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Set the fscreate security context for subsequent file creations.
|
|
Chris PeBenito |
473ea7 |
Call with NULL if you want to reset to the default. */
|
|
Chris PeBenito |
473ea7 |
extern int setfscreatecon(security_context_t context);
|
|
Chris PeBenito |
473ea7 |
extern int setfscreatecon_raw(security_context_t context);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Wrappers for the xattr API. */
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Get file context, and set *con to refer to it.
|
|
Chris PeBenito |
473ea7 |
Caller must free via freecon. */
|
|
Chris PeBenito |
473ea7 |
extern int getfilecon(const char *path, security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
extern int getfilecon_raw(const char *path, security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
extern int lgetfilecon(const char *path, security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
extern int lgetfilecon_raw(const char *path, security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
extern int fgetfilecon(int fd, security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
extern int fgetfilecon_raw(int fd, security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Set file context */
|
|
Chris PeBenito |
473ea7 |
extern int setfilecon(const char *path, security_context_t con);
|
|
Chris PeBenito |
473ea7 |
extern int setfilecon_raw(const char *path, security_context_t con);
|
|
Chris PeBenito |
473ea7 |
extern int lsetfilecon(const char *path, security_context_t con);
|
|
Chris PeBenito |
473ea7 |
extern int lsetfilecon_raw(const char *path, security_context_t con);
|
|
Chris PeBenito |
473ea7 |
extern int fsetfilecon(int fd, security_context_t con);
|
|
Chris PeBenito |
473ea7 |
extern int fsetfilecon_raw(int fd, security_context_t con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Wrappers for the socket API */
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Get context of peer socket, and set *con to refer to it.
|
|
Chris PeBenito |
473ea7 |
Caller must free via freecon. */
|
|
Chris PeBenito |
473ea7 |
extern int getpeercon(int fd, security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
extern int getpeercon_raw(int fd, security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Wrappers for the selinuxfs (policy) API. */
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
typedef unsigned int access_vector_t;
|
|
Chris PeBenito |
473ea7 |
typedef unsigned short security_class_t;
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
struct av_decision {
|
|
Chris PeBenito |
473ea7 |
access_vector_t allowed;
|
|
Chris PeBenito |
473ea7 |
access_vector_t decided;
|
|
Chris PeBenito |
473ea7 |
access_vector_t auditallow;
|
|
Chris PeBenito |
473ea7 |
access_vector_t auditdeny;
|
|
Chris PeBenito |
473ea7 |
unsigned int seqno;
|
|
Chris PeBenito |
473ea7 |
};
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Compute an access decision. */
|
|
Chris PeBenito |
473ea7 |
extern int security_compute_av(security_context_t scon,
|
|
Chris PeBenito |
473ea7 |
security_context_t tcon,
|
|
Chris PeBenito |
473ea7 |
security_class_t tclass,
|
|
Chris PeBenito |
473ea7 |
access_vector_t requested,
|
|
Chris PeBenito |
473ea7 |
struct av_decision *avd);
|
|
Chris PeBenito |
473ea7 |
extern int security_compute_av_raw(security_context_t scon,
|
|
Chris PeBenito |
473ea7 |
security_context_t tcon,
|
|
Chris PeBenito |
473ea7 |
security_class_t tclass,
|
|
Chris PeBenito |
473ea7 |
access_vector_t requested,
|
|
Chris PeBenito |
473ea7 |
struct av_decision *avd);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Compute a labeling decision and set *newcon to refer to it.
|
|
Chris PeBenito |
473ea7 |
Caller must free via freecon. */
|
|
Chris PeBenito |
473ea7 |
extern int security_compute_create(security_context_t scon,
|
|
Chris PeBenito |
473ea7 |
security_context_t tcon,
|
|
Chris PeBenito |
473ea7 |
security_class_t tclass,
|
|
Chris PeBenito |
473ea7 |
security_context_t *newcon);
|
|
Chris PeBenito |
473ea7 |
extern int security_compute_create_raw(security_context_t scon,
|
|
Chris PeBenito |
473ea7 |
security_context_t tcon,
|
|
Chris PeBenito |
473ea7 |
security_class_t tclass,
|
|
Chris PeBenito |
473ea7 |
security_context_t *newcon);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Compute a relabeling decision and set *newcon to refer to it.
|
|
Chris PeBenito |
473ea7 |
Caller must free via freecon. */
|
|
Chris PeBenito |
473ea7 |
extern int security_compute_relabel(security_context_t scon,
|
|
Chris PeBenito |
473ea7 |
security_context_t tcon,
|
|
Chris PeBenito |
473ea7 |
security_class_t tclass,
|
|
Chris PeBenito |
473ea7 |
security_context_t *newcon);
|
|
Chris PeBenito |
473ea7 |
extern int security_compute_relabel_raw(security_context_t scon,
|
|
Chris PeBenito |
473ea7 |
security_context_t tcon,
|
|
Chris PeBenito |
473ea7 |
security_class_t tclass,
|
|
Chris PeBenito |
473ea7 |
security_context_t *newcon);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Compute a polyinstantiation member decision and set *newcon to refer to it.
|
|
Chris PeBenito |
473ea7 |
Caller must free via freecon. */
|
|
Chris PeBenito |
473ea7 |
extern int security_compute_member(security_context_t scon,
|
|
Chris PeBenito |
473ea7 |
security_context_t tcon,
|
|
Chris PeBenito |
473ea7 |
security_class_t tclass,
|
|
Chris PeBenito |
473ea7 |
security_context_t *newcon);
|
|
Chris PeBenito |
473ea7 |
extern int security_compute_member_raw(security_context_t scon,
|
|
Chris PeBenito |
473ea7 |
security_context_t tcon,
|
|
Chris PeBenito |
473ea7 |
security_class_t tclass,
|
|
Chris PeBenito |
473ea7 |
security_context_t *newcon);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Compute the set of reachable user contexts and set *con to refer to
|
|
Chris PeBenito |
473ea7 |
the NULL-terminated array of contexts. Caller must free via freeconary. */
|
|
Chris PeBenito |
473ea7 |
extern int security_compute_user(security_context_t scon,
|
|
Chris PeBenito |
473ea7 |
const char *username,
|
|
Chris PeBenito |
473ea7 |
security_context_t **con);
|
|
Chris PeBenito |
473ea7 |
extern int security_compute_user_raw(security_context_t scon,
|
|
Chris PeBenito |
473ea7 |
const char *username,
|
|
Chris PeBenito |
473ea7 |
security_context_t **con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Load a policy configuration. */
|
|
Chris PeBenito |
473ea7 |
extern int security_load_policy(void *data, size_t len);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/*
|
|
Chris PeBenito |
473ea7 |
* Make a policy image and load it.
|
|
Chris PeBenito |
473ea7 |
* This function provides a higher level interface for loading policy
|
|
Chris PeBenito |
473ea7 |
* than security_load_policy, internally determining the right policy
|
|
Chris PeBenito |
473ea7 |
* version, locating and opening the policy file, mapping it into memory,
|
|
Chris PeBenito |
473ea7 |
* manipulating it as needed for current boolean settings and/or local
|
|
Chris PeBenito |
473ea7 |
* definitions, and then calling security_load_policy to load it.
|
|
Chris PeBenito |
473ea7 |
*
|
|
Chris PeBenito |
473ea7 |
* 'preservebools' is a boolean flag indicating whether current
|
|
Chris PeBenito |
473ea7 |
* policy boolean values should be preserved into the new policy (if 1)
|
|
Chris PeBenito |
473ea7 |
* or reset to the saved policy settings (if 0). The former case is the
|
|
Chris PeBenito |
473ea7 |
* default for policy reloads, while the latter case is an option for policy
|
|
Chris PeBenito |
473ea7 |
* reloads but is primarily for the initial policy load.
|
|
Chris PeBenito |
473ea7 |
*/
|
|
Chris PeBenito |
473ea7 |
extern int selinux_mkload_policy(int preservebools);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/*
|
|
Chris PeBenito |
473ea7 |
* Perform the initial policy load.
|
|
Chris PeBenito |
473ea7 |
* This function determines the desired enforcing mode, sets the
|
|
Chris PeBenito |
473ea7 |
* the *enforce argument accordingly for the caller to use, sets the
|
|
Chris PeBenito |
473ea7 |
* SELinux kernel enforcing status to match it, and loads the policy.
|
|
Chris PeBenito |
473ea7 |
* It also internally handles the initial selinuxfs mount required to
|
|
Chris PeBenito |
473ea7 |
* perform these actions.
|
|
Chris PeBenito |
473ea7 |
*
|
|
Chris PeBenito |
473ea7 |
* The function returns 0 if everything including the policy load succeeds.
|
|
Chris PeBenito |
473ea7 |
* In this case, init is expected to re-exec itself in order to transition
|
|
Chris PeBenito |
473ea7 |
* to the proper security context.
|
|
Chris PeBenito |
473ea7 |
* Otherwise, the function returns -1, and init must check *enforce to
|
|
Chris PeBenito |
473ea7 |
* determine how to proceed. If enforcing (*enforce > 0), then init should
|
|
Chris PeBenito |
473ea7 |
* halt the system. Otherwise, init may proceed normally without a re-exec.
|
|
Chris PeBenito |
473ea7 |
*/
|
|
Chris PeBenito |
473ea7 |
extern int selinux_init_load_policy(int *enforce);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Translate boolean strict to name value pair. */
|
|
Chris PeBenito |
473ea7 |
typedef struct {
|
|
Chris PeBenito |
473ea7 |
char *name;
|
|
Chris PeBenito |
473ea7 |
int value;
|
|
Chris PeBenito |
473ea7 |
} SELboolean;
|
|
Chris PeBenito |
473ea7 |
/* save a list of booleans in a single transaction. */
|
|
Chris PeBenito |
473ea7 |
extern int security_set_boolean_list(size_t boolcnt,
|
|
Chris PeBenito |
473ea7 |
SELboolean *boollist,
|
|
Chris PeBenito |
473ea7 |
int permanent);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Load policy boolean settings.
|
|
Chris PeBenito |
473ea7 |
Path may be NULL, in which case the booleans are loaded from
|
|
Chris PeBenito |
473ea7 |
the active policy boolean configuration file. */
|
|
Chris PeBenito |
473ea7 |
extern int security_load_booleans(char *path);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Check the validity of a security context. */
|
|
Chris PeBenito |
473ea7 |
extern int security_check_context(security_context_t con);
|
|
Chris PeBenito |
473ea7 |
extern int security_check_context_raw(security_context_t con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Get the enforce flag value. */
|
|
Chris PeBenito |
473ea7 |
extern int security_getenforce(void);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Set the enforce flag value. */
|
|
Chris PeBenito |
473ea7 |
extern int security_setenforce(int value);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Disable SELinux at runtime (must be done prior to initial policy load). */
|
|
Chris PeBenito |
473ea7 |
extern int security_disable(void);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Get the policy version number. */
|
|
Chris PeBenito |
473ea7 |
extern int security_policyvers(void);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Get the boolean names */
|
|
Chris PeBenito |
473ea7 |
extern int security_get_boolean_names(char ***names, int *len);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Get the pending value for the boolean */
|
|
Chris PeBenito |
473ea7 |
extern int security_get_boolean_pending(const char *name);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Get the active value for the boolean */
|
|
Chris PeBenito |
473ea7 |
extern int security_get_boolean_active(const char *name);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Set the pending value for the boolean */
|
|
Chris PeBenito |
473ea7 |
extern int security_set_boolean(const char *name, int value);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Commit the pending values for the booleans */
|
|
Chris PeBenito |
473ea7 |
extern int security_commit_booleans(void);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Common helpers */
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Return the security class value for a given class name. */
|
|
Chris PeBenito |
473ea7 |
extern security_class_t string_to_security_class(const char *name);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Return an access vector for a given class and permission name. */
|
|
Chris PeBenito |
473ea7 |
extern access_vector_t string_to_av_perm(security_class_t tclass, const char *name);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Display an access vector in a string representation. */
|
|
Chris PeBenito |
473ea7 |
extern void print_access_vector(security_class_t tclass, access_vector_t av);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Set the function used by matchpathcon_init when displaying
|
|
Chris PeBenito |
473ea7 |
errors about the file_contexts configuration. If not set,
|
|
Chris PeBenito |
473ea7 |
then this defaults to fprintf(stderr, fmt, ...). */
|
|
Chris PeBenito |
473ea7 |
extern void set_matchpathcon_printf(void (*f)(const char *fmt, ...));
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Set the function used by matchpathcon_init when checking the
|
|
Chris PeBenito |
473ea7 |
validity of a context in the file contexts configuration. If not set,
|
|
Chris PeBenito |
473ea7 |
then this defaults to a test based on security_check_context().
|
|
Chris PeBenito |
473ea7 |
The function is also responsible for reporting any such error, and
|
|
Chris PeBenito |
473ea7 |
may include the 'path' and 'lineno' in such error messages. */
|
|
Chris PeBenito |
473ea7 |
extern void set_matchpathcon_invalidcon(int (*f)(const char *path,
|
|
Chris PeBenito |
473ea7 |
unsigned lineno,
|
|
Chris PeBenito |
473ea7 |
char *context));
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Set flags controlling operation of matchpathcon_init or matchpathcon. */
|
|
Chris PeBenito |
473ea7 |
#define MATCHPATHCON_BASEONLY 1 /* Only process the base file_contexts file. */
|
|
Chris PeBenito |
473ea7 |
extern void set_matchpathcon_flags(unsigned int flags);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Load the file contexts configuration specified by 'path'
|
|
Chris PeBenito |
473ea7 |
into memory for use by subsequent matchpathcon calls.
|
|
Chris PeBenito |
473ea7 |
If 'path' is NULL, then load the active file contexts configuration,
|
|
Chris PeBenito |
473ea7 |
i.e. the path returned by selinux_file_context_path().
|
|
Chris PeBenito |
473ea7 |
Unless the MATCHPATHCON_BASEONLY flag has been set, this
|
|
Chris PeBenito |
473ea7 |
function also checks for a 'path'.homedirs file and
|
|
Chris PeBenito |
473ea7 |
a 'path'.local file and loads additional specifications
|
|
Chris PeBenito |
473ea7 |
from them if present. */
|
|
Chris PeBenito |
473ea7 |
extern int matchpathcon_init(const char *path);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Match the specified pathname and mode against the file contexts
|
|
Chris PeBenito |
473ea7 |
configuration and set *con to refer to the resulting context.
|
|
Chris PeBenito |
473ea7 |
'mode' can be 0 to disable mode matching.
|
|
Chris PeBenito |
473ea7 |
Caller must free via freecon.
|
|
Chris PeBenito |
473ea7 |
If matchpathcon_init has not already been called, then this function
|
|
Chris PeBenito |
473ea7 |
will call it upon its first invocation with a NULL path. */
|
|
Chris PeBenito |
473ea7 |
extern int matchpathcon(const char *path,
|
|
Chris PeBenito |
473ea7 |
mode_t mode,
|
|
Chris PeBenito |
473ea7 |
security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Same as above, but return a specification index for
|
|
Chris PeBenito |
473ea7 |
later use in a matchpathcon_filespec_add() call - see below. */
|
|
Chris PeBenito |
473ea7 |
extern int matchpathcon_index(const char *path,
|
|
Chris PeBenito |
473ea7 |
mode_t mode,
|
|
Chris PeBenito |
473ea7 |
security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Maintain an association between an inode and a specification index,
|
|
Chris PeBenito |
473ea7 |
and check whether a conflicting specification is already associated
|
|
Chris PeBenito |
473ea7 |
with the same inode (e.g. due to multiple hard links). If so, then
|
|
Chris PeBenito |
473ea7 |
use the latter of the two specifications based on their order in the
|
|
Chris PeBenito |
473ea7 |
file contexts configuration. Return the used specification index. */
|
|
Chris PeBenito |
473ea7 |
extern int matchpathcon_filespec_add(ino_t ino, int specind, const char *file);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Destroy any inode associations that have been added, e.g. to restart
|
|
Chris PeBenito |
473ea7 |
for a new filesystem. */
|
|
Chris PeBenito |
473ea7 |
extern void matchpathcon_filespec_destroy(void);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Display statistics on the hash table usage for the associations. */
|
|
Chris PeBenito |
473ea7 |
extern void matchpathcon_filespec_eval(void);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Check to see whether any specifications had no matches and report them.
|
|
Chris PeBenito |
473ea7 |
The 'str' is used as a prefix for any warning messages. */
|
|
Chris PeBenito |
473ea7 |
extern void matchpathcon_checkmatches(char *str);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Match the specified media and against the media contexts
|
|
Chris PeBenito |
473ea7 |
configuration and set *con to refer to the resulting context.
|
|
Chris PeBenito |
473ea7 |
Caller must free con via freecon. */
|
|
Chris PeBenito |
473ea7 |
extern int matchmediacon(const char *media,
|
|
Chris PeBenito |
473ea7 |
security_context_t *con);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/*
|
|
Chris PeBenito |
473ea7 |
selinux_getenforcemode reads the /etc/selinux/config file and determines
|
|
Chris PeBenito |
473ea7 |
whether the machine should be started in enforcing (1), permissive (0) or
|
|
Chris PeBenito |
473ea7 |
disabled (-1) mode.
|
|
Chris PeBenito |
473ea7 |
*/
|
|
Chris PeBenito |
473ea7 |
extern int selinux_getenforcemode(int *enforce);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/*
|
|
Chris PeBenito |
473ea7 |
selinux_policy_root reads the /etc/selinux/config file and returns
|
|
Chris PeBenito |
473ea7 |
the directory path under which the compiled policy file and context
|
|
Chris PeBenito |
473ea7 |
configuration files exist.
|
|
Chris PeBenito |
473ea7 |
*/
|
|
Chris PeBenito |
473ea7 |
extern const char *selinux_policy_root(void);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* These functions return the paths to specific files under the
|
|
Chris PeBenito |
473ea7 |
policy root directory. */
|
|
Chris PeBenito |
473ea7 |
extern const char *selinux_binary_policy_path(void);
|
|
Chris PeBenito |
473ea7 |
extern const char *selinux_failsafe_context_path(void);
|
|
Chris PeBenito |
473ea7 |
extern const char *selinux_removable_context_path(void);
|
|
Chris PeBenito |
473ea7 |
extern const char *selinux_default_context_path(void);
|
|
Chris PeBenito |
473ea7 |
extern const char *selinux_user_contexts_path(void);
|
|
Chris PeBenito |
473ea7 |
extern const char *selinux_file_context_path(void);
|
|
Chris PeBenito |
473ea7 |
extern const char *selinux_media_context_path(void);
|
|
Chris PeBenito |
473ea7 |
extern const char *selinux_contexts_path(void);
|
|
Chris PeBenito |
473ea7 |
extern const char *selinux_booleans_path(void);
|
|
Chris PeBenito |
473ea7 |
extern const char *selinux_customizable_types_path(void);
|
|
Chris PeBenito |
473ea7 |
extern const char *selinux_users_path(void);
|
|
Chris PeBenito |
473ea7 |
extern const char *selinux_usersconf_path(void);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Check a permission in the passwd class.
|
|
Chris PeBenito |
473ea7 |
Return 0 if granted or -1 otherwise. */
|
|
Chris PeBenito |
473ea7 |
extern int selinux_check_passwd_access(access_vector_t requested);
|
|
Chris PeBenito |
473ea7 |
extern int checkPasswdAccess(access_vector_t requested);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Set the path to the selinuxfs mount point explicitly.
|
|
Chris PeBenito |
473ea7 |
Normally, this is determined automatically during libselinux
|
|
Chris PeBenito |
473ea7 |
initialization, but this is not always possible, e.g. for /sbin/init
|
|
Chris PeBenito |
473ea7 |
which performs the initial mount of selinuxfs. */
|
|
Chris PeBenito |
473ea7 |
void set_selinuxmnt(char *mnt);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Execute a helper for rpm in an appropriate security context. */
|
|
Chris PeBenito |
473ea7 |
extern int rpm_execcon(unsigned int verified,
|
|
Chris PeBenito |
473ea7 |
const char *filename,
|
|
Chris PeBenito |
473ea7 |
char *const argv[], char *const envp[]);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Returns whether a file context is customizable, and should not
|
|
Chris PeBenito |
473ea7 |
be relabeled . */
|
|
Chris PeBenito |
473ea7 |
extern int is_context_customizable (security_context_t scontext);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Perform context translation between the human-readable format
|
|
Chris PeBenito |
473ea7 |
("translated") and the internal system format ("raw").
|
|
Chris PeBenito |
473ea7 |
Caller must free the resulting context via freecon.
|
|
Chris PeBenito |
473ea7 |
Returns -1 upon an error or 0 otherwise.
|
|
Chris PeBenito |
473ea7 |
If passed NULL, sets the returned context to NULL and returns 0. */
|
|
Chris PeBenito |
473ea7 |
extern int selinux_trans_to_raw_context(security_context_t trans,
|
|
Chris PeBenito |
473ea7 |
security_context_t *rawp);
|
|
Chris PeBenito |
473ea7 |
extern int selinux_raw_to_trans_context(security_context_t raw,
|
|
Chris PeBenito |
473ea7 |
security_context_t *transp);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
/* Get the SELinux username and level to use for a given Linux username.
|
|
Chris PeBenito |
473ea7 |
These values may then be passed into the get_ordered_context_list*
|
|
Chris PeBenito |
473ea7 |
and get_default_context* functions to obtain a context for the user.
|
|
Chris PeBenito |
473ea7 |
Returns 0 on success or -1 otherwise.
|
|
Chris PeBenito |
473ea7 |
Caller must free the returned strings via free. */
|
|
Chris PeBenito |
473ea7 |
extern int getseuserbyname(const char *linuxuser, char **seuser, char **level);
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
#ifdef __cplusplus
|
|
Chris PeBenito |
473ea7 |
}
|
|
Chris PeBenito |
473ea7 |
#endif
|
|
Chris PeBenito |
473ea7 |
|
|
Chris PeBenito |
473ea7 |
#endif
|