ID: 40083 User updated by: tuxracer69 at gmail dot com Reported By: tuxracer69 at gmail dot com -Status: Feedback +Status: Open Bug Type: Unknown/Other Function Operating System: Linux debi 2.6.17-2-k7 #1 SMP Fr PHP Version: 5.2.0 New Comment:
Hi Tony, I saw you replaced the string RETVAL_ by the string RETURN_ in the php_milter.c code. And I confirm that works *fine* now. Thank you. -- Please, please, please, do not remove the SAPI from the distribution. Leaving it as 'experimental' is OK but removing it would be a drama. With that many spam on the Internet, it is *so* cool to be able to use our favorite programming language to fight spam or manipulate mails! Please don't force me to use C or Perl to talk to sendmail ;)(Even so there is huge amount of work done with Perl). I think the SAPI code is relatively small, so not not complicated to maintain. As so many programs already depend on the sendmail milter API, we can hope they won't change it soon. We, the user base, will keep reporting the bugs we find to keep this part of the code up to date. I will also try to publish some tutorials on the Internet to let people know about this SAPI. Thanks again for your help and the very fast fix. Previous Comments: ------------------------------------------------------------------------ [2007-01-10 12:04:27] [EMAIL PROTECTED] Please try the next snapshot from http://snaps.php.net, it should be fixed there. (Though I would not recommend using this SAPI, as it's unmaintained for a long time). ------------------------------------------------------------------------ [2007-01-10 11:58:38] tuxracer69 at gmail dot com Hi Iliia, I confirm it is bug in PHP and I even provide a fix below ;) and thus reopen this bug. In the file PHPROOT/sapi/milter/php_milter.c the last line in the function PHP_FUNCTION(smfi_getsymval) (i.e. the line RETVAL_NULL(); ) seems to be always called and thus the function when called in PHP always return NULL. Although I am not a SAPI expert (nor a C expert BTW) and thus do not understand why it is always called, removing this line and considering each case fixes the bug. Iliia could you please confirm this? Thanks Alex ==== here is an example of code fixing the bug ====== PHP_FUNCTION(smfi_getsymval) { char *symname, *ret; int len; /* valid in any callback */ if (MG(state) == MLFI_NONE) { /*php_error(E_WARNING, IS_NONE, get_active_function_name(TSRMLS_C));*/ RETVAL_STRING("MLFI_NONE", 1); } else { if (zend_parse_parameters(1 TSRMLS_CC, "s", &symname, &len) == SUCCESS) { if ((ret = smfi_getsymval(MG(ctx), symname)) != NULL) { RETVAL_STRING(ret, 1); } else { RETVAL_STRING("isnull", 1); } } else { RETVAL_STRING("zend_parse_parameters returned FAILURE", 1); } } } Note that if I just add again the line RETVAL_NULL(); at the bottom of the function above, I will again get a NULL string all the time. ------------------------------------------------------------------------ [2007-01-10 03:52:03] [EMAIL PROTECTED] Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. The function is a direct wrapper around smfi_getsymval() milter function. So the fact it does not return anything can be traced directly to milter and not PHP. ------------------------------------------------------------------------ [2007-01-09 20:51:26] tuxracer69 at gmail dot com Description: ------------ The milter SAPI seems unable to get the values of the sendmail macros using the smfi_getsymval function. My steup: 0) I compile PHP with "--with-milter --disable-cli --disable-cgi" 1) I create a script milter1.php (code below) 2) I insert in my /etc/mail/sendmail.mc the two lines below: ====== define(`MILTER',`1')dnl INPUT_MAIL_FILTER(`php-milter1',`S=local:/tmp/milter.sock,F=T,T=S:10m;R:10m;E:10m')dnl ====== 3) I start the milter with: php-milter -D -p /tmp/milter.sock milter1.php 4) I forge a mail to localhot using telnet to port 25 5) I look at the milter logs which shoud display the vaue of the "i" sendmail macro (the sendmail queueid). Reproduce code: --------------- <?php function milter_log($msg) { $GLOBALS['log'] = fopen("/var/log/milter.log", "a"); fwrite($GLOBALS['log'], date("[H:i:s d.m.Y] p").getmypid()."\t{$msg}\n"); fclose($GLOBALS['log']); } function milter_init() { milter_log("-- startup --"); milter_log("milter_init()"); } function milter_envfrom($args){ $queueid=smfi_getsymval("i"); milter_log("queueid=".$queueid); milter_log("milter_envfrom(args[])"); foreach ($args as $ix => $arg) { milter_log("\targs[$ix] = $arg"); } } ?> Expected result: ---------------- After having started the milter: # php-milter -D -p /tmp/milter.sock milter1.php I forge a mail: # telnet localhost 25 Trying 127.0.0.1... Connected to debi. Escape character is '^]'. 220 debi.local. ESMTP Sendmail 8.13.7/8.13.7/Debian-2; Tue, 9 Jan 2007 21:25:35 +0100; (No UCE/UBE) logging access from: debi(OK)-debi [127.0.0.1] helo me 250 debi.local. Hello debi [127.0.0.1], pleased to meet you mail from: [EMAIL PROTECTED] 250 2.1.0 [EMAIL PROTECTED] Sender ok quit 221 2.0.0 debi.local. closing connection Connection closed by foreign host. I get the queueid from the sendmail logs: # tail -n 1 /var/log/mail.log Jan 9 21:25:55 debi sm-mta[14429]: l09KPZRk014429: [EMAIL PROTECTED], size=0, class=0, nrcpts=0, proto=SMTP, daemon=MTA-v4, relay=debi [127.0.0.1] And a would expect a line in the milter logs saying [21:25:49 09.01.2007] p14426 queueid=l09KPZRk014429 But (see below the logs I get), I can not get any value for the "i" macro. I am sure it is set. If I strace -v -f the milter I see the queueid in a read system call. Actual result: -------------- The third line in the milter logs shows a blank queueid tail -f /var/log/milter.log [21:25:26 09.01.2007] p14426 -- startup -- [21:25:26 09.01.2007] p14426 milter_init() [21:25:49 09.01.2007] p14426 queueid= [21:25:49 09.01.2007] p14426 milter_envfrom(args[]) [21:25:49 09.01.2007] p14426 args[0] = [EMAIL PROTECTED] I tried to modify my PHP code and call the macro "{i}" but it does not help. I would say it is a PHP bug and not a sendmail bug; here is my sendmail version anyway: # sendmail -d0.1 Version 8.13.7 Compiled with: DNSMAP LDAPMAP LDAP_REFERRALS LOG MAP_REGEX MATCHGECOS MILTER MIME7TO8 MIME8TO7 NAMED_BIND NETINET NETINET6 NETUNIX NEWDB NIS NISPLUS PIPELINING SASLv2 SCANF SOCKETMAP STARTTLS USERDB USE_LDAP_INIT XDEBUG ============ SYSTEM IDENTITY (after readcf) ============ (short domain name) $w = debi (canonical domain name) $j = debi.local. (subdomain name) $m = local. (node name) $k = debi ======================================================== ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40083&edit=1