---
name: "set_matchpathcon_invalidcon"
section: "3"
platform: "linux"
package: "libselinux1-dev"
version: "3.8.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/set_matchpathcon_flags"
---

# set\_matchpathcon\_invalidcon(3)

set flags controlling the operation of matchpathcon or matchpathcon\_index and configure the behaviour of validity checking and error displaying

Part of [set\_matchpathcon\_flags(3)](/set_matchpathcon_flags/3.md).

## 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

**#include \<selinux/selinux.h\>**

**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

**set\_matchpathcon\_flags**() sets the flags controlling the operation of  [**matchpathcon\_init**(3)](/matchpathcon_init/3.md) and subsequently [**matchpathcon\_index**(3)](/matchpathcon_index/3.md) or [**matchpathcon**(3)](/matchpathcon/3.md). 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)](/matchpathcon_init/3.md) 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)](/security_check_context/3.md), 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)](/sepol_check_context/3.md), 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)](/matchpathcon_init/3.md) 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

Returns zero on success or -1 otherwise.

## SEE ALSO

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