Thanks fo the answer. But, another example: -------------------- #!/usr/local/bin/php-5.2 -q
//set group ID to operator posix_setgid(5); posix_setegid(5); //set user ID to nobody posix_setuid($_uid); echo 'getuid: ' . posix_getuid() . "\n"; echo 'getgid: ' . posix_getgid() . "\n"; echo 'getegid: ' . posix_getegid() . "\n"; echo file_get_contents('/etc/sudoers'); -------------------- This script returns contents of /etc/sudoers file. But it shouldn't becouse perms of /etc/sudoers permissions are: ----- -r--r----- 1 root wheel 1354 Aug 17 2011 /etc/sudoers ---- I'm I right ? Bambero On Wed, Oct 9, 2013 at 4:30 PM, Otto Moerbeek <o...@drijf.net> wrote: > On Wed, Oct 09, 2013 at 04:26:20PM +0200, Bambero wrote: > > > Hello > > > > I have a small php script which creates a file: > > > > -------------------- > > #!/usr/local/bin/php-5.2 -q > > > > //set group ID to operator > > posix_setgid(5); > > posix_setegid(5); > > > > //set user ID to nobody > > posix_setuid($_uid); > > > > // create file > > touch('/tmp/permtest'); > > > > echo 'getuid: ' . posix_getuid() . "\n"; > > echo 'getgid: ' . posix_getgid() . "\n"; > > echo 'getegid: ' . posix_getegid() . "\n"; > > -------------------- > > > > Script returns (as expected): > > ---------- > > getuid: 2 > > getgid: 5 > > getegid: 5 > > ---------- > > > > But file created with that script has perms: > > > > -rw-r--r-- 1 operator wheel 0 Oct 9 16:16 permtest > > > > So it looks like the setgid not works ? > > > > Can anyone help ? > > > > Bambero > > On *BSD systems, the group owner of a file is inherited from the directory. > > -Otto