summaryrefslogtreecommitdiff
path: root/ext/standard/mail.c
diff options
context:
space:
mode:
authorMarkus Fischer <mfischer@php.net>2002-03-16 12:45:43 +0000
committerMarkus Fischer <mfischer@php.net>2002-03-16 12:45:43 +0000
commitd4e63bc5bf1dacce00f317bc2b3b759f6f6138d7 (patch)
tree5633faef833e805ae7f1ecb40f3bbe8fcd7b8ad5 /ext/standard/mail.c
parent01e5d78b8051d7dca7e8fbd49098f1d9ca476d12 (diff)
downloadphp-git-d4e63bc5bf1dacce00f317bc2b3b759f6f6138d7.tar.gz
- Raise warning when trying to execute non-executeable shell
for mail delivery binary.
Diffstat (limited to 'ext/standard/mail.c')
-rw-r--r--ext/standard/mail.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/ext/standard/mail.c b/ext/standard/mail.c
index 7600d3eeb0..68e10edc1e 100644
--- a/ext/standard/mail.c
+++ b/ext/standard/mail.c
@@ -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;
}