remove hacky php 5.3
Hanno Böck

Hanno Böck commited on 2010-07-30 00:15:55
Zeige 10 geänderte Dateien mit 0 Einfügungen und 2983 Löschungen.

... ...
@@ -1,15 +0,0 @@
1
-AUX 20php5-envd 145 RMD160 8c81fb7dc1d1ddf16fd956d748514db3bcb27603 SHA1 f1cef57c0def8e2c5422aaf136f40b4ff47801d2 SHA256 efaae9e6ae5f7010e073c2ab6d8a9dda009f0707c7d7b0c027e142c94f7041a4
2
-AUX 70_mod_php5.conf-apache2 490 RMD160 745bdb5db622577f473703d5ee8dc7f3c66f8f0c SHA1 7daf9c9ec2e6d108f850981853f9f4f599be0b71 SHA256 5667d06cb7a18c30d11decd28d55b87e36287c76c4d3a450b1cb37271e7fdcd1
3
-AUX 70_mod_php5.conf-apache2-r1 374 RMD160 ca06cdc9d1a3dc4129a60c938ee3a1b542497fbb SHA1 4733066b6324c5870e716485484c44c7c26a9ff1 SHA256 815c1ca23c9afe8479568ceaac4057eb91ea5444fbd863866b29adb4eea2c82b
4
-AUX 70_mod_php5_concurr.conf-apache2 414 RMD160 1783b6c830119f021c3fb6cb35a631f43c4fa70c SHA1 09f9076f35bc84994fc8c687b4befc0400475f1a SHA256 ccc3bc073eafc83f98049679a411801e80f84620bd51c37c36de2b9ee9492aa2
5
-AUX 70_mod_php5_concurr.conf-apache2-r1 376 RMD160 4f7de5c0784b6191450b5c1a7de7ad941620e199 SHA1 c42a23bd7a1d3e8c7e0ac906f50f180116349f76 SHA256 c05f499d9c8927391c586b94716a9f59d63767165552ea527ec7ff63c36eaa40
6
-AUX php-5.3.1-sha512.diff 58046 RMD160 1479068ed76c041427cdd85f18911b76f5d9bf02 SHA1 6745a2ea314554ddf3550e9ebaa192bc2ed04c8a SHA256 f152e27055e26817448f60b88d8d0738cc3def6d6f10c2d7fbbd84e5a096a344
7
-AUX php5-ldvs 22 RMD160 5846dab2745b68a88175dd4e72d0b8cf4756dd46 SHA1 592398c92575adb14ec972847ce2aca28a7b9c2c SHA256 b79d0e52b1b3b4543b31ad45525ae1c2814a27ea8e676772ab10bf6fb12dfe79
8
-DIST php-5.3.1.tar.bz2 10457046 RMD160 01183a9f752ce5982a7b91dcd43721fd1b9cd88b SHA1 be08ca9337a4962cd4acf8709cd695e1e31c1149 SHA256 9803ce0d6eb2ae072f0149158f5921135b47b633ef5632b4688b30a23be20dba
9
-DIST php-5.3.2.tar.bz2 10477662 RMD160 60a8aac0d51511ecaf8dcad9d31bdf072c0c99cf SHA1 79ea4ee3da3a7542d1e348ac963a5b38bcbb4b6b SHA256 9a380a574adcb3a9abe3226e7c3a9bae619e8a1b90842ec2a7edf0ad92afdeda
10
-DIST php-patchset-5.3.1-r0.tar.bz2 7301 RMD160 2582efa0b514d9c744a403b84b9ea185f1d8fd6e SHA1 9177c25ae67c301fbe038ae1cc7d55a6a16bb06f SHA256 2dbd8743d309fffda3e2896256d26631d2522eab3ba759c81192d8cc5950bb1f
11
-DIST php-patchset-5.3.2-r0.tar.bz2 6877 RMD160 e4a0b9bf880dbb28f857196d578d904499c77612 SHA1 ae9069d137e7901d0d173fac7c833a767fe6f768 SHA256 2c23f154e9ed1291bf3a6283b9e33103509776fe14e23cbd26b44a6331bf69c5
12
-DIST suhosin-patch-5.3.1RC1-0.9.8.patch.gz 38250 RMD160 cfb60da9b4142b0d3fd0f7e193fe2419ba9a5d31 SHA1 d3e8f83f81311a5f382b545cbd745dcedd5f3c93 SHA256 46a3aff061b4d6c7f3721aa65824177c36821631247a502bc77e120559a37721
13
-DIST suhosin-patch-5.3.2-0.9.9.1.patch.gz 40847 RMD160 64d8b7ec2ec91fd7a43b0cd95c0aa0df5b666768 SHA1 c48d3f24341d3b0214ca3e980320b23864aa93ba SHA256 a61f081022888bf78997e434744d6c0604194c73a00e70c1165524a0a6329de2
14
-EBUILD php-5.3.1.ebuild 16816 RMD160 932192368c8d50c6b9b0f0fa0fdc72c3958c7237 SHA1 a1c7de3f071982526bcd224b907887b5ff011e63 SHA256 20247583d9640161710683100a0b9fe4f3ab49eaff7d923259e519ad75f11c85
15
-EBUILD php-5.3.2.ebuild 16775 RMD160 57961e9edd366f20a04c7a6354c28d4f6f8af359 SHA1 c22b5491e925a0b822cef45cfce3b87ef3145bac SHA256 791c64ee335d7c22a86bc3e7913a674ecd7f3947cc71ed2c4c2fd00c0ff8c6df
... ...
@@ -1,2 +0,0 @@
1
-MANPATH="/usr/lib/php5/man/"
2
-CONFIG_PROTECT_MASK="/etc/php/cli-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/apache2-php5/ext-active/"
... ...
@@ -1,18 +0,0 @@
1
-<IfDefine PHP5>
2
-	# Load the module first
3
-	<IfModule !mod_php5.c>
4
-		LoadModule php5_module    modules/libphp5.so
5
-	</IfModule>
6
-
7
-	# Set it to handle the files
8
-	<IfModule mod_mime.c>
9
-		AddType application/x-httpd-php .php
10
-		AddType application/x-httpd-php .phtml
11
-		AddType application/x-httpd-php .php3
12
-		AddType application/x-httpd-php .php4
13
-		AddType application/x-httpd-php .php5
14
-		AddType application/x-httpd-php-source .phps
15
-	</IfModule>
16
-
17
-	DirectoryIndex index.php index.phtml
18
-</IfDefine>
... ...
@@ -1,17 +0,0 @@
1
-<IfDefine PHP5>
2
-	# Load the module first
3
-	<IfModule !mod_php5.c>
4
-		LoadModule php5_module    modules/libphp5.so
5
-	</IfModule>
6
-
7
-	# Set it to handle the files
8
-	<FilesMatch "\.ph(p5?|tml)$">
9
-		SetHandler application/x-httpd-php
10
-	</FilesMatch>
11
-
12
-	<FilesMatch "\.phps$">
13
-		SetHandler application/x-httpd-php-source
14
-	</FilesMatch>
15
-
16
-	DirectoryIndex index.php index.phtml
17
-</IfDefine>
... ...
@@ -1,16 +0,0 @@
1
-<IfDefine PHP5>
2
-	# Load the module first
3
-	<IfModule !mod_php5.c>
4
-		LoadModule php5_module    modules/libphp5.so
5
-	</IfModule>
6
-
7
-	# Set it to handle the files
8
-	<IfModule mod_mime.c>
9
-		AddType application/x-httpd-php5 .php
10
-		AddType application/x-httpd-php5 .phtml
11
-		AddType application/x-httpd-php5 .php5
12
-		AddType application/x-httpd-php5-source .phps
13
-	</IfModule>
14
-
15
-	DirectoryIndex index.php index.phtml
16
-</IfDefine>
... ...
@@ -1,17 +0,0 @@
1
-<IfDefine PHP5>
2
-	# Load the module first
3
-	<IfModule !mod_php5.c>
4
-		LoadModule php5_module    modules/libphp5.so
5
-	</IfModule>
6
-
7
-	# Set it to handle the files
8
-	<FilesMatch "\.ph(p5?|tml)$">
9
-		SetHandler application/x-httpd-php5
10
-	</FilesMatch>
11
-
12
-	<FilesMatch "\.phps$">
13
-		SetHandler application/x-httpd-php5-source
14
-	</FilesMatch>
15
-
16
-	DirectoryIndex index.php index.phtml
17
-</IfDefine>
... ...
@@ -1,1801 +0,0 @@
1
-Index: ext/standard/crypt_sha512.c
2
-===================================================================
3
---- ext/standard/crypt_sha512.c	(Revision 0)
4
-+++ ext/standard/crypt_sha512.c	(Revision 291899)
5
-@@ -0,0 +1,831 @@
6
-+/* SHA512-based Unix crypt implementation.
7
-+   Released into the Public Domain by Ulrich Drepper <drepper@redhat.com>.  */
8
-+/* Windows VC++ port by Pierre Joye <pierre@php.net> */
9
-+
10
-+#ifndef PHP_WIN32
11
-+# include <endian.h>
12
-+# include "php.h"
13
-+# include "php_main.h"
14
-+#endif
15
-+
16
-+#include <errno.h>
17
-+#include <limits.h>
18
-+#ifdef PHP_WIN32
19
-+# include "win32/php_stdint.h"
20
-+# include "win32/php_stdbool.h"
21
-+# define __alignof__ __alignof
22
-+# define alloca _alloca
23
-+#else
24
-+# if HAVE_INTTYPES_H
25
-+#  include <inttypes.h>
26
-+# elif HAVE_STDINT_H
27
-+#  include <stdint.h>
28
-+# endif
29
-+# include <stdbool.h>
30
-+#endif
31
-+
32
-+#include <stdio.h>
33
-+#include <stdlib.h>
34
-+
35
-+#ifdef PHP_WIN32
36
-+# include <string.h>
37
-+#else
38
-+# include <sys/param.h>
39
-+# include <sys/types.h>
40
-+# if HAVE_STRING_H
41
-+#  define __USE_GNU 
42
-+#  include <string.h>
43
-+# else
44
-+#  include <strings.h>
45
-+# endif
46
-+#endif
47
-+#if 0
48
-+#ifndef stpncpy
49
-+char * stpncpy(char *dst, const char *src, size_t len)
50
-+{
51
-+	size_t n = strlen(src);
52
-+	if (n > len) {
53
-+		n = len;
54
-+	}
55
-+	return strncpy(dst, src, len) + n;
56
-+}
57
-+#endif
58
-+
59
-+#ifndef mempcpy
60
-+void * mempcpy(void * dst, const void * src, size_t len)
61
-+{
62
-+	return (((char *)memcpy(dst, src, len)) + len);
63
-+}
64
-+#endif
65
-+#endif
66
-+
67
-+#ifndef MIN
68
-+# define MIN(a, b) (((a) < (b)) ? (a) : (b))
69
-+#endif
70
-+#ifndef MAX
71
-+# define MAX(a, b) (((a) > (b)) ? (a) : (b))
72
-+#endif
73
-+
74
-+/* Structure to save state of computation between the single steps.  */
75
-+struct sha512_ctx
76
-+{
77
-+	uint64_t H[8];
78
-+
79
-+	uint64_t total[2];
80
-+	uint64_t buflen;
81
-+	char buffer[256];	/* NB: always correctly aligned for uint64_t.  */
82
-+};
83
-+
84
-+
85
-+#if PHP_WIN32 || (__BYTE_ORDER == __LITTLE_ENDIAN)
86
-+# define SWAP(n) \
87
-+  (((n) << 56)					\
88
-+   | (((n) & 0xff00) << 40)			\
89
-+   | (((n) & 0xff0000) << 24)			\
90
-+   | (((n) & 0xff000000) << 8)			\
91
-+   | (((n) >> 8) & 0xff000000)			\
92
-+   | (((n) >> 24) & 0xff0000)			\
93
-+   | (((n) >> 40) & 0xff00)			\
94
-+   | ((n) >> 56))
95
-+#else
96
-+# define SWAP(n) (n)
97
-+#endif
98
-+
99
-+/* This array contains the bytes used to pad the buffer to the next
100
-+   64-byte boundary.  (FIPS 180-2:5.1.2)  */
101
-+static const unsigned char fillbuf[128] = { 0x80, 0 /* , 0, 0, ...  */ };
102
-+
103
-+/* Constants for SHA512 from FIPS 180-2:4.2.3.  */
104
-+static const uint64_t K[80] = {
105
-+	UINT64_C (0x428a2f98d728ae22), UINT64_C (0x7137449123ef65cd),
106
-+	UINT64_C (0xb5c0fbcfec4d3b2f), UINT64_C (0xe9b5dba58189dbbc),
107
-+	UINT64_C (0x3956c25bf348b538), UINT64_C (0x59f111f1b605d019),
108
-+	UINT64_C (0x923f82a4af194f9b), UINT64_C (0xab1c5ed5da6d8118),
109
-+	UINT64_C (0xd807aa98a3030242), UINT64_C (0x12835b0145706fbe),
110
-+	UINT64_C (0x243185be4ee4b28c), UINT64_C (0x550c7dc3d5ffb4e2),
111
-+	UINT64_C (0x72be5d74f27b896f), UINT64_C (0x80deb1fe3b1696b1),
112
-+	UINT64_C (0x9bdc06a725c71235), UINT64_C (0xc19bf174cf692694),
113
-+	UINT64_C (0xe49b69c19ef14ad2), UINT64_C (0xefbe4786384f25e3),
114
-+	UINT64_C (0x0fc19dc68b8cd5b5), UINT64_C (0x240ca1cc77ac9c65),
115
-+	UINT64_C (0x2de92c6f592b0275), UINT64_C (0x4a7484aa6ea6e483),
116
-+	UINT64_C (0x5cb0a9dcbd41fbd4), UINT64_C (0x76f988da831153b5),
117
-+	UINT64_C (0x983e5152ee66dfab), UINT64_C (0xa831c66d2db43210),
118
-+	UINT64_C (0xb00327c898fb213f), UINT64_C (0xbf597fc7beef0ee4),
119
-+	UINT64_C (0xc6e00bf33da88fc2), UINT64_C (0xd5a79147930aa725),
120
-+	UINT64_C (0x06ca6351e003826f), UINT64_C (0x142929670a0e6e70),
121
-+	UINT64_C (0x27b70a8546d22ffc), UINT64_C (0x2e1b21385c26c926),
122
-+	UINT64_C (0x4d2c6dfc5ac42aed), UINT64_C (0x53380d139d95b3df),
123
-+	UINT64_C (0x650a73548baf63de), UINT64_C (0x766a0abb3c77b2a8),
124
-+	UINT64_C (0x81c2c92e47edaee6), UINT64_C (0x92722c851482353b),
125
-+	UINT64_C (0xa2bfe8a14cf10364), UINT64_C (0xa81a664bbc423001),
126
-+	UINT64_C (0xc24b8b70d0f89791), UINT64_C (0xc76c51a30654be30),
127
-+	UINT64_C (0xd192e819d6ef5218), UINT64_C (0xd69906245565a910),
128
-+	UINT64_C (0xf40e35855771202a), UINT64_C (0x106aa07032bbd1b8),
129
-+	UINT64_C (0x19a4c116b8d2d0c8), UINT64_C (0x1e376c085141ab53),
130
-+	UINT64_C (0x2748774cdf8eeb99), UINT64_C (0x34b0bcb5e19b48a8),
131
-+	UINT64_C (0x391c0cb3c5c95a63), UINT64_C (0x4ed8aa4ae3418acb),
132
-+	UINT64_C (0x5b9cca4f7763e373), UINT64_C (0x682e6ff3d6b2b8a3),
133
-+	UINT64_C (0x748f82ee5defb2fc), UINT64_C (0x78a5636f43172f60),
134
-+	UINT64_C (0x84c87814a1f0ab72), UINT64_C (0x8cc702081a6439ec),
135
-+	UINT64_C (0x90befffa23631e28), UINT64_C (0xa4506cebde82bde9),
136
-+	UINT64_C (0xbef9a3f7b2c67915), UINT64_C (0xc67178f2e372532b),
137
-+	UINT64_C (0xca273eceea26619c), UINT64_C (0xd186b8c721c0c207),
138
-+	UINT64_C (0xeada7dd6cde0eb1e), UINT64_C (0xf57d4f7fee6ed178),
139
-+	UINT64_C (0x06f067aa72176fba), UINT64_C (0x0a637dc5a2c898a6),
140
-+	UINT64_C (0x113f9804bef90dae), UINT64_C (0x1b710b35131c471b),
141
-+	UINT64_C (0x28db77f523047d84), UINT64_C (0x32caab7b40c72493),
142
-+	UINT64_C (0x3c9ebe0a15c9bebc), UINT64_C (0x431d67c49c100d4c),
143
-+	UINT64_C (0x4cc5d4becb3e42b6), UINT64_C (0x597f299cfc657e2a),
144
-+	UINT64_C (0x5fcb6fab3ad6faec), UINT64_C (0x6c44198c4a475817)
145
-+  };
146
-+
147
-+
148
-+/* Process LEN bytes of BUFFER, accumulating context into CTX.
149
-+   It is assumed that LEN % 128 == 0.  */
150
-+static void
151
-+sha512_process_block(const void *buffer, size_t len, struct sha512_ctx *ctx) {
152
-+	const uint64_t *words = buffer;
153
-+	size_t nwords = len / sizeof(uint64_t);
154
-+	uint64_t a = ctx->H[0];
155
-+	uint64_t b = ctx->H[1];
156
-+	uint64_t c = ctx->H[2];
157
-+	uint64_t d = ctx->H[3];
158
-+	uint64_t e = ctx->H[4];
159
-+	uint64_t f = ctx->H[5];
160
-+	uint64_t g = ctx->H[6];
161
-+	uint64_t h = ctx->H[7];
162
-+
163
-+  /* First increment the byte count.  FIPS 180-2 specifies the possible
164
-+	 length of the file up to 2^128 bits.  Here we only compute the
165
-+	 number of bytes.  Do a double word increment.  */
166
-+	ctx->total[0] += len;
167
-+	if (ctx->total[0] < len) {
168
-+		++ctx->total[1];
169
-+	}
170
-+
171
-+	/* Process all bytes in the buffer with 128 bytes in each round of
172
-+	 the loop.  */
173
-+	while (nwords > 0) {
174
-+		uint64_t W[80];
175
-+		uint64_t a_save = a;
176
-+		uint64_t b_save = b;
177
-+		uint64_t c_save = c;
178
-+		uint64_t d_save = d;
179
-+		uint64_t e_save = e;
180
-+		uint64_t f_save = f;
181
-+		uint64_t g_save = g;
182
-+		uint64_t h_save = h;
183
-+		unsigned int t;
184
-+
185
-+/* Operators defined in FIPS 180-2:4.1.2.  */
186
-+#define Ch(x, y, z) ((x & y) ^ (~x & z))
187
-+#define Maj(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
188
-+#define S0(x) (CYCLIC (x, 28) ^ CYCLIC (x, 34) ^ CYCLIC (x, 39))
189
-+#define S1(x) (CYCLIC (x, 14) ^ CYCLIC (x, 18) ^ CYCLIC (x, 41))
190
-+#define R0(x) (CYCLIC (x, 1) ^ CYCLIC (x, 8) ^ (x >> 7))
191
-+#define R1(x) (CYCLIC (x, 19) ^ CYCLIC (x, 61) ^ (x >> 6))
192
-+
193
-+		/* It is unfortunate that C does not provide an operator for
194
-+		   cyclic rotation.  Hope the C compiler is smart enough.  */
195
-+#define CYCLIC(w, s) ((w >> s) | (w << (64 - s)))
196
-+
197
-+		/* Compute the message schedule according to FIPS 180-2:6.3.2 step 2.  */
198
-+		for (t = 0; t < 16; ++t) {
199
-+			W[t] = SWAP (*words);
200
-+			++words;
201
-+		}
202
-+
203
-+		for (t = 16; t < 80; ++t) {
204
-+			W[t] = R1 (W[t - 2]) + W[t - 7] + R0 (W[t - 15]) + W[t - 16];
205
-+		}
206
-+
207
-+		/* The actual computation according to FIPS 180-2:6.3.2 step 3.  */
208
-+		for (t = 0; t < 80; ++t) {
209
-+			uint64_t T1 = h + S1 (e) + Ch (e, f, g) + K[t] + W[t];
210
-+			uint64_t T2 = S0 (a) + Maj (a, b, c);
211
-+			h = g;
212
-+			g = f;
213
-+			f = e;
214
-+			e = d + T1;
215
-+			d = c;
216
-+			c = b;
217
-+			b = a;
218
-+			a = T1 + T2;
219
-+		}
220
-+
221
-+		/* Add the starting values of the context according to FIPS 180-2:6.3.2
222
-+		step 4.  */
223
-+		a += a_save;
224
-+		b += b_save;
225
-+		c += c_save;
226
-+		d += d_save;
227
-+		e += e_save;
228
-+		f += f_save;
229
-+		g += g_save;
230
-+		h += h_save;
231
-+
232
-+		/* Prepare for the next round.  */
233
-+		nwords -= 16;
234
-+	}
235
-+
236
-+	/* Put checksum in context given as argument.  */
237
-+	ctx->H[0] = a;
238
-+	ctx->H[1] = b;
239
-+	ctx->H[2] = c;
240
-+	ctx->H[3] = d;
241
-+	ctx->H[4] = e;
242
-+	ctx->H[5] = f;
243
-+	ctx->H[6] = g;
244
-+	ctx->H[7] = h;
245
-+}
246
-+
247
-+
248
-+/* Initialize structure containing state of computation.
249
-+   (FIPS 180-2:5.3.3)  */
250
-+static void sha512_init_ctx (struct sha512_ctx *ctx) {
251
-+	ctx->H[0] = UINT64_C (0x6a09e667f3bcc908);
252
-+	ctx->H[1] = UINT64_C (0xbb67ae8584caa73b);
253
-+	ctx->H[2] = UINT64_C (0x3c6ef372fe94f82b);
254
-+	ctx->H[3] = UINT64_C (0xa54ff53a5f1d36f1);
255
-+	ctx->H[4] = UINT64_C (0x510e527fade682d1);
256
-+	ctx->H[5] = UINT64_C (0x9b05688c2b3e6c1f);
257
-+	ctx->H[6] = UINT64_C (0x1f83d9abfb41bd6b);
258
-+	ctx->H[7] = UINT64_C (0x5be0cd19137e2179);
259
-+
260
-+	ctx->total[0] = ctx->total[1] = 0;
261
-+	ctx->buflen = 0;
262
-+}
263
-+
264
-+
265
-+/* Process the remaining bytes in the internal buffer and the usual
266
-+	prolog according to the standard and write the result to RESBUF.
267
-+
268
-+	IMPORTANT: On some systems it is required that RESBUF is correctly
269
-+	aligned for a 32 bits value. */
270
-+static void * sha512_finish_ctx (struct sha512_ctx *ctx, void *resbuf) {
271
-+	/* Take yet unprocessed bytes into account.  */
272
-+	uint64_t bytes = ctx->buflen;
273
-+	size_t pad;
274
-+	unsigned int i;
275
-+
276
-+	/* Now count remaining bytes.  */
277
-+	ctx->total[0] += bytes;
278
-+	if (ctx->total[0] < bytes) {
279
-+		++ctx->total[1];
280
-+	}
281
-+
282
-+	pad = bytes >= 112 ? 128 + 112 - (size_t)bytes : 112 - (size_t)bytes;
283
-+	memcpy(&ctx->buffer[bytes], fillbuf, pad);
284
-+
285
-+	/* Put the 128-bit file length in *bits* at the end of the buffer.  */
286
-+	*(uint64_t *) &ctx->buffer[bytes + pad + 8] = SWAP(ctx->total[0] << 3);
287
-+	*(uint64_t *) &ctx->buffer[bytes + pad] = SWAP((ctx->total[1] << 3) |
288
-+						(ctx->total[0] >> 61));
289
-+
290
-+	/* Process last bytes.  */
291
-+	sha512_process_block(ctx->buffer, (size_t)(bytes + pad + 16), ctx);
292
-+
293
-+	/* Put result from CTX in first 64 bytes following RESBUF.  */
294
-+	for (i = 0; i < 8; ++i) {
295
-+		((uint64_t *) resbuf)[i] = SWAP(ctx->H[i]);
296
-+	}
297
-+
298
-+	return resbuf;
299
-+}
300
-+
301
-+static void
302
-+sha512_process_bytes(const void *buffer, size_t len, struct sha512_ctx *ctx) {
303
-+	/* When we already have some bits in our internal buffer concatenate
304
-+	 both inputs first.  */
305
-+	if (ctx->buflen != 0) {
306
-+		size_t left_over = (size_t)ctx->buflen;
307
-+		size_t add = (size_t)(256 - left_over > len ? len : 256 - left_over);
308
-+
309
-+		memcpy(&ctx->buffer[left_over], buffer, add);
310
-+		ctx->buflen += add;
311
-+
312
-+		if (ctx->buflen > 128) {
313
-+			sha512_process_block(ctx->buffer, ctx->buflen & ~127, ctx);
314
-+
315
-+			ctx->buflen &= 127;
316
-+			/* The regions in the following copy operation cannot overlap.  */
317
-+			memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~127],
318
-+					(size_t)ctx->buflen);
319
-+		}
320
-+
321
-+		buffer = (const char *) buffer + add;
322
-+		len -= add;
323
-+	}
324
-+
325
-+	/* Process available complete blocks.  */
326
-+	if (len >= 128) {
327
-+#if !_STRING_ARCH_unaligned
328
-+/* To check alignment gcc has an appropriate operator.  Other
329
-+   compilers don't.  */
330
-+# if __GNUC__ >= 2
331
-+#  define UNALIGNED_P(p) (((uintptr_t) p) % __alignof__ (uint64_t) != 0)
332
-+# else
333
-+#  define UNALIGNED_P(p) (((uintptr_t) p) % sizeof(uint64_t) != 0)
334
-+# endif
335
-+		if (UNALIGNED_P(buffer))
336
-+			while (len > 128) {
337
-+				sha512_process_block(memcpy(ctx->buffer, buffer, 128), 128, ctx);
338
-+				buffer = (const char *) buffer + 128;
339
-+				len -= 128;
340
-+			}
341
-+		else
342
-+#endif
343
-+		{
344
-+		  sha512_process_block(buffer, len & ~127, ctx);
345
-+		  buffer = (const char *) buffer + (len & ~127);
346
-+		  len &= 127;
347
-+		}
348
-+	}
349
-+
350
-+  /* Move remaining bytes into internal buffer.  */
351
-+	if (len > 0) {
352
-+		size_t left_over = (size_t)ctx->buflen;
353
-+
354
-+		memcpy(&ctx->buffer[left_over], buffer, len);
355
-+		left_over += len;
356
-+		if (left_over >= 128) {
357
-+			sha512_process_block(ctx->buffer, 128, ctx);
358
-+			left_over -= 128;
359
-+			memcpy(ctx->buffer, &ctx->buffer[128], left_over);
360
-+		}
361
-+		ctx->buflen = left_over;
362
-+	}
363
-+}
364
-+
365
-+
366
-+/* Define our magic string to mark salt for SHA512 "encryption"
367
-+   replacement.  */
368
-+static const char sha512_salt_prefix[] = "$6$";
369
-+
370
-+/* Prefix for optional rounds specification.  */
371
-+static const char sha512_rounds_prefix[] = "rounds=";
372
-+
373
-+/* Maximum salt string length.  */
374
-+#define SALT_LEN_MAX 16
375
-+/* Default number of rounds if not explicitly specified.  */
376
-+#define ROUNDS_DEFAULT 5000
377
-+/* Minimum number of rounds.  */
378
-+#define ROUNDS_MIN 1000
379
-+/* Maximum number of rounds.  */
380
-+#define ROUNDS_MAX 999999999
381
-+
382
-+/* Table with characters for base64 transformation.  */
383
-+static const char b64t[64] =
384
-+"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
385
-+
386
-+
387
-+char *
388
-+php_sha512_crypt_r(const char *key, const char *salt, char *buffer, int buflen) {
389
-+#ifdef PHP_WIN32
390
-+	__declspec(align(64)) unsigned char alt_result[64];
391
-+	__declspec(align(64)) unsigned char temp_result[64];
392
-+#else
393
-+	unsigned char alt_result[64]
394
-+		__attribute__ ((__aligned__ (__alignof__ (uint64_t))));
395
-+	unsigned char temp_result[64]
396
-+		__attribute__ ((__aligned__ (__alignof__ (uint64_t))));
397
-+#endif
398
-+	struct sha512_ctx ctx;
399
-+	struct sha512_ctx alt_ctx;
400
-+	size_t salt_len;
401
-+	size_t key_len;
402
-+	size_t cnt;
403
-+	char *cp;
404
-+	char *copied_key = NULL;
405
-+	char *copied_salt = NULL;
406
-+	char *p_bytes;
407
-+	char *s_bytes;
408
-+	/* Default number of rounds.  */
409
-+	size_t rounds = ROUNDS_DEFAULT;
410
-+	bool rounds_custom = false;
411
-+
412
-+	/* Find beginning of salt string.  The prefix should normally always
413
-+	 be present.  Just in case it is not.  */
414
-+	if (strncmp(sha512_salt_prefix, salt, sizeof(sha512_salt_prefix) - 1) == 0) {
415
-+		/* Skip salt prefix.  */
416
-+		salt += sizeof(sha512_salt_prefix) - 1;
417
-+	}
418
-+
419
-+	if (strncmp(salt, sha512_rounds_prefix, sizeof(sha512_rounds_prefix) - 1) == 0) {
420
-+		const char *num = salt + sizeof(sha512_rounds_prefix) - 1;
421
-+		char *endp;
422
-+		unsigned long int srounds = strtoul(num, &endp, 10);
423
-+
424
-+		if (*endp == '$') {
425
-+			salt = endp + 1;
426
-+			rounds = MAX(ROUNDS_MIN, MIN(srounds, ROUNDS_MAX));
427
-+			rounds_custom = true;
428
-+		}
429
-+	}
430
-+
431
-+	salt_len = MIN(strcspn(salt, "$"), SALT_LEN_MAX);
432
-+	key_len = strlen(key);
433
-+
434
-+	if ((key - (char *) 0) % __alignof__ (uint64_t) != 0) {
435
-+		char *tmp = (char *) alloca (key_len + __alignof__ (uint64_t));
436
-+		key = copied_key =
437
-+		memcpy(tmp + __alignof__(uint64_t) - (tmp - (char *) 0) % __alignof__(uint64_t), key, key_len);
438
-+	}
439
-+
440
-+	if ((salt - (char *) 0) % __alignof__ (uint64_t) != 0) {
441
-+		char *tmp = (char *) alloca(salt_len + __alignof__(uint64_t));
442
-+
443
-+		salt = copied_salt = memcpy(tmp + __alignof__(uint64_t) - (tmp - (char *) 0) % __alignof__(uint64_t), salt, salt_len);
444
-+	}
445
-+
446
-+	/* Prepare for the real work.  */
447
-+	sha512_init_ctx(&ctx);
448
-+
449
-+	/* Add the key string.  */
450
-+	sha512_process_bytes(key, key_len, &ctx);
451
-+
452
-+	/* The last part is the salt string.  This must be at most 16
453
-+	 characters and it ends at the first `$' character (for
454
-+	 compatibility with existing implementations).  */
455
-+	sha512_process_bytes(salt, salt_len, &ctx);
456
-+
457
-+
458
-+	/* Compute alternate SHA512 sum with input KEY, SALT, and KEY.  The
459
-+	 final result will be added to the first context.  */
460
-+	sha512_init_ctx(&alt_ctx);
461
-+
462
-+	/* Add key.  */
463
-+	sha512_process_bytes(key, key_len, &alt_ctx);
464
-+
465
-+	/* Add salt.  */
466
-+	sha512_process_bytes(salt, salt_len, &alt_ctx);
467
-+
468
-+	/* Add key again.  */
469
-+	sha512_process_bytes(key, key_len, &alt_ctx);
470
-+
471
-+	/* Now get result of this (64 bytes) and add it to the other
472
-+	 context.  */
473
-+	sha512_finish_ctx(&alt_ctx, alt_result);
474
-+
475
-+	/* Add for any character in the key one byte of the alternate sum.  */
476
-+	for (cnt = key_len; cnt > 64; cnt -= 64) {
477
-+		sha512_process_bytes(alt_result, 64, &ctx);
478
-+	}
479
-+	sha512_process_bytes(alt_result, cnt, &ctx);
480
-+
481
-+	/* Take the binary representation of the length of the key and for every
482
-+	 1 add the alternate sum, for every 0 the key.  */
483
-+	for (cnt = key_len; cnt > 0; cnt >>= 1) {
484
-+		if ((cnt & 1) != 0) {
485
-+			sha512_process_bytes(alt_result, 64, &ctx);
486
-+		} else {
487
-+			sha512_process_bytes(key, key_len, &ctx);
488
-+		}
489
-+	}
490
-+
491
-+	/* Create intermediate result.  */
492
-+	sha512_finish_ctx(&ctx, alt_result);
493
-+
494
-+	/* Start computation of P byte sequence.  */
495
-+	sha512_init_ctx(&alt_ctx);
496
-+
497
-+	/* For every character in the password add the entire password.  */
498
-+	for (cnt = 0; cnt < key_len; ++cnt) {
499
-+		sha512_process_bytes(key, key_len, &alt_ctx);
500
-+	}
501
-+
502
-+	/* Finish the digest.  */
503
-+	sha512_finish_ctx(&alt_ctx, temp_result);
504
-+
505
-+	/* Create byte sequence P.  */
506
-+	cp = p_bytes = alloca(key_len);
507
-+	for (cnt = key_len; cnt >= 64; cnt -= 64) {
508
-+		cp = mempcpy((void *) cp, (const void *)temp_result, 64);
509
-+	}
510
-+
511
-+	memcpy(cp, temp_result, cnt);
512
-+
513
-+	/* Start computation of S byte sequence.  */
514
-+	sha512_init_ctx(&alt_ctx);
515
-+
516
-+	/* For every character in the password add the entire password.  */
517
-+	for (cnt = 0; cnt < 16 + alt_result[0]; ++cnt) {
518
-+		sha512_process_bytes(salt, salt_len, &alt_ctx);
519
-+	}
520
-+
521
-+	/* Finish the digest.  */
522
-+	sha512_finish_ctx(&alt_ctx, temp_result);
523
-+
524
-+	/* Create byte sequence S.  */
525
-+	cp = s_bytes = alloca(salt_len);
526
-+	for (cnt = salt_len; cnt >= 64; cnt -= 64) {
527
-+		cp = mempcpy(cp, temp_result, 64);
528
-+	}
529
-+	memcpy(cp, temp_result, cnt);
530
-+
531
-+	/* Repeatedly run the collected hash value through SHA512 to burn
532
-+	 CPU cycles.  */
533
-+	for (cnt = 0; cnt < rounds; ++cnt) {
534
-+		/* New context.  */
535
-+		sha512_init_ctx(&ctx);
536
-+
537
-+		/* Add key or last result.  */
538
-+		if ((cnt & 1) != 0) {
539
-+			sha512_process_bytes(p_bytes, key_len, &ctx);
540
-+		} else {
541
-+			sha512_process_bytes(alt_result, 64, &ctx);
542
-+		}
543
-+
544
-+		/* Add salt for numbers not divisible by 3.  */
545
-+		if (cnt % 3 != 0) {
546
-+			sha512_process_bytes(s_bytes, salt_len, &ctx);
547
-+		}
548
-+
549
-+		/* Add key for numbers not divisible by 7.  */
550
-+		if (cnt % 7 != 0) {
551
-+			sha512_process_bytes(p_bytes, key_len, &ctx);
552
-+		}
553
-+
554
-+		/* Add key or last result.  */
555
-+		if ((cnt & 1) != 0) {
556
-+			sha512_process_bytes(alt_result, 64, &ctx);
557
-+		} else {
558
-+			sha512_process_bytes(p_bytes, key_len, &ctx);
559
-+		}
560
-+
561
-+		/* Create intermediate result.  */
562
-+		sha512_finish_ctx(&ctx, alt_result);
563
-+	}
564
-+
565
-+	/* Now we can construct the result string.  It consists of three
566
-+	 parts.  */
567
-+	cp = stpncpy(buffer, sha512_salt_prefix, MAX(0, buflen));
568
-+	buflen -= sizeof(sha512_salt_prefix) - 1;
569
-+
570
-+	if (rounds_custom) {
571
-+#ifdef PHP_WIN32
572
-+	  int n = _snprintf(cp, MAX(0, buflen), "%s%u$", sha512_rounds_prefix, rounds);
573
-+#else
574
-+	  int n = snprintf(cp, MAX(0, buflen), "%s%zu$", sha512_rounds_prefix, rounds);
575
-+#endif
576
-+	  cp += n;
577
-+	  buflen -= n;
578
-+	}
579
-+
580
-+	cp = stpncpy(cp, salt, MIN((size_t) MAX(0, buflen), salt_len));
581
-+	buflen -= (int) MIN((size_t) MAX(0, buflen), salt_len);
582
-+
583
-+	if (buflen > 0) {
584
-+		*cp++ = '$';
585
-+		--buflen;
586
-+	}
587
-+
588
-+#define b64_from_24bit(B2, B1, B0, N)                    \
589
-+  do {									                 \
590
-+	unsigned int w = ((B2) << 16) | ((B1) << 8) | (B0);	 \
591
-+	int n = (N);							             \
592
-+	while (n-- > 0 && buflen > 0)					     \
593
-+	  {									                 \
594
-+	*cp++ = b64t[w & 0x3f];						         \
595
-+	--buflen;							                 \
596
-+	w >>= 6;							                 \
597
-+	  }									                 \
598
-+  } while (0)
599
-+
600
-+	b64_from_24bit(alt_result[0], alt_result[21], alt_result[42], 4);
601
-+	b64_from_24bit(alt_result[22], alt_result[43], alt_result[1], 4);
602
-+	b64_from_24bit(alt_result[44], alt_result[2], alt_result[23], 4);
603
-+	b64_from_24bit(alt_result[3], alt_result[24], alt_result[45], 4);
604
-+	b64_from_24bit(alt_result[25], alt_result[46], alt_result[4], 4);
605
-+	b64_from_24bit(alt_result[47], alt_result[5], alt_result[26], 4);
606
-+	b64_from_24bit(alt_result[6], alt_result[27], alt_result[48], 4);
607
-+	b64_from_24bit(alt_result[28], alt_result[49], alt_result[7], 4);
608
-+	b64_from_24bit(alt_result[50], alt_result[8], alt_result[29], 4);
609
-+	b64_from_24bit(alt_result[9], alt_result[30], alt_result[51], 4);
610
-+	b64_from_24bit(alt_result[31], alt_result[52], alt_result[10], 4);
611
-+	b64_from_24bit(alt_result[53], alt_result[11], alt_result[32], 4);
612
-+	b64_from_24bit(alt_result[12], alt_result[33], alt_result[54], 4);
613
-+	b64_from_24bit(alt_result[34], alt_result[55], alt_result[13], 4);
614
-+	b64_from_24bit(alt_result[56], alt_result[14], alt_result[35], 4);
615
-+	b64_from_24bit(alt_result[15], alt_result[36], alt_result[57], 4);
616
-+	b64_from_24bit(alt_result[37], alt_result[58], alt_result[16], 4);
617
-+	b64_from_24bit(alt_result[59], alt_result[17], alt_result[38], 4);
618
-+	b64_from_24bit(alt_result[18], alt_result[39], alt_result[60], 4);
619
-+	b64_from_24bit(alt_result[40], alt_result[61], alt_result[19], 4);
620
-+	b64_from_24bit(alt_result[62], alt_result[20], alt_result[41], 4);
621
-+	b64_from_24bit(0, 0, alt_result[63], 2);
622
-+
623
-+	if (buflen <= 0) {
624
-+		errno = ERANGE;
625
-+		buffer = NULL;
626
-+	} else {
627
-+		*cp = '\0';		/* Terminate the string.  */
628
-+	}
629
-+
630
-+	/* Clear the buffer for the intermediate result so that people
631
-+	 attaching to processes or reading core dumps cannot get any
632
-+	 information.  We do it in this way to clear correct_words[]
633
-+	 inside the SHA512 implementation as well.  */
634
-+	sha512_init_ctx(&ctx);
635
-+	sha512_finish_ctx(&ctx, alt_result);
636
-+	memset(temp_result, '\0', sizeof(temp_result));
637
-+	memset(p_bytes, '\0', key_len);
638
-+	memset(s_bytes, '\0', salt_len);
639
-+	memset(&ctx, '\0', sizeof(ctx));
640
-+	memset(&alt_ctx, '\0', sizeof(alt_ctx));
641
-+	if (copied_key != NULL) {
642
-+		memset(copied_key, '\0', key_len);
643
-+	}
644
-+	if (copied_salt != NULL) {
645
-+		memset(copied_salt, '\0', salt_len);
646
-+	}
647
-+
648
-+	return buffer;
649
-+}
650
-+
651
-+
652
-+/* This entry point is equivalent to the `crypt' function in Unix
653
-+   libcs.  */
654
-+char *
655
-+php_sha512_crypt(const char *key, const char *salt) {
656
-+	/* We don't want to have an arbitrary limit in the size of the
657
-+	 password.  We can compute an upper bound for the size of the
658
-+	 result in advance and so we can prepare the buffer we pass to
659
-+	 `sha512_crypt_r'.  */
660
-+	static char *buffer;
661
-+	static int buflen;
662
-+	int needed = (int)(sizeof(sha512_salt_prefix) - 1
663
-+		+ sizeof(sha512_rounds_prefix) + 9 + 1
664
-+		+ strlen(salt) + 1 + 86 + 1);
665
-+
666
-+	if (buflen < needed) {
667
-+		char *new_buffer = (char *) realloc(buffer, needed);
668
-+		if (new_buffer == NULL) {
669
-+			return NULL;
670
-+		}
671
-+
672
-+		buffer = new_buffer;
673
-+		buflen = needed;
674
-+	}
675
-+
676
-+	return php_sha512_crypt_r (key, salt, buffer, buflen);
677
-+}
678
-+
679
-+#ifdef TEST
680
-+static const struct {
681
-+	const char *input;
682
-+	const char result[64];
683
-+} tests[] =
684
-+	{
685
-+	/* Test vectors from FIPS 180-2: appendix C.1.  */
686
-+	{ "abc",
687
-+	  "\xdd\xaf\x35\xa1\x93\x61\x7a\xba\xcc\x41\x73\x49\xae\x20\x41\x31"
688
-+	  "\x12\xe6\xfa\x4e\x89\xa9\x7e\xa2\x0a\x9e\xee\xe6\x4b\x55\xd3\x9a"
689
-+	  "\x21\x92\x99\x2a\x27\x4f\xc1\xa8\x36\xba\x3c\x23\xa3\xfe\xeb\xbd"
690
-+	  "\x45\x4d\x44\x23\x64\x3c\xe8\x0e\x2a\x9a\xc9\x4f\xa5\x4c\xa4\x9f" },
691
-+	/* Test vectors from FIPS 180-2: appendix C.2.  */
692
-+	{ "abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmn"
693
-+	  "hijklmnoijklmnopjklmnopqklmnopqrlmnopqrsmnopqrstnopqrstu",
694
-+	  "\x8e\x95\x9b\x75\xda\xe3\x13\xda\x8c\xf4\xf7\x28\x14\xfc\x14\x3f"
695
-+	  "\x8f\x77\x79\xc6\xeb\x9f\x7f\xa1\x72\x99\xae\xad\xb6\x88\x90\x18"
696
-+	  "\x50\x1d\x28\x9e\x49\x00\xf7\xe4\x33\x1b\x99\xde\xc4\xb5\x43\x3a"
697
-+	  "\xc7\xd3\x29\xee\xb6\xdd\x26\x54\x5e\x96\xe5\x5b\x87\x4b\xe9\x09" },
698
-+	/* Test vectors from the NESSIE project.  */
699
-+	{ "",
700
-+	  "\xcf\x83\xe1\x35\x7e\xef\xb8\xbd\xf1\x54\x28\x50\xd6\x6d\x80\x07"
701
-+	  "\xd6\x20\xe4\x05\x0b\x57\x15\xdc\x83\xf4\xa9\x21\xd3\x6c\xe9\xce"
702
-+	  "\x47\xd0\xd1\x3c\x5d\x85\xf2\xb0\xff\x83\x18\xd2\x87\x7e\xec\x2f"
703
-+	  "\x63\xb9\x31\xbd\x47\x41\x7a\x81\xa5\x38\x32\x7a\xf9\x27\xda\x3e" },
704
-+	{ "a",
705
-+	  "\x1f\x40\xfc\x92\xda\x24\x16\x94\x75\x09\x79\xee\x6c\xf5\x82\xf2"
706
-+	  "\xd5\xd7\xd2\x8e\x18\x33\x5d\xe0\x5a\xbc\x54\xd0\x56\x0e\x0f\x53"
707
-+	  "\x02\x86\x0c\x65\x2b\xf0\x8d\x56\x02\x52\xaa\x5e\x74\x21\x05\x46"
708
-+	  "\xf3\x69\xfb\xbb\xce\x8c\x12\xcf\xc7\x95\x7b\x26\x52\xfe\x9a\x75" },
709
-+	{ "message digest",
710
-+	  "\x10\x7d\xbf\x38\x9d\x9e\x9f\x71\xa3\xa9\x5f\x6c\x05\x5b\x92\x51"
711
-+	  "\xbc\x52\x68\xc2\xbe\x16\xd6\xc1\x34\x92\xea\x45\xb0\x19\x9f\x33"
712
-+	  "\x09\xe1\x64\x55\xab\x1e\x96\x11\x8e\x8a\x90\x5d\x55\x97\xb7\x20"
713
-+	  "\x38\xdd\xb3\x72\xa8\x98\x26\x04\x6d\xe6\x66\x87\xbb\x42\x0e\x7c" },
714
-+	{ "abcdefghijklmnopqrstuvwxyz",
715
-+	  "\x4d\xbf\xf8\x6c\xc2\xca\x1b\xae\x1e\x16\x46\x8a\x05\xcb\x98\x81"
716
-+	  "\xc9\x7f\x17\x53\xbc\xe3\x61\x90\x34\x89\x8f\xaa\x1a\xab\xe4\x29"
717
-+	  "\x95\x5a\x1b\xf8\xec\x48\x3d\x74\x21\xfe\x3c\x16\x46\x61\x3a\x59"
718
-+	  "\xed\x54\x41\xfb\x0f\x32\x13\x89\xf7\x7f\x48\xa8\x79\xc7\xb1\xf1" },
719
-+	{ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
720
-+	  "\x20\x4a\x8f\xc6\xdd\xa8\x2f\x0a\x0c\xed\x7b\xeb\x8e\x08\xa4\x16"
721
-+	  "\x57\xc1\x6e\xf4\x68\xb2\x28\xa8\x27\x9b\xe3\x31\xa7\x03\xc3\x35"
722
-+	  "\x96\xfd\x15\xc1\x3b\x1b\x07\xf9\xaa\x1d\x3b\xea\x57\x78\x9c\xa0"
723
-+	  "\x31\xad\x85\xc7\xa7\x1d\xd7\x03\x54\xec\x63\x12\x38\xca\x34\x45" },
724
-+	{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
725
-+	  "\x1e\x07\xbe\x23\xc2\x6a\x86\xea\x37\xea\x81\x0c\x8e\xc7\x80\x93"
726
-+	  "\x52\x51\x5a\x97\x0e\x92\x53\xc2\x6f\x53\x6c\xfc\x7a\x99\x96\xc4"
727
-+	  "\x5c\x83\x70\x58\x3e\x0a\x78\xfa\x4a\x90\x04\x1d\x71\xa4\xce\xab"
728
-+	  "\x74\x23\xf1\x9c\x71\xb9\xd5\xa3\xe0\x12\x49\xf0\xbe\xbd\x58\x94" },
729
-+	{ "123456789012345678901234567890123456789012345678901234567890"
730
-+	  "12345678901234567890",
731
-+	  "\x72\xec\x1e\xf1\x12\x4a\x45\xb0\x47\xe8\xb7\xc7\x5a\x93\x21\x95"
732
-+	  "\x13\x5b\xb6\x1d\xe2\x4e\xc0\xd1\x91\x40\x42\x24\x6e\x0a\xec\x3a"
733
-+	  "\x23\x54\xe0\x93\xd7\x6f\x30\x48\xb4\x56\x76\x43\x46\x90\x0c\xb1"
734
-+	  "\x30\xd2\xa4\xfd\x5d\xd1\x6a\xbb\x5e\x30\xbc\xb8\x50\xde\xe8\x43" }
735
-+  };
736
-+#define ntests (sizeof (tests) / sizeof (tests[0]))
737
-+
738
-+
739
-+static const struct
740
-+{
741
-+	const char *salt;
742
-+	const char *input;
743
-+	const char *expected;
744
-+} tests2[] = {
745
-+	{ "$6$saltstring", "Hello world!",
746
-+	"$6$saltstring$svn8UoSVapNtMuq1ukKS4tPQd8iKwSMHWjl/O817G3uBnIFNjnQJu"
747
-+	"esI68u4OTLiBFdcbYEdFCoEOfaS35inz1"},
748
-+	{ "$6$rounds=10000$saltstringsaltstring", "Hello world!",
749
-+	"$6$rounds=10000$saltstringsaltst$OW1/O6BYHV6BcXZu8QVeXbDWra3Oeqh0sb"
750
-+	"HbbMCVNSnCM/UrjmM0Dp8vOuZeHBy/YTBmSK6H9qs/y3RnOaw5v." },
751
-+	{ "$6$rounds=5000$toolongsaltstring", "This is just a test",
752
-+	"$6$rounds=5000$toolongsaltstrin$lQ8jolhgVRVhY4b5pZKaysCLi0QBxGoNeKQ"
753
-+	"zQ3glMhwllF7oGDZxUhx1yxdYcz/e1JSbq3y6JMxxl8audkUEm0" },
754
-+	{ "$6$rounds=1400$anotherlongsaltstring",
755
-+	"a very much longer text to encrypt.  This one even stretches over more"
756
-+	"than one line.",
757
-+	"$6$rounds=1400$anotherlongsalts$POfYwTEok97VWcjxIiSOjiykti.o/pQs.wP"
758
-+	"vMxQ6Fm7I6IoYN3CmLs66x9t0oSwbtEW7o7UmJEiDwGqd8p4ur1" },
759
-+	{ "$6$rounds=77777$short",
760
-+	"we have a short salt string but not a short password",
761
-+	"$6$rounds=77777$short$WuQyW2YR.hBNpjjRhpYD/ifIw05xdfeEyQoMxIXbkvr0g"
762
-+	"ge1a1x3yRULJ5CCaUeOxFmtlcGZelFl5CxtgfiAc0" },
763
-+	{ "$6$rounds=123456$asaltof16chars..", "a short string",
764
-+	"$6$rounds=123456$asaltof16chars..$BtCwjqMJGx5hrJhZywWvt0RLE8uZ4oPwc"
765
-+	"elCjmw2kSYu.Ec6ycULevoBK25fs2xXgMNrCzIMVcgEJAstJeonj1" },
766
-+	{ "$6$rounds=10$roundstoolow", "the minimum number is still observed",
767
-+	"$6$rounds=1000$roundstoolow$kUMsbe306n21p9R.FRkW3IGn.S9NPN0x50YhH1x"
768
-+	"hLsPuWGsUSklZt58jaTfF4ZEQpyUNGc0dqbpBYYBaHHrsX." },
769
-+};
770
-+#define ntests2 (sizeof (tests2) / sizeof (tests2[0]))
771
-+
772
-+
773
-+int main (void) {
774
-+	struct sha512_ctx ctx;
775
-+	char sum[64];
776
-+	int result = 0;
777
-+	int cnt;
778
-+	int i;
779
-+	char buf[1000];
780
-+	static const char expected[64] =
781
-+		"\xe7\x18\x48\x3d\x0c\xe7\x69\x64\x4e\x2e\x42\xc7\xbc\x15\xb4\x63"
782
-+		"\x8e\x1f\x98\xb1\x3b\x20\x44\x28\x56\x32\xa8\x03\xaf\xa9\x73\xeb"
783
-+		"\xde\x0f\xf2\x44\x87\x7e\xa6\x0a\x4c\xb0\x43\x2c\xe5\x77\xc3\x1b"
784
-+		"\xeb\x00\x9c\x5c\x2c\x49\xaa\x2e\x4e\xad\xb2\x17\xad\x8c\xc0\x9b";
785
-+
786
-+	for (cnt = 0; cnt < (int) ntests; ++cnt) {
787
-+		sha512_init_ctx (&ctx);
788
-+		sha512_process_bytes (tests[cnt].input, strlen (tests[cnt].input), &ctx);
789
-+		sha512_finish_ctx (&ctx, sum);
790
-+		if (memcmp (tests[cnt].result, sum, 64) != 0) {
791
-+			printf ("test %d run %d failed\n", cnt, 1);
792
-+			result = 1;
793
-+		}
794
-+
795
-+		sha512_init_ctx (&ctx);
796
-+		for (i = 0; tests[cnt].input[i] != '\0'; ++i) {
797
-+			sha512_process_bytes (&tests[cnt].input[i], 1, &ctx);
798
-+		}
799
-+		sha512_finish_ctx (&ctx, sum);
800
-+		if (memcmp (tests[cnt].result, sum, 64) != 0) {
801
-+			printf ("test %d run %d failed\n", cnt, 2);
802
-+			result = 1;
803
-+		}
804
-+	}
805
-+
806
-+	/* Test vector from FIPS 180-2: appendix C.3.  */
807
-+
808
-+	memset (buf, 'a', sizeof (buf));
809
-+	sha512_init_ctx (&ctx);
810
-+	for (i = 0; i < 1000; ++i) {
811
-+		sha512_process_bytes (buf, sizeof (buf), &ctx);
812
-+	}
813
-+
814
-+	sha512_finish_ctx (&ctx, sum);
815
-+	if (memcmp (expected, sum, 64) != 0) {
816
-+		printf ("test %d failed\n", cnt);
817
-+		result = 1;
818
-+	}
819
-+
820
-+	for (cnt = 0; cnt < ntests2; ++cnt) {
821
-+		char *cp = php_sha512_crypt(tests2[cnt].input, tests2[cnt].salt);
822
-+
823
-+		if (strcmp (cp, tests2[cnt].expected) != 0) {
824
-+			printf ("test %d: expected \"%s\", got \"%s\"\n",
825
-+					cnt, tests2[cnt].expected, cp);
826
-+			result = 1;
827
-+		}
828
-+	}
829
-+
830
-+	if (result == 0) {
831
-+		puts ("all tests OK");
832
-+	}
833
-+
834
-+	return result;
835
-+}
836
-+#endif
837
-Index: ext/standard/crypt_sha256.c
838
-===================================================================
839
---- ext/standard/crypt_sha256.c	(Revision 0)
840
-+++ ext/standard/crypt_sha256.c	(Revision 291899)
841
-@@ -0,0 +1,754 @@
842
-+/* SHA256-based Unix crypt implementation.
843
-+   Released into the Public Domain by Ulrich Drepper <drepper@redhat.com>.  */
844
-+/* Windows VC++ port by Pierre Joye <pierre@php.net> */
845
-+
846
-+#ifndef PHP_WIN32
847
-+# include <endian.h>
848
-+# include "php.h"
849
-+# include "php_main.h"
850
-+#endif
851
-+
852
-+#include <errno.h>
853
-+#include <limits.h>
854
-+
855
-+#ifdef PHP_WIN32
856
-+# include "win32/php_stdint.h"
857
-+# include "win32/php_stdbool.h"
858
-+# define __alignof__ __alignof
859
-+# define alloca _alloca
860
-+#else
861
-+# if HAVE_INTTYPES_H
862
-+#  include <inttypes.h>
863
-+# elif HAVE_STDINT_H
864
-+#  include <stdint.h>
865
-+# endif
866
-+# include <stdbool.h>
867
-+#endif
868
-+
869
-+#include <stdio.h>
870
-+#include <stdlib.h>
871
-+
872
-+#ifdef PHP_WIN32
873
-+# include <string.h>
874
-+#else
875
-+# include <sys/param.h>
876
-+# include <sys/types.h>
877
-+# if HAVE_STRING_H
878
-+//#  define __USE_GNU 1
879
-+#  include <string.h>
880
-+# else
881
-+#  include <strings.h>
882
-+# endif
883
-+#endif
884
-+
885
-+#ifndef HAVE_STRPNCPY 
886
-+char * stpncpy(char *dst, const char *src, size_t len)
887
-+{
888
-+	size_t n = strlen(src);
889
-+	if (n > len) {
890
-+		n = len;
891
-+	}
892
-+	return strncpy(dst, src, len) + n;
893
-+}
894
-+#endif
895
-+
896
-+#ifndef HAVE_MEMPCPY 
897
-+void * mempcpy(void * dst, const void * src, size_t len)
898
-+{
899
-+	return (((char *)memcpy(dst, src, len)) + len);
900
-+}
901
-+#endif
902
-+
903
-+#ifndef MIN
904
-+# define MIN(a, b) (((a) < (b)) ? (a) : (b))
905
-+#endif
906
-+#ifndef MAX
907
-+# define MAX(a, b) (((a) > (b)) ? (a) : (b))
908
-+#endif
909
-+
910
-+/* Structure to save state of computation between the single steps.  */
911
-+struct sha256_ctx {
912
-+	uint32_t H[8];
913
-+
914
-+	uint32_t total[2];
915
-+	uint32_t buflen;
916
-+	char buffer[128]; /* NB: always correctly aligned for uint32_t.  */
917
-+};
918
-+
919
-+#if PHP_WIN32 || (__BYTE_ORDER == __LITTLE_ENDIAN)
920
-+# define SWAP(n) \
921
-+    (((n) << 24) | (((n) & 0xff00) << 8) | (((n) >> 8) & 0xff00) | ((n) >> 24))
922
-+#else
923
-+# define SWAP(n) (n)
924
-+#endif
925
-+
926
-+/* This array contains the bytes used to pad the buffer to the next
927
-+   64-byte boundary.  (FIPS 180-2:5.1.1)  */
928
-+static const unsigned char fillbuf[64] = { 0x80, 0 /* , 0, 0, ...  */ };
929
-+
930
-+
931
-+/* Constants for SHA256 from FIPS 180-2:4.2.2.  */
932
-+static const uint32_t K[64] = {
933
-+	0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,
934
-+	0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,
935
-+	0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,
936
-+	0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,
937
-+	0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,
938
-+	0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,
939
-+	0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,
940
-+	0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,
941
-+	0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,
942
-+	0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,
943
-+	0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,
944
-+	0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,
945
-+	0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,
946
-+	0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,
947
-+	0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,
948
-+	0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2
949
-+};
950
-+
951
-+
952
-+/* Process LEN bytes of BUFFER, accumulating context into CTX.
953
-+   It is assumed that LEN % 64 == 0.  */
954
-+static void sha256_process_block (const void *buffer, size_t len, struct sha256_ctx *ctx) {
955
-+	const uint32_t *words = buffer;
956
-+	size_t nwords = len / sizeof (uint32_t);
957
-+	unsigned int t;
958
-+
959
-+	uint32_t a = ctx->H[0];
960
-+	uint32_t b = ctx->H[1];
961
-+	uint32_t c = ctx->H[2];
962
-+	uint32_t d = ctx->H[3];
963
-+	uint32_t e = ctx->H[4];
964
-+	uint32_t f = ctx->H[5];
965
-+	uint32_t g = ctx->H[6];
966
-+	uint32_t h = ctx->H[7];
967
-+
968
-+	/* First increment the byte count.  FIPS 180-2 specifies the possible
969
-+	 length of the file up to 2^64 bits.  Here we only compute the
970
-+	 number of bytes.  Do a double word increment.  */
971
-+	ctx->total[0] += len;
972
-+	if (ctx->total[0] < len) {
973
-+		++ctx->total[1];
974
-+	}
975
-+
976
-+	/* Process all bytes in the buffer with 64 bytes in each round of
977
-+	 the loop.  */
978
-+	while (nwords > 0) {
979
-+		uint32_t W[64];
980
-+		uint32_t a_save = a;
981
-+		uint32_t b_save = b;
982
-+		uint32_t c_save = c;
983
-+		uint32_t d_save = d;
984
-+		uint32_t e_save = e;
985
-+		uint32_t f_save = f;
986
-+		uint32_t g_save = g;
987
-+		uint32_t h_save = h;
988
-+
989
-+	/* Operators defined in FIPS 180-2:4.1.2.  */
990
-+#define Ch(x, y, z) ((x & y) ^ (~x & z))
991
-+#define Maj(x, y, z) ((x & y) ^ (x & z) ^ (y & z))
992
-+#define S0(x) (CYCLIC (x, 2) ^ CYCLIC (x, 13) ^ CYCLIC (x, 22))
993
-+#define S1(x) (CYCLIC (x, 6) ^ CYCLIC (x, 11) ^ CYCLIC (x, 25))
994
-+#define R0(x) (CYCLIC (x, 7) ^ CYCLIC (x, 18) ^ (x >> 3))
995
-+#define R1(x) (CYCLIC (x, 17) ^ CYCLIC (x, 19) ^ (x >> 10))
996
-+
997
-+	/* It is unfortunate that C does not provide an operator for
998
-+	cyclic rotation.  Hope the C compiler is smart enough.  */
999
-+#define CYCLIC(w, s) ((w >> s) | (w << (32 - s)))
1000
-+
1001
-+		/* Compute the message schedule according to FIPS 180-2:6.2.2 step 2.  */
1002
-+		for (t = 0; t < 16; ++t) {
1003
-+			W[t] = SWAP (*words);
1004
-+			++words;
1005
-+		}
1006
-+		for (t = 16; t < 64; ++t)
1007
-+			W[t] = R1 (W[t - 2]) + W[t - 7] + R0 (W[t - 15]) + W[t - 16];
1008
-+
1009
-+		/* The actual computation according to FIPS 180-2:6.2.2 step 3.  */
1010
-+		for (t = 0; t < 64; ++t) {
1011
-+			uint32_t T1 = h + S1 (e) + Ch (e, f, g) + K[t] + W[t];
1012
-+			uint32_t T2 = S0 (a) + Maj (a, b, c);
1013
-+			h = g;
1014
-+			g = f;
1015
-+			f = e;
1016
-+			e = d + T1;
1017
-+			d = c;
1018
-+			c = b;
1019
-+			b = a;
1020
-+			a = T1 + T2;
1021
-+		}
1022
-+
1023
-+		/* Add the starting values of the context according to FIPS 180-2:6.2.2
1024
-+		step 4.  */
1025
-+		a += a_save;
1026
-+		b += b_save;
1027
-+		c += c_save;
1028
-+		d += d_save;
1029
-+		e += e_save;
1030
-+		f += f_save;
1031
-+		g += g_save;
1032
-+		h += h_save;
1033
-+
1034
-+		/* Prepare for the next round.  */
1035
-+		nwords -= 16;
1036
-+	}
1037
-+
1038
-+	/* Put checksum in context given as argument.  */
1039
-+	ctx->H[0] = a;
1040
-+	ctx->H[1] = b;
1041
-+	ctx->H[2] = c;
1042
-+	ctx->H[3] = d;
1043
-+	ctx->H[4] = e;
1044
-+	ctx->H[5] = f;
1045
-+	ctx->H[6] = g;
1046
-+	ctx->H[7] = h;
1047
-+}
1048
-+
1049
-+
1050
-+/* Initialize structure containing state of computation.
1051
-+   (FIPS 180-2:5.3.2)  */
1052
-+static void sha256_init_ctx(struct sha256_ctx *ctx) {
1053
-+	ctx->H[0] = 0x6a09e667;
1054
-+	ctx->H[1] = 0xbb67ae85;
1055
-+	ctx->H[2] = 0x3c6ef372;
1056
-+	ctx->H[3] = 0xa54ff53a;
1057
-+	ctx->H[4] = 0x510e527f;
1058
-+	ctx->H[5] = 0x9b05688c;
1059
-+	ctx->H[6] = 0x1f83d9ab;
1060
-+	ctx->H[7] = 0x5be0cd19;
1061
-+
1062
-+	ctx->total[0] = ctx->total[1] = 0;
1063
-+	ctx->buflen = 0;
1064
-+}
1065
-+
1066
-+
1067
-+/* Process the remaining bytes in the internal buffer and the usual
1068
-+   prolog according to the standard and write the result to RESBUF.
1069
-+
1070
-+   IMPORTANT: On some systems it is required that RESBUF is correctly
1071
-+   aligned for a 32 bits value.  */
1072
-+static void * sha256_finish_ctx(struct sha256_ctx *ctx, void *resbuf) {
1073
-+	/* Take yet unprocessed bytes into account.  */
1074
-+	uint32_t bytes = ctx->buflen;
1075
-+	size_t pad;
1076
-+	unsigned int i;
1077
-+
1078
-+	/* Now count remaining bytes.  */
1079
-+	ctx->total[0] += bytes;
1080
-+	if (ctx->total[0] < bytes) {
1081
-+		++ctx->total[1];
1082
-+	}
1083
-+
1084
-+	pad = bytes >= 56 ? 64 + 56 - bytes : 56 - bytes;
1085
-+	memcpy(&ctx->buffer[bytes], fillbuf, pad);
1086
-+
1087
-+	/* Put the 64-bit file length in *bits* at the end of the buffer.  */
1088
-+	*(uint32_t *) &ctx->buffer[bytes + pad + 4] = SWAP (ctx->total[0] << 3);
1089
-+	*(uint32_t *) &ctx->buffer[bytes + pad] = SWAP ((ctx->total[1] << 3) |
1090
-+						  (ctx->total[0] >> 29));
1091
-+
1092
-+	/* Process last bytes.  */
1093
-+	sha256_process_block(ctx->buffer, bytes + pad + 8, ctx);
1094
-+
1095
-+	/* Put result from CTX in first 32 bytes following RESBUF.  */
1096
-+	for (i = 0; i < 8; ++i) {
1097
-+		((uint32_t *) resbuf)[i] = SWAP(ctx->H[i]);
1098
-+	}
1099
-+
1100
-+	return resbuf;
1101
-+}
1102
-+
1103
-+
1104
-+static void sha256_process_bytes(const void *buffer, size_t len, struct sha256_ctx *ctx) {
1105
-+	/* When we already have some bits in our internal buffer concatenate
1106
-+	 both inputs first.  */
1107
-+	if (ctx->buflen != 0) {
1108
-+		size_t left_over = ctx->buflen;
1109
-+		size_t add = 128 - left_over > len ? len : 128 - left_over;
1110
-+
1111
-+		  memcpy(&ctx->buffer[left_over], buffer, add);
1112
-+		  ctx->buflen += add;
1113
-+
1114
-+		if (ctx->buflen > 64) {
1115
-+			sha256_process_block(ctx->buffer, ctx->buflen & ~63, ctx);
1116
-+			ctx->buflen &= 63;
1117
-+			/* The regions in the following copy operation cannot overlap.  */
1118
-+			memcpy(ctx->buffer, &ctx->buffer[(left_over + add) & ~63], ctx->buflen);
1119
-+		}
1120
-+
1121
-+		buffer = (const char *) buffer + add;
1122
-+		len -= add;
1123
-+	}
1124
-+
1125
-+	/* Process available complete blocks.  */
1126
-+	if (len >= 64) {
1127
-+/* To check alignment gcc has an appropriate operator.  Other
1128
-+compilers don't.  */
1129
-+#if __GNUC__ >= 2
1130
-+# define UNALIGNED_P(p) (((uintptr_t) p) % __alignof__ (uint32_t) != 0)
1131
-+#else
1132
-+# define UNALIGNED_P(p) (((uintptr_t) p) % sizeof (uint32_t) != 0)
1133
-+#endif
1134
-+		if (UNALIGNED_P (buffer))
1135
-+			while (len > 64) {
1136
-+				sha256_process_block(memcpy(ctx->buffer, buffer, 64), 64, ctx);
1137
-+				buffer = (const char *) buffer + 64;
1138
-+				len -= 64;
1139
-+			} else {
1140
-+				sha256_process_block(buffer, len & ~63, ctx);
1141
-+				buffer = (const char *) buffer + (len & ~63);
1142
-+				len &= 63;
1143
-+			}
1144
-+	}
1145
-+
1146
-+	/* Move remaining bytes into internal buffer.  */
1147
-+	if (len > 0) {
1148
-+		size_t left_over = ctx->buflen;
1149
-+
1150
-+		memcpy(&ctx->buffer[left_over], buffer, len);
1151
-+		left_over += len;
1152
-+		if (left_over >= 64) {
1153
-+			sha256_process_block(ctx->buffer, 64, ctx);
1154
-+			left_over -= 64;
1155
-+			memcpy(ctx->buffer, &ctx->buffer[64], left_over);
1156
-+		}
1157
-+		ctx->buflen = left_over;
1158
-+	}
1159
-+}
1160
-+
1161
-+
1162
-+/* Define our magic string to mark salt for SHA256 "encryption"
1163
-+   replacement.  */
1164
-+static const char sha256_salt_prefix[] = "$5$";
1165
-+
1166
-+/* Prefix for optional rounds specification.  */
1167
-+static const char sha256_rounds_prefix[] = "rounds=";
1168
-+
1169
-+/* Maximum salt string length.  */
1170
-+#define SALT_LEN_MAX 16
1171
-+/* Default number of rounds if not explicitly specified.  */
1172
-+#define ROUNDS_DEFAULT 5000
1173
-+/* Minimum number of rounds.  */
1174
-+#define ROUNDS_MIN 1000
1175
-+/* Maximum number of rounds.  */
1176
-+#define ROUNDS_MAX 999999999
1177
-+
1178
-+/* Table with characters for base64 transformation.  */
1179
-+static const char b64t[64] =
1180
-+"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
1181
-+
1182
-+char * php_sha256_crypt_r(const char *key, const char *salt, char *buffer, int buflen)
1183
-+{
1184
-+#ifdef PHP_WIN32
1185
-+	__declspec(align(32)) unsigned char alt_result[32];
1186
-+	__declspec(align(32)) unsigned char temp_result[32];
1187
-+#else
1188
-+	unsigned char alt_result[32]
1189
-+	__attribute__ ((__aligned__ (__alignof__ (uint32_t))));
1190
-+	unsigned char temp_result[32]
1191
-+	__attribute__ ((__aligned__ (__alignof__ (uint32_t))));
1192
-+#endif
1193
-+
1194
-+	struct sha256_ctx ctx;
1195
-+	struct sha256_ctx alt_ctx;
1196
-+	size_t salt_len;
1197
-+	size_t key_len;
1198
-+	size_t cnt;
1199
-+	char *cp;
1200
-+	char *copied_key = NULL;
1201
-+	char *copied_salt = NULL;
1202
-+	char *p_bytes;
1203
-+	char *s_bytes;
1204
-+	/* Default number of rounds.  */
1205
-+	size_t rounds = ROUNDS_DEFAULT;
1206
-+	bool rounds_custom = false;
1207
-+
1208
-+	/* Find beginning of salt string.  The prefix should normally always
1209
-+	be present.  Just in case it is not.  */
1210
-+	if (strncmp(sha256_salt_prefix, salt, sizeof(sha256_salt_prefix) - 1) == 0) {
1211
-+		/* Skip salt prefix.  */
1212
-+		salt += sizeof(sha256_salt_prefix) - 1;
1213
-+	}
1214
-+
1215
-+	if (strncmp(salt, sha256_rounds_prefix, sizeof(sha256_rounds_prefix) - 1) == 0) {
1216
-+		const char *num = salt + sizeof(sha256_rounds_prefix) - 1;
1217
-+		char *endp;
1218
-+		unsigned long int srounds = strtoul(num, &endp, 10);
1219
-+		if (*endp == '$') {
1220
-+			salt = endp + 1;
1221
-+			rounds = MAX(ROUNDS_MIN, MIN(srounds, ROUNDS_MAX));
1222
-+			rounds_custom = true;
1223
-+		}
1224
-+	}
1225
-+
1226
-+	salt_len = MIN(strcspn(salt, "$"), SALT_LEN_MAX);
1227
-+	key_len = strlen(key);
1228
-+
1229
-+	if ((key - (char *) 0) % __alignof__ (uint32_t) != 0) {
1230
-+		char *tmp = (char *) alloca(key_len + __alignof__(uint32_t));
1231
-+		key = copied_key = memcpy(tmp + __alignof__(uint32_t) - (tmp - (char *) 0) % __alignof__(uint32_t), key, key_len);
1232
-+	}
1233
-+
1234
-+	if ((salt - (char *) 0) % __alignof__(uint32_t) != 0) {
1235
-+		char *tmp = (char *) alloca(salt_len + __alignof__(uint32_t));
1236
-+		salt = copied_salt =
1237
-+		memcpy(tmp + __alignof__(uint32_t) - (tmp - (char *) 0) % __alignof__ (uint32_t), salt, salt_len);
1238
-+	}
1239
-+
1240
-+	/* Prepare for the real work.  */
1241
-+	sha256_init_ctx(&ctx);
1242
-+
1243
-+	/* Add the key string.  */
1244
-+	sha256_process_bytes(key, key_len, &ctx);
1245
-+
1246
-+	/* The last part is the salt string.  This must be at most 16
1247
-+	 characters and it ends at the first `$' character (for
1248
-+	 compatibility with existing implementations).  */
1249
-+	sha256_process_bytes(salt, salt_len, &ctx);
1250
-+
1251
-+
1252
-+	/* Compute alternate SHA256 sum with input KEY, SALT, and KEY.  The
1253
-+	 final result will be added to the first context.  */
1254
-+	sha256_init_ctx(&alt_ctx);
1255
-+
1256
-+	/* Add key.  */
1257
-+	sha256_process_bytes(key, key_len, &alt_ctx);
1258
-+
1259
-+	/* Add salt.  */
1260
-+	sha256_process_bytes(salt, salt_len, &alt_ctx);
1261
-+
1262
-+	/* Add key again.  */
1263
-+	sha256_process_bytes(key, key_len, &alt_ctx);
1264
-+
1265
-+	/* Now get result of this (32 bytes) and add it to the other
1266
-+	 context.  */
1267
-+	sha256_finish_ctx(&alt_ctx, alt_result);
1268
-+
1269
-+	/* Add for any character in the key one byte of the alternate sum.  */
1270
-+	for (cnt = key_len; cnt > 32; cnt -= 32) {
1271
-+		sha256_process_bytes(alt_result, 32, &ctx);
1272
-+	}
1273
-+	sha256_process_bytes(alt_result, cnt, &ctx);
1274
-+
1275
-+	/* Take the binary representation of the length of the key and for every
1276
-+	1 add the alternate sum, for every 0 the key.  */
1277
-+	for (cnt = key_len; cnt > 0; cnt >>= 1) {
1278
-+		if ((cnt & 1) != 0) {
1279
-+			sha256_process_bytes(alt_result, 32, &ctx);
1280
-+		} else {
1281
-+			sha256_process_bytes(key, key_len, &ctx);
1282
-+		}
1283
-+	}
1284
-+
1285
-+	/* Create intermediate result.  */
1286
-+	sha256_finish_ctx(&ctx, alt_result);
1287
-+
1288
-+	/* Start computation of P byte sequence.  */
1289
-+	sha256_init_ctx(&alt_ctx);
1290
-+
1291
-+	/* For every character in the password add the entire password.  */
1292
-+	for (cnt = 0; cnt < key_len; ++cnt) {
1293
-+		sha256_process_bytes(key, key_len, &alt_ctx);
1294
-+	}
1295
-+
1296
-+	/* Finish the digest.  */
1297
-+	sha256_finish_ctx(&alt_ctx, temp_result);
1298
-+
1299
-+	/* Create byte sequence P.  */
1300
-+	cp = p_bytes = alloca(key_len);
1301
-+	for (cnt = key_len; cnt >= 32; cnt -= 32) {
1302
-+		cp = mempcpy((void *)cp, (const void *)temp_result, 32);
1303
-+	}
1304
-+	memcpy(cp, temp_result, cnt);
1305
-+
1306
-+	/* Start computation of S byte sequence.  */
1307
-+	sha256_init_ctx(&alt_ctx);
1308
-+
1309
-+	/* For every character in the password add the entire password.  */
1310
-+	for (cnt = 0; cnt < 16 + alt_result[0]; ++cnt) {
1311
-+		sha256_process_bytes(salt, salt_len, &alt_ctx);
1312
-+	}
1313
-+
1314
-+	/* Finish the digest.  */
1315
-+	sha256_finish_ctx(&alt_ctx, temp_result);
1316
-+
1317
-+	/* Create byte sequence S.  */
1318
-+	cp = s_bytes = alloca(salt_len);
1319
-+	for (cnt = salt_len; cnt >= 32; cnt -= 32) {
1320
-+		cp = mempcpy(cp, temp_result, 32);
1321
-+	}
1322
-+	memcpy(cp, temp_result, cnt);
1323
-+
1324
-+	/* Repeatedly run the collected hash value through SHA256 to burn
1325
-+	CPU cycles.  */
1326
-+	for (cnt = 0; cnt < rounds; ++cnt) {
1327
-+		/* New context.  */
1328
-+		sha256_init_ctx(&ctx);
1329
-+
1330
-+		/* Add key or last result.  */
1331
-+		if ((cnt & 1) != 0) {
1332
-+			sha256_process_bytes(p_bytes, key_len, &ctx);
1333
-+		} else {
1334
-+			sha256_process_bytes(alt_result, 32, &ctx);
1335
-+		}
1336
-+
1337
-+		/* Add salt for numbers not divisible by 3.  */
1338
-+		if (cnt % 3 != 0) {
1339
-+			sha256_process_bytes(s_bytes, salt_len, &ctx);
1340
-+		}
1341
-+
1342
-+		/* Add key for numbers not divisible by 7.  */
1343
-+		if (cnt % 7 != 0) {
1344
-+			sha256_process_bytes(p_bytes, key_len, &ctx);
1345
-+		}
1346
-+
1347
-+		/* Add key or last result.  */
1348
-+		if ((cnt & 1) != 0) {
1349
-+			sha256_process_bytes(alt_result, 32, &ctx);
1350
-+		} else {
1351
-+			sha256_process_bytes(p_bytes, key_len, &ctx);
1352
-+		}
1353
-+
1354
-+		/* Create intermediate result.  */
1355
-+		sha256_finish_ctx(&ctx, alt_result);
1356
-+	}
1357
-+
1358
-+	/* Now we can construct the result string.  It consists of three
1359
-+	parts.  */
1360
-+	cp = stpncpy(buffer, sha256_salt_prefix, MAX(0, buflen));
1361
-+	buflen -= sizeof(sha256_salt_prefix) - 1;
1362
-+
1363
-+	if (rounds_custom) {
1364
-+#ifdef PHP_WIN32
1365
-+		int n = _snprintf(cp, MAX(0, buflen), "%s%u$", sha256_rounds_prefix, rounds);
1366
-+#else
1367
-+		int n = snprintf(cp, MAX(0, buflen), "%s%zu$", sha256_rounds_prefix, rounds);
1368
-+#endif
1369
-+		cp += n;
1370
-+		buflen -= n;
1371
-+	}
1372
-+
1373
-+	cp = stpncpy(cp, salt, MIN ((size_t) MAX (0, buflen), salt_len));
1374
-+	buflen -= MIN((size_t) MAX (0, buflen), salt_len);
1375
-+
1376
-+	if (buflen > 0) {
1377
-+		*cp++ = '$';
1378
-+		--buflen;
1379
-+	}
1380
-+
1381
-+#define b64_from_24bit(B2, B1, B0, N)					      \
1382
-+  do {									      \
1383
-+    unsigned int w = ((B2) << 16) | ((B1) << 8) | (B0);			      \
1384
-+    int n = (N);							      \
1385
-+    while (n-- > 0 && buflen > 0)					      \
1386
-+      {									      \
1387
-+	*cp++ = b64t[w & 0x3f];						      \
1388
-+	--buflen;							      \
1389
-+	w >>= 6;							      \
1390
-+      }									      \
1391
-+  } while (0)
1392
-+
1393
-+	b64_from_24bit(alt_result[0], alt_result[10], alt_result[20], 4);
1394
-+	b64_from_24bit(alt_result[21], alt_result[1], alt_result[11], 4);
1395
-+	b64_from_24bit(alt_result[12], alt_result[22], alt_result[2], 4);
1396
-+	b64_from_24bit(alt_result[3], alt_result[13], alt_result[23], 4);
1397
-+	b64_from_24bit(alt_result[24], alt_result[4], alt_result[14], 4);
1398
-+	b64_from_24bit(alt_result[15], alt_result[25], alt_result[5], 4);
1399
-+	b64_from_24bit(alt_result[6], alt_result[16], alt_result[26], 4);
1400
-+	b64_from_24bit(alt_result[27], alt_result[7], alt_result[17], 4);
1401
-+	b64_from_24bit(alt_result[18], alt_result[28], alt_result[8], 4);
1402
-+	b64_from_24bit(alt_result[9], alt_result[19], alt_result[29], 4);
1403
-+	b64_from_24bit(0, alt_result[31], alt_result[30], 3);
1404
-+	if (buflen <= 0) {
1405
-+		errno = ERANGE;
1406
-+		buffer = NULL;
1407
-+	} else
1408
-+		*cp = '\0';		/* Terminate the string.  */
1409
-+
1410
-+	/* Clear the buffer for the intermediate result so that people
1411
-+     attaching to processes or reading core dumps cannot get any
1412
-+     information.  We do it in this way to clear correct_words[]
1413
-+     inside the SHA256 implementation as well.  */
1414
-+	sha256_init_ctx(&ctx);
1415
-+	sha256_finish_ctx(&ctx, alt_result);
1416
-+	memset(temp_result, '\0', sizeof(temp_result));
1417
-+	memset(p_bytes, '\0', key_len);
1418
-+	memset(s_bytes, '\0', salt_len);
1419
-+	memset(&ctx, '\0', sizeof(ctx));
1420
-+	memset(&alt_ctx, '\0', sizeof(alt_ctx));
1421
-+
1422
-+	if (copied_key != NULL) {
1423
-+		memset(copied_key, '\0', key_len);
1424
-+
1425
-+	}
1426
-+	if (copied_salt != NULL) {
1427
-+		memset(copied_salt, '\0', salt_len);
1428
-+	}
1429
-+
1430
-+	return buffer;
1431
-+}
1432
-+
1433
-+
1434
-+/* This entry point is equivalent to the `crypt' function in Unix
1435
-+   libcs.  */
1436
-+char * php_sha256_crypt(const char *key, const char *salt)
1437
-+{
1438
-+	/* We don't want to have an arbitrary limit in the size of the
1439
-+	password.  We can compute an upper bound for the size of the
1440
-+	result in advance and so we can prepare the buffer we pass to
1441
-+	`sha256_crypt_r'.  */
1442
-+	static char *buffer;
1443
-+	static int buflen;
1444
-+	int needed = (sizeof(sha256_salt_prefix) - 1
1445
-+			+ sizeof(sha256_rounds_prefix) + 9 + 1
1446
-+			+ strlen(salt) + 1 + 43 + 1);
1447
-+
1448
-+	if (buflen < needed) {
1449
-+		char *new_buffer = (char *) realloc(buffer, needed);
1450
-+		if (new_buffer == NULL) {
1451
-+			return NULL;
1452
-+		}
1453
-+
1454
-+		buffer = new_buffer;
1455
-+		buflen = needed;
1456
-+	}
1457
-+
1458
-+	return php_sha256_crypt_r(key, salt, buffer, buflen);
1459
-+}
1460
-+
1461
-+
1462
-+#ifdef TEST
1463
-+static const struct
1464
-+{
1465
-+	const char *input;
1466
-+	const char result[32];
1467
-+} tests[] =
1468
-+	{
1469
-+	/* Test vectors from FIPS 180-2: appendix B.1.  */
1470
-+	{ "abc",
1471
-+	"\xba\x78\x16\xbf\x8f\x01\xcf\xea\x41\x41\x40\xde\x5d\xae\x22\x23"
1472
-+	"\xb0\x03\x61\xa3\x96\x17\x7a\x9c\xb4\x10\xff\x61\xf2\x00\x15\xad" },
1473
-+	/* Test vectors from FIPS 180-2: appendix B.2.  */
1474
-+	{ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
1475
-+	"\x24\x8d\x6a\x61\xd2\x06\x38\xb8\xe5\xc0\x26\x93\x0c\x3e\x60\x39"
1476
-+	"\xa3\x3c\xe4\x59\x64\xff\x21\x67\xf6\xec\xed\xd4\x19\xdb\x06\xc1" },
1477
-+	/* Test vectors from the NESSIE project.  */
1478
-+	{ "",
1479
-+	"\xe3\xb0\xc4\x42\x98\xfc\x1c\x14\x9a\xfb\xf4\xc8\x99\x6f\xb9\x24"
1480
-+	"\x27\xae\x41\xe4\x64\x9b\x93\x4c\xa4\x95\x99\x1b\x78\x52\xb8\x55" },
1481
-+	{ "a",
1482
-+	"\xca\x97\x81\x12\xca\x1b\xbd\xca\xfa\xc2\x31\xb3\x9a\x23\xdc\x4d"
1483
-+	"\xa7\x86\xef\xf8\x14\x7c\x4e\x72\xb9\x80\x77\x85\xaf\xee\x48\xbb" },
1484
-+	{ "message digest",
1485
-+	"\xf7\x84\x6f\x55\xcf\x23\xe1\x4e\xeb\xea\xb5\xb4\xe1\x55\x0c\xad"
1486
-+	"\x5b\x50\x9e\x33\x48\xfb\xc4\xef\xa3\xa1\x41\x3d\x39\x3c\xb6\x50" },
1487
-+	{ "abcdefghijklmnopqrstuvwxyz",
1488
-+	"\x71\xc4\x80\xdf\x93\xd6\xae\x2f\x1e\xfa\xd1\x44\x7c\x66\xc9\x52"
1489
-+	"\x5e\x31\x62\x18\xcf\x51\xfc\x8d\x9e\xd8\x32\xf2\xda\xf1\x8b\x73" },
1490
-+	{ "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq",
1491
-+	"\x24\x8d\x6a\x61\xd2\x06\x38\xb8\xe5\xc0\x26\x93\x0c\x3e\x60\x39"
1492
-+	"\xa3\x3c\xe4\x59\x64\xff\x21\x67\xf6\xec\xed\xd4\x19\xdb\x06\xc1" },
1493
-+	{ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
1494
-+	"\xdb\x4b\xfc\xbd\x4d\xa0\xcd\x85\xa6\x0c\x3c\x37\xd3\xfb\xd8\x80"
1495
-+	"\x5c\x77\xf1\x5f\xc6\xb1\xfd\xfe\x61\x4e\xe0\xa7\xc8\xfd\xb4\xc0" },
1496
-+	{ "123456789012345678901234567890123456789012345678901234567890"
1497
-+	"12345678901234567890",
1498
-+	"\xf3\x71\xbc\x4a\x31\x1f\x2b\x00\x9e\xef\x95\x2d\xd8\x3c\xa8\x0e"
1499
-+	"\x2b\x60\x02\x6c\x8e\x93\x55\x92\xd0\xf9\xc3\x08\x45\x3c\x81\x3e" }
1500
-+  };
1501
-+#define ntests (sizeof (tests) / sizeof (tests[0]))
1502
-+
1503
-+
1504
-+static const struct
1505
-+{
1506
-+	const char *salt;
1507
-+	const char *input;
1508
-+	const char *expected;
1509
-+} tests2[] =
1510
-+{
1511
-+	{ "$5$saltstring", "Hello world!",
1512
-+	"$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5" },
1513
-+	{ "$5$rounds=10000$saltstringsaltstring", "Hello world!",
1514
-+	"$5$rounds=10000$saltstringsaltst$3xv.VbSHBb41AL9AvLeujZkZRBAwqFMz2."
1515
-+	"opqey6IcA" },
1516
-+	{ "$5$rounds=5000$toolongsaltstring", "This is just a test",
1517
-+	"$5$rounds=5000$toolongsaltstrin$Un/5jzAHMgOGZ5.mWJpuVolil07guHPvOW8"
1518
-+	"mGRcvxa5" },
1519
-+	{ "$5$rounds=1400$anotherlongsaltstring",
1520
-+	"a very much longer text to encrypt.  This one even stretches over more"
1521
-+	"than one line.",
1522
-+	"$5$rounds=1400$anotherlongsalts$Rx.j8H.h8HjEDGomFU8bDkXm3XIUnzyxf12"
1523
-+	"oP84Bnq1" },
1524
-+	{ "$5$rounds=77777$short",
1525
-+	"we have a short salt string but not a short password",
1526
-+	"$5$rounds=77777$short$JiO1O3ZpDAxGJeaDIuqCoEFysAe1mZNJRs3pw0KQRd/" },
1527
-+	{ "$5$rounds=123456$asaltof16chars..", "a short string",
1528
-+	"$5$rounds=123456$asaltof16chars..$gP3VQ/6X7UUEW3HkBn2w1/Ptq2jxPyzV/"
1529
-+	"cZKmF/wJvD" },
1530
-+	{ "$5$rounds=10$roundstoolow", "the minimum number is still observed",
1531
-+	"$5$rounds=1000$roundstoolow$yfvwcWrQ8l/K0DAWyuPMDNHpIVlTQebY9l/gL97"
1532
-+	"2bIC" },
1533
-+};
1534
-+#define ntests2 (sizeof (tests2) / sizeof (tests2[0]))
1535
-+
1536
-+
1537
-+int main(void) {
1538
-+	struct sha256_ctx ctx;
1539
-+	char sum[32];
1540
-+	int result = 0;
1541
-+	int cnt, i;
1542
-+	char buf[1000];
1543
-+	static const char expected[32] =
1544
-+	"\xcd\xc7\x6e\x5c\x99\x14\xfb\x92\x81\xa1\xc7\xe2\x84\xd7\x3e\x67"
1545
-+	"\xf1\x80\x9a\x48\xa4\x97\x20\x0e\x04\x6d\x39\xcc\xc7\x11\x2c\xd0";
1546
-+
1547
-+	for (cnt = 0; cnt < (int) ntests; ++cnt) {
1548
-+		sha256_init_ctx(&ctx);
1549
-+		sha256_process_bytes(tests[cnt].input, strlen(tests[cnt].input), &ctx);
1550
-+		sha256_finish_ctx(&ctx, sum);
1551
-+		if (memcmp(tests[cnt].result, sum, 32) != 0) {
1552
-+			printf("test %d run %d failed\n", cnt, 1);
1553
-+			result = 1;
1554
-+		}
1555
-+
1556
-+		sha256_init_ctx(&ctx);
1557
-+		for (i = 0; tests[cnt].input[i] != '\0'; ++i) {
1558
-+			sha256_process_bytes(&tests[cnt].input[i], 1, &ctx);
1559
-+		}
1560
-+		sha256_finish_ctx(&ctx, sum);
1561
-+		if (memcmp(tests[cnt].result, sum, 32) != 0) {
1562
-+			printf("test %d run %d failed\n", cnt, 2);
1563
-+			result = 1;
1564
-+		}
1565
-+	}
1566
-+
1567
-+	/* Test vector from FIPS 180-2: appendix B.3.  */
1568
-+
1569
-+	memset(buf, 'a', sizeof(buf));
1570
-+	sha256_init_ctx(&ctx);
1571
-+	for (i = 0; i < 1000; ++i) {
1572
-+		sha256_process_bytes (buf, sizeof (buf), &ctx);
1573
-+	}
1574
-+
1575
-+	sha256_finish_ctx(&ctx, sum);
1576
-+
1577
-+	if (memcmp(expected, sum, 32) != 0) {
1578
-+		printf("test %d failed\n", cnt);
1579
-+		result = 1;
1580
-+	}
1581
-+
1582
-+	for (cnt = 0; cnt < ntests2; ++cnt) {
1583
-+		char *cp = php_sha256_crypt(tests2[cnt].input, tests2[cnt].salt);
1584
-+		if (strcmp(cp, tests2[cnt].expected) != 0) {
1585
-+			printf("test %d: expected \"%s\", got \"%s\"\n", cnt, tests2[cnt].expected, cp);
1586
-+			result = 1;
1587
-+		}
1588
-+	}
1589
-+
1590
-+	if (result == 0)
1591
-+	puts("all tests OK");
1592
-+
1593
-+	return result;
1594
-+}
1595
-+#endif
1596
-Index: ext/standard/config.w32
1597
-===================================================================
1598
---- ext/standard/config.w32	(Revision 291898)
1599
-+++ ext/standard/config.w32	(Revision 291899)
1600
-@@ -9,8 +9,8 @@
1601
- CHECK_HEADER_ADD_INCLUDE("timelib_config.h", "CFLAGS_STANDARD", "ext/date/lib");
1602
- 
1603
- EXTENSION("standard", "array.c base64.c basic_functions.c browscap.c \
1604
--	crc32.c crypt.c \
1605
--	crypt_freesec.c crypt_blowfish.c php_crypt_r.c \
1606
-+	crc32.c crypt.c crypt_freesec.c crypt_blowfish.c crypt_sha256.c \
1607
-+	crypt_sha512.c  php_crypt_r.c \
1608
- 	cyr_convert.c datetime.c dir.c dl.c dns.c dns_win32.c exec.c \
1609
- 	file.c filestat.c formatted_print.c fsock.c head.c html.c image.c \
1610
- 	info.c iptc.c lcg.c link_win32.c mail.c math.c md5.c metaphone.c microtime.c \
1611
-Index: ext/standard/php_crypt_r.h
1612
-===================================================================
1613
---- ext/standard/php_crypt_r.h	(Revision 291898)
1614
-+++ ext/standard/php_crypt_r.h	(Revision 291899)
1615
-@@ -49,6 +49,8 @@
1616
- extern char * php_md5_crypt_r(const char *pw, const char *salt, char *out);
1617
- extern char * php_crypt_blowfish_rn(__CONST char *key, __CONST char *setting,
1618
- 	char *output, int size);
1619
-+extern char * php_sha512_crypt_r (const char *key, const char *salt, char *buffer, int buflen);
1620
-+extern char * php_sha256_crypt_r (const char *key, const char *salt, char *buffer, int buflen);
1621
- 
1622
- #ifdef __cplusplus
1623
- }
1624
-Index: ext/standard/crypt.c
1625
-===================================================================
1626
---- ext/standard/crypt.c	(Revision 291898)
1627
-+++ ext/standard/crypt.c	(Revision 291899)
1628
-@@ -82,6 +82,12 @@
1629
- #define PHP_MAX_SALT_LEN 60
1630
- #endif
1631
- 
1632
-+#if PHP_SHA512_CRYPT
1633
-+#undef PHP_MAX_SALT_LEN
1634
-+#define PHP_MAX_SALT_LEN 123
1635
-+#endif
1636
-+
1637
-+
1638
- /* If the configure-time checks fail, we provide DES.
1639
-  * XXX: This is a hack. Fix the real problem! */
1640
- 
1641
-@@ -163,6 +169,7 @@
1642
- 		php_to64(&salt[0], PHP_CRYPT_RAND, 2);
1643
- 		salt[2] = '\0';
1644
- #endif
1645
-+		salt_in_len = strlen(salt);
1646
- 	}
1647
- 
1648
- /* Windows (win32/crypt) has a stripped down version of libxcrypt and 
1649
-@@ -175,7 +182,36 @@
1650
- 			char output[MD5_HASH_MAX_LEN];
1651
- 
1652
- 			RETURN_STRING(php_md5_crypt_r(str, salt, output), 1);
1653
--		} else  if (
1654
-+		} else if (salt[0]=='$' && salt[1]=='6' && salt[2]=='$') {
1655
-+			const char sha512_salt_prefix[] = "$6$";
1656
-+			const char sha512_rounds_prefix[] = "rounds=";
1657
-+			char *output;
1658
-+			int needed = (sizeof(sha512_salt_prefix) - 1
1659
-+						+ sizeof(sha512_rounds_prefix) + 9 + 1
1660
-+						+ strlen(salt) + 1 + 43 + 1);
1661
-+			output = emalloc(needed * sizeof(char *));
1662
-+			salt[salt_in_len] = '\0';
1663
-+
1664
-+			php_sha512_crypt_r(str, salt, output, needed);
1665
-+
1666
-+			RETVAL_STRING(output, 1);
1667
-+			memset(output, 0, PHP_MAX_SALT_LEN + 1);
1668
-+			efree(output);
1669
-+		} else if (salt[0]=='$' && salt[1]=='5' && salt[2]=='$') {
1670
-+			const char sha256_salt_prefix[] = "$5$";
1671
-+			const char sha256_rounds_prefix[] = "rounds=";
1672
-+			char *output;
1673
-+			int needed = (sizeof(sha256_salt_prefix) - 1
1674
-+						+ sizeof(sha256_rounds_prefix) + 9 + 1
1675
-+						+ strlen(salt) + 1 + 43 + 1);
1676
-+			output = emalloc(needed * sizeof(char *));
1677
-+			salt[salt_in_len] = '\0';
1678
-+			php_sha256_crypt_r(str, salt, output, needed);
1679
-+
1680
-+			RETVAL_STRING(output, 1);
1681
-+			memset(output, 0, PHP_MAX_SALT_LEN + 1);
1682
-+			efree(output);
1683
-+		} else if (
1684
- 				salt[0] == '$' &&
1685
- 				salt[1] == '2' &&
1686
- 				salt[2] == 'a' &&
1687
-Index: ext/standard/config.m4
1688
-===================================================================
1689
---- ext/standard/config.m4	(Revision 291898)
1690
-+++ ext/standard/config.m4	(Revision 291899)
1691
-@@ -172,6 +172,65 @@
1692
-   ac_cv_crypt_blowfish=no
1693
- ])])
1694
- 
1695
-+AC_CACHE_CHECK(for SHA512 crypt, ac_cv_crypt_SHA512,[
1696
-+AC_TRY_RUN([
1697
-+#if HAVE_UNISTD_H
1698
-+#include <unistd.h>
1699
-+#endif
1700
-+
1701
-+#if HAVE_CRYPT_H
1702
-+#include <crypt.h>
1703
-+#endif
1704
-+
1705
-+main() {
1706
-+#if HAVE_CRYPT
1707
-+    char salt[30], answer[80];
1708
-+    
1709
-+    salt[0]='$'; salt[1]='6'; salt[2]='$'; salt[3]='$'; salt[4]='b'; salt[5]='a'; salt[6]='r'; salt[7]='\0';
1710
-+    strcpy(answer, salt);
1711
-+    strcpy(&answer[29],"$6$$QMXjqd7rHQZPQ1yHsXkQqC1FBzDiVfTHXL.LaeDAeVV.IzMaV9VU4MQ8kPuZa2SOP1A0RPm772EaFYjpEJtdu.");
1712
-+    exit (strcmp((char *)crypt("foo",salt),answer));
1713
-+#else
1714
-+	exit(0);
1715
-+#endif
1716
-+}],[
1717
-+  ac_cv_crypt_SHA512=yes
1718
-+],[
1719
-+  ac_cv_crypt_SHA512=no
1720
-+],[
1721
-+  ac_cv_crypt_SHA512=no
1722
-+])])
1723
-+
1724
-+AC_CACHE_CHECK(for SHA256 crypt, ac_cv_crypt_SHA256,[
1725
-+AC_TRY_RUN([
1726
-+#if HAVE_UNISTD_H
1727
-+#include <unistd.h>
1728
-+#endif
1729
-+
1730
-+#if HAVE_CRYPT_H
1731
-+#include <crypt.h>
1732
-+#endif
1733
-+
1734
-+main() {
1735
-+#if HAVE_CRYPT
1736
-+    char salt[30], answer[80];
1737
-+    salt[0]='$'; salt[1]='5'; salt[2]='$'; salt[3]='$'; salt[4]='s'; salt[5]='a'; salt[6]='l'; salt[7]='t';  salt[8]='s'; salt[9]='t'; salt[10]='r'; salt[11]='i'; salt[12]='n'; salt[13]='g'; salt[14]='\0';    
1738
-+    strcat(salt,"");
1739
-+    strcpy(answer, salt);
1740
-+    strcpy(&answer[29], "$5$saltstring$5B8vYYiY.CVt1RlTTf8KbXBH3hsxY/GNooZaBBGWEc5");
1741
-+    exit (strcmp((char *)crypt("foo",salt),answer));
1742
-+#else
1743
-+	exit(0);
1744
-+#endif
1745
-+}],[
1746
-+  ac_cv_crypt_SHA256=yes
1747
-+],[
1748
-+  ac_cv_crypt_SHA256=no
1749
-+],[
1750
-+  ac_cv_crypt_SHA256=no
1751
-+])])
1752
-+
1753
-+
1754
- dnl
1755
- dnl If one of them is missing, use our own implementation, portable code is then possible
1756
- dnl
1757
-@@ -181,8 +240,10 @@
1758
-   AC_DEFINE_UNQUOTED(PHP_BLOWFISH_CRYPT, 1, [Whether the system supports BlowFish salt])
1759
-   AC_DEFINE_UNQUOTED(PHP_EXT_DES_CRYPT, 1, [Whether the system supports extended DES salt])
1760
-   AC_DEFINE_UNQUOTED(PHP_MD5_CRYPT, 1, [Whether the system supports extended DES salt])
1761
-+  AC_DEFINE_UNQUOTED(PHP_SHA512_CRYPT, 1, [Whether the system supports SHA512 salt])
1762
-+  AC_DEFINE_UNQUOTED(PHP_SHA256_CRYPT, 1, [Whether the system supports SHA256 salt])
1763
- 
1764
--  PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c php_crypt_r.c)
1765
-+  PHP_ADD_SOURCES(PHP_EXT_DIR(standard), crypt_freesec.c crypt_blowfish.c crypt_sha512.c crypt_sha256.c php_crypt_r.c)
1766
- else
1767
-   if test "$ac_cv_crypt_des" = "yes"; then
1768
-     ac_result=1
1769
-@@ -211,13 +272,31 @@
1770
-   fi
1771
-   AC_DEFINE_UNQUOTED(PHP_EXT_DES_CRYPT, $ac_result, [Whether the system supports extended DES salt])
1772
- 
1773
-+  if test "$ac_cv_crypt_sha512" = "yes"; then
1774
-+    ac_result=1
1775
-+    ac_crypt_sha512=1
1776
-+  else
1777
-+    ac_result=0
1778
-+    ac_crypt_sha512=0
1779
-+  fi
1780
-+  AC_DEFINE_UNQUOTED(PHP_EXT_SHA512_CRYPT, $ac_result, [Whether the system supports SHA512 salt])
1781
-+
1782
-+  if test "$ac_cv_crypt_sha256" = "yes"; then
1783
-+    ac_result=1
1784
-+    ac_crypt_sha256=1
1785
-+  else
1786
-+    ac_result=0
1787
-+    ac_crypt_sha256=0
1788
-+  fi
1789
-+  AC_DEFINE_UNQUOTED(PHP_EXT_SHA256_CRYPT, $ac_result, [Whether the system supports SHA256 salt])
1790
-+
1791
-   AC_DEFINE_UNQUOTED(PHP_USE_PHP_CRYPT_R, 0, [Whether PHP has to use its own crypt_r for blowfish, des and ext des])
1792
- fi
1793
- 
1794
- dnl
1795
- dnl Check for available functions
1796
- dnl
1797
--AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan)
1798
-+AC_CHECK_FUNCS(getcwd getwd asinh acosh atanh log1p hypot glob strfmon nice fpclass isinf isnan mempcpy strpncpy)
1799
- AC_FUNC_FNMATCH	
1800
- 
1801
- divert(5)dnl
... ...
@@ -1 +0,0 @@
1
-PHP_5 { global: *; };
... ...
@@ -1,549 +0,0 @@
1
-# Copyright 1999-2009 Gentoo Foundation
2
-# Distributed under the terms of the GNU General Public License v2
3
-# $Header: /var/cvsroot/gentoo-x86/dev-lang/php/php-5.2.10.ebuild,v 1.7 2009/06/30 13:33:13 armin76 Exp $
4
-
5
-CGI_SAPI_USE="discard-path force-cgi-redirect"
6
-APACHE2_SAPI_USE="concurrentmodphp threads"
7
-IUSE="cli cgi ${CGI_SAPI_USE} ${APACHE2_SAPI_USE} fastbuild"
8
-
9
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd"
10
-
11
-# NOTE: Portage doesn't support setting PROVIDE based on the USE flags
12
-#		that have been enabled, so we have to PROVIDE everything for now
13
-#		and hope for the best
14
-PROVIDE="virtual/php virtual/httpd-php"
15
-
16
-# php package settings
17
-SLOT="5.3"
18
-MY_PHP_PV="${PV}"
19
-MY_PHP_P="php-${MY_PHP_PV}"
20
-PHP_PACKAGE="1"
21
-
22
-# php patch settings, general
23
-PHP_PATCHSET_REV="${PR/r/}"
24
-SUHOSIN_PATCH="suhosin-patch-5.3.1RC1-0.9.8.patch.gz"
25
-MULTILIB_PATCH="${MY_PHP_PV}/opt/multilib-search-path.patch"
26
-# php patch settings, ebuild specific
27
-FASTBUILD_PATCH="${MY_PHP_PV}/opt/fastbuild.patch"
28
-CONCURRENTMODPHP_PATCH="${MY_PHP_PV}/opt/concurrent_apache_modules.patch"
29
-# kolab patch - http://kolab.org/cgi-bin/viewcvs-kolab.cgi/server/patches/php/
30
-# bugs about this go to wrobel@gentoo.org
31
-KOLAB_PATCH="${MY_PHP_PV}/opt/kolab-imap-annotations.patch"
32
-
33
-inherit versionator php5_3-sapi apache-module
34
-
35
-# Suhosin patch support
36
-[[ -n "${SUHOSIN_PATCH}" ]] && SRC_URI="${SRC_URI} suhosin? ( http://download.suhosin.org/${SUHOSIN_PATCH} )"
37
-
38
-DESCRIPTION="The PHP language runtime engine: CLI, CGI and Apache2 SAPIs."
39
-
40
-DEPEND="app-admin/php-toolkit
41
-	imap? ( >=virtual/imap-c-client-2006k )
42
-	pcre? ( >=dev-libs/libpcre-7.8 )
43
-	xml? ( >=dev-libs/libxml2-2.7.2-r2 )
44
-	xmlrpc? ( >=dev-libs/libxml2-2.7.2-r2 virtual/libiconv )"
45
-
46
-RDEPEND="${DEPEND}"
47
-if [[ -n "${KOLAB_PATCH}" ]] ; then
48
-	IUSE="${IUSE} kolab"
49
-	DEPEND="${DEPEND}
50
-		kolab? ( >=net-libs/c-client-2004g-r1 )"
51
-fi
52
-
53
-want_apache
54
-
55
-pkg_setup() {
56
-	PHPCONFUTILS_AUTO_USE=""
57
-
58
-	# Make sure the user has specified at least one SAPI
59
-	einfo "Determining SAPI(s) to build"
60
-	phpconfutils_require_any "  Enabled  SAPI:" "  Disabled SAPI:" cli cgi apache2
61
-
62
-	# Threaded Apache2 support
63
-	if use apache2 ; then
64
-		has_apache_threads
65
-	fi
66
-
67
-	# Concurrent PHP Apache2 modules support
68
-	if use apache2 ; then
69
-		if use concurrentmodphp ; then
70
-			ewarn
71
-			ewarn "'concurrentmodphp' makes it possible to load multiple, differently"
72
-			ewarn "versioned mod_php's into the same Apache instance. This is done with"
73
-			ewarn "a few linker tricks and workarounds, and is not guaranteed to always"
74
-			ewarn "work correctly, so use it at your own risk. Especially, do not use"
75
-			ewarn "this in conjunction with PHP modules (PECL, ...) other than the ones"
76
-			ewarn "you may find in the Portage tree or the PHP Overlay!"
77
-			ewarn "This is an experimental feature, so please rebuild PHP"
78
-			ewarn "without the 'concurrentmodphp' USE flag if you experience"
79
-			ewarn "any problems, and then reproduce any bugs before filing"
80
-			ewarn "them in Gentoo's Bugzilla or bugs.php.net."
81
-			ewarn "If you have conclusive evidence that a bug directly"
82
-			ewarn "derives from 'concurrentmodphp', please file a bug in"
83
-			ewarn "Gentoo's Bugzilla only."
84
-			ewarn
85
-			ebeep 5
86
-		fi
87
-	fi
88
-
89
-	# fastbuild support
90
-	if use fastbuild ; then
91
-		ewarn
92
-		ewarn "'fastbuild' attempts to build all SAPIs in a single pass."
93
-		ewarn "This is an experimental feature, so please rebuild PHP"
94
-		ewarn "without the 'fastbuild' USE flag if you experience"
95
-		ewarn "any problems, and then reproduce any bugs before filing"
96
-		ewarn "them in Gentoo's Bugzilla or bugs.php.net."
97
-		ewarn "If you have conclusive evidence that a bug directly"
98
-		ewarn "derives from 'fastbuild', please file a bug in"
99
-		ewarn "Gentoo's Bugzilla only."
100
-		ewarn
101
-	fi
102
-
103
-	if use pcre ; then
104
-		built_with_use dev-libs/libpcre unicode || \
105
-			die "Please rebuild dev-libs/libpcre with USE=unicode"
106
-	fi
107
-
108
-	depend.apache_pkg_setup
109
-	php5_3-sapi_pkg_setup
110
-}
111
-
112
-php_determine_sapis() {
113
-	# holds the list of sapis that we want to build
114
-	PHPSAPIS=
115
-
116
-	if use cli || phpconfutils_usecheck cli ; then
117
-		PHPSAPIS="${PHPSAPIS} cli"
118
-	fi
119
-
120
-	if use cgi ; then
121
-		PHPSAPIS="${PHPSAPIS} cgi"
122
-	fi
123
-
124
-	# note - apache SAPI comes after the simpler cli/cgi sapis
125
-	if use apache2 ; then
126
-		PHPSAPIS="${PHPSAPIS} apache${APACHE_VERSION}"
127
-	fi
128
-}
129
-
130
-src_unpack() {
131
-	if [[ "${PHP_PACKAGE}" == 1 ]] ; then
132
-		unpack ${A}
133
-	fi
134
-
135
-	cd "${S}"
136
-
137
-	epatch "${FILESDIR}/${P}-sha512.diff"
138
-
139
-	# Concurrent PHP Apache2 modules support
140
-	if use apache2 ; then
141
-		if use concurrentmodphp ; then
142
-			if [[ -n "${CONCURRENTMODPHP_PATCH}" ]] && [[ -f "${WORKDIR}/${CONCURRENTMODPHP_PATCH}" ]] ; then
143
-				epatch "${WORKDIR}/${CONCURRENTMODPHP_PATCH}"
144
-			else
145
-				ewarn "There is no concurrent mod_php patch available for this PHP release yet!"
146
-			fi
147
-		fi
148
-	fi
149
-
150
-	# fastbuild support
151
-	if use fastbuild ; then
152
-		if [[ -n "${FASTBUILD_PATCH}" ]] && [[ -f "${WORKDIR}/${FASTBUILD_PATCH}" ]] ; then
153
-			epatch "${WORKDIR}/${FASTBUILD_PATCH}"
154
-		else
155
-			ewarn "There is no fastbuild patch available for this PHP release yet!"
156
-		fi
157
-	fi
158
-
159
-	# kolab support
160
-	if [[ -n "${KOLAB_PATCH}" ]] ; then
161
-		use kolab && epatch "${WORKDIR}/${KOLAB_PATCH}"
162
-	fi
163
-
164
-	# pretend to not have flex, bug 221357
165
-	sed -re 's:( +)PHP_SUBST\(LEX\):\1LEX="exit 0;"\n\0:' -i acinclude.m4
166
-
167
-	# Now let the eclass do the rest and regenerate the configure
168
-	php5_3-sapi_src_unpack
169
-
170
-	# Fix Makefile.global:test to consider the CGI SAPI if present
171
-	if use cgi ; then
172
-		sed -e "s|test \! -z \"\$(top_builddir)/php-cli\" \&\& test -x \"\$(top_builddir)/php-cli\"|test \! -z \"\$(top_builddir)/php-cli\" \&\& test -x \"\$(top_builddir)/php-cli\" \&\& test \! -z \"\$(top_builddir)/php-cgi\" \&\& test -x \"\$(top_builddir)/php-cgi\"|g" -i Makefile.global
173
-		sed -e "s|TEST_PHP_EXECUTABLE=\"\$(top_builddir)/php-cli\"|TEST_PHP_EXECUTABLE=\"\$(top_builddir)/php-cli\" TEST_PHP_CGI_EXECUTABLE=\"\$(top_builddir)/php-cgi\"|g" -i Makefile.global
174
-	fi
175
-
176
-	# try to fix some test cases which fail because of sandbox otherwise
177
-	sed -e 's:/no/such/:.\0:' -i ext/standard/tests/file/005_error.phpt \
178
-		ext/standard/tests/file/006_error.phpt \
179
-		ext/standard/tests/file/touch.phpt
180
-
181
-	# REMOVING BROKEN TESTS:
182
-	# removing this test as it has been broken for ages and is not easily
183
-	# fixable (depends on a lot of factors)
184
-	rm ext/standard/tests/general_functions/phpinfo.phpt
185
-
186
-	# never worked properly, no easy fix
187
-	rm ext/iconv/tests/bug16069.phpt ext/iconv/tests/iconv_stream_filter.phpt
188
-
189
-	# needs write access to /tmp and others
190
-	rm ext/session/tests/session_save_path_variation5.phpt
191
-
192
-	# new tests since 5.2.7 which have never been working for me
193
-	rm ext/spl/tests/arrayObject___construct_basic4.phpt \
194
-		ext/spl/tests/arrayObject___construct_basic5.phpt \
195
-		ext/spl/tests/arrayObject_exchangeArray_basic3.phpt \
196
-		ext/spl/tests/arrayObject_setFlags_basic1.phpt \
197
-		tests/lang/bug45392.phpt
198
-
199
-	# those might as well be related to suhosin
200
-	rm ext/session/tests/session_decode_variation3.phpt \
201
-		ext/session/tests/session_encode_variation8.phpt
202
-
203
-	# missing skipif
204
-	use reflection || \
205
-		rm ext/standard/tests/directory/DirectoryClass_basic_001.phpt
206
-
207
-	# sandbox-related (sandbox checks for permissions before even looking
208
-	# at the fs, but the tests expect "No such file or directory"
209
-	sed -e 's:/blah:./bla:' -i \
210
-		ext/session/tests/session_save_path_variation{2,3}.phpt
211
-	rm ext/standard/tests/file/rename_variation13.phpt
212
-
213
-	# test passes, but run-tests.php claims failure
214
-	rm ext/standard/tests/file/tempnam_variation4.phpt
215
-
216
-	# these tests behave differently with suhosin enabled, adapting them...
217
-	use suhosin && sed -e 's:File(\.\./):File(..):g' -i \
218
-		tests/security/open_basedir*{.inc,.phpt}
219
-}
220
-
221
-src_compile() {
222
-	# bug 217392 (autconf-2.62 behavior changes)
223
-	export CFLAGS="${CFLAGS} -D_GNU_SOURCE"
224
-	export CXXFLAGS="${CXXFLAGS} -D_GNU_SOURCE"
225
-	if use fastbuild && [[ -n "${FASTBUILD_PATCH}" ]] ; then
226
-		src_compile_fastbuild
227
-	else
228
-		src_compile_normal
229
-	fi
230
-}
231
-
232
-src_compile_fastbuild() {
233
-	php_determine_sapis
234
-
235
-	build_cli=0
236
-	build_cgi=0
237
-	build_apache2=0
238
-	my_conf=""
239
-
240
-	for x in ${PHPSAPIS} ; do
241
-		case ${x} in
242
-			cli)
243
-				build_cli=1
244
-				;;
245
-			cgi)
246
-				build_cgi=1
247
-				;;
248
-			apache2)
249
-				build_apache2=1
250
-				;;
251
-		esac
252
-	done
253
-
254
-	if [[ ${build_cli} = 1 ]] ; then
255
-		my_conf="${my_conf} --enable-cli"
256
-	else
257
-		my_conf="${my_conf} --disable-cli"
258
-	fi
259
-
260
-	if [[ ${build_cgi} = 1 ]] ; then
261
-		my_conf="${my_conf} --enable-cgi --enable-fastcgi"
262
-		phpconfutils_extension_enable "discard-path" "discard-path" 0
263
-		phpconfutils_extension_enable "force-cgi-redirect" "force-cgi-redirect" 0
264
-	else
265
-		my_conf="${my_conf} --disable-cgi"
266
-	fi
267
-
268
-	if [[ ${build_apache2} = 1 ]] ; then
269
-		my_conf="${my_conf} --with-apxs2=/usr/sbin/apxs2"
270
-
271
-		# Threaded Apache2 support
272
-		if use threads ; then
273
-			my_conf="${my_conf} --enable-maintainer-zts"
274
-			ewarn "Enabling ZTS for Apache2 MPM"
275
-		fi
276
-
277
-		# Concurrent PHP Apache2 modules support
278
-		if use concurrentmodphp ; then
279
-			append-ldflags "-Wl,--version-script=${FILESDIR}/php5-ldvs"
280
-		fi
281
-	fi
282
-
283
-	if use pcre || phpconfutils_usecheck pcre ; then
284
-		myconf="${my_conf} --with-pcre-dir=/usr"
285
-		phpconfutils_extension_with "pcre-regex" "pcre" 0 "/usr"
286
-	fi
287
-
288
-	# Now we know what we are building, build it
289
-	php5_3-sapi_src_compile
290
-
291
-	# To keep the separate php.ini files for each SAPI, we change the
292
-	# build-defs.h and recompile
293
-
294
-	if [[ ${build_cli} = 1 ]] ; then
295
-		einfo
296
-		einfo "Building CLI SAPI"
297
-		einfo
298
-
299
-		sed -e 's|^#define PHP_CONFIG_FILE_PATH.*|#define PHP_CONFIG_FILE_PATH "/etc/php53/cli-php5"|g;' -i main/build-defs.h
300
-		sed -e 's|^#define PHP_CONFIG_FILE_SCAN_DIR.*|#define PHP_CONFIG_FILE_SCAN_DIR "/etc/php53/cli-php5/ext-active"|g;' -i main/build-defs.h
301
-		for x in main/main.o main/main.lo main/php_ini.o main/php_ini.lo ; do
302
-			[[ -f ${x} ]] && rm -f ${x}
303
-		done
304
-		make sapi/cli/php || die "Unable to make CLI SAPI"
305
-		cp sapi/cli/php php-cli || die "Unable to copy CLI SAPI"
306
-	fi
307
-
308
-	if [[ ${build_cgi} = 1 ]] ; then
309
-		einfo
310
-		einfo "Building CGI SAPI"
311
-		einfo
312
-
313
-		sed -e 's|^#define PHP_CONFIG_FILE_PATH.*|#define PHP_CONFIG_FILE_PATH "/etc/php53/cgi-php5"|g;' -i main/build-defs.h
314
-		sed -e 's|^#define PHP_CONFIG_FILE_SCAN_DIR.*|#define PHP_CONFIG_FILE_SCAN_DIR "/etc/php53/cgi-php5/ext-active"|g;' -i main/build-defs.h
315
-		for x in main/main.o main/main.lo main/php_ini.o main/php_ini.lo ; do
316
-			[[ -f ${x} ]] && rm -f ${x}
317
-		done
318
-		make sapi/cgi/php-cgi || die "Unable to make CGI SAPI"
319
-		cp sapi/cgi/php-cgi php-cgi || die "Unable to copy CGI SAPI"
320
-	fi
321
-
322
-	if [[ ${build_apache2} = 1 ]] ; then
323
-		einfo
324
-		einfo "Building apache${APACHE_VERSION} SAPI"
325
-		einfo
326
-
327
-		sed -e "s|^#define PHP_CONFIG_FILE_PATH.*|#define PHP_CONFIG_FILE_PATH \"/etc/php53/apache${APACHE_VERSION}-php5\"|g;" -i main/build-defs.h
328
-		sed -e "s|^#define PHP_CONFIG_FILE_SCAN_DIR.*|#define PHP_CONFIG_FILE_SCAN_DIR \"/etc/php53/apache${APACHE_VERSION}-php5/ext-active\"|g;" -i main/build-defs.h
329
-		for x in main/main.o main/main.lo main/php_ini.o main/php_ini.lo ; do
330
-			[[ -f ${x} ]] && rm -f ${x}
331
-		done
332
-		make || die "Unable to make apache${APACHE_VERSION} SAPI"
333
-	fi
334
-}
335
-
336
-src_compile_normal() {
337
-	php_determine_sapis
338
-
339
-	CLEAN_REQUIRED=0
340
-	my_conf=""
341
-
342
-	# Support the Apache2 extras, they must be set globally for all
343
-	# SAPIs to work correctly, especially for external PHP extensions
344
-	if use apache2 ; then
345
-		# Concurrent PHP Apache2 modules support
346
-		if use concurrentmodphp ; then
347
-			append-ldflags "-Wl,--version-script=${FILESDIR}/php5-ldvs"
348
-		fi
349
-	fi
350
-
351
-	for x in ${PHPSAPIS} ; do
352
-		if use pcre || phpconfutils_usecheck pcre ; then
353
-			myconf="${my_conf} --with-pcre-dir=/usr"
354
-			phpconfutils_extension_with "pcre-regex" "pcre" 0 "/usr"
355
-		fi
356
-
357
-		# Support the Apache2 extras, they must be set globally for all
358
-		# SAPIs to work correctly, especially for external PHP extensions
359
-		if use apache2 ; then
360
-			# Threaded Apache2 support
361
-			if use threads ; then
362
-				my_conf="${my_conf} --enable-maintainer-zts"
363
-				ewarn "Enabling ZTS for Apache2 MPM"
364
-			fi
365
-		fi
366
-
367
-		if [[ "${CLEAN_REQUIRED}" = 1 ]] ; then
368
-			make clean
369
-		fi
370
-
371
-		PHPSAPI="${x}"
372
-
373
-		case ${x} in
374
-			cli)
375
-				my_conf="${my_conf} --enable-cli --disable-cgi"
376
-				php5_3-sapi_src_compile
377
-				cp sapi/cli/php php-cli || die "Unable to copy CLI SAPI"
378
-				;;
379
-			cgi)
380
-				my_conf="${my_conf} --disable-cli --enable-cgi --enable-fastcgi"
381
-				phpconfutils_extension_enable "discard-path" "discard-path" 0
382
-				phpconfutils_extension_enable "force-cgi-redirect" "force-cgi-redirect" 0
383
-				php5_3-sapi_src_compile
384
-				cp sapi/cgi/php-cgi php-cgi || die "Unable to copy CGI SAPI"
385
-				;;
386
-			apache2)
387
-				my_conf="${my_conf} --disable-cli --with-apxs2=/usr/sbin/apxs2"
388
-				php5_3-sapi_src_compile
389
-				;;
390
-		esac
391
-
392
-		CLEAN_REQUIRED=1
393
-		my_conf=""
394
-	done
395
-}
396
-
397
-src_install() {
398
-	php_determine_sapis
399
-
400
-	destdir=/usr/$(get_libdir)/php${SLOT/./}
401
-
402
-	# Let the eclass do the common work
403
-	php5_3-sapi_src_install
404
-
405
-	einfo
406
-	einfo "Installing SAPI(s) ${PHPSAPIS}"
407
-	einfo
408
-
409
-	for x in ${PHPSAPIS} ; do
410
-
411
-		PHPSAPI="${x}"
412
-
413
-		case ${x} in
414
-			cli)
415
-				einfo "Installing CLI SAPI"
416
-				into ${destdir}
417
-				newbin php-cli php || die "Unable to install ${x} sapi"
418
-				php5_3-sapi_install_ini
419
-				;;
420
-			cgi)
421
-				einfo "Installing CGI SAPI"
422
-				into ${destdir}
423
-				dobin php-cgi || die "Unable to install ${x} sapi"
424
-				php5_3-sapi_install_ini
425
-				;;
426
-			apache2)
427
-				einfo "Installing Apache${APACHE_VERSION} SAPI"
428
-				make INSTALL_ROOT="${D}" install-sapi || die "Unable to install ${x} SAPI"
429
-				if use concurrentmodphp ; then
430
-					einfo "Installing Apache${APACHE_VERSION} config file for PHP5-concurrent (70_mod_php5_concurr.conf)"
431
-					insinto ${APACHE_MODULES_CONFDIR}
432
-					newins "${FILESDIR}/70_mod_php5_concurr.conf-apache2-r1" "70_mod_php5_concurr.conf"
433
-
434
-					# Put the ld version script in the right place so it's always accessible
435
-					insinto "/var/lib/php-pkg/${CATEGORY}/${PN}-${PVR}/"
436
-					doins "${FILESDIR}/php5-ldvs"
437
-
438
-					# Redefine the extension dir to have the modphp suffix
439
-					PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`-versioned"
440
-				else
441
-					einfo "Installing Apache${APACHE_VERSION} config file for PHP5 (70_mod_php5.conf)"
442
-					insinto ${APACHE_MODULES_CONFDIR}
443
-					newins "${FILESDIR}/70_mod_php5.conf-apache2-r1" "70_mod_php5.conf"
444
-				fi
445
-				php5_3-sapi_install_ini
446
-				;;
447
-		esac
448
-	done
449
-
450
-	# Install env.d files
451
-	newenvd "${FILESDIR}/20php5-envd" "20php53"
452
-	sed -e "s|/lib/php5|/$(get_libdir)/php53|g" -i "${D}/etc/env.d/20php53"
453
-}
454
-
455
-pkg_postinst() {
456
-	# Output some general info to the user
457
-	if use apache2 ; then
458
-		APACHE2_MOD_DEFINE="PHP5"
459
-		if use concurrentmodphp ; then
460
-			APACHE2_MOD_CONF="70_mod_php5_concurr"
461
-		else
462
-			APACHE2_MOD_CONF="70_mod_php5"
463
-		fi
464
-		apache-module_pkg_postinst
465
-	fi
466
-
467
-	# Update Apache2 to use mod_php
468
-	if use apache2 ; then
469
-		"${ROOT}/usr/sbin/php-select" -t apache2 php5 > /dev/null 2>&1
470
-		exitStatus=$?
471
-		if [[ ${exitStatus} == 2 ]] ; then
472
-			php-select apache2 php5
473
-		elif [[ ${exitStatus} == 4 ]] ; then
474
-			ewarn
475
-			ewarn "Apache2 is configured to load a different version of PHP."
476
-			ewarn "To make Apache2 use PHP v5, use php-select:"
477
-			ewarn
478
-			ewarn "    php-select apache2 php5"
479
-			ewarn
480
-		fi
481
-	fi
482
-
483
-	# Create the symlinks for php-cli
484
-	if use cli || phpconfutils_usecheck cli ; then
485
-		"${ROOT}/usr/sbin/php-select" -t php php5 > /dev/null 2>&1
486
-		exitStatus=$?
487
-		if [[ ${exitStatus} == 5 ]] ; then
488
-			php-select php php5
489
-		elif [[ ${exitStatus} == 4 ]] ; then
490
-			ewarn
491
-			ewarn "/usr/bin/php links to a different version of PHP."
492
-			ewarn "To make /usr/bin/php point to PHP v5, use php-select:"
493
-			ewarn
494
-			ewarn "    php-select php php5"
495
-			ewarn
496
-		fi
497
-	fi
498
-
499
-	# Create the symlinks for php-cgi
500
-	if use cgi ; then
501
-		"${ROOT}/usr/sbin/php-select" -t php-cgi php5 > /dev/null 2>&1
502
-		exitStatus=$?
503
-		if [[ ${exitStatus} == 5 ]] ; then
504
-			php-select php-cgi php5
505
-		elif [[ ${exitStatus} == 4 ]] ; then
506
-			ewarn
507
-			ewarn "/usr/bin/php-cgi links to a different version of PHP."
508
-			ewarn "To make /usr/bin/php-cgi point to PHP v5, use php-select:"
509
-			ewarn
510
-			ewarn "    php-select php-cgi php5"
511
-			ewarn
512
-		fi
513
-	fi
514
-
515
-	# Create the symlinks for php-devel
516
-	"${ROOT}/usr/sbin/php-select" -t php-devel php5 > /dev/null 2>&1
517
-	exitStatus=$?
518
-	if [[ $exitStatus == 5 ]] ; then
519
-		php-select php-devel php5
520
-	elif [[ $exitStatus == 4 ]] ; then
521
-		ewarn
522
-		ewarn "/usr/bin/php-config and/or /usr/bin/phpize are linked to a"
523
-		ewarn "different version of PHP. To make them point to PHP v5, use"
524
-		ewarn "php-select:"
525
-		ewarn
526
-		ewarn "    php-select php-devel php5"
527
-		ewarn
528
-	fi
529
-
530
-	php5_3-sapi_pkg_postinst
531
-}
532
-
533
-src_test() {
534
-	vecho ">>> Test phase [test]: ${CATEGORY}/${PF}"
535
-	if [[ ! -x "${S}"/php-cli ]]; then
536
-		ewarn "Running the php test suite requires USE=cli"
537
-		return
538
-	fi
539
-
540
-	export TEST_PHP_EXECUTABLE="${S}"/php-cli
541
-	if [[ -x "${S}"/php-cgi ]]; then
542
-		export TEST_PHP_CGI_EXECUTABLE="${S}"/php-cgi
543
-	fi
544
-	REPORT_EXIT_STATUS=1 "${S}"/php-cli -n "${S}"/run-tests.php -n
545
-
546
-	if [[ $? != 0 ]] ; then
547
-		eerror "Not all tests were successful!"
548
-	fi
549
-}
... ...
@@ -1,547 +0,0 @@
1
-# Copyright 1999-2009 Gentoo Foundation
2
-# Distributed under the terms of the GNU General Public License v2
3
-# $Header: /var/cvsroot/gentoo-x86/dev-lang/php/php-5.2.10.ebuild,v 1.7 2009/06/30 13:33:13 armin76 Exp $
4
-
5
-CGI_SAPI_USE="discard-path force-cgi-redirect"
6
-APACHE2_SAPI_USE="concurrentmodphp threads"
7
-IUSE="cli cgi ${CGI_SAPI_USE} ${APACHE2_SAPI_USE} fastbuild"
8
-
9
-KEYWORDS="~alpha ~amd64 ~arm ~hppa ~ia64 ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~x86-fbsd"
10
-
11
-# NOTE: Portage doesn't support setting PROVIDE based on the USE flags
12
-#		that have been enabled, so we have to PROVIDE everything for now
13
-#		and hope for the best
14
-PROVIDE="virtual/php virtual/httpd-php"
15
-
16
-# php package settings
17
-SLOT="5.3"
18
-MY_PHP_PV="${PV}"
19
-MY_PHP_P="php-${MY_PHP_PV}"
20
-PHP_PACKAGE="1"
21
-
22
-# php patch settings, general
23
-PHP_PATCHSET_REV="${PR/r/}"
24
-SUHOSIN_PATCH="suhosin-patch-${PV}-0.9.9.1.patch.gz"
25
-MULTILIB_PATCH="${MY_PHP_PV}/opt/multilib-search-path.patch"
26
-# php patch settings, ebuild specific
27
-FASTBUILD_PATCH="${MY_PHP_PV}/opt/fastbuild.patch"
28
-CONCURRENTMODPHP_PATCH="${MY_PHP_PV}/opt/concurrent_apache_modules.patch"
29
-# kolab patch - http://kolab.org/cgi-bin/viewcvs-kolab.cgi/server/patches/php/
30
-# bugs about this go to wrobel@gentoo.org
31
-KOLAB_PATCH="${MY_PHP_PV}/opt/kolab-imap-annotations.patch"
32
-
33
-inherit versionator php5_3-sapi apache-module
34
-
35
-# Suhosin patch support
36
-[[ -n "${SUHOSIN_PATCH}" ]] && SRC_URI="${SRC_URI} suhosin? ( http://download.suhosin.org/${SUHOSIN_PATCH} )"
37
-
38
-DESCRIPTION="The PHP language runtime engine: CLI, CGI and Apache2 SAPIs."
39
-
40
-DEPEND="app-admin/php-toolkit
41
-	imap? ( >=virtual/imap-c-client-2006k )
42
-	pcre? ( >=dev-libs/libpcre-7.8 )
43
-	xml? ( >=dev-libs/libxml2-2.7.2-r2 )
44
-	xmlrpc? ( >=dev-libs/libxml2-2.7.2-r2 virtual/libiconv )"
45
-
46
-RDEPEND="${DEPEND}"
47
-if [[ -n "${KOLAB_PATCH}" ]] ; then
48
-	IUSE="${IUSE} kolab"
49
-	DEPEND="${DEPEND}
50
-		kolab? ( >=net-libs/c-client-2004g-r1 )"
51
-fi
52
-
53
-want_apache
54
-
55
-pkg_setup() {
56
-	PHPCONFUTILS_AUTO_USE=""
57
-
58
-	# Make sure the user has specified at least one SAPI
59
-	einfo "Determining SAPI(s) to build"
60
-	phpconfutils_require_any "  Enabled  SAPI:" "  Disabled SAPI:" cli cgi apache2
61
-
62
-	# Threaded Apache2 support
63
-	if use apache2 ; then
64
-		has_apache_threads
65
-	fi
66
-
67
-	# Concurrent PHP Apache2 modules support
68
-	if use apache2 ; then
69
-		if use concurrentmodphp ; then
70
-			ewarn
71
-			ewarn "'concurrentmodphp' makes it possible to load multiple, differently"
72
-			ewarn "versioned mod_php's into the same Apache instance. This is done with"
73
-			ewarn "a few linker tricks and workarounds, and is not guaranteed to always"
74
-			ewarn "work correctly, so use it at your own risk. Especially, do not use"
75
-			ewarn "this in conjunction with PHP modules (PECL, ...) other than the ones"
76
-			ewarn "you may find in the Portage tree or the PHP Overlay!"
77
-			ewarn "This is an experimental feature, so please rebuild PHP"
78
-			ewarn "without the 'concurrentmodphp' USE flag if you experience"
79
-			ewarn "any problems, and then reproduce any bugs before filing"
80
-			ewarn "them in Gentoo's Bugzilla or bugs.php.net."
81
-			ewarn "If you have conclusive evidence that a bug directly"
82
-			ewarn "derives from 'concurrentmodphp', please file a bug in"
83
-			ewarn "Gentoo's Bugzilla only."
84
-			ewarn
85
-			ebeep 5
86
-		fi
87
-	fi
88
-
89
-	# fastbuild support
90
-	if use fastbuild ; then
91
-		ewarn
92
-		ewarn "'fastbuild' attempts to build all SAPIs in a single pass."
93
-		ewarn "This is an experimental feature, so please rebuild PHP"
94
-		ewarn "without the 'fastbuild' USE flag if you experience"
95
-		ewarn "any problems, and then reproduce any bugs before filing"
96
-		ewarn "them in Gentoo's Bugzilla or bugs.php.net."
97
-		ewarn "If you have conclusive evidence that a bug directly"
98
-		ewarn "derives from 'fastbuild', please file a bug in"
99
-		ewarn "Gentoo's Bugzilla only."
100
-		ewarn
101
-	fi
102
-
103
-	if use pcre ; then
104
-		built_with_use dev-libs/libpcre unicode || \
105
-			die "Please rebuild dev-libs/libpcre with USE=unicode"
106
-	fi
107
-
108
-	depend.apache_pkg_setup
109
-	php5_3-sapi_pkg_setup
110
-}
111
-
112
-php_determine_sapis() {
113
-	# holds the list of sapis that we want to build
114
-	PHPSAPIS=
115
-
116
-	if use cli || phpconfutils_usecheck cli ; then
117
-		PHPSAPIS="${PHPSAPIS} cli"
118
-	fi
119
-
120
-	if use cgi ; then
121
-		PHPSAPIS="${PHPSAPIS} cgi"
122
-	fi
123
-
124
-	# note - apache SAPI comes after the simpler cli/cgi sapis
125
-	if use apache2 ; then
126
-		PHPSAPIS="${PHPSAPIS} apache${APACHE_VERSION}"
127
-	fi
128
-}
129
-
130
-src_unpack() {
131
-	if [[ "${PHP_PACKAGE}" == 1 ]] ; then
132
-		unpack ${A}
133
-	fi
134
-
135
-	cd "${S}"
136
-
137
-	# Concurrent PHP Apache2 modules support
138
-	if use apache2 ; then
139
-		if use concurrentmodphp ; then
140
-			if [[ -n "${CONCURRENTMODPHP_PATCH}" ]] && [[ -f "${WORKDIR}/${CONCURRENTMODPHP_PATCH}" ]] ; then
141
-				epatch "${WORKDIR}/${CONCURRENTMODPHP_PATCH}"
142
-			else
143
-				ewarn "There is no concurrent mod_php patch available for this PHP release yet!"
144
-			fi
145
-		fi
146
-	fi
147
-
148
-	# fastbuild support
149
-	if use fastbuild ; then
150
-		if [[ -n "${FASTBUILD_PATCH}" ]] && [[ -f "${WORKDIR}/${FASTBUILD_PATCH}" ]] ; then
151
-			epatch "${WORKDIR}/${FASTBUILD_PATCH}"
152
-		else
153
-			ewarn "There is no fastbuild patch available for this PHP release yet!"
154
-		fi
155
-	fi
156
-
157
-	# kolab support
158
-	if [[ -n "${KOLAB_PATCH}" ]] ; then
159
-		use kolab && epatch "${WORKDIR}/${KOLAB_PATCH}"
160
-	fi
161
-
162
-	# pretend to not have flex, bug 221357
163
-	sed -re 's:( +)PHP_SUBST\(LEX\):\1LEX="exit 0;"\n\0:' -i acinclude.m4
164
-
165
-	# Now let the eclass do the rest and regenerate the configure
166
-	php5_3-sapi_src_unpack
167
-
168
-	# Fix Makefile.global:test to consider the CGI SAPI if present
169
-	if use cgi ; then
170
-		sed -e "s|test \! -z \"\$(top_builddir)/php-cli\" \&\& test -x \"\$(top_builddir)/php-cli\"|test \! -z \"\$(top_builddir)/php-cli\" \&\& test -x \"\$(top_builddir)/php-cli\" \&\& test \! -z \"\$(top_builddir)/php-cgi\" \&\& test -x \"\$(top_builddir)/php-cgi\"|g" -i Makefile.global
171
-		sed -e "s|TEST_PHP_EXECUTABLE=\"\$(top_builddir)/php-cli\"|TEST_PHP_EXECUTABLE=\"\$(top_builddir)/php-cli\" TEST_PHP_CGI_EXECUTABLE=\"\$(top_builddir)/php-cgi\"|g" -i Makefile.global
172
-	fi
173
-
174
-	# try to fix some test cases which fail because of sandbox otherwise
175
-	sed -e 's:/no/such/:.\0:' -i ext/standard/tests/file/005_error.phpt \
176
-		ext/standard/tests/file/006_error.phpt \
177
-		ext/standard/tests/file/touch.phpt
178
-
179
-	# REMOVING BROKEN TESTS:
180
-	# removing this test as it has been broken for ages and is not easily
181
-	# fixable (depends on a lot of factors)
182
-	rm ext/standard/tests/general_functions/phpinfo.phpt
183
-
184
-	# never worked properly, no easy fix
185
-	rm ext/iconv/tests/bug16069.phpt ext/iconv/tests/iconv_stream_filter.phpt
186
-
187
-	# needs write access to /tmp and others
188
-	rm ext/session/tests/session_save_path_variation5.phpt
189
-
190
-	# new tests since 5.2.7 which have never been working for me
191
-	rm ext/spl/tests/arrayObject___construct_basic4.phpt \
192
-		ext/spl/tests/arrayObject___construct_basic5.phpt \
193
-		ext/spl/tests/arrayObject_exchangeArray_basic3.phpt \
194
-		ext/spl/tests/arrayObject_setFlags_basic1.phpt \
195
-		tests/lang/bug45392.phpt
196
-
197
-	# those might as well be related to suhosin
198
-	rm ext/session/tests/session_decode_variation3.phpt \
199
-		ext/session/tests/session_encode_variation8.phpt
200
-
201
-	# missing skipif
202
-	use reflection || \
203
-		rm ext/standard/tests/directory/DirectoryClass_basic_001.phpt
204
-
205
-	# sandbox-related (sandbox checks for permissions before even looking
206
-	# at the fs, but the tests expect "No such file or directory"
207
-	sed -e 's:/blah:./bla:' -i \
208
-		ext/session/tests/session_save_path_variation{2,3}.phpt
209
-	rm ext/standard/tests/file/rename_variation13.phpt
210
-
211
-	# test passes, but run-tests.php claims failure
212
-	rm ext/standard/tests/file/tempnam_variation4.phpt
213
-
214
-	# these tests behave differently with suhosin enabled, adapting them...
215
-	use suhosin && sed -e 's:File(\.\./):File(..):g' -i \
216
-		tests/security/open_basedir*{.inc,.phpt}
217
-}
218
-
219
-src_compile() {
220
-	# bug 217392 (autconf-2.62 behavior changes)
221
-	export CFLAGS="${CFLAGS} -D_GNU_SOURCE"
222
-	export CXXFLAGS="${CXXFLAGS} -D_GNU_SOURCE"
223
-	if use fastbuild && [[ -n "${FASTBUILD_PATCH}" ]] ; then
224
-		src_compile_fastbuild
225
-	else
226
-		src_compile_normal
227
-	fi
228
-}
229
-
230
-src_compile_fastbuild() {
231
-	php_determine_sapis
232
-
233
-	build_cli=0
234
-	build_cgi=0
235
-	build_apache2=0
236
-	my_conf=""
237
-
238
-	for x in ${PHPSAPIS} ; do
239
-		case ${x} in
240
-			cli)
241
-				build_cli=1
242
-				;;
243
-			cgi)
244
-				build_cgi=1
245
-				;;
246
-			apache2)
247
-				build_apache2=1
248
-				;;
249
-		esac
250
-	done
251
-
252
-	if [[ ${build_cli} = 1 ]] ; then
253
-		my_conf="${my_conf} --enable-cli"
254
-	else
255
-		my_conf="${my_conf} --disable-cli"
256
-	fi
257
-
258
-	if [[ ${build_cgi} = 1 ]] ; then
259
-		my_conf="${my_conf} --enable-cgi --enable-fastcgi"
260
-		phpconfutils_extension_enable "discard-path" "discard-path" 0
261
-		phpconfutils_extension_enable "force-cgi-redirect" "force-cgi-redirect" 0
262
-	else
263
-		my_conf="${my_conf} --disable-cgi"
264
-	fi
265
-
266
-	if [[ ${build_apache2} = 1 ]] ; then
267
-		my_conf="${my_conf} --with-apxs2=/usr/sbin/apxs2"
268
-
269
-		# Threaded Apache2 support
270
-		if use threads ; then
271
-			my_conf="${my_conf} --enable-maintainer-zts"
272
-			ewarn "Enabling ZTS for Apache2 MPM"
273
-		fi
274
-
275
-		# Concurrent PHP Apache2 modules support
276
-		if use concurrentmodphp ; then
277
-			append-ldflags "-Wl,--version-script=${FILESDIR}/php5-ldvs"
278
-		fi
279
-	fi
280
-
281
-	if use pcre || phpconfutils_usecheck pcre ; then
282
-		myconf="${my_conf} --with-pcre-dir=/usr"
283
-		phpconfutils_extension_with "pcre-regex" "pcre" 0 "/usr"
284
-	fi
285
-
286
-	# Now we know what we are building, build it
287
-	php5_3-sapi_src_compile
288
-
289
-	# To keep the separate php.ini files for each SAPI, we change the
290
-	# build-defs.h and recompile
291
-
292
-	if [[ ${build_cli} = 1 ]] ; then
293
-		einfo
294
-		einfo "Building CLI SAPI"
295
-		einfo
296
-
297
-		sed -e 's|^#define PHP_CONFIG_FILE_PATH.*|#define PHP_CONFIG_FILE_PATH "/etc/php53/cli-php5"|g;' -i main/build-defs.h
298
-		sed -e 's|^#define PHP_CONFIG_FILE_SCAN_DIR.*|#define PHP_CONFIG_FILE_SCAN_DIR "/etc/php53/cli-php5/ext-active"|g;' -i main/build-defs.h
299
-		for x in main/main.o main/main.lo main/php_ini.o main/php_ini.lo ; do
300
-			[[ -f ${x} ]] && rm -f ${x}
301
-		done
302
-		make sapi/cli/php || die "Unable to make CLI SAPI"
303
-		cp sapi/cli/php php-cli || die "Unable to copy CLI SAPI"
304
-	fi
305
-
306
-	if [[ ${build_cgi} = 1 ]] ; then
307
-		einfo
308
-		einfo "Building CGI SAPI"
309
-		einfo
310
-
311
-		sed -e 's|^#define PHP_CONFIG_FILE_PATH.*|#define PHP_CONFIG_FILE_PATH "/etc/php53/cgi-php5"|g;' -i main/build-defs.h
312
-		sed -e 's|^#define PHP_CONFIG_FILE_SCAN_DIR.*|#define PHP_CONFIG_FILE_SCAN_DIR "/etc/php53/cgi-php5/ext-active"|g;' -i main/build-defs.h
313
-		for x in main/main.o main/main.lo main/php_ini.o main/php_ini.lo ; do
314
-			[[ -f ${x} ]] && rm -f ${x}
315
-		done
316
-		make sapi/cgi/php-cgi || die "Unable to make CGI SAPI"
317
-		cp sapi/cgi/php-cgi php-cgi || die "Unable to copy CGI SAPI"
318
-	fi
319
-
320
-	if [[ ${build_apache2} = 1 ]] ; then
321
-		einfo
322
-		einfo "Building apache${APACHE_VERSION} SAPI"
323
-		einfo
324
-
325
-		sed -e "s|^#define PHP_CONFIG_FILE_PATH.*|#define PHP_CONFIG_FILE_PATH \"/etc/php53/apache${APACHE_VERSION}-php5\"|g;" -i main/build-defs.h
326
-		sed -e "s|^#define PHP_CONFIG_FILE_SCAN_DIR.*|#define PHP_CONFIG_FILE_SCAN_DIR \"/etc/php53/apache${APACHE_VERSION}-php5/ext-active\"|g;" -i main/build-defs.h
327
-		for x in main/main.o main/main.lo main/php_ini.o main/php_ini.lo ; do
328
-			[[ -f ${x} ]] && rm -f ${x}
329
-		done
330
-		make || die "Unable to make apache${APACHE_VERSION} SAPI"
331
-	fi
332
-}
333
-
334
-src_compile_normal() {
335
-	php_determine_sapis
336
-
337
-	CLEAN_REQUIRED=0
338
-	my_conf=""
339
-
340
-	# Support the Apache2 extras, they must be set globally for all
341
-	# SAPIs to work correctly, especially for external PHP extensions
342
-	if use apache2 ; then
343
-		# Concurrent PHP Apache2 modules support
344
-		if use concurrentmodphp ; then
345
-			append-ldflags "-Wl,--version-script=${FILESDIR}/php5-ldvs"
346
-		fi
347
-	fi
348
-
349
-	for x in ${PHPSAPIS} ; do
350
-		if use pcre || phpconfutils_usecheck pcre ; then
351
-			myconf="${my_conf} --with-pcre-dir=/usr"
352
-			phpconfutils_extension_with "pcre-regex" "pcre" 0 "/usr"
353
-		fi
354
-
355
-		# Support the Apache2 extras, they must be set globally for all
356
-		# SAPIs to work correctly, especially for external PHP extensions
357
-		if use apache2 ; then
358
-			# Threaded Apache2 support
359
-			if use threads ; then
360
-				my_conf="${my_conf} --enable-maintainer-zts"
361
-				ewarn "Enabling ZTS for Apache2 MPM"
362
-			fi
363
-		fi
364
-
365
-		if [[ "${CLEAN_REQUIRED}" = 1 ]] ; then
366
-			make clean
367
-		fi
368
-
369
-		PHPSAPI="${x}"
370
-
371
-		case ${x} in
372
-			cli)
373
-				my_conf="${my_conf} --enable-cli --disable-cgi"
374
-				php5_3-sapi_src_compile
375
-				cp sapi/cli/php php-cli || die "Unable to copy CLI SAPI"
376
-				;;
377
-			cgi)
378
-				my_conf="${my_conf} --disable-cli --enable-cgi --enable-fastcgi"
379
-				phpconfutils_extension_enable "discard-path" "discard-path" 0
380
-				phpconfutils_extension_enable "force-cgi-redirect" "force-cgi-redirect" 0
381
-				php5_3-sapi_src_compile
382
-				cp sapi/cgi/php-cgi php-cgi || die "Unable to copy CGI SAPI"
383
-				;;
384
-			apache2)
385
-				my_conf="${my_conf} --disable-cli --with-apxs2=/usr/sbin/apxs2"
386
-				php5_3-sapi_src_compile
387
-				;;
388
-		esac
389
-
390
-		CLEAN_REQUIRED=1
391
-		my_conf=""
392
-	done
393
-}
394
-
395
-src_install() {
396
-	php_determine_sapis
397
-
398
-	destdir=/usr/$(get_libdir)/php${SLOT/./}
399
-
400
-	# Let the eclass do the common work
401
-	php5_3-sapi_src_install
402
-
403
-	einfo
404
-	einfo "Installing SAPI(s) ${PHPSAPIS}"
405
-	einfo
406
-
407
-	for x in ${PHPSAPIS} ; do
408
-
409
-		PHPSAPI="${x}"
410
-
411
-		case ${x} in
412
-			cli)
413
-				einfo "Installing CLI SAPI"
414
-				into ${destdir}
415
-				newbin php-cli php || die "Unable to install ${x} sapi"
416
-				php5_3-sapi_install_ini
417
-				;;
418
-			cgi)
419
-				einfo "Installing CGI SAPI"
420
-				into ${destdir}
421
-				dobin php-cgi || die "Unable to install ${x} sapi"
422
-				php5_3-sapi_install_ini
423
-				;;
424
-			apache2)
425
-				einfo "Installing Apache${APACHE_VERSION} SAPI"
426
-				make INSTALL_ROOT="${D}" install-sapi || die "Unable to install ${x} SAPI"
427
-				if use concurrentmodphp ; then
428
-					einfo "Installing Apache${APACHE_VERSION} config file for PHP5-concurrent (70_mod_php5_concurr.conf)"
429
-					insinto ${APACHE_MODULES_CONFDIR}
430
-					newins "${FILESDIR}/70_mod_php5_concurr.conf-apache2-r1" "70_mod_php5_concurr.conf"
431
-
432
-					# Put the ld version script in the right place so it's always accessible
433
-					insinto "/var/lib/php-pkg/${CATEGORY}/${PN}-${PVR}/"
434
-					doins "${FILESDIR}/php5-ldvs"
435
-
436
-					# Redefine the extension dir to have the modphp suffix
437
-					PHPEXTDIR="`"${D}/${destdir}/bin/php-config" --extension-dir`-versioned"
438
-				else
439
-					einfo "Installing Apache${APACHE_VERSION} config file for PHP5 (70_mod_php5.conf)"
440
-					insinto ${APACHE_MODULES_CONFDIR}
441
-					newins "${FILESDIR}/70_mod_php5.conf-apache2-r1" "70_mod_php5.conf"
442
-				fi
443
-				php5_3-sapi_install_ini
444
-				;;
445
-		esac
446
-	done
447
-
448
-	# Install env.d files
449
-	newenvd "${FILESDIR}/20php5-envd" "20php53"
450
-	sed -e "s|/lib/php5|/$(get_libdir)/php53|g" -i "${D}/etc/env.d/20php53"
451
-}
452
-
453
-pkg_postinst() {
454
-	# Output some general info to the user
455
-	if use apache2 ; then
456
-		APACHE2_MOD_DEFINE="PHP5"
457
-		if use concurrentmodphp ; then
458
-			APACHE2_MOD_CONF="70_mod_php5_concurr"
459
-		else
460
-			APACHE2_MOD_CONF="70_mod_php5"
461
-		fi
462
-		apache-module_pkg_postinst
463
-	fi
464
-
465
-	# Update Apache2 to use mod_php
466
-	if use apache2 ; then
467
-		"${ROOT}/usr/sbin/php-select" -t apache2 php5 > /dev/null 2>&1
468
-		exitStatus=$?
469
-		if [[ ${exitStatus} == 2 ]] ; then
470
-			php-select apache2 php5
471
-		elif [[ ${exitStatus} == 4 ]] ; then
472
-			ewarn
473
-			ewarn "Apache2 is configured to load a different version of PHP."
474
-			ewarn "To make Apache2 use PHP v5, use php-select:"
475
-			ewarn
476
-			ewarn "    php-select apache2 php5"
477
-			ewarn
478
-		fi
479
-	fi
480
-
481
-	# Create the symlinks for php-cli
482
-	if use cli || phpconfutils_usecheck cli ; then
483
-		"${ROOT}/usr/sbin/php-select" -t php php5 > /dev/null 2>&1
484
-		exitStatus=$?
485
-		if [[ ${exitStatus} == 5 ]] ; then
486
-			php-select php php5
487
-		elif [[ ${exitStatus} == 4 ]] ; then
488
-			ewarn
489
-			ewarn "/usr/bin/php links to a different version of PHP."
490
-			ewarn "To make /usr/bin/php point to PHP v5, use php-select:"
491
-			ewarn
492
-			ewarn "    php-select php php5"
493
-			ewarn
494
-		fi
495
-	fi
496
-
497
-	# Create the symlinks for php-cgi
498
-	if use cgi ; then
499
-		"${ROOT}/usr/sbin/php-select" -t php-cgi php5 > /dev/null 2>&1
500
-		exitStatus=$?
501
-		if [[ ${exitStatus} == 5 ]] ; then
502
-			php-select php-cgi php5
503
-		elif [[ ${exitStatus} == 4 ]] ; then
504
-			ewarn
505
-			ewarn "/usr/bin/php-cgi links to a different version of PHP."
506
-			ewarn "To make /usr/bin/php-cgi point to PHP v5, use php-select:"
507
-			ewarn
508
-			ewarn "    php-select php-cgi php5"
509
-			ewarn
510
-		fi
511
-	fi
512
-
513
-	# Create the symlinks for php-devel
514
-	"${ROOT}/usr/sbin/php-select" -t php-devel php5 > /dev/null 2>&1
515
-	exitStatus=$?
516
-	if [[ $exitStatus == 5 ]] ; then
517
-		php-select php-devel php5
518
-	elif [[ $exitStatus == 4 ]] ; then
519
-		ewarn
520
-		ewarn "/usr/bin/php-config and/or /usr/bin/phpize are linked to a"
521
-		ewarn "different version of PHP. To make them point to PHP v5, use"
522
-		ewarn "php-select:"
523
-		ewarn
524
-		ewarn "    php-select php-devel php5"
525
-		ewarn
526
-	fi
527
-
528
-	php5_3-sapi_pkg_postinst
529
-}
530
-
531
-src_test() {
532
-	vecho ">>> Test phase [test]: ${CATEGORY}/${PF}"
533
-	if [[ ! -x "${S}"/php-cli ]]; then
534
-		ewarn "Running the php test suite requires USE=cli"
535
-		return
536
-	fi
537
-
538
-	export TEST_PHP_EXECUTABLE="${S}"/php-cli
539
-	if [[ -x "${S}"/php-cgi ]]; then
540
-		export TEST_PHP_CGI_EXECUTABLE="${S}"/php-cgi
541
-	fi
542
-	REPORT_EXIT_STATUS=1 "${S}"/php-cli -n "${S}"/run-tests.php -n
543
-
544
-	if [[ $? != 0 ]] ; then
545
-		eerror "Not all tests were successful!"
546
-	fi
547
-}
548 0