我在哪里可以找到libselinux中函数"setcon"的源代码?
where can I find the source code of function "setcon" in libselinux?
我试图弄清楚 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);
这个是我自己想出来的。实际上,函数 "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",它也是在同一个源文件中定义的。
我试图弄清楚 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);
这个是我自己想出来的。实际上,函数 "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",它也是在同一个源文件中定义的。