diff options
author | Kristian Köhntopp <kk@php.net> | 2000-07-26 21:25:01 +0000 |
---|---|---|
committer | Kristian Köhntopp <kk@php.net> | 2000-07-26 21:25:01 +0000 |
commit | 102156298a889c27aaaa11c36d10ba1644fae2e6 (patch) | |
tree | 9f5c346508dabc9f1cfdf31dfb11acf7a57b2aa0 /ext/posix/posix.c | |
parent | f1f91467fa2e93d8436936aab12bebc140790618 (diff) | |
download | php-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.
Diffstat (limited to 'ext/posix/posix.c')
-rw-r--r-- | ext/posix/posix.c | 61 |
1 files changed, 61 insertions, 0 deletions
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) |