note 104149 modified in function.posix-setgid by danbrown

From: Date: Thu, 26 May 2011 17:51:18 +0000
Subject: note 104149 modified in function.posix-setgid by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-180058@lists.php.net to get a copy of this message
if you're going to use this along with posix_setuid, make sure you call posix_setgid first: <?php define (PROC_USER, 'john'); define (PROC_GRP, 'admins'); ?> following works: <?php $user = posix_getpwnam( PROC_USER ); $group = posix_getgrnam( PROC_GRP); echo posix_getuid()."\n"; echo posix_getgid()."\n"; posix_setgid($group['gid']); posix_setuid($user['uid']); echo posix_getuid()."\n"; echo posix_getgid()."\n"; ?> following will not set gid <?php $user = posix_getpwnam( PROC_USER ); $group = posix_getgrnam( PROC_GRP); echo posix_getuid()."\n"; echo posix_getgid()."\n"; posix_setuid($user['uid']); posix_setgid($group['gid']); echo posix_getuid()."\n"; echo posix_getgid()."\n"; ?> --was-- if you're going to use this along with posix_setuid, make sure you call posix_setgid first: define (PROC_USER, 'john'); define (PROC_GRP, 'admins'); following works: $user = posix_getpwnam( PROC_USER ); $group = posix_getgrnam( PROC_GRP); echo posix_getuid()."\n"; echo posix_getgid()."\n"; posix_setgid($group['gid']); posix_setuid($user['uid']); echo posix_getuid()."\n"; echo posix_getgid()."\n"; following will not set gid $user = posix_getpwnam( PROC_USER ); $group = posix_getgrnam( PROC_GRP); echo posix_getuid()."\n"; echo posix_getgid()."\n"; posix_setuid($user['uid']); posix_setgid($group['gid']); echo posix_getuid()."\n"; echo posix_getgid()."\n"; http://php.net/manual/en/function.posix-setgid.php

« previous php.notes (#180058) next »