Trouble with setexeccon/setcon
Quoted 8 lines
Quoted 7 lines · Mario Fanelli
Quoted 4 lines
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
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
and function setexeccon don't work.
My apache process runs in
dummy_tdomain and suPhp file has asecurity context "user_u:object_r:dummy_exec_t"; in the policy file I
write:
Quoted 22 lines
Quoted 21 lines
Quoted 10 lines
"
domain_trans(dummy_t,dummy_exec_t,dummy_change_context_t)""
domain_trans(dummy_t,dummy_exec_t,dummy_change1_context_t)"Quoted 5 lines
And before calling
apr_create_processinmod_suphp, I use
setexeccon("user_u:object_r:dummy_change_context_t")but thefunction return
^^^^^^^^Quoted 1 line
always -1
Quoted 7 lines
Quoted 3 lines
You need
user_rinstead ofobject_r. I've never used this api so Ican'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
Quoted 1 line
policycoreutils) or runcon (in coreutils) for examples of how to construct
a context by taking an existing context and
Quoted 9 lines
then just mutating a particular field, like the type.
--
Stephen Smalley
National Security Agency
Yes, but runcon and newrole are user-space command.
I have to modify the SuPhp C source code because I want that the process SuPhp has different security context depending of an environment variable that mod_suphp set. I try to use setexecon in mod_suphp beforce executing SuPhp but the security context don't change..setexeccon return -1.so I try to modify the suPhp exec with a calling to setcon but another setcon don't work.
If I use runcon all works, but I need to modify the source code.
Quoted 10 lines · Mario Fanelli
Yes, but runcon and newrole are user-space command.
I have to modify the SuPhp C source code because I want that the process SuPhp has different security context depending of an environment variable that
mod_suphpset. I try to use setexecon inmod_suphpbeforce executing SuPhp but the security context don’t change..setexeccon return -1…so I try to modify the suPhp exec with a calling to setcon but another setcon don’t work.If I use runcon all works, but I need to modify the source code…
Right, I meant to look at the runcon.c or newrole.c source code as examples of how to use setexeccon() as well as how to create a context in the first place from a combination of the caller's context and some new type. What errno do you get after the failed setexeccon() call? In addition to replacing object_r with a legitimate process role, you also need to ensure that the role is authorized for the type/domain.
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.