我试图弄清楚Selinux是如何工作的,我在几个地方看到一个名为setcon的函数,它是在selinux/selinux.h中声明的,并且有一个手册页条目。但是,我在libselinux的源代码中找不到这个函数的实现(即源代码)。谁能告诉我setcon的源代码在哪里?非常感谢。
/* Set the current security context to con.
Note that use of this function requires that the entire application
be trusted to maintain any desired separation between the old and new
security contexts, unlike exec-based transitions performed via setexeccon.
When possible, decompose your application and use setexeccon()+execve()
instead. Note that the application may lose access to its open descriptors
as a result of a setcon() unless policy allows it to use descriptors opened
by the old context. */
extern int setcon(const char * con);发布于 2020-04-12 12:05:52
我自己想出来的。实际上,函数"setcon“是在/libselinux/src/proattr.c中使用几个宏定义的。
#define setselfattr_def(fn, attr) \
int set##fn(const char * c) \
{ \
return setprocattrcon(c, 0, #attr); \
}
#define all_selfattr_def(fn, attr) \
getselfattr_def(fn, attr) \
setselfattr_def(fn, attr)
all_selfattr_def(con, current)从上面我们可以看到,真正的函数是"setprocattrcon",它也是在同一个源文件中定义的。
https://stackoverflow.com/questions/60992632
复制相似问题