summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKristian Köhntopp <kk@php.net>2000-07-26 21:25:01 +0000
committerKristian Köhntopp <kk@php.net>2000-07-26 21:25:01 +0000
commit102156298a889c27aaaa11c36d10ba1644fae2e6 (patch)
tree9f5c346508dabc9f1cfdf31dfb11acf7a57b2aa0
parentf1f91467fa2e93d8436936aab12bebc140790618 (diff)
downloadphp-git-102156298a889c27aaaa11c36d10ba1644fae2e6.tar.gz
Added seteuid and setegid functions on request by max@valkyrie.sscf.ucsb.edu.
Also fixed the function detection for the HAVE_ functions.
-rw-r--r--ext/posix/config.m44
-rw-r--r--ext/posix/php_posix.h3
-rw-r--r--ext/posix/posix.c61
3 files changed, 66 insertions, 2 deletions
diff --git a/ext/posix/config.m4 b/ext/posix/config.m4
index cc17d0329f..6ee4ba5b36 100644
--- a/ext/posix/config.m4
+++ b/ext/posix/config.m4
@@ -2,12 +2,12 @@ dnl $Id$
dnl config.m4 for extension posix
dnl don't forget to call PHP_EXTENSION(posix)
-
-
PHP_ARG_ENABLE(posix,whether to include POSIX-like functions,
[ --disable-posix Disable POSIX-like functions], yes)
if test "$PHP_POSIX" = "yes"; then
AC_DEFINE(HAVE_POSIX, 1, [whether to include POSIX-like functions])
PHP_EXTENSION(posix, $ext_shared)
+
+ AC_CHECK_FUNCS(seteuid setegid setsid getsid setpgid ctermid mkfifo getrlimit)
fi
diff --git a/ext/posix/php_posix.h b/ext/posix/php_posix.h
index b10da3c0c4..c3da444cff 100644
--- a/ext/posix/php_posix.h
+++ b/ext/posix/php_posix.h
@@ -52,6 +52,9 @@ PHP_FUNCTION(posix_geteuid);
PHP_FUNCTION(posix_getegid);
PHP_FUNCTION(posix_setuid);
PHP_FUNCTION(posix_setgid);
+PHP_FUNCTION(posix_seteuid);
+PHP_FUNCTION(posix_setegid);
+
PHP_FUNCTION(posix_getgroups);
PHP_FUNCTION(posix_getlogin);
diff --git a/ext/posix/posix.c b/ext/posix/posix.c
index b4320b892d..72bd8277c4 100644
--- a/ext/posix/posix.c
+++ b/ext/posix/posix.c
@@ -74,9 +74,11 @@ function_entry posix_functions[] = {
PHP_FE(posix_getuid, NULL)
PHP_FE(posix_setuid, NULL)
PHP_FE(posix_geteuid, NULL)
+ PHP_FE(posix_seteuid, NULL)
PHP_FE(posix_getgid, NULL)
PHP_FE(posix_setgid, NULL)
PHP_FE(posix_getegid, NULL)
+ PHP_FE(posix_setegid, NULL)
PHP_FE(posix_getgroups, NULL)
PHP_FE(posix_getlogin, NULL)
@@ -285,6 +287,65 @@ PHP_FUNCTION(posix_setgid)
}
/* }}} */
+/* {{{ proto long posix_seteuid(long uid)
+ Set effective user id */
+PHP_FUNCTION(posix_seteuid)
+{
+#ifdef HAVE_SETEUID
+ pval *uid;
+ int result;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters(ht, 1, &uid)==FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long(uid);
+
+ result = seteuid(uid->value.lval);
+ if (result < 0) {
+ php_error(E_WARNING, "posix_setuid(%d) failed with '%s'.",
+ uid->value.lval,
+ strerror(errno));
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+#else
+ RETURN_FALSE;
+#endif
+}
+/* }}} */
+
+/* {{{ proto long posix_setegid(long uid)
+ Set effective group id */
+PHP_FUNCTION(posix_setegid)
+{
+#ifdef HAVE_SETEGID
+ pval *gid;
+ int result;
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters(ht, 1, &gid)==FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long(gid);
+
+ result = setegid(gid->value.lval);
+ if (result < 0) {
+ php_error(E_WARNING, "posix_setgid(%d) failed with '%s'.",
+ gid->value.lval,
+ strerror(errno));
+ RETURN_FALSE;
+ }
+
+ RETURN_TRUE;
+#else
+ RETURN_FALSE;
+#endif
+}
+/* }}} */
+
+
/* {{{ proto long posix_getgroups(void)
Get supplementary group id's (POSIX.1, 4.2.3) */
PHP_FUNCTION(posix_getgroups)