]> granicus.if.org Git - php/commitdiff
- Raise warning when trying to execute non-executeable shell
authorMarkus Fischer <mfischer@php.net>
Sat, 16 Mar 2002 12:45:43 +0000 (12:45 +0000)
committerMarkus Fischer <mfischer@php.net>
Sat, 16 Mar 2002 12:45:43 +0000 (12:45 +0000)
  for mail delivery binary.

ext/mbstring/mbstring.c
ext/standard/basic_functions.c
ext/standard/mail.c
ext/standard/php_mail.h

index c1e19b168c89703b642214d7932edeeb671d3c7e..b29cde4612ce917f7af4dae51a5710ad621797b2 100644 (file)
@@ -2796,7 +2796,7 @@ PHP_FUNCTION(mb_send_mail)
                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 52af756dfc01388cd27c705dac2f0570c231e4e4..5f50c1c07e7994e5f527ac5733828d869cadec79 100644 (file)
@@ -1515,8 +1515,7 @@ PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers T
                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 7600d3eeb014ac1833471113e16d77d6a82ee2ab..68e10edc1ec6d226aa7b1c9ebdd888eb1eaab123 100644 (file)
@@ -96,7 +96,7 @@ PHP_FUNCTION(mail)
        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_FUNCTION(mail)
 
 /* {{{ 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 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
 #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 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
 #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 @@ PHPAPI int php_mail(char *to, char *subject, char *message, char *headers, char
                        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 a182a5bb5f3a2e63b32fced487109b9357bda823..b96c85a936ec8703fe9e749b4fd5fc500fcf93bd 100644 (file)
@@ -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