php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17310 mail() function has problems with sendmail 8.12
Submitted: 2002-05-20 11:13 UTC Modified: 2002-05-20 13:44 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: glen at broadpool dot com Assigned:
Status: Not a bug Package: Mail related
PHP Version: 4.2.1 OS: FreeBSD 4.6-RC #5
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: glen at broadpool dot com
New email:
PHP Version: OS:

 

 [2002-05-20 11:13 UTC] glen at broadpool dot com
I recently upgraded my server to PHP 4.1.2 and sendmail 8.12. Once both upgrades were complete, I can no longer send mail using the PHP mail() function.

sendmail 8.12 introduced a number a security features. Among these are the fact that the mail queue directory (/var/spool/mqueue) is now has the permissions 0700; i.e., it's not readable or writeable by anyone other than root.

It *appears* (I'm not familiar with PHP internals) that the PHP mail() function attempts to chdir to the /var/spool/mqueue directory. When I attempt to send mail using PHP's mail() function, this is the usual result:

May 20 08:07:10 virgil sendmail[667]: NOQUEUE: SYSER(www): can not chdir(/var/spool/mqueue/): Permission denied

If I relax the permissions on the mqueue directory, that error goes away and a queue file is created; however, sendmail now reports that there is a bogus queue file in the mqueue directory, and refuses to send it (this is another of sendmail's new security features to prevent unauthorized mail).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-20 12:35 UTC] mfischer@php.net
This is a configuration issue with Sendmail, not with PHP. PHP is just invoking the sendmail binary (which probably isn't setuid for /var/spool/mqueue).
 [2002-05-20 12:44 UTC] glen at broadpool dot com
Not true. I've confirmed all the sendmail settings, including the setuid bit for the sendmail group. For some reason, something in PHP is trying to chdir to /var/spool/mqueue, which is owned by root and does not have group/world read or write permissions. The problem ONLY occurs with PHP mail().
 [2002-05-20 12:46 UTC] mfischer@php.net
Ok, let's see what we can do here. Btw, I still think it's an issue not related to PHP.

However, try to strace the PHP binary and see if it's really doping the chdir() itself
 [2002-05-20 12:52 UTC] rasmus@php.net
Nowhere in the mail() code do we do a chdir().  We fetch the sendmail_cmd as configured in the php.ini file, play a bit with the mail() function arguments to get them into the right format and then we open a pipe to the configured sendmail_cmd using a popen() call.  Then we fprintf() the data to that open pipe and finally pclose().  If something is doing a chdir() it is not PHP.
 [2002-05-20 13:28 UTC] glen at broadpool dot com
AAaarrgh. I believe you. I also believe what I'm seeing, which is that sendmail, when invoked by PHP, fails with the error. Perhaps it is a sendmail configuration problem, but I've checked and rechecked it over and over again, and everything appears to match the sendmail/SECURITY document.
 [2002-05-20 13:38 UTC] rasmus@php.net
Try: su - nobody  (or whatever your web user id is) and then run the sendmail command configured in your php.ini file.  Most likely "sendmail -t -i" on a text file that has the various headers and a body in it.  See if that works.  My guess is that you will have the same problem in which case PHP is completely out of the picture.
 [2002-05-20 13:44 UTC] mfischer@php.net
No doubts, not a PHP issue.
 [2002-05-20 19:09 UTC] glen at broadpool dot com
thanks for your assistance. I guess it is a sendmail problem; I scrapped everything and did a "make world" to reinstall; it's still having problems. I get weirder problems depending upon the command line specified in php.ini. According to the sendmail docs, it's a setgid program, and you should invoke it with "-Ac" which uses submit.cf. However, THAT (which is supposedly the correct way to do thing) seems to cause some problem with NIS; I get repeated "yp_match: RPC timed out" errors when I do that.

If I invoke sendmail with "-t -i", it does not appear to respect the end of file; it reads anything input, and then hangs. 

Anyway, like you said, probably not a PHP problem, though Lord knows I have no idea what else to do. Been working about 16 hours trying to fix this one.

Glen
 [2002-05-20 19:11 UTC] glen at broadpool dot com
Damn. I changed /usr/libexec/sendmail/sendmail from setgid to setuid and now everything's working like it's supposed to. Piece of shit software...
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 11 11:01:27 2024 UTC