83#define FILE_PREFIX "sess_"
89#define SESS_FILE_BUF_SIZE(sz) ((unsigned int)(sz > INT_MAX ? INT_MAX : (unsigned int)sz))
122 for (i = 0; i < (int)
data->dirdepth; i++) {
141 if (
data->fd != -1) {
155#if !defined(O_NOFOLLOW) || !defined(PHP_WIN32)
156 struct stat sbuf = {0};
160 if (
data->fd < 0 || !
data->last_key || !zend_string_equals(
key,
data->last_key)) {
161 if (
data->last_key) {
166 ps_files_close(
data);
169 php_error_docref(
NULL,
E_WARNING,
"Session ID is too long or contains illegal characters. Only the A-Z, a-z, 0-9, \"-\", and \",\" characters are allowed");
178 data->last_key = zend_string_copy(
key);
192 if (
data->fd != -1) {
202 if (
zend_fstat(
data->fd, &sbuf) || (sbuf.st_uid != 0 && sbuf.st_uid != getuid() && sbuf.st_uid != geteuid() && getuid() != 0)) {
211 }
while (
ret == -1 &&
errno == EINTR);
250 unsigned int to_write = SESS_FILE_BUF_SIZE(
ZSTR_LEN(
val));
255 wrote = _write(
data->fd,
buf, to_write);
258 buf = wrote > -1 ?
buf + wrote : 0;
259 to_write = wrote > -1 ? SESS_FILE_BUF_SIZE(
ZSTR_LEN(
val) -
n) : 0;
269 if (
n == (
size_t)-1) {
322 (
now - sbuf.st_mtime) > maxlifetime) {
350#define PS_FILES_DATA ps_files *data = PS_GET_MOD_DATA()
367 const char *
p, *
last;
373 if (*save_path ==
'\0') {
396 if (
errno == ERANGE) {
405 if (
errno == ERANGE || filemode < 0 || filemode > 07777) {
410 save_path = argv[argc - 1];
415 data->dirdepth = dirdepth;
416 data->filemode = filemode;
417 data->basedir = zend_string_init(save_path,
strlen(save_path),
false);
420 ps_close_files(mod_data);
442 ps_files_close(
data);
444 if (
data->last_key) {
482 data->st_size = sbuf.st_size;
484 if (sbuf.st_size == 0) {
489 *
val = zend_string_alloc(sbuf.st_size, 0);
497 unsigned int to_read = SESS_FILE_BUF_SIZE(
ZSTR_LEN(*
val));
502 read_in = _read(
data->fd,
buf, to_read);
505 buf = read_in > -1 ?
buf + read_in : 0;
506 to_read = read_in > -1 ? SESS_FILE_BUF_SIZE(
ZSTR_LEN(*
val) -
n) : 0;
508 }
while(read_in > 0);
602 if (
data->fd != -1) {
603 ps_files_close(
data);
637 if (
data->dirdepth == 0) {
638 *nrdels = ps_files_cleanup_dir(
data->basedir, maxlifetime);
703 return ps_files_key_exists(
data,
key);
readdir($dir_handle=null)
ftruncate($stream, int $size)
closedir($dir_handle=null)
opendir(string $directory, $context=null)
dirname(string $path, int $levels=1)
dir(string $directory, $context=null)
flock($stream, int $operation, &$would_block=null)
strchr(string $haystack, string $needle, bool $before_needle=false)
zend_ffi_ctype_name_buf buf
PHPAPI int php_check_open_basedir(const char *path)
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
const ps_module ps_mod_files
#define PHP_DIR_SEPARATOR
#define php_ignore_value(x)
PHPAPI const char * php_get_temporary_directory(void)
unsigned char key[REFLECTION_KEY_LEN]
#define PS_UPDATE_TIMESTAMP_FUNC(x)
PHPAPI zend_result php_session_valid_key(const char *key)
struct ps_module_struct ps_module
#define PS_VALIDATE_SID_FUNC(x)
#define PS_SET_MOD_DATA(a)
#define PS_DESTROY_FUNC(x)
#define PS_MOD_UPDATE_TIMESTAMP(x)
#define PS_GET_MOD_DATA()
PHPAPI zend_string * php_session_create_id(PS_CREATE_SID_ARGS)
#define PS_CREATE_SID_FUNC(x)
#define ecalloc(nmemb, size)
strncmp(string $string1, string $string2, int $length)
zend_string_release_ex(func->internal_function.function_name, 0)
#define ZEND_STRTOL(s0, s1, base)
struct _zend_string zend_string
#define ZSTR_EMPTY_ALLOC()
ZEND_RESULT_CODE zend_result
#define VCWD_UNLINK(path)
#define VCWD_OPEN_MODE(path, flags, mode)
#define VCWD_ACCESS(pathname, mode)
#define VCWD_STAT(path, buff)