]> granicus.if.org Git - php/commitdiff
Added seteuid and setegid functions on request by max@valkyrie.sscf.ucsb.edu.
authorKristian Köhntopp <kk@php.net>
Wed, 26 Jul 2000 21:25:01 +0000 (21:25 +0000)
committerKristian Köhntopp <kk@php.net>
Wed, 26 Jul 2000 21:25:01 +0000 (21:25 +0000)
Also fixed the function detection for the HAVE_ functions.

ext/posix/config.m4
ext/posix/php_posix.h
ext/posix/posix.c

index cc17d0329fbffb95d4166d540329fe769b8432be..6ee4ba5b36a0b9ffd909ced7b06ece1b4bfbb173 100644 (file)
@@ -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
index b10da3c0c44c36c7b497f3035c65511b663cbe81..c3da444cffa14b45b5d4c15e3d1cb619483d8323 100644 (file)
@@ -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);
 
index b4320b892db79d97153dc454c25891af4969affb..72bd8277c4de3b6bcb51458d44083cbd4652651b 100644 (file)
@@ -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)