Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

selabel_open(3) [debian man page]

selabel_open(3) 					     SELinux API documentation						   selabel_open(3)

NAME
selabel_open, selabel_close - userspace SELinux labeling interface. SYNOPSIS
#include <selinux/selinux.h> #include <selinux/label.h> struct selabel_handle *selabel_open(int backend, struct selinux_opt *options, unsigned nopt); void selabel_close(struct selabel_handle *hnd); DESCRIPTION
selabel_open is used to initialize a labeling handle to be used for lookup operations. The backend argument specifies which backend is to be opened; the list of current backends appears in BACKENDS below. The options argument should be NULL or a pointer to an array of selinux_opt structures of length nopt: struct selinux_opt { int type; const char *value; }; The available option types are described in GLOBAL OPTIONS below as well as in the documentation for each individual backend. The return value on success is a non-NULL value for use in subsequent label operations. selabel_close terminates use of a handle, freeing any internal resources associated with it. After this call has been made, the handle must not be used again. GLOBAL OPTIONS
Global options which may be passed to selabel_open include the following: SELABEL_OPT_UNUSED The option with a type code of zero is a no-op. Thus an array of options may be initizalized to zero and any untouched elements will not cause an error. SELABEL_OPT_VALIDATE A non-null value for this option enables context validation. By default, security_check_context(3) is used; a custom validation function can be provided via selinux_set_callback(3). Note that an invalid context may not be treated as an error unless it is actually encountered during a lookup operation. BACKENDS
SELABEL_CTX_FILE File contexts backend, described in selabel_file(5). SELABEL_CTX_MEDIA Media contexts backend, described in selabel_media(5). SELABEL_CTX_X X Windows contexts backend, described in selabel_x(5). SELABEL_CTX_DB Database objects contexts backend, described in selabel_db(5). RETURN VALUE
A non-NULL handle value is returned on success. On error, NULL is returned and errno is set appropriately. AUTHOR
Eamon Walsh <ewalsh@tycho.nsa.gov> SEE ALSO
selabel_lookup(3), selabel_stats(3), selinux_set_callback(3), selinux(8) 18 Jun 2007 selabel_open(3)

Check Out this Related Man Page

selabel_media(5)					     SELinux API documentation						  selabel_media(5)

NAME
selabel_media - userspace SELinux labeling interface and configuration file format for the media contexts backend SYNOPSIS
#include <selinux/label.h> int selabel_lookup(struct selabel_handle *hnd, security_context_t *context, const char *device_name, int unused); int selabel_lookup_raw(struct selabel_handle *hnd, security_context_t *context, const char *device_name, int unused); DESCRIPTION
The media contexts backend maps from media device names such as "cdrom" or "floppy" into security contexts. It is used to find the appro- priate context for establishing context mounts on these devices. The returned context must be freed using freecon(3). selabel_lookup(3) describes the function with its return and error codes. The integer lookup argument is currently unused and should be set to zero. Any messages generated by selabel_lookup(3) are sent to stderr by default, although this can be changed by selinux_set_callback(3). selabel_lookup_raw(3) behaves identically to selabel_lookup(3) but does not perform context translation. The FILES section details the configuration files used to determine the media context. OPTIONS
In addition to the global options described in selabel_open(3), this backend recognizes the following options: SELABEL_OPT_PATH A non-null value for this option specifies a path to a file that will be opened in lieu of the standard media contexts file. FILES
The media context file used to retrieve a default context depends on the SELABEL_OPT_PATH parameter passed to selabel_open(3). If NULL, then the SELABEL_OPT_PATH value will default to the active policy media contexts location (as returned by selinux_media_context_path(3)), otherwise the actual SELABEL_OPT_PATH value specified is used. The default media contexts file is: /etc/selinux/{SELINUXTYPE}/contexts/files/media Where {SELINUXTYPE} is the entry from the selinux configuration file config (see selinux_config(5)). Should there not be a valid entry in the media file, then the default removable_context file will be read (see removable_context(5)). FILE FORMAT
Each line within the media file is as follows: device_name context Where: device_name The media identifier (e.g. cdrom, floppy, disk and usb). context The context to be used for labeling the device. Example: # contexts/files/media cdrom system_u:object_r:removable_device_t floppy system_u:object_r:removable_device_t disk system_u:object_r:fixed_disk_device_t NOTES
If contexts are to be validated, then the global option SELABEL_OPT_VALIDATE must be set before calling selabel_open(3). If this is not set, then it is possible for an invalid context to be returned. SEE ALSO
selinux(8), selabel_open(3), selabel_lookup(3), selabel_stats(3), selabel_close(3), selinux_set_callback(3), selinux_media_context_path(3), freecon(3), selinux_config(5), removable_context(5) Security Enhanced Linux 29 Nov 2011 selabel_media(5)
Man Page