]> granicus.if.org Git - php/commitdiff
MFB: Added posix_initgroups() function.
authorIlia Alshanetsky <iliaa@php.net>
Mon, 19 Jun 2006 02:19:45 +0000 (02:19 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Mon, 19 Jun 2006 02:19:45 +0000 (02:19 +0000)
ext/posix/config.m4
ext/posix/php_posix.h
ext/posix/posix.c

index 6b95375d8849d8747d38c6ec8c9732750caf588e..b6b1cf7c1a237a3cc075021470cda816f1ebc44d 100644 (file)
@@ -11,5 +11,5 @@ if test "$PHP_POSIX" = "yes"; then
 
   AC_CHECK_HEADERS(sys/mkdev.h)
 
-  AC_CHECK_FUNCS(seteuid setegid setsid getsid setpgid getpgid ctermid mkfifo mknod getrlimit getlogin getgroups makedev)
+  AC_CHECK_FUNCS(seteuid setegid setsid getsid setpgid getpgid ctermid mkfifo mknod getrlimit getlogin getgroups makedev initgroups)
 fi
index 70982918a8b8239abef90ff01dd6e07747e16610..ddaa401a47927c3d274f5fc2ca8a83444646e03d 100644 (file)
@@ -110,6 +110,10 @@ PHP_FUNCTION(posix_getpwuid);
 PHP_FUNCTION(posix_getrlimit);
 #endif
 
+#ifdef HAVE_INITGROUPS
+PHP_FUNCTION(posix_initgroups);
+#endif
+
 PHP_FUNCTION(posix_get_last_error);
 PHP_FUNCTION(posix_strerror);
 
index 73436d208d9d51cda87cd82aa4776f4a87b6eb7b..28921033d49a5cbd1b7dccac3e7083cbedd4ded0 100644 (file)
@@ -134,6 +134,9 @@ zend_function_entry posix_functions[] = {
        PHP_FE(posix_get_last_error,                                    NULL)
        PHP_FALIAS(posix_errno, posix_get_last_error,   NULL)
        PHP_FE(posix_strerror,                                                  NULL)
+#ifdef HAVE_INITGROUPS
+       PHP_FE(posix_initgroups,        NULL)
+#endif
 
        {NULL, NULL, NULL}
 };
@@ -1050,6 +1053,22 @@ PHP_FUNCTION(posix_strerror)
 
 #endif
 
+/* {{{ proto bool initgroups(string name, int base_group_id)
+   Calculate the group access list for the user specified in name. */
+PHP_FUNCTION(posix_initgroups)
+{
+       long basegid;
+       char *name;
+       int name_len;
+
+       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &name, &name_len, &basegid) == FAILURE) {
+               RETURN_FALSE;
+       }
+
+       RETURN_BOOL(!initgroups((const char *)name, basegid));
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4