0

In the example below, the uid is set correctly to 1234, but the gid remains 1000 (my current user Linux.)

In production this particular script gets to run as root, so it works flawlessly there. But I want to be able to test it using vfsStream.

There seems to be no way to tell vfsStream to mimic the root user, and I'm puzzled why chown works, but chgrp doesn't.

$structure = [
    'etc' => [],
];

$root = vfsStream::setup('root', null, $structure);

$directory = $root->url() . '/etc/test';
mkdir($directory);
chown($directory, 1234);
chgrp($directory, 1234);
clearstatcache();
dd(stat($directory));
matiaslauriti
  • 7,065
  • 4
  • 31
  • 43
Niels
  • 1
  • 1
  • Looks like swapping chgrp and chown avoids the issue. The chown seems to take away my permission to do the chgrp. (I do think it's a bug, because this also happens when you run the code as root.) – Niels Aug 02 '21 at 11:51
  • If you do think it is a bug, please report it to the upstream project and leave a cross-reference to your report here. – hakre Aug 04 '21 at 09:10

0 Answers0