1
1
/*
2
2
+----------------------------------------------------------------------+
3
- | PHP version 4.0 |
3
+ | PHP Version 4 |
4
4
+----------------------------------------------------------------------+
5
- | Copyright (c) 1997-2001 The PHP Group |
5
+ | Copyright (c) 1997-2002 The PHP Group |
6
6
+----------------------------------------------------------------------+
7
7
| This source file is subject to version 2.02 of the PHP license, |
8
8
| that is bundled with this package in the file LICENSE, and is |
22
22
23
23
#ifdef HAVE_LIBMM
24
24
25
+ #include <unistd.h>
25
26
#include <mm.h>
26
27
#include <time.h>
27
28
#include <sys/stat.h>
30
31
31
32
#include "php_session.h"
32
33
#include "mod_mm.h"
34
+ #include "SAPI.h"
33
35
34
36
#ifdef ZTS
35
37
# error mm is not thread-safe
36
38
#endif
37
39
38
- #define PS_MM_PATH "/tmp/session_mm "
40
+ #define PS_MM_FILE "session_mm_ "
39
41
40
42
/* For php_uint32 */
41
43
#include "ext/standard/basic_functions.h"
@@ -247,8 +249,36 @@ static void ps_mm_destroy(ps_mm *data)
247
249
248
250
PHP_MINIT_FUNCTION (ps_mm )
249
251
{
252
+ int save_path_len = strlen (PS (save_path ));
253
+ int mod_name_len = strlen (sapi_module .name );
254
+ char * ps_mm_path , euid [30 ];
255
+ int ret ;
256
+
250
257
ps_mm_instance = calloc (sizeof (* ps_mm_instance ), 1 );
251
- if (ps_mm_initialize (ps_mm_instance , PS_MM_PATH ) != SUCCESS ) {
258
+ if (!ps_mm_instance )
259
+ return FAILURE ;
260
+
261
+ if (!sprintf (euid ,"%d" , geteuid ()))
262
+ return FAILURE ;
263
+
264
+ /* Directory + '/' + File + Module Name + Effective UID + \0 */
265
+ ps_mm_path = do_alloca (save_path_len + 1 + sizeof (PS_MM_FILE )+ mod_name_len + strlen (euid )+ 1 );
266
+
267
+ memcpy (ps_mm_path , PS (save_path ), save_path_len + 1 );
268
+ if (save_path_len > 0 && ps_mm_path [save_path_len - 1 ] != DEFAULT_SLASH ) {
269
+ ps_mm_path [save_path_len ] = DEFAULT_SLASH ;
270
+ ps_mm_path [save_path_len + 1 ] = '\0' ;
271
+ }
272
+ strcat (ps_mm_path , PS_MM_FILE );
273
+ strcat (ps_mm_path , sapi_module .name );
274
+ strcat (ps_mm_path , euid );
275
+
276
+ ret = ps_mm_initialize (ps_mm_instance , ps_mm_path );
277
+
278
+ free_alloca (ps_mm_path );
279
+
280
+ if (ret != SUCCESS ) {
281
+ free (ps_mm_instance );
252
282
ps_mm_instance = NULL ;
253
283
return FAILURE ;
254
284
}
@@ -289,7 +319,6 @@ PS_READ_FUNC(mm)
289
319
{
290
320
PS_MM_DATA ;
291
321
ps_sd * sd ;
292
- int ret = FAILURE ;
293
322
294
323
mm_lock (data -> mm , MM_LOCK_RD );
295
324
@@ -299,12 +328,13 @@ PS_READ_FUNC(mm)
299
328
* val = emalloc (sd -> datalen + 1 );
300
329
memcpy (* val , sd -> data , sd -> datalen );
301
330
(* val )[sd -> datalen ] = '\0' ;
302
- ret = SUCCESS ;
303
331
}
304
-
332
+ else {
333
+ * val = estrdup ("" );
334
+ }
305
335
mm_unlock (data -> mm );
306
336
307
- return ret ;
337
+ return SUCCESS ;
308
338
}
309
339
310
340
PS_WRITE_FUNC (mm )
@@ -411,6 +441,6 @@ zend_module_entry php_session_mm_module = {
411
441
* tab-width: 4
412
442
* c-basic-offset: 4
413
443
* End:
414
- * vim600: sw=4 ts=4 tw=78 fdm=marker
415
- * vim<600: sw=4 ts=4 tw=78
444
+ * vim600: sw=4 ts=4 fdm=marker
445
+ * vim<600: sw=4 ts=4
416
446
*/
0 commit comments