Get the gid of a group by php

I need your help, Still learning how work this lkjqsgfhjksgfhkdjsghsghf of php :slight_smile:

I want to retrieve the gid of a group by php, I know how to do it by perl, I could find it and save it in a db during a template-expand, but I would do it directly in the server-manager.

for what I saw, I could install php-process and use some functions, but it doesn’t work (I tested my function with a standard ($a=‘toto’;return $a;), the problem is not here)

private function readgid()
{
$a = $this->parameters[‘OwningGroup’];
$gid = posix_getegid (’$a’);
return $gid;
}

If possible, run it as bash or perl action. Otherwise use exec() or php backtick operator and parse id or getent command output.

This is an example

1 Like

The posix_getgrnam searches a group by its name and returns an array which contains the gid.
(Some php hardening guides suggest to disable this and similar functions to prevent information disclosure).

1 Like

Ok I found what is wrong in my code :’(

the space separator in the group name (domain users@stephdl.dyndns.org), was not a good idea :slight_smile:

Ok I did it in perl :blush: but at the end I still don’t get why to code netgui in php if we (almost) rely on perl…I’m kidding, thank to all

My (little) issue was the space in the variable.

1 Like