cvs: php4 /ext/posix config.m4 php_posix.h posix.c
| From: | Kristian K�hntopp | Date: | Wed, 26 Jul 2000 21:25:02 +0000 |
| Subject: | cvs: php4 /ext/posix config.m4 php_posix.h posix.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-946@lists.php.net to get a copy of this message | ||
kk Wed Jul 26 14:25:02 2000 EDT
Modified files:
/php4/ext/posix config.m4 php_posix.h posix.c
Log:
Added seteuid and setegid functions on request by max@valkyrie.sscf.ucsb.edu.
Also fixed the function detection for the HAVE_ functions.
Index: php4/ext/posix/config.m4
diff -u php4/ext/posix/config.m4:1.3 php4/ext/posix/config.m4:1.4
--- php4/ext/posix/config.m4:1.3 Mon May 1 14:36:52 2000
+++ php4/ext/posix/config.m4 Wed Jul 26 14:25:01 2000
@@ -1,13 +1,13 @@
-dnl $Id: config.m4,v 1.3 2000/05/01 21:36:52 sas Exp $
+dnl $Id: config.m4,v 1.4 2000/07/26 21:25:01 kk Exp $
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: php4/ext/posix/php_posix.h
diff -u php4/ext/posix/php_posix.h:1.6 php4/ext/posix/php_posix.h:1.7
--- php4/ext/posix/php_posix.h:1.6 Sat Jul 15 07:35:41 2000
+++ php4/ext/posix/php_posix.h Wed Jul 26 14:25:01 2000
@@ -28,7 +28,7 @@
*/
-/* $Id: php_posix.h,v 1.6 2000/07/15 14:35:41 eschmid Exp $ */
+/* $Id: php_posix.h,v 1.7 2000/07/26 21:25:01 kk Exp $ */
#ifndef PHP_POSIX_H
#define PHP_POSIX_H
@@ -52,6 +52,9 @@
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: php4/ext/posix/posix.c
diff -u php4/ext/posix/posix.c:1.19 php4/ext/posix/posix.c:1.20
--- php4/ext/posix/posix.c:1.19 Sat Jul 15 07:35:41 2000
+++ php4/ext/posix/posix.c Wed Jul 26 14:25:01 2000
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: posix.c,v 1.19 2000/07/15 14:35:41 eschmid Exp $ */
+/* $Id: posix.c,v 1.20 2000/07/26 21:25:01 kk Exp $ */
#include "php.h"
@@ -74,9 +74,11 @@
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)
@@ -136,7 +138,7 @@
static PHP_MINFO_FUNCTION(posix)
{
php_info_print_table_start();
- php_info_print_table_row(2, "Revision", "$Revision: 1.19 $");
+ php_info_print_table_row(2, "Revision", "$Revision: 1.20 $");
php_info_print_table_end();
}
@@ -284,6 +286,65 @@
RETURN_TRUE;
}
/* }}} */
+
+/* {{{ 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) */