首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在libselinux中哪里可以找到setcon函数的源代码?

在libselinux中哪里可以找到setcon函数的源代码?
EN

Stack Overflow用户
提问于 2020-04-02 21:24:52
回答 1查看 157关注 0票数 1

我试图弄清楚Selinux是如何工作的,我在几个地方看到一个名为setcon的函数,它是在selinux/selinux.h中声明的,并且有一个手册页条目。但是,我在libselinux的源代码中找不到这个函数的实现(即源代码)。谁能告诉我setcon的源代码在哪里?非常感谢。

代码语言:javascript
复制
/* 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);
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-04-12 12:05:52

我自己想出来的。实际上,函数"setcon“是在/libselinux/src/proattr.c中使用几个宏定义的。

代码语言:javascript
复制
#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",它也是在同一个源文件中定义的。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60992632

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档