cvs: php4(PHP_4_0_7) /ext/session mod_mm.c session.c

From: Date: Mon, 25 Feb 2002 00:21:15 +0000
Subject: cvs: php4(PHP_4_0_7) /ext/session mod_mm.c session.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-9444@lists.php.net to get a copy of this message
yohgaki Sun Feb 24 19:21:15 2002 EDT Modified files: (Branch: PHP_4_0_7) /php4/ext/session mod_mm.c session.c Log: MFH - Fixed CGI (or other SAPI) start up failure when mm save handler is used # More fixes will be merged when I commit session & output control patch Index: php4/ext/session/mod_mm.c diff -u php4/ext/session/mod_mm.c:1.22.2.3 php4/ext/session/mod_mm.c:1.22.2.4 --- php4/ext/session/mod_mm.c:1.22.2.3 Thu Jan 10 03:48:23 2002 +++ php4/ext/session/mod_mm.c Sun Feb 24 19:21:14 2002 @@ -1,8 +1,8 @@ /* +----------------------------------------------------------------------+ - | PHP version 4.0 | + | PHP Version 4 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2001 The PHP Group | + | Copyright (c) 1997-2002 The PHP Group | +----------------------------------------------------------------------+ | This source file is subject to version 2.02 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -16,12 +16,13 @@ +----------------------------------------------------------------------+ */ -/* $Id: mod_mm.c,v 1.22.2.3 2002/01/10 08:48:23 yohgaki Exp $ */ +/* $Id: mod_mm.c,v 1.22.2.4 2002/02/25 00:21:14 yohgaki Exp $ */ #include "php.h" #ifdef HAVE_LIBMM +#include <unistd.h> #include <mm.h> #include <time.h> #include <sys/stat.h> @@ -30,12 +31,13 @@ #include "php_session.h" #include "mod_mm.h" +#include "SAPI.h" #ifdef ZTS # error mm is not thread-safe #endif -#define PS_MM_PATH "/tmp/session_mm" +#define PS_MM_FILE "session_mm_" /* For php_uint32 */ #include "ext/standard/basic_functions.h" @@ -247,8 +249,36 @@ PHP_MINIT_FUNCTION(ps_mm) { + int save_path_len = strlen(PS(save_path)); + int mod_name_len = strlen(sapi_module.name); + char *ps_mm_path, euid[30]; + int ret; + ps_mm_instance = calloc(sizeof(*ps_mm_instance), 1); - if (ps_mm_initialize(ps_mm_instance, PS_MM_PATH) != SUCCESS) { + if (!ps_mm_instance) + return FAILURE; + + if (!sprintf(euid,"%d", geteuid())) + return FAILURE; + + /* Directory + '/' + File + Module Name + Effective UID + \0 */ + ps_mm_path = do_alloca(save_path_len+1+sizeof(PS_MM_FILE)+mod_name_len+strlen(euid)+1); + + memcpy(ps_mm_path, PS(save_path), save_path_len + 1); + if (save_path_len > 0 && ps_mm_path[save_path_len - 1] != DEFAULT_SLASH) { + ps_mm_path[save_path_len] = DEFAULT_SLASH; + ps_mm_path[save_path_len+1] = '\0'; + } + strcat(ps_mm_path, PS_MM_FILE); + strcat(ps_mm_path, sapi_module.name); + strcat(ps_mm_path, euid); + + ret = ps_mm_initialize(ps_mm_instance, ps_mm_path); + + free_alloca(ps_mm_path); + + if (ret != SUCCESS) { + free(ps_mm_instance); ps_mm_instance = NULL; return FAILURE; } @@ -289,7 +319,6 @@ { PS_MM_DATA; ps_sd *sd; - int ret = FAILURE; mm_lock(data->mm, MM_LOCK_RD); @@ -299,12 +328,13 @@ *val = emalloc(sd->datalen + 1); memcpy(*val, sd->data, sd->datalen); (*val)[sd->datalen] = '\0'; - ret = SUCCESS; } - + else { + *val = estrdup(""); + } mm_unlock(data->mm); - return ret; + return SUCCESS; } PS_WRITE_FUNC(mm) @@ -411,6 +441,6 @@ * tab-width: 4 * c-basic-offset: 4 * End: - * vim600: sw=4 ts=4 tw=78 fdm=marker - * vim<600: sw=4 ts=4 tw=78 + * vim600: sw=4 ts=4 fdm=marker + * vim<600: sw=4 ts=4 */ Index: php4/ext/session/session.c diff -u php4/ext/session/session.c:1.237.2.6 php4/ext/session/session.c:1.237.2.7 --- php4/ext/session/session.c:1.237.2.6 Fri Feb 22 10:01:20 2002 +++ php4/ext/session/session.c Sun Feb 24 19:21:14 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: session.c,v 1.237.2.6 2002/02/22 15:01:20 yohgaki Exp $ */ +/* $Id: session.c,v 1.237.2.7 2002/02/25 00:21:14 yohgaki Exp $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -437,7 +437,7 @@ MAKE_STD_ZVAL(PS(http_session_vars)); array_init(PS(http_session_vars)); ZEND_SET_GLOBAL_VAR_WITH_LENGTH("HTTP_SESSION_VARS", sizeof("HTTP_SESSION_VARS"), PS(http_session_vars), 1, 0); - ZEND_SET_GLOBAL_VAR_WITH_LENGTH("_SESSION", sizeof("_SESSION"), PS(http_session_vars), 2, 0); + ZEND_SET_GLOBAL_VAR_WITH_LENGTH("_SESSION", sizeof("_SESSION"), PS(http_session_vars), 1, 0); } }

« previous php.cvs (#9444) next »