Bug #62881 [Com]: posix_getpwnam("") && posix_getgrnam("") didn't return false on Mac OSX 10.8

2012-08-21 Thread reeze dot xia at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=62881&edit=1

 ID: 62881
 Comment by: reeze dot xia at gmail dot com
 Reported by:reeze dot xia at gmail dot com
 Summary:posix_getpwnam("") && posix_getgrnam("") didn't
 return false on Mac OSX 10.8
 Status: Wont fix
 Type:   Bug
 Package:POSIX related
 Operating System:   Mac OSX 10.8
 PHP Version:Irrelevant
 Block user comment: N
 Private report: N

 New Comment:

NO, I don't mean that. PHP isn't always running on lastest OS.
It just a conditional workaround for buggy api.

Since there are not that much application running on OSX.
I'm ok if you guys think we didn't fix that.


Previous Comments:

[2012-08-22 04:57:57] larue...@php.net

you think we should fix this, then after apple fixed their bug, we remove this 
fix 
then?


[2012-08-22 04:10:58] reeze dot xia at gmail dot com

OooK... by hacking /etc/passwd  hmmm. $ useradd didn't allow that.

so technically uid could be -1, etc heh.

anyway, there always trade off, I prefer it get fixed.


[2012-08-22 03:50:53] ahar...@php.net

Yeah, I had to edit /etc/passwd directly to do it, but it's possible, and once 
created, the account works normally on Linux: http://i.imgur.com/PI3zt.png


[2012-08-22 03:45:25] reeze dot xia at gmail dot com

Hi, aharvey
  how did you made it? by a tricky way?. :)


[2012-08-22 03:43:45] larue...@php.net

it's no need:

1. first it's a knew bug of apple, apple will fix that

2. as you said, you can create a group with empty string in ubuntu.

we have no reason to introduce such a temporary fix




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=62881


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62881&edit=1


Bug #62881 [Com]: posix_getpwnam("") && posix_getgrnam("") didn't return false on Mac OSX 10.8

2012-08-21 Thread reeze dot xia at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=62881&edit=1

 ID: 62881
 Comment by: reeze dot xia at gmail dot com
 Reported by:reeze dot xia at gmail dot com
 Summary:posix_getpwnam("") && posix_getgrnam("") didn't
 return false on Mac OSX 10.8
 Status: Wont fix
 Type:   Bug
 Package:POSIX related
 Operating System:   Mac OSX 10.8
 PHP Version:Irrelevant
 Block user comment: N
 Private report: N

 New Comment:

OooK... by hacking /etc/passwd  hmmm. $ useradd didn't allow that.

so technically uid could be -1, etc heh.

anyway, there always trade off, I prefer it get fixed.


Previous Comments:

[2012-08-22 03:50:53] ahar...@php.net

Yeah, I had to edit /etc/passwd directly to do it, but it's possible, and once 
created, the account works normally on Linux: http://i.imgur.com/PI3zt.png


[2012-08-22 03:45:25] reeze dot xia at gmail dot com

Hi, aharvey
  how did you made it? by a tricky way?. :)


[2012-08-22 03:43:45] larue...@php.net

it's no need:

1. first it's a knew bug of apple, apple will fix that

2. as you said, you can create a group with empty string in ubuntu.

we have no reason to introduce such a temporary fix


[2012-08-22 03:18:07] ahar...@php.net

To reiterate what I said on GitHub: I think we could put a workaround in just 
for those OS X versions behind an appropriate #if guard (blank user and group 
names are valid in at least some POSIX OSes, so we don't want to hardcode the 
behaviour for posix_getgrnam('')), but it's probably not worth the code clutter 
in the grand scheme of things.


[2012-08-22 03:02:37] larue...@php.net

same comment copied from the pr:

we don't fix bug doesn't belong to php
Linux man page of posix_getpwnam doesn't specific the situation about empty 
string
Posix functions are buggy in mac os. so, won't fix for this, leave it to apple .
btw:

after a quick google, seems you have file a bug to apple, then file another bug 
to ruby..

and the ruby guy told you the same thing I told.

why you still think it should be fixed in php self?




The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

https://bugs.php.net/bug.php?id=62881


-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62881&edit=1


Bug #62881 [Com]: posix_getpwnam("") && posix_getgrnam("") didn't return false on Mac OSX 10.8

2012-08-21 Thread reeze dot xia at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=62881&edit=1

 ID: 62881
 Comment by: reeze dot xia at gmail dot com
 Reported by:reeze dot xia at gmail dot com
 Summary:posix_getpwnam("") && posix_getgrnam("") didn't
 return false on Mac OSX 10.8
 Status: Wont fix
 Type:   Bug
 Package:POSIX related
 Operating System:   Mac OSX 10.8
 PHP Version:Irrelevant
 Block user comment: N
 Private report: N

 New Comment:

Hi, aharvey
  how did you made it? by a tricky way?. :)


Previous Comments:

[2012-08-22 03:43:45] larue...@php.net

it's no need:

1. first it's a knew bug of apple, apple will fix that

2. as you said, you can create a group with empty string in ubuntu.

we have no reason to introduce such a temporary fix


[2012-08-22 03:18:07] ahar...@php.net

To reiterate what I said on GitHub: I think we could put a workaround in just 
for those OS X versions behind an appropriate #if guard (blank user and group 
names are valid in at least some POSIX OSes, so we don't want to hardcode the 
behaviour for posix_getgrnam('')), but it's probably not worth the code clutter 
in the grand scheme of things.


[2012-08-22 03:02:37] larue...@php.net

same comment copied from the pr:

we don't fix bug doesn't belong to php
Linux man page of posix_getpwnam doesn't specific the situation about empty 
string
Posix functions are buggy in mac os. so, won't fix for this, leave it to apple .
btw:

after a quick google, seems you have file a bug to apple, then file another bug 
to ruby..

and the ruby guy told you the same thing I told.

why you still think it should be fixed in php self?


[2012-08-21 17:06:22] reeze dot xia at gmail dot com

Hi,
  I'v sent a pull request for this bug:

https://github.com/php/php-src/pull/176


thanks


[2012-08-21 16:54:16] reeze dot xia at gmail dot com

Description:

In Mac OS X 10.8 mountain lion, getpwnam() && getgrnam() didn't return NULL
when empty string supplied. this is a bug of 10.8.0

since uid 0 an gid 0 most belongs to root, this might have security issue.

and this breaks these test cases:
posix_getgrnam(): Basic tests [ext/posix/tests/posix_getgrnam.phpt]
posix_getgrnam(): Basic tests [ext/posix/tests/posix_getgrnam_basic.phpt]
posix_getpwnam(): Basic tests [ext/posix/tests/posix_getpwnam.phpt]
posix_getpwnam(): Basic tests [ext/posix/tests/posix_getpwnam_basic.phpt]

here is reproducible code from: Andreas Fink :
#include 
#include 
#include 
#include 
#include 

#define MAYBE_NULL_STRING(a)(a ? a : "(NULL)")

extern int errno;

int main(int argc, char *argv[])
{
errno = 0;
struct passwd *pwdstruct = getpwnam("");
printf("errno = %d\n",errno);
if(pwdstruct == NULL)
{
printf("pwdstruct == NULL\n");
exit(0);
}

printf("pw_name: %s\n",MAYBE_NULL_STRING(pwdstruct->pw_name));
printf("pw_passwd: %s\n",MAYBE_NULL_STRING(pwdstruct->pw_passwd));
printf("pw_uid: %d\n",pwdstruct->pw_uid);
printf("pw_gid: %d\n",pwdstruct->pw_gid);
}


produces

$ ./a.out 
errno = 0
pw_name: 
pw_passwd: 
pw_uid: 0
pw_gid: 0


Test script:
---

  string(0) ""
  ["passwd"]=>
  string(0) ""
  ["uid"]=>
  int(0)
  ["gid"]=>
  int(0)
  ["gecos"]=>
  string(0) ""
  ["dir"]=>
  string(0) ""
  ["shell"]=>
  string(0) ""
}
array(4) {
  ["name"]=>
  string(0) ""
  ["passwd"]=>
  string(0) ""
  ["members"]=>
  array(0) {
  }
  ["gid"]=>
  int(0)
}






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62881&edit=1


Bug #62881 [Com]: posix_getpwnam("") && posix_getgrnam("") didn't return false on Mac OSX 10.8

2012-08-21 Thread reeze dot xia at gmail dot com
Edit report at https://bugs.php.net/bug.php?id=62881&edit=1

 ID: 62881
 Comment by: reeze dot xia at gmail dot com
 Reported by:reeze dot xia at gmail dot com
 Summary:posix_getpwnam("") && posix_getgrnam("") didn't
 return false on Mac OSX 10.8
 Status: Open
 Type:   Bug
 Package:POSIX related
 Operating System:   Mac OSX 10.8
 PHP Version:Irrelevant
 Block user comment: N
 Private report: N

 New Comment:

Hi,
  I'v sent a pull request for this bug:

https://github.com/php/php-src/pull/176


thanks


Previous Comments:

[2012-08-21 16:54:16] reeze dot xia at gmail dot com

Description:

In Mac OS X 10.8 mountain lion, getpwnam() && getgrnam() didn't return NULL
when empty string supplied. this is a bug of 10.8.0

since uid 0 an gid 0 most belongs to root, this might have security issue.

and this breaks these test cases:
posix_getgrnam(): Basic tests [ext/posix/tests/posix_getgrnam.phpt]
posix_getgrnam(): Basic tests [ext/posix/tests/posix_getgrnam_basic.phpt]
posix_getpwnam(): Basic tests [ext/posix/tests/posix_getpwnam.phpt]
posix_getpwnam(): Basic tests [ext/posix/tests/posix_getpwnam_basic.phpt]

here is reproducible code from: Andreas Fink :
#include 
#include 
#include 
#include 
#include 

#define MAYBE_NULL_STRING(a)(a ? a : "(NULL)")

extern int errno;

int main(int argc, char *argv[])
{
errno = 0;
struct passwd *pwdstruct = getpwnam("");
printf("errno = %d\n",errno);
if(pwdstruct == NULL)
{
printf("pwdstruct == NULL\n");
exit(0);
}

printf("pw_name: %s\n",MAYBE_NULL_STRING(pwdstruct->pw_name));
printf("pw_passwd: %s\n",MAYBE_NULL_STRING(pwdstruct->pw_passwd));
printf("pw_uid: %d\n",pwdstruct->pw_uid);
printf("pw_gid: %d\n",pwdstruct->pw_gid);
}


produces

$ ./a.out 
errno = 0
pw_name: 
pw_passwd: 
pw_uid: 0
pw_gid: 0


Test script:
---

  string(0) ""
  ["passwd"]=>
  string(0) ""
  ["uid"]=>
  int(0)
  ["gid"]=>
  int(0)
  ["gecos"]=>
  string(0) ""
  ["dir"]=>
  string(0) ""
  ["shell"]=>
  string(0) ""
}
array(4) {
  ["name"]=>
  string(0) ""
  ["passwd"]=>
  string(0) ""
  ["members"]=>
  array(0) {
  }
  ["gid"]=>
  int(0)
}






-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62881&edit=1