"unsigned int " restorecon_flags ");" "int selinux_restorecon_parallel(const char *" pathname ,
"unsigned int " restorecon_flags ","
"size_t " nthreads ");" .
pathname containing a directory or file to be relabeled.
If this is a directory and the restorecon_flags SELINUX_RESTORECON_RECURSE has been set (for descending through directories), then selinux_restorecon () will write an SHA1 digest of specfile entries calculated by selabel_get_digests_all_partial_matches (3) to an extended attribute of security.sehash once the relabeling has been completed successfully (see the NOTES section for details).
These digests will be checked should selinux_restorecon () be rerun with the restorecon_flags SELINUX_RESTORECON_RECURSE flag set. If any of the specfile entries had been updated, the digest will also be updated. However if the digest is the same, no relabeling checks will take place.
The restorecon_flags that can be used to manage the usage of the SHA1 digest are:
SELINUX_RESTORECON_SKIP_DIGEST
SELINUX_RESTORECON_IGNORE_DIGEST
SELINUX_RESTORECON_SKIP_DIGEST Do not check or update any extended attribute security.sehash entries. SELINUX_RESTORECON_IGNORE_DIGEST force the checking of labels even if the stored SHA1 digest matches the specfile entries SHA1 digest. The specfile entries digest will be written to the security.sehash extended attribute once relabeling has been completed successfully provided the SELINUX_RESTORECON_NOCHANGE flag has not been set, and no errors have been skipped during the file tree walk due to the SELINUX_RESTORECON_COUNT_ERRORS flag. SELINUX_RESTORECON_NOCHANGE don't change any file labels (passive check) or update the digest in the security.sehash extended attribute. SELINUX_RESTORECON_SET_SPECFILE_CTX If set, reset the files label to match the default specfile context. If not set only reset the files "type" component of the context to match the default specfile context. SELINUX_RESTORECON_RECURSE change file and directory labels recursively (descend directories) and if successful write an SHA1 digest of the specfile entries to an extended attribute as described in the NOTES section. SELINUX_RESTORECON_VERBOSE log file label changes.
Note that if SELINUX_RESTORECON_VERBOSE and SELINUX_RESTORECON_PROGRESS flags are set, then SELINUX_RESTORECON_PROGRESS will take precedence.
Setting SELINUX_RESTORECON_IGNORE_MOUNTS is useful where there is a non-seclabel fs mounted with a seclabel fs mounted on a directory below this. SELINUX_RESTORECON_CONFLICT_ERROR to treat conflicting specifications, such as where two hardlinks for the same inode have different contexts, as errors. SELINUX_RESTORECON_COUNT_ERRORS Count, but otherwise ignore, errors during the file tree walk. Only makes a difference if the SELINUX_RESTORECON_ABORT_ON_ERROR flag is clear. Call selinux_restorecon_get_skipped_errors (3) for fetching the ignored (skipped) error count after selinux_restorecon (3) or selinux_restorecon_parallel (3) completes with success. In case any errors were skipped during the file tree walk, the specfile entries SHA1 digest will not have been written to the security.sehash extended attribute.
nthreads specifies the number of threads to use during relabeling. When set to 1, the behavior is the same as calling selinux_restorecon (3). When set to 0, the function will try to use as many threads as there are online CPU cores. When set to any other number, the function will try to use the given number of threads. Note that to use the parallel relabeling capability, the calling process must be linked with the libpthread library (either at compile time or dynamically at run time). Otherwise the function will print a warning and fall back to the single threaded mode. .
getfattr -e hex -n security.sehash /
selinux_restorecon_set_sehandle (3),
selinux_restorecon_default_handle (3),
selinux_restorecon_get_skipped_errors (3),
selinux_restorecon_set_exclude_list (3),
selinux_restorecon_set_alt_rootpath (3),
selinux_restorecon_xattr (3),
selinux_set_callback (3)