Seg Fault on posix_getpwnam()
| From: | Gashaw Teshome | Date: | Wed, 06 Sep 2000 21:00:46 +0000 |
| Subject: | Seg Fault on posix_getpwnam() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-15599@lists.php.net to get a copy of this message | ||
I have a script that seg faults when run:
<?
$handle=opendir("/home");
while ($username = readdir($handle)) {
$r=posix_getpwnam("$username");
$gid=$r["gid"];
if ($username != "." && $username != ".." && $gid == 507) {
echo "$username<br>";
}
}
closedir($handle);
?>
The scripts reads /home, gets the trailing path -ie, username (and no,
this is probably not the best way to do it)- and gets the group id of
the user. The scripts works if I substitute posix_getgrnam($username)
but the results aren't what I need. Anyone see a problem with my script
or is this a bug in PHP 4.0.1pl2?
BTW, posix_getpwnam() works on its own. I think the while loop is
killing it somehow.
Thanks
Gash