Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 182187
Collapse All | Expand All

(-)php-5.2.2.vanilla/ext/standard/mail.c (-11 / +59 lines)
Lines 23-28 Link Here
23
#include <stdio.h>
23
#include <stdio.h>
24
#include "php.h"
24
#include "php.h"
25
#include "ext/standard/info.h"
25
#include "ext/standard/info.h"
26
#include "ext/standard/php_string.h"
27
#include "ext/standard/basic_functions.h"
26
28
27
#if HAVE_SYSEXITS_H
29
#if HAVE_SYSEXITS_H
28
#include <sysexits.h>
30
#include <sysexits.h>
Lines 62-67 Link Here
62
		*p = ' ';				\
64
		*p = ' ';				\
63
	}						\
65
	}						\
64
66
67
extern long php_getuid(void);
65
68
66
/* {{{ proto int ezmlm_hash(string addr)
69
/* {{{ proto int ezmlm_hash(string addr)
67
   Calculate EZMLM list hash value. */
70
   Calculate EZMLM list hash value. */
Lines 201-222 Link Here
201
	int ret;
204
	int ret;
202
	char *sendmail_path = INI_STR("sendmail_path");
205
	char *sendmail_path = INI_STR("sendmail_path");
203
	char *sendmail_cmd = NULL;
206
	char *sendmail_cmd = NULL;
207
	char *mail_log = INI_STR("mail.log");
208
	char *hdr = headers;
209
210
#define MAIL_RET(val) \
211
	if (hdr != headers) {	\
212
		efree(hdr);	\
213
	}	\
214
	return val;	\
215
216
	if (mail_log) {
217
		char *tmp;
218
		int l = spprintf(&tmp, 0, "mail() on [%s:%d]: To: %s -- Headers: %s\n", zend_get_executed_filename(TSRMLS_C), zend_get_executed_lineno(TSRMLS_C), to, hdr ? hdr : "");
219
		if (hdr) { /* find all \r\n instances and replace them with spaces, so a log line is always one line long */ 
220
			char *p = tmp;
221
			while ((p = strpbrk(p, "\r\n"))) {
222
				*p = ' ';
223
			}
224
			tmp[l - 1] = '\n';
225
		}
226
		_php_error_log(3, tmp, mail_log, NULL TSRMLS_CC);
227
		efree(tmp);
228
	}
229
	if (PG(mail_x_header)) {
230
		char *tmp = zend_get_executed_filename(TSRMLS_C);
231
		char *f;
232
		size_t f_len;
233
		php_basename(tmp, strlen(tmp), NULL, 0, &f, &f_len TSRMLS_CC);
234
		
235
		if (!sendmail_path) {
236
			/* sending via SMTP requires \r\n, but ... */
237
			if (headers != NULL) {
238
				spprintf(&hdr, 0, "%s\r\nX-PHP-Originating-Script: %ld:%s\r\n", headers, php_getuid(), f);
239
			} else {
240
				spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\r\n", php_getuid(), f);
241
			}
242
		} else {
243
			/* ... sending via sendmail requires \n */
244
			if (headers != NULL) {
245
				spprintf(&hdr, 0, "%s\nX-PHP-Originating-Script: %ld:%s\n", headers, php_getuid(), f);
246
			} else {
247
				spprintf(&hdr, 0, "X-PHP-Originating-Script: %ld:%s\n", php_getuid(), f);
248
			}
249
		}
250
		efree(f);
251
	}
204
252
205
	if (!sendmail_path) {
253
	if (!sendmail_path) {
206
#if (defined PHP_WIN32 || defined NETWARE)
254
#if (defined PHP_WIN32 || defined NETWARE)
207
		/* handle old style win smtp sending */
255
		/* handle old style win smtp sending */
208
		if (TSendMail(INI_STR("SMTP"), &tsm_err, &tsm_errmsg, headers, subject, to, message, NULL, NULL, NULL TSRMLS_CC) == FAILURE) {
256
		if (TSendMail(INI_STR("SMTP"), &tsm_err, &tsm_errmsg, hdr, subject, to, message, NULL, NULL, NULL TSRMLS_CC) == FAILURE) {
209
			if (tsm_errmsg) {
257
			if (tsm_errmsg) {
210
				php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", tsm_errmsg);
258
				php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", tsm_errmsg);
211
				efree(tsm_errmsg);
259
				efree(tsm_errmsg);
212
			} else {
260
			} else {
213
				php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", GetSMErrorText(tsm_err));
261
				php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", GetSMErrorText(tsm_err));
214
			}
262
			}
215
			return 0;
263
			MAIL_RET(0);
216
		}
264
		}
217
		return 1;
265
		MAIL_RET(1);
218
#else
266
#else
219
		return 0;
267
		MAIL_RET(0);
220
#endif
268
#endif
221
	}
269
	}
222
	if (extra_cmd != NULL) {
270
	if (extra_cmd != NULL) {
Lines 242-254 Link Here
242
		if (EACCES == errno) {
290
		if (EACCES == errno) {
243
			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Permission denied: unable to execute shell to run mail delivery binary '%s'", sendmail_path);
291
			php_error_docref(NULL TSRMLS_CC, E_WARNING, "Permission denied: unable to execute shell to run mail delivery binary '%s'", sendmail_path);
244
			pclose(sendmail);
292
			pclose(sendmail);
245
			return 0;
293
			MAIL_RET(0);
246
		}
294
		}
247
#endif
295
#endif
248
		fprintf(sendmail, "To: %s\n", to);
296
		fprintf(sendmail, "To: %s\n", to);
249
		fprintf(sendmail, "Subject: %s\n", subject);
297
		fprintf(sendmail, "Subject: %s\n", subject);
250
		if (headers != NULL) {
298
		if (hdr != NULL) {
251
			fprintf(sendmail, "%s\n", headers);
299
			fprintf(sendmail, "%s\n", hdr);
252
		}
300
		}
253
		fprintf(sendmail, "\n%s\n", message);
301
		fprintf(sendmail, "\n%s\n", message);
254
		ret = pclose(sendmail);
302
		ret = pclose(sendmail);
Lines 264-279 Link Here
264
#endif
312
#endif
265
#endif
313
#endif
266
		{
314
		{
267
			return 0;
315
			MAIL_RET(0);
268
		} else {
316
		} else {
269
			return 1;
317
			MAIL_RET(1);
270
		}
318
		}
271
	} else {
319
	} else {
272
		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not execute mail delivery program '%s'", sendmail_path);
320
		php_error_docref(NULL TSRMLS_CC, E_WARNING, "Could not execute mail delivery program '%s'", sendmail_path);
273
		return 0;
321
		MAIL_RET(0);
274
	}
322
	}
275
323
276
	return 1; /* never reached */
324
	MAIL_RET(1); /* never reached */
277
}
325
}
278
/* }}} */
326
/* }}} */
279
327
(-)php-5.2.2.vanilla/main/main.c (+2 lines)
Lines 316-321 Link Here
316
316
317
	PHP_INI_ENTRY("SMTP",						"localhost",PHP_INI_ALL,		NULL)
317
	PHP_INI_ENTRY("SMTP",						"localhost",PHP_INI_ALL,		NULL)
318
	PHP_INI_ENTRY("smtp_port",					"25",		PHP_INI_ALL,		NULL)
318
	PHP_INI_ENTRY("smtp_port",					"25",		PHP_INI_ALL,		NULL)
319
	STD_PHP_INI_BOOLEAN("mail.add_x_header",			"0",		PHP_INI_SYSTEM,		OnUpdateBool,			mail_x_header,			php_core_globals,	core_globals)
320
	STD_PHP_INI_ENTRY("mail.log",					NULL,		PHP_INI_SYSTEM,		OnUpdateString,			mail_log,			php_core_globals,	core_globals)
319
	PHP_INI_ENTRY("browscap",					NULL,		PHP_INI_SYSTEM,		NULL)
321
	PHP_INI_ENTRY("browscap",					NULL,		PHP_INI_SYSTEM,		NULL)
320
	PHP_INI_ENTRY("memory_limit",				"128M",		PHP_INI_ALL,		OnChangeMemoryLimit)
322
	PHP_INI_ENTRY("memory_limit",				"128M",		PHP_INI_ALL,		OnChangeMemoryLimit)
321
	PHP_INI_ENTRY("precision",					"14",		PHP_INI_ALL,		OnSetPrecision)
323
	PHP_INI_ENTRY("precision",					"14",		PHP_INI_ALL,		OnSetPrecision)
(-)php-5.2.2.vanilla/main/php_globals.h (+3 lines)
Lines 71-76 Link Here
71
	char *unserialize_callback_func;
71
	char *unserialize_callback_func;
72
	long serialize_precision;
72
	long serialize_precision;
73
73
74
	zend_bool mail_x_header;
75
	char *mail_log;
76
74
	char *safe_mode_exec_dir;
77
	char *safe_mode_exec_dir;
75
78
76
	long memory_limit;
79
	long memory_limit;
(-)php-5.2.2.vanilla/php.ini-dist (+6 lines)
Lines 686-691 Link Here
686
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
686
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
687
;sendmail_path =
687
;sendmail_path =
688
688
689
; Add X-PHP-Originaiting-Script: that will include uid of the script followed by the filename
690
mail.add_x_header = On
691
692
; Log all mail() calls including the full path of the script, line #, to address and headers
693
mail.log =
694
689
; Force the addition of the specified parameters to be passed as extra parameters
695
; Force the addition of the specified parameters to be passed as extra parameters
690
; to the sendmail binary. These parameters will always replace the value of
696
; to the sendmail binary. These parameters will always replace the value of
691
; the 5th parameter to mail(), even in safe mode.
697
; the 5th parameter to mail(), even in safe mode.
(-)php-5.2.2.vanilla/php.ini-recommended (+6 lines)
Lines 731-736 Link Here
731
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
731
; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
732
;sendmail_path =
732
;sendmail_path =
733
733
734
; Add X-PHP-Originaiting-Script: that will include uid of the script followed by the filename
735
mail.add_x_header = On
736
737
; Log all mail() calls including the full path of the script, line #, to address and headers
738
mail.log =
739
734
; Force the addition of the specified parameters to be passed as extra parameters
740
; Force the addition of the specified parameters to be passed as extra parameters
735
; to the sendmail binary. These parameters will always replace the value of
741
; to the sendmail binary. These parameters will always replace the value of
736
; the 5th parameter to mail(), even in safe mode.
742
; the 5th parameter to mail(), even in safe mode.

Return to bug 182187