Trouble sending mail from PHP scripts

Scott Gifford sgifford at suspectclass.com
Sun Jan 2 06:01:11 UTC 2011


On Fri, Dec 31, 2010 at 4:19 AM, Dominick Grift <domg472 at gmail.com> wrote:
[ ... ]

>  > Maybe it makes sense to run the mail server backend in unconfined_t?
>  That
> > seems risky in its own way.
>
> Why not use the mta module policy for your qmail other mtas also run in
> this domain. i guess yoou could simply label qmail executable file
> sendmail_exec_t?
>

Thanks, that is a good idea, I tried it out and am not getting so many
warnings in my audit.log.  I am concerned they may just be suppressed
though; when I look at policies for system_mail_t by running:

sesearch -a -s system_mail_t


I see lines like this:

dontaudit system_mail_t httpd_t : file { ioctl read getattr lock };
dontaudit system_mail_t httpd_t : tcp_socket { read write };


Since I am currently running in permissive mode, those lines seem like they
would mask the problem without solving it.  Maybe I will need to set up a
dev server to test this.

[ ... ]

> >  > Third, is there a useful guide for troubleshooting SELinux policy
> >> execution?
> >>>  When things don't work as I expect them to, it's hard to find the
> reason
> >> if
> >>> it's not obvious from the audit.log.
> >>
> >> Examples?
> >>
> >> It usually boils down to analyzing AVC denials.
> >>
> >
> > I may be able to find what I need in the AVC logs.  I think I'm just not
> yet
> > confident enough that my policies work as they should, and it would be
> > reassuring to see the domain transitions as they run.
>
> stuff only transitions if you tell it to transition.
>
> you can also use sesearch to see where your domain is allowed to
> transition:
>
> example:
>
> sesearch --allow -SC -s ntpd_t -t domain -c process -p transition
>

Thanks, that is a great tool I did not know about!

So here then is an example I am not sure how to troubleshoot.

I don't understand how the mail backend is able to send messages without
generating AVC denials.  "ps -efZ" shows qmail-send, qmail's main backend
process, and qmail-rspawn, which handles remote messages, as running with
type "init_t".  That makes sense, since they are started by a sequence that
begins with init(8) and don't transition to any other context.  To send the
mail, it needs to read the configuration files, which are labeled
"etc_mail_t", and read and write queue files labeled "mqueue_spool_t".  It
shouldn't have permission to do anything with those files:

$ sesearch -a -s init_t |egrep 'etc_mail|mqueue'
$


But somehow it does, or at least seems to to it without generating any AVC
denials.

Since this is succeeding, there's nothing in the audit.log, and from my own
inspection the contexts shouldn't allow this.  If I were programming I would
use a debugger or strace(1) to figure out exactly what is going on, but I'm
not sure if there is an equivalent tool here, or what my options are apart
from staring at the same information and hoping for insight.

 [ ... ]

> > I have had some problems with failed assertions, which have far too
> little
> > debug information to troubleshoot them with anything but guesswork, but
> > that's probably a separate issue.
>
> examples?
>

For example, early on in trying out a qmail policy, I forgot this line:

domain_type(mail_qmail_queue_t)

The policy compiled fine, but when I tried to load it I got these errors:

   - libsepol.check_assertion_helper: assertion on line 0 violated by allow
   mail_qmail_queue_t sendmail_t:process { sigchld };
   - libsepol.check_assertion_helper: assertion on line 0 violated by allow
   mail_qmail_queue_t httpd_sys_script_t:process { sigchld };
   - libsepol.check_assertion_helper: assertion on line 0 violated by allow
   mail_qmail_queue_t httpd_t:process { sigchld };
   - libsepol.check_assertion_helper: assertion on line 0 violated by allow
   mail_qmail_queue_t mail_qmail_queue_t:process { transition sigchld };
   - libsepol.check_assertion_helper: assertion on line 0 violated by allow
   mail_qmail_queue_t unconfined_t:process { sigchld };
   - libsepol.check_assertion_helper: assertion on line 0 violated by allow
   sendmail_t mail_qmail_queue_t:process { transition sigchld };
   - libsepol.check_assertion_helper: assertion on line 0 violated by allow
   httpd_sys_script_t mail_qmail_queue_t:process { transition sigchld };
   - libsepol.check_assertion_helper: assertion on line 0 violated by allow
   httpd_t mail_qmail_queue_t:process { transition sigchld };
   - libsepol.check_assertion_helper: assertion on line 0 violated by allow
   unconfined_t mail_qmail_queue_t:process { transition sigchld };
   - libsepol.check_assertion_helper: assertion on line 0 violated by allow
   sendmail_t mail_qmail_queue_t:process { transition };
   - libsepol.check_assertion_helper: assertion on line 0 violated by allow
   httpd_sys_script_t mail_qmail_queue_t:process { transition };
   - libsepol.check_assertion_helper: assertion on line 0 violated by allow
   httpd_t mail_qmail_queue_t:process { transition };
   - libsepol.check_assertion_helper: assertion on line 0 violated by allow
   unconfined_t mail_qmail_queue_t:process { transition };
   - libsepol.check_assertions: 13 assertion violations occured
   - libsemanage.semanage_expand_sandbox: Expand module failed
   - semodule:  Failed!

Eventually after staring at it awhile, a bit of googling, and some lucky
guesses I was able to figure it out.

Are there any tools or guidelines that can help with these sorts of things?

Thanks again for all of your help!

-----Scott.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.fedoraproject.org/pipermail/selinux/attachments/20110102/88f70f2b/attachment.html 


More information about the selinux mailing list