cvs: php4 /ext/mbstring mbstring.c /ext/standard basic_functions.c mail.c php_mail.h

From: Date: Sat, 16 Mar 2002 12:45:43 +0000
Subject: cvs: php4 /ext/mbstring mbstring.c /ext/standard basic_functions.c mail.c php_mail.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-10234@lists.php.net to get a copy of this message
mfischer Sat Mar 16 07:45:43 2002 EDT Modified files: /php4/ext/mbstring mbstring.c /php4/ext/standard basic_functions.c mail.c php_mail.h Log: - Raise warning when trying to execute non-executeable shell for mail delivery binary. Index: php4/ext/mbstring/mbstring.c diff -u php4/ext/mbstring/mbstring.c:1.48 php4/ext/mbstring/mbstring.c:1.49 --- php4/ext/mbstring/mbstring.c:1.48 Thu Feb 28 03:26:20 2002 +++ php4/ext/mbstring/mbstring.c Sat Mar 16 07:45:41 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mbstring.c,v 1.48 2002/02/28 08:26:20 sebastian Exp $ */ +/* $Id: mbstring.c,v 1.49 2002/03/16 12:45:41 mfischer Exp $ */ /* * PHP4 Multibyte String module "mbstring" (currently only for Japanese) @@ -2796,7 +2796,7 @@ extra_cmd = Z_STRVAL_PP(argv[4]); } - if (!err && php_mail(to, subject, message, headers, extra_cmd)){ + if (!err && php_mail(to, subject, message, headers, extra_cmd TSRMLS_CC)) { RETVAL_TRUE; } else { RETVAL_FALSE; Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.449 php4/ext/standard/basic_functions.c:1.450 --- php4/ext/standard/basic_functions.c:1.449 Fri Mar 15 20:28:38 2002 +++ php4/ext/standard/basic_functions.c Sat Mar 16 07:45:42 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.449 2002/03/16 01:28:38 wez Exp $ */ +/* $Id: basic_functions.c,v 1.450 2002/03/16 12:45:42 mfischer Exp $ */ #include "php.h" #include "php_streams.h" @@ -1515,8 +1515,7 @@ case 1: /*send an email */ { #if HAVE_SENDMAIL - if (!php_mail - (opt, "PHP error_log message", message, headers, NULL)) { + if (!php_mail(opt, "PHP error_log message", message, headers, NULL TSRMLS_CC)) { return FAILURE; } #else Index: php4/ext/standard/mail.c diff -u php4/ext/standard/mail.c:1.48 php4/ext/standard/mail.c:1.49 --- php4/ext/standard/mail.c:1.48 Thu Feb 28 03:26:46 2002 +++ php4/ext/standard/mail.c Sat Mar 16 07:45:43 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: mail.c,v 1.48 2002/02/28 08:26:46 sebastian Exp $ */ +/* $Id: mail.c,v 1.49 2002/03/16 12:45:43 mfischer Exp $ */ #include <stdlib.h> #include <ctype.h> @@ -96,7 +96,7 @@ if(extra_cmd) extra_cmd = php_escape_shell_arg(extra_cmd); - if (php_mail(to, subject, message, headers, extra_cmd)) { + if (php_mail(to, subject, message, headers, extra_cmd TSRMLS_CC)) { RETVAL_TRUE; } else { RETVAL_FALSE; @@ -108,7 +108,7 @@ /* {{{ php_mail */ -PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd) +PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd TSRMLS_DC) { #ifdef PHP_WIN32 int tsm_err; @@ -122,7 +122,7 @@ #ifdef PHP_WIN32 /* handle old style win smtp sending */ if (TSendMail(INI_STR("SMTP"), &tsm_err, headers, subject, to, message) != SUCCESS){ - php_error(E_WARNING, GetSMErrorText(tsm_err)); + php_error(E_WARNING, "%s() %s", get_active_function_name(TSRMLS_C), GetSMErrorText(tsm_err)); return 0; } return 1; @@ -142,12 +142,23 @@ #ifdef PHP_WIN32 sendmail = popen(sendmail_cmd, "wb"); #else + /* Since popen() doesn't indicate if the internal fork() doesn't work + * (e.g. the shell can't be executed) we explicitely set it to 0 to be + * sure we don't catch any older errno value. */ + errno = 0; sendmail = popen(sendmail_cmd, "w"); #endif if (extra_cmd != NULL) efree (sendmail_cmd); if (sendmail) { +#ifndef PHP_WIN32 + if (EACCES == errno) { + php_error(E_WARNING, "%s() permission denied; unable to execute shell to run mail delivery binary", + get_active_function_name(TSRMLS_C)); + return 0; + } +#endif fprintf(sendmail, "To: %s\n", to); fprintf(sendmail, "Subject: %s\n", subject); if (headers != NULL) { @@ -170,7 +181,8 @@ return 1; } } else { - php_error(E_WARNING, "Could not execute mail delivery program"); + php_error(E_WARNING, "%s() could not execute mail delivery program", + get_active_function_name(TSRMLS_C)); return 0; } Index: php4/ext/standard/php_mail.h diff -u php4/ext/standard/php_mail.h:1.12 php4/ext/standard/php_mail.h:1.13 --- php4/ext/standard/php_mail.h:1.12 Thu Feb 28 03:26:47 2002 +++ php4/ext/standard/php_mail.h Sat Mar 16 07:45:43 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_mail.h,v 1.12 2002/02/28 08:26:47 sebastian Exp $ */ +/* $Id: php_mail.h,v 1.13 2002/03/16 12:45:43 mfischer Exp $ */ #ifndef PHP_MAIL_H #define PHP_MAIL_H @@ -26,7 +26,7 @@ PHP_FUNCTION(mail); PHP_FUNCTION(ezmlm_hash); PHP_MINFO_FUNCTION(mail); -PHPAPI extern int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd); +PHPAPI extern int php_mail(char *to, char *subject, char *message, char *headers, char *extra_cmd TSRMLS_DC); #endif

« previous php.cvs (#10234) next »