Trouble with setexeccon/setcon
Hello, my name is Mario and I have a trouble with selinux's api. My goal is to modify the suPhp apache module, but the function setcon and function setexeccon don't work.
My apache process runs in dummy_t domain and suPhp file has a security context "user_u:object_r:dummy_exec_t"; in the policy file I write:
"domain_trans(dummy_t,dummy_exec_t,dummy_change_context_t)"
"domain_trans(dummy_t,dummy_exec_t,dummy_change1_context_t)"
And before calling apr_create_process in mod_suphp, I use setexeccon("user_u:object_r:dummy_change_context_t") but the function return always -1
Quoted 7 lines · Mario Fanelli
Hello, my name is Mario and I have a trouble with selinux's api. My goal is to modify the suPhp apache module, but the function setcon and function setexeccon don't work.
My apache process runs in
dummy_tdomain and suPhp file has a security context "user_u:object_r:dummy_exec_t"; in the policy file I write:
Quoted 6 lines
"
domain_trans(dummy_t,dummy_exec_t,dummy_change_context_t)""
domain_trans(dummy_t,dummy_exec_t,dummy_change1_context_t)"And before calling
apr_create_processinmod_suphp, I usesetexeccon("user_u:object_r:dummy_change_context_t")but the function return
^^^^^^^^
Quoted 1 line
always -1
You need user_r instead of object_r. I've never used this api so I can't comment further, but at least you need to change this.
Thomas
Quoted 12 lines · Thomas Bleher
Quoted 11 lines · Mario Fanelli
Hello, my name is Mario and I have a trouble with selinux's api. My goal is to modify the suPhp apache module, but the function setcon and function setexeccon don't work.
My apache process runs in
dummy_tdomain and suPhp file has a security context "user_u:object_r:dummy_exec_t"; in the policy file I write:"
domain_trans(dummy_t,dummy_exec_t,dummy_change_context_t)""
domain_trans(dummy_t,dummy_exec_t,dummy_change1_context_t)"
Quoted 7 lines
Quoted 2 lines
And before calling
apr_create_processinmod_suphp, I usesetexeccon("user_u:object_r:dummy_change_context_t")but the function return^^^^^^^^Quoted 1 line
always -1
You need
user_rinstead ofobject_r. I've never used this api so I can't comment further, but at least you need to change this.
Yes, and please don't hardcode security contexts in your program. Make sure that they are configurable so that your code can adapt to other policies. Note that you likely just want to configure the type, and let the rest be inherited from the caller's context. See newrole (in policycoreutils) or runcon (in coreutils) for examples of how to construct a context by taking an existing context and then just mutating a particular field, like the type.
Signature · 8 lines
Stephen Smalley National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.