문제

In C or C++ if I want to modify the filesystem permissions of a file I can us a standard library function (chmod), which is very similar to the utility that one can execute from the UNIX prompt.

Is there an equivalently simple way to set the selinux context for a file? If so, what libraries do I need to link to and what header files need to be included? Something which is similarly simple to use as the command line utility chcon would be ideal.

도움이 되었습니까?

해결책

#include <selinux/selinux.h>

typedef char *security_context_t;

int setfilecon(const char *path, security_context_t con);

is probably the function you are looking for. You have to link against libselinux.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top