33#include <sys/resource.h>
34#include <sys/utsname.h>
43# include <sys/mkdev.h>
44#elif defined(MAJOR_IN_SYSMACROS)
45# include <sys/sysmacros.h>
64#if defined(COMPILE_DL_POSIX) && defined(ZTS)
67 posix_globals->last_error = 0;
74 register_posix_symbols(module_number);
99#ifdef COMPILE_DL_POSIX
106#define PHP_POSIX_RETURN_LONG_FUNC(func_name) \
107 ZEND_PARSE_PARAMETERS_NONE(); \
108 RETURN_LONG(func_name());
110#define PHP_POSIX_SINGLE_ARG_FUNC(func_name) \
112 ZEND_PARSE_PARAMETERS_START(1, 1) \
114 ZEND_PARSE_PARAMETERS_END(); \
115 if (func_name(val) < 0) { \
116 POSIX_G(last_error) = errno; \
132 if (kill(pid, sig) < 0) {
144 PHP_POSIX_RETURN_LONG_FUNC(getpid);
151 PHP_POSIX_RETURN_LONG_FUNC(getppid);
158 PHP_POSIX_RETURN_LONG_FUNC(getuid);
165 PHP_POSIX_RETURN_LONG_FUNC(getgid);
172 PHP_POSIX_RETURN_LONG_FUNC(geteuid);
179 PHP_POSIX_RETURN_LONG_FUNC(getegid);
186 PHP_POSIX_SINGLE_ARG_FUNC(setuid);
193 PHP_POSIX_SINGLE_ARG_FUNC(setgid);
201 PHP_POSIX_SINGLE_ARG_FUNC(seteuid);
210 PHP_POSIX_SINGLE_ARG_FUNC(setegid);
241 for (i=0; i<
result; i++) {
257 if (
NULL == (
p = getlogin())) {
270 PHP_POSIX_RETURN_LONG_FUNC(getpgrp);
278 PHP_POSIX_RETURN_LONG_FUNC(setsid);
293 if (setpgid(pid, pgid) < 0) {
360#if defined(_GNU_SOURCE) && defined(HAVE_STRUCT_UTSNAME_DOMAINNAME)
378 if ((ticks = times(&t)) == -1) {
425 if (stream ==
NULL) {
454#if defined(ZTS) && defined(HAVE_TTYNAME_R) && defined(_SC_TTY_NAME_MAX)
464 if (php_posix_stream_get_fd(z_fd, &
fd) ==
FAILURE) {
468 if (!zend_parse_arg_long(z_fd, &
fd,
NULL,
false, 1)) {
471 fd = zval_get_long(z_fd);
479#if defined(ZTS) && defined(HAVE_TTYNAME_R) && defined(_SC_TTY_NAME_MAX)
480 buflen = sysconf(_SC_TTY_NAME_MAX);
491 err = ttyname_r(
fd,
p, buflen);
505 if (
NULL == (
p = ttyname(
fd))) {
525 if (php_posix_stream_get_fd(z_fd, &
fd) ==
FAILURE) {
529 if (!zend_parse_arg_long(z_fd, &
fd,
NULL,
false, 1)) {
659int php_posix_group_to_array(
struct group *g,
zval *array_group)
672 add_assoc_string(array_group,
"name", g->gr_name);
674 add_assoc_string(array_group,
"passwd", g->gr_passwd);
676 add_assoc_null(array_group,
"passwd");
681 memcpy(&gr_mem, &g->gr_mem[
count],
sizeof(
char *));
689 add_assoc_long(array_group,
"gid", g->gr_gid);
706 char *filename, *path;
742 char *filename, *path;
789#if defined(ZTS) && defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX)
800#if defined(ZTS) && defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX)
801 buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
837#if defined(ZTS) && defined(HAVE_GETGRNAM_R) && defined(_SC_GETGR_R_SIZE_MAX)
847#if defined(ZTS) && defined(HAVE_GETGRGID_R) && defined(_SC_GETGR_R_SIZE_MAX)
850 struct group *retgrptr =
NULL;
860#if defined(ZTS) && defined(HAVE_GETGRGID_R) && defined(_SC_GETGR_R_SIZE_MAX)
862 grbuflen = sysconf(_SC_GETGR_R_SIZE_MAX);
874 err = getgrgid_r(gid, &_g, grbuf, grbuflen, &retgrptr);
887 if (
NULL == (g = getgrgid(gid))) {
899#if defined(ZTS) && defined(HAVE_GETGRGID_R) && defined(_SC_GETGR_R_SIZE_MAX)
913 add_assoc_string(
return_value,
"passwd", pw->pw_passwd);
929#if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWNAM_R)
940#if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWNAM_R)
941 buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
965 if (
NULL == (pw = getpwnam(
name))) {
977#if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWNAM_R)
987#if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWUID_R)
989 struct passwd *retpwptr =
NULL;
1000#if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWUID_R)
1001 pwbuflen = sysconf(_SC_GETPW_R_SIZE_MAX);
1012 err = getpwuid_r(uid, &_pw, pwbuf, pwbuflen, &retpwptr);
1013 if (
err || retpwptr ==
NULL) {
1014 if (
err == ERANGE) {
1025 if (
NULL == (pw = getpwuid(uid))) {
1037#if defined(ZTS) && defined(_SC_GETPW_R_SIZE_MAX) && defined(HAVE_GETPWUID_R)
1044#ifdef HAVE_GETRLIMIT
1046#define UNLIMITED_STRING "unlimited"
1058 result = getrlimit(limit, &rl);
1064 if (rl.rlim_cur == RLIM_INFINITY) {
1065 add_assoc_stringl(
return_value, soft, UNLIMITED_STRING,
sizeof(UNLIMITED_STRING)-1);
1070 if (rl.rlim_max == RLIM_INFINITY) {
1071 add_assoc_stringl(
return_value, hard, UNLIMITED_STRING,
sizeof(UNLIMITED_STRING)-1);
1081static const struct limitlist {
1086 { RLIMIT_CORE,
"core" },
1090 { RLIMIT_DATA,
"data" },
1094 { RLIMIT_STACK,
"stack" },
1098 { RLIMIT_VMEM,
"virtualmem" },
1102 { RLIMIT_AS,
"totalmem" },
1106 { RLIMIT_RSS,
"rss" },
1110 { RLIMIT_NPROC,
"maxproc" },
1113#ifdef RLIMIT_MEMLOCK
1114 { RLIMIT_MEMLOCK,
"memlock" },
1118 { RLIMIT_CPU,
"cpu" },
1122 { RLIMIT_FSIZE,
"filesize" },
1126 { RLIMIT_NOFILE,
"openfiles" },
1130 { RLIMIT_OFILE,
"openfiles" },
1133#ifdef RLIMIT_KQUEUES
1134 { RLIMIT_KQUEUES,
"kqueues" },
1138 { RLIMIT_NPTS,
"npts" },
1149 const struct limitlist *l =
NULL;
1151 bool res_is_null =
true;
1161 for (l=limits; l->name; l++) {
1176 if (rl.rlim_cur == RLIM_INFINITY) {
1182 if (rl.rlim_max == RLIM_INFINITY) {
1193#ifdef HAVE_SETRLIMIT
1209 if (setrlimit(
res, &rl) == -1) {
1245#ifdef HAVE_INITGROUPS
1258 if (name_len == 0) {
1290 if (path_len == 0) {
1309#ifdef HAVE_FPATHCONF
1321 if (php_posix_stream_get_fd(z_fd, &
fd) ==
FAILURE) {
1325 if (!zend_parse_arg_long(z_fd, &
fd,
NULL,
false, 1)) {
count(Countable|array $value, int $mode=COUNT_NORMAL)
zend_ffi_ctype_name_buf buf
PHPAPI int php_check_open_basedir(const char *path)
PHPAPI char * expand_filepath(const char *filepath, char *real_path)
PHPAPI int php_check_open_basedir_ex(const char *path, int warn)
foreach($dp as $el) foreach( $dp as $el) if( $pass2< 2) echo ""
PHPAPI ZEND_COLD void php_error_docref(const char *docref, int type, const char *format,...)
php_info_print_table_start()
php_info_print_table_row(2, "PDO Driver for Firebird", "enabled")
php_info_print_table_end()
#define PHP_MINIT_FUNCTION
#define PHP_MINFO_FUNCTION
#define PHP_GINIT_FUNCTION
#define PHP_MODULE_GLOBALS
#define php_stream_cast(stream, as, ret, show_err)
struct _php_stream php_stream
#define PHP_STREAM_AS_FD_FOR_SELECT
#define php_stream_can_cast(stream, as)
#define php_stream_from_zval_no_verify(xstr, pzval)
#define PHP_STREAM_CAST_INTERNAL
posix_pathconf(string $path, int $name)
posix_setrlimit(int $resource, int $soft_limit, int $hard_limit)
posix_strerror(int $error_code)
posix_getpgid(int $process_id)
posix_access(string $filename, int $flags=0)
posix_getgrnam(string $name)
posix_kill(int $process_id, int $signal)
posix_seteuid(int $user_id)
posix_getrlimit(?int $resource=null)
posix_sysconf(int $conf_id)
posix_setegid(int $group_id)
posix_getpwnam(string $username)
posix_getsid(int $process_id)
posix_setpgid(int $process_id, int $process_group_id)
posix_ttyname($file_descriptor)
posix_getgrgid(int $group_id)
posix_fpathconf($file_descriptor, int $name)
posix_setuid(int $user_id)
posix_mkfifo(string $filename, int $permissions)
posix_initgroups(string $username, int $group_id)
posix_setgid(int $group_id)
posix_mknod(string $filename, int $flags, int $major=0, int $minor=0)
posix_isatty($file_descriptor)
posix_eaccess(string $filename, int $flags=0)
posix_getpwuid(int $user_id)
const php_stream_ops * ops
#define ZEND_TSRMLS_CACHE_UPDATE()
#define ZEND_TSRMLS_CACHE_DEFINE()
ZEND_API const char * zend_zval_value_name(const zval *arg)
ZEND_API zend_result add_next_index_stringl(zval *arg, const char *str, size_t length)
ZEND_API zend_result add_next_index_long(zval *arg, zend_long n)
ZEND_API ZEND_COLD void zend_argument_must_not_be_empty_error(uint32_t arg_num)
ZEND_API ZEND_COLD void zend_argument_value_error(uint32_t arg_num, const char *format,...)
ZEND_API ZEND_COLD void zend_argument_type_error(uint32_t arg_num, const char *format,...)
ZEND_API zend_result add_next_index_string(zval *arg, const char *str)
#define Z_PARAM_PATH_STR(dest)
#define ZEND_PARSE_PARAMETERS_END()
#define ZEND_PARSE_PARAMETERS_NONE()
#define ZEND_DECLARE_MODULE_GLOBALS(module_name)
#define ZEND_GET_MODULE(name)
#define Z_PARAM_STRING(dest, dest_len)
#define ZEND_PARSE_PARAMETERS_START(min_num_args, max_num_args)
#define Z_PARAM_LONG(dest)
#define Z_PARAM_LONG_OR_NULL(dest, is_null)
#define Z_PARAM_PATH(dest, dest_len)
#define Z_PARAM_ZVAL(dest)
#define erealloc(ptr, size)
ZEND_API zval *ZEND_FASTCALL zend_hash_str_update(HashTable *ht, const char *str, size_t len, zval *pData)
ZEND_API void ZEND_FASTCALL zend_array_destroy(HashTable *ht)
struct _zend_string zend_string
#define STANDARD_MODULE_HEADER
struct _zend_module_entry zend_module_entry
#define STANDARD_MODULE_PROPERTIES_EX
ZEND_DLIMPORT int isatty(int fd)
#define Z_ARRVAL_P(zval_p)
ZEND_RESULT_CODE zend_result
#define VCWD_GETCWD(buff, size)