2008-08-19 19:30:36 +00:00
. \" Hey Emacs! This file is -*- nroff -*- source.
. \"
. \" Author: Eamon Walsh (ewalsh@tycho.nsa.gov) 2007
2011-12-01 16:24:33 +00:00
.TH "selabel_media" "5" "29 Nov 2011" "Security Enhanced Linux" "SELinux API documentation"
2008-08-19 19:30:36 +00:00
.SH "NAME"
2012-11-13 20:15:34 +00:00
selabel_media \- userspace SELinux labeling interface and configuration file format for the media contexts backend
.
2011-12-01 16:24:33 +00:00
.SH "SYNOPSIS"
2008-08-19 19:30:36 +00:00
.B #include <selinux/label.h>
.sp
.BI "int selabel_lookup(struct selabel_handle *" hnd ,
.in +\w'int selabel_lookup('u
2014-02-19 14:16:17 +00:00
.BI "char **" context ,
2011-12-01 16:24:33 +00:00
.br
.BI "const char *" device_name ", int " unused ");"
.in
.sp
.BI "int selabel_lookup_raw(struct selabel_handle *" hnd ,
.in +\w'int selabel_lookup('u
2014-02-19 14:16:17 +00:00
.BI "char **" context ,
2011-12-01 16:24:33 +00:00
.br
2008-08-19 19:30:36 +00:00
.BI "const char *" device_name ", int " unused ");"
2012-11-13 20:15:34 +00:00
.
2008-08-19 19:30:36 +00:00
.SH "DESCRIPTION"
2011-12-01 16:24:33 +00:00
The media contexts backend maps from media device names such as "cdrom" or "floppy" into security contexts. It is used to find the appropriate context for establishing context mounts on these devices. The returned \fI context\fR must be freed using \fB freecon\fR (3).
.br
\fB selabel_lookup\fR (3) describes the function with its return and error codes.
.sp
2008-08-19 19:30:36 +00:00
The integer lookup argument is currently unused and should be set to zero.
2011-12-01 16:24:33 +00:00
.sp
2012-11-13 20:15:34 +00:00
Any messages generated by \fB selabel_lookup\fR (3) are sent to \fI stderr\fR
by default, although this can be changed by \fB selinux_set_callback\fR (3).
2011-12-01 16:24:33 +00:00
.sp
2012-11-13 20:15:34 +00:00
.BR selabel_lookup_raw (3)
behaves identically to \fB selabel_lookup\fR (3) but does not perform context
translation.
2011-12-01 16:24:33 +00:00
.sp
The \fB FILES\fR section details the configuration files used to determine the media context.
2012-11-13 20:15:34 +00:00
.
2008-08-19 19:30:36 +00:00
.SH "OPTIONS"
2011-12-01 16:24:33 +00:00
In addition to the global options described in \fB selabel_open\fR (3), this backend recognizes the following options:
2008-08-19 19:30:36 +00:00
.TP
.B SELABEL_OPT_PATH
2011-12-01 16:24:33 +00:00
A non-null value for this option specifies a path to a file that will be opened in lieu of the standard \fI media\fR contexts file.
2012-11-13 20:15:34 +00:00
.
2011-12-01 16:24:33 +00:00
.SH "FILES"
The media context file used to retrieve a default context depends on the \fB SELABEL_OPT_PATH\fR parameter passed to \fB selabel_open\F R(3). If \fI NULL\fR , then the \fB SELABEL_OPT_PATH\fR value will default to the active policy media contexts location (as returned by \fB selinux_media_context_path\fR (3)), otherwise the actual \fB SELABEL_OPT_PATH\fR value specified is used.
.sp
The default media contexts file is:
.RS
.I /etc/selinux/{SELINUXTYPE}/contexts/files/media
.RE
.sp
Where \fI {SELINUXTYPE}\fR is the entry from the selinux configuration file \fI config\fR (see \fB selinux_config\fR (5)).
.sp
Should there not be a valid entry in the \fI media\fR file, then the default \fI removable_context\fR file will be read (see \fB removable_context\fR (5)).
2012-11-13 20:15:34 +00:00
.
2011-12-01 16:24:33 +00:00
.SH "FILE FORMAT"
Each line within the \fI media\fR file is as follows:
.RS
.I device_name context
.RE
.sp
Where:
.RS
.I device_name
.RS
The media identifier (e.g. cdrom, floppy, disk and usb).
.RE
.I context
.RS
The context to be used for labeling the device.
.RE
.RE
.sp
Example:
.RS
# contexts/files/media
.br
cdrom system_u:object_r:removable_device_t
.br
floppy system_u:object_r:removable_device_t
.br
disk system_u:object_r:fixed_disk_device_t
2012-11-13 20:15:34 +00:00
.
2011-12-01 16:24:33 +00:00
.SH "NOTES"
If contexts are to be validated, then the global option \fB SELABEL_OPT_VALIDATE\fR must be set before calling \fB selabel_open\fR (3). If
this is not set, then it is possible for an invalid context to be returned.
2012-11-13 20:15:34 +00:00
.
2011-12-01 16:24:33 +00:00
.SH "SEE ALSO"
2012-11-13 20:15:34 +00:00
.ad l
.nh
2011-12-01 16:24:33 +00:00
.BR 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) "