September 2014
Intermediate to advanced
240 pages
5h 53m
English
In this recipe, we will be querying the SELinux userland to obtain the default context for a given user based on the context of the current process. The process is responsible for gathering the Linux username of the user upfront.
Query the SELinux configuration as follows:
char * curcon = 0;
rc = getcon(&curcon);
if (rc) {
… // Getting context failed
if (permissive) {
… // Continue with the application logic, ignoring SELinux stuff
} else {
… // Log failure and stop application logic
};
};name variable) and get the SELinux user:char * sename = 0; char * selevel = 0; rc = getseuserbyname(name, &sename, &selevel); ...
Read now
Unlock full access