Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

findcon(1) [centos man page]

findcon(1)						      General Commands Manual							findcon(1)

NAME
findcon - SELinux file context search tool SYNOPSIS
findcon FCLIST [OPTIONS] [EXPRESSION] DESCRIPTION
findcon allows the user to search for files with a specified context. Results can be filtered by object class as described below. FCLIST
The findcon tool operates upon a file context list source. There are three valid file context lists. directory If FCLIST is a name of a directory then begin the search at that directory and recurse within it. Be sure there are no circular mounts within it. file_contexts If FCLIST is the name of a file_contexts file (e.g., /etc/selinux/strict/contexts/files/file_contexts) then open that file and find matching entries. database If FCLIST is the name of a database as created by a previous run of indexcon or apol then open the database and execute queries into it. EXPRESSION
The following options allow the user to specify which files to print. A file must meet all specified criteria. If no expression is pro- vided, all files are printed. -t TYPE, --type=TYPE Search for files with a context containing the type TYPE. -u USER, --user=USER Search for files with a context containing the user USER. -r ROLE, --role=ROLE Search for files with a context containing the role ROLE. -m RANGE, --mls-range=RANGE Search for files with a context with the MLS range of RANGE. Note that findcon ignores the SELinux translation library, if present. In addition, this flag is ignored if the FCLIST has no MLS information. --context=CONTEXT Search for files matching this partial context. This flag overrides -t, -u, -r, and -m. -p PATH, --path=PATH Search for files which include PATH. -c CLASS, --class=CLASS Search only files of object class CLASS. OPTIONS
The following additional options are available. -R, --regex Search using regular expressions instead of exact string matching. This option does not affect the --class flag. -h, --help Print help information and exit. -V, --version Print version information and exit. PARTIAL CONTEXT
The --context flag specifies a partial context, which is a a colon separated list of user, role, and type. If the system supports MLS, the context may have a fourth field that gives the range. If a field is not specified or is the literal asterisk, then the query will always match the field. OBJECT CLASSES
Valid object class strings are block, char, dir, fifo, file, link, or sock. NOTE
The findcon utility always operates on "raw" SELinux file contexts. If the system has an installed translation library (i.e., libsetrans), those translations are ignored in favor of reading the original contexts from the filesystem (if FCFILE is a directory). EXAMPLES
findcon . Find every context in the current directory and all of its subdirectories. findcon -u user_u . Find every context whose user is user_u in the current directory and all subdirectories. findcon -u system_u -t bin_t file_contexts Find entries user system_u and type bin_t within a file_contexts file, assuming that file_contexts is a file contexts file. findcon --context=system_u::bin_t file_contexts This is equivalent to the previous example. findcon --context=system_u:*:bin_t:* file_contexts This is also equivalent to the above example. AUTHOR
This manual page was written by Jeremy A. Mowery <jmowery@tresys.com>. COPYRIGHT
Copyright(C) 2003-2007 Tresys Technology, LLC BUGS
Please report bugs via an email to setools-bugs@tresys.com. SEE ALSO
replcon(1), indexcon(1) findcon(1)

Check Out this Related Man Page

selinux_file_context_verify(3)				     Library Functions Manual				    selinux_file_context_verify(3)

NAME
selinux_file_context_verify - Compare the SELinux security context on disk to the default security context required by the policy file con- texts file SYNOPSIS
#include <selinux/selinux.h> int selinux_file_context_verify(const char *path, mode_t mode); DESCRIPTION
selinux_file_context_verify() compares the context of the specified path that is held on disk (in the extended attribute), to the system default entry held in the file contexts series of files. The mode may be zero. Note that the two contexts are compared for "significant" differences (i.e. the user component of the contexts are ignored) as shown in the EXAMPLE section. RETURN VALUE
If the contexts significantly match, 1 (one) is returned. If the contexts do not match 0 (zero) is returned and errno is set to either ENOENT or EINVAL for the reasons listed in the ERRORS section, or if errno = 0 then the contexts did not match. On failure -1 is returned and errno set appropriately. ERRORS
ENOTSUP if extended attributes are not supported by the file system. ENOENT if there is no entry in the file contexts series of files or path does not exist. EINVAL if the entry in the file contexts series of files or path are invalid, or the returned context fails validation. ENOMEM if attempt to allocate memory failed. FILES
The following configuration files (the file contexts series of files) supporting the active policy will be used (should they exist) to determine the path default context: contexts/files/file_contexts - This file must exist. contexts/files/file_contexts.local - If exists has local customizations. contexts/files/file_contexts.homedirs - If exists has users home directory customizations. contexts/files/file_contexts.subs - If exists has substitutions that are then applied to the 'in memory' version of the file con- texts files. EXAMPLE
If the files context is: unconfined_u:object_r:admin_home_t:s0 and the default context defined in the file contexts file is: system_u:object_r:admin_home_t:s0 then the actual strings compared are: :object_r:admin_home_t:s0 and :object_r:admin_home_t:s0 Therefore they will match and selinux_file_context_verify() will return 1. SEE ALSO
selinux(8) SELinux API documentation 08 March 2011 selinux_file_context_verify(3)
Man Page