mirror of
https://github.com/ericonr/util-linux.git
synced 2024-04-21 09:12:35 -05:00
* selinux/av_permissions.h and magic constants are deprecated, the recommended solution is to use string_to_security_class() and string_to_av_perm() to get access vector * it also seems that selinux_check_passwd_access() does exactly the same as our checkAccess(), let's use it. Signed-off-by: Karel Zak <kzak@redhat.com>
30 lines
604 B
C
30 lines
604 B
C
#include <selinux/context.h>
|
|
#include <selinux/selinux.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <sys/types.h>
|
|
|
|
#include "selinux_utils.h"
|
|
|
|
access_vector_t get_access_vector(const char *tclass, const char *op)
|
|
{
|
|
security_class_t tc = string_to_security_class(tclass);
|
|
|
|
return tc ? string_to_av_perm(tc, op) : 0;
|
|
}
|
|
|
|
int setupDefaultContext(char *orig_file)
|
|
{
|
|
if (is_selinux_enabled() > 0) {
|
|
security_context_t scontext;
|
|
if (getfilecon(orig_file, &scontext) < 0)
|
|
return 1;
|
|
if (setfscreatecon(scontext) < 0) {
|
|
freecon(scontext);
|
|
return 1;
|
|
}
|
|
freecon(scontext);
|
|
}
|
|
return 0;
|
|
}
|