set\_matchpathcon\_flags(3) SELinux API documentation set\_matchpathcon\_flags(3)

# [NAME](#NAME)

set\_matchpathcon\_flags, set\_matchpathcon\_invalidcon, set\_matchpathcon\_printf - set flags controlling the operation of matchpathcon or matchpathcon\_index and configure the behaviour of validity checking and error displaying

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;selinux/selinux.h&gt;**

**void set\_matchpathcon\_flags(unsigned int flags);**

**void set\_matchpathcon\_invalidcon(int (\*f)(const char \*path, unsigned lineno, char \*context));**

**void set\_matchpathcon\_printf(void (\*f)(const char \*fmt, ...));**

# [DESCRIPTION](#DESCRIPTION)

**set\_matchpathcon\_flags**() sets the flags controlling the operation of [**matchpathcon\_init**(3)](/man/os/libselinux/matchpathcon_init.3) and subsequently [**matchpathcon\_index**(3)](/man/os/libselinux/matchpathcon_index.3) or [**matchpathcon**(3)](/man/os/libselinux/matchpathcon.3). If the **MATCHPATHCON\_BASEONLY** flag is set, then only the base file contexts configuration file will be processed, not any dynamically generated entries or local customizations.

**set\_matchpathcon\_invalidcon**() sets the function used by [**matchpathcon\_init**(3)](/man/os/libselinux/matchpathcon_init.3) when checking the validity of a context in the file contexts configuration. If not set, then this defaults to a test based on [**security\_check\_context**(3)](/man/os/libselinux/security_check_context.3), which checks validity against the active policy on a SELinux system. This can be set to instead perform checking based on a binary policy file, e.g. using [**sepol\_check\_context**(3)](/man/os/libselinux/sepol_check_context.3), as is done by **setfiles -c.** The function is also responsible for reporting any such error, and may include the *path* and *lineno* in such error messages.

**set\_matchpathcon\_printf**() sets the function used by [**matchpathcon\_init**(3)](/man/os/libselinux/matchpathcon_init.3) when displaying errors about the file contexts configuration. If not set, then this defaults to fprintf(stderr, fmt, ...). This can be set to redirect error reporting to a different destination.

# [RETURN VALUE](#RETURN_VALUE)

Returns zero on success or -1 otherwise.

# [SEE ALSO](#SEE_ALSO)

[**selinux**(8)](/man/os/libselinux/selinux.8), [**matchpathcon**(3)](/man/os/libselinux/matchpathcon.3), [**matchpathcon\_index**(3)](/man/os/libselinux/matchpathcon_index.3), [**set\_matchpathcon\_invalidcon**(3)](/man/os/libselinux/set_matchpathcon_invalidcon.3), [**set\_matchpathcon\_printf**(3)](/man/os/libselinux/set_matchpathcon_printf.3), [**freecon**(3)](/man/os/libselinux/freecon.3), [**setfilecon**(3)](/man/os/libselinux/setfilecon.3), [**setfscreatecon**(3)](/man/os/libselinux/setfscreatecon.3)

21 November 2009 stephen.smalley.work@gmail.com

---

Document: set_matchpathcon_printf(3) from libselinux 3.11-r2 (Chainguard OS)
Source: https://github.com/SELinuxProject/selinux.git
