Skip to contentSkip to conversation

Trouble with setexeccon/setcon

DISCUSSION Mario Fanelli 2 participants 2 messages May 13, 2006 – May 15, 2006 SELinux security module

lore
Share & tools
lore
#0 lore raw
Quoted 39 lines

-----Messaggio originale-----
Da: Stephen Smalley [mailto:[email protected]]
Inviato: Friday, May 12, 2006 4:17 PM
A: Mario Fanelli
Cc: SeLinux Mailing List
Oggetto: Re: Trouble with setexeccon/setcon

Quoted 12 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_suphp set. I try to use setexecon in

mod_suphp beforce executing SuPhp but the security context don't

Quoted 7 lines

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

Quoted 15 lines

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 · 3 lines
Stephen Smalley

 National Security Agency

I think that there is a problem with setcon/setexecon ..

Perhaps now I try to write a wrapper program that execute the command "runcon -t dummy_change_context_t /path/of/suphp"..the program only use an enviroment variable "SUPHP_SELINUX_DOMAIN" and call execve() with same environment, but the result doesn't change

Now I have written a policy for suPhp with a domain_auto_trans macro.when apache executes suphp, the context changes.but if I use a domain_trans and a setcon in suPhp, I obtain an error and I don't find any error message in /var/log/messages.I'm using a targetd policy and I put apache2 in unconfined_t domain.

Where can I find the runcon/newrole source code?

#1 lore raw
Quoted 1 line · Mario Fanelli

I think that there is a problem with setcon/setexecon ….

Please disable HTML mail in your mail client.

Quoted 4 lines

Perhaps now I try to write a wrapper program that execute the command “runcon –t dummy_change_context_t /path/of/suphp”..the program only use an enviroment variable “SUPHP_SELINUX_DOMAIN” and call execve() with same environment, but the result doesn’t change

I'm not certain as to what you mean by the above statement. Does it
fail? Does running that same command by hand succeed? What is the
output? What is logged in /var/log/messages
or /var/log/audit/audit.log?

Quoted 5 lines

Now I have written a policy for suPhp with a domain_auto_trans macro… when apache executes suphp, the context changes…but if I use a domain_trans and a setcon in suPhp, I obtain an error and I don’t find any error message in /var/log/messages…I’m using a targetd policy and I put apache2 in unconfined_t domain…

Point of clarification: domain_trans is for authorizing transitions via execve. It does not authorize a dynamic context transition. So if you want to transition upon execve (as in runcon), then you want to use setexeccon() prior to the execve, and you need to allow process setexec permission as well as the domain transition (in the example policy, this is done by the can_setexec() macro). If you want to transition within the current process without performing an execve via setcon(), then you need to separately allow process dyntransition permission.

Did you also check for a /var/log/audit/audit.log? That is where messages are logged if running auditd (as in FC4).

Quoted 1 line

Where can I find the runcon/newrole source code?

runcon is part of coreutils, so it would be in the coreutils SRPM, or you can just grab coreutils-selinux.patch.

newrole is part of policycoreutils, so you can grab that SRPM or upstream tar ball.

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.