Forum: Ruby-core [ruby-trunk - Bug #6831][Assigned] test_getpwuid() on Mountain Lion

Posted by kosaki (Motohiro KOSAKI) (Guest)
on 2012-08-04 08:02
(Received via mailing list)
Issue #6831 has been reported by kosaki (Motohiro KOSAKI).

----------------------------------------
Bug #6831: test_getpwuid() on Mountain Lion
https://bugs.ruby-lang.org/issues/6831

Author: kosaki (Motohiro KOSAKI)
Status: Assigned
Priority: Normal
Assignee: mrkn (Kenta Murata)
Category: ext
Target version: 2.0.0
ruby -v:  ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0]


When using Mountain Lion, following test failure occur.

  1) Failure:
test_getpwuid(TestEtc) [/ruby/git/test/etc/test_etc.rb:34]:
<#<struct Struct::Passwd
 name="_appleevents",
 passwd="*",
 uid=55,
 gid=55,
 gecos="AppleEvents Daemon",
 dir="/var/empty",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>> expected but was
<#<struct Struct::Passwd
 name="_pcastagent",
 passwd="*",
 uid=55,
 gid=55,
 gecos="Podcast Producer Agent",
 dir="/var/pcast/agent",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>>.
------------------------------------------

getpwent() of Mountain Lion seems buggy. see below:

test_getpwent.c
-----------------------------------------
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>

int main(void)
{
  struct passwd *ent;

  while((ent = getpwent()) != NULL) {
    if (ent->pw_uid == 55)
  printf("%s:%d:%s\n", ent->pw_name, ent->pw_uid, ent->pw_gecos);
  }

  return 0;
}


result
Posted by kosaki (Motohiro KOSAKI) (Guest)
on 2012-08-04 08:51
(Received via mailing list)
Issue #6831 has been updated by kosaki (Motohiro KOSAKI).


Is this right way to skip?



diff --git a/test/etc/test_etc.rb b/test/etc/test_etc.rb
index c4db71c..dafcdbb 100644
--- a/test/etc/test_etc.rb
+++ b/test/etc/test_etc.rb
@@ -29,7 +29,15 @@ class TestEtc < Test::Unit::TestCase

   def test_getpwuid
     passwd = {}
-    Etc.passwd {|s| passwd[s.uid] ||= s }
+    Etc.passwd {|s|
+
+      # skip if passwd database has duplicated entry
+      # especially getpwent(3) on Mac OS X often return duplicated 
entry by default.
+      if passwd.has_key?(s.uid)
+        return
+      end
+      passwd[s.uid] ||= s\
+      }
     passwd.each_value do |s|
       assert_equal(s, Etc.getpwuid(s.uid))
       assert_equal(s, Etc.getpwuid) if Process.euid == s.uid
----------------------------------------
Bug #6831: test_getpwuid() on Mountain Lion
https://bugs.ruby-lang.org/issues/6831#change-28637

Author: kosaki (Motohiro KOSAKI)
Status: Assigned
Priority: Normal
Assignee: mrkn (Kenta Murata)
Category: ext
Target version: 2.0.0
ruby -v:  ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0]


When using Mountain Lion, following test failure occur.

  1) Failure:
test_getpwuid(TestEtc) [/ruby/git/test/etc/test_etc.rb:34]:
<#<struct Struct::Passwd
 name="_appleevents",
 passwd="*",
 uid=55,
 gid=55,
 gecos="AppleEvents Daemon",
 dir="/var/empty",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>> expected but was
<#<struct Struct::Passwd
 name="_pcastagent",
 passwd="*",
 uid=55,
 gid=55,
 gecos="Podcast Producer Agent",
 dir="/var/pcast/agent",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>>.
------------------------------------------

getpwent() of Mountain Lion seems buggy. see below:

test_getpwent.c
-----------------------------------------
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>

int main(void)
{
  struct passwd *ent;

  while((ent = getpwent()) != NULL) {
    if (ent->pw_uid == 55)
  printf("%s:%d:%s\n", ent->pw_name, ent->pw_uid, ent->pw_gecos);
  }

  return 0;
}


result
Posted by Nobuyoshi Nakada (nobu)
on 2012-08-04 15:00
(Received via mailing list)
Issue #6831 has been updated by nobu (Nobuyoshi Nakada).


It doesn't seem duplicated, but just two entries sharing same uid.
I think it is a bug of the test, which does not consider such case, so 
don't agree your patch.
----------------------------------------
Bug #6831: test_getpwuid() on Mountain Lion
https://bugs.ruby-lang.org/issues/6831#change-28640

Author: kosaki (Motohiro KOSAKI)
Status: Assigned
Priority: Normal
Assignee: mrkn (Kenta Murata)
Category: ext
Target version: 2.0.0
ruby -v:  ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0]


When using Mountain Lion, following test failure occur.

  1) Failure:
test_getpwuid(TestEtc) [/ruby/git/test/etc/test_etc.rb:34]:
<#<struct Struct::Passwd
 name="_appleevents",
 passwd="*",
 uid=55,
 gid=55,
 gecos="AppleEvents Daemon",
 dir="/var/empty",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>> expected but was
<#<struct Struct::Passwd
 name="_pcastagent",
 passwd="*",
 uid=55,
 gid=55,
 gecos="Podcast Producer Agent",
 dir="/var/pcast/agent",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>>.
------------------------------------------

getpwent() of Mountain Lion seems buggy. see below:

test_getpwent.c
-----------------------------------------
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>

int main(void)
{
  struct passwd *ent;

  while((ent = getpwent()) != NULL) {
    if (ent->pw_uid == 55)
  printf("%s:%d:%s\n", ent->pw_name, ent->pw_uid, ent->pw_gecos);
  }

  return 0;
}


result
Posted by Nobuyoshi Nakada (nobu)
on 2012-08-04 15:39
(Received via mailing list)
Issue #6831 has been updated by nobu (Nobuyoshi Nakada).

Status changed from Assigned to Feedback

=begin
Does this patch fix it?

 diff --git i/test/etc/test_etc.rb w/test/etc/test_etc.rb
 index c4db71c..b73a95f 100644
 --- i/test/etc/test_etc.rb
 +++ w/test/etc/test_etc.rb
 @@ -29,9 +29,16 @@ class TestEtc < Test::Unit::TestCase

    def test_getpwuid
 -    passwd = {}
 -    Etc.passwd {|s| passwd[s.uid] ||= s }
 -    passwd.each_value do |s|
 -      assert_equal(s, Etc.getpwuid(s.uid))
 -      assert_equal(s, Etc.getpwuid) if Process.euid == s.uid
 +    # password database is not unique on UID, and which entry will be
 +    # returned by getpwuid() is not specified.
 +    passwd = Hash.new {[]}
 +    # on MacOSX, same entries are returned from /etc/passwd and Open
 +    # Directory.
 +    Etc.passwd {|s| passwd[s.uid] |= [s]}
 +    passwd.each_pair do |uid, s|
 +      assert_include(s, Etc.getpwuid(uid))
 +    end
 +    s = passwd[Process.euid]
 +    if s
 +      assert_include(s, Etc.getpwuid)
      end
    end
=end

----------------------------------------
Bug #6831: test_getpwuid() on Mountain Lion
https://bugs.ruby-lang.org/issues/6831#change-28643

Author: kosaki (Motohiro KOSAKI)
Status: Feedback
Priority: Normal
Assignee: mrkn (Kenta Murata)
Category: ext
Target version: 2.0.0
ruby -v:  ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0]


When using Mountain Lion, following test failure occur.

  1) Failure:
test_getpwuid(TestEtc) [/ruby/git/test/etc/test_etc.rb:34]:
<#<struct Struct::Passwd
 name="_appleevents",
 passwd="*",
 uid=55,
 gid=55,
 gecos="AppleEvents Daemon",
 dir="/var/empty",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>> expected but was
<#<struct Struct::Passwd
 name="_pcastagent",
 passwd="*",
 uid=55,
 gid=55,
 gecos="Podcast Producer Agent",
 dir="/var/pcast/agent",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>>.
------------------------------------------

getpwent() of Mountain Lion seems buggy. see below:

test_getpwent.c
-----------------------------------------
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>

int main(void)
{
  struct passwd *ent;

  while((ent = getpwent()) != NULL) {
    if (ent->pw_uid == 55)
  printf("%s:%d:%s\n", ent->pw_name, ent->pw_uid, ent->pw_gecos);
  }

  return 0;
}


result
Posted by kosaki (Motohiro KOSAKI) (Guest)
on 2012-08-04 20:40
(Received via mailing list)
Issue #6831 has been updated by kosaki (Motohiro KOSAKI).

Status changed from Feedback to Assigned
Assignee changed from mrkn (Kenta Murata) to nobu (Nobuyoshi Nakada)

> Does this patch fix it?

Yes.

----------------------------------------
Bug #6831: test_getpwuid() on Mountain Lion
https://bugs.ruby-lang.org/issues/6831#change-28648

Author: kosaki (Motohiro KOSAKI)
Status: Assigned
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: ext
Target version: 2.0.0
ruby -v:  ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0]


When using Mountain Lion, following test failure occur.

  1) Failure:
test_getpwuid(TestEtc) [/ruby/git/test/etc/test_etc.rb:34]:
<#<struct Struct::Passwd
 name="_appleevents",
 passwd="*",
 uid=55,
 gid=55,
 gecos="AppleEvents Daemon",
 dir="/var/empty",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>> expected but was
<#<struct Struct::Passwd
 name="_pcastagent",
 passwd="*",
 uid=55,
 gid=55,
 gecos="Podcast Producer Agent",
 dir="/var/pcast/agent",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>>.
------------------------------------------

getpwent() of Mountain Lion seems buggy. see below:

test_getpwent.c
-----------------------------------------
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>

int main(void)
{
  struct passwd *ent;

  while((ent = getpwent()) != NULL) {
    if (ent->pw_uid == 55)
  printf("%s:%d:%s\n", ent->pw_name, ent->pw_uid, ent->pw_gecos);
  }

  return 0;
}


result
Posted by reeze (reeze xia) (Guest)
on 2012-08-06 18:49
(Received via mailing list)
Issue #6831 has been updated by reeze (reeze xia).


Hi,
  I got a question about Etc.getpwnam && Etc.getgrnam in Mac OS X, Both 
of them will return a found entry for empty string "".

Since they are related to Etc. so I posted here.

1.9.3p125 :007 > Etc.getpwnam("")
 => #<struct Struct::Passwd name="", passwd="", uid=0, gid=0, gecos="", 
dir="", shell="", change=0, uclass="", expire=0>
1.9.3p125 :008 > Etc.getgrnam("")
 => #<struct Struct::Group name="", passwd="", gid=0, mem=[]>

This didn't happen in other OS, Does OSX have an empty user and group ?

Thanks
----------------------------------------
Bug #6831: test_getpwuid() on Mountain Lion
https://bugs.ruby-lang.org/issues/6831#change-28681

Author: kosaki (Motohiro KOSAKI)
Status: Closed
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: ext
Target version: 2.0.0
ruby -v:  ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0]


When using Mountain Lion, following test failure occur.

  1) Failure:
test_getpwuid(TestEtc) [/ruby/git/test/etc/test_etc.rb:34]:
<#<struct Struct::Passwd
 name="_appleevents",
 passwd="*",
 uid=55,
 gid=55,
 gecos="AppleEvents Daemon",
 dir="/var/empty",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>> expected but was
<#<struct Struct::Passwd
 name="_pcastagent",
 passwd="*",
 uid=55,
 gid=55,
 gecos="Podcast Producer Agent",
 dir="/var/pcast/agent",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>>.
------------------------------------------

getpwent() of Mountain Lion seems buggy. see below:

test_getpwent.c
-----------------------------------------
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>

int main(void)
{
  struct passwd *ent;

  while((ent = getpwent()) != NULL) {
    if (ent->pw_uid == 55)
  printf("%s:%d:%s\n", ent->pw_name, ent->pw_uid, ent->pw_gecos);
  }

  return 0;
}


result
Posted by kosaki (Motohiro KOSAKI) (Guest)
on 2012-08-06 21:12
(Received via mailing list)
Issue #6831 has been updated by kosaki (Motohiro KOSAKI).


> This didn't happen in other OS, Does OSX have an empty user and group ?

Only Apple can answer this. we can't. Etc extension is just wrapper 
functionality of OS feature.
So, I suggest you report it to apple.

thanks.

----------------------------------------
Bug #6831: test_getpwuid() on Mountain Lion
https://bugs.ruby-lang.org/issues/6831#change-28684

Author: kosaki (Motohiro KOSAKI)
Status: Closed
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: ext
Target version: 2.0.0
ruby -v:  ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0]


When using Mountain Lion, following test failure occur.

  1) Failure:
test_getpwuid(TestEtc) [/ruby/git/test/etc/test_etc.rb:34]:
<#<struct Struct::Passwd
 name="_appleevents",
 passwd="*",
 uid=55,
 gid=55,
 gecos="AppleEvents Daemon",
 dir="/var/empty",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>> expected but was
<#<struct Struct::Passwd
 name="_pcastagent",
 passwd="*",
 uid=55,
 gid=55,
 gecos="Podcast Producer Agent",
 dir="/var/pcast/agent",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>>.
------------------------------------------

getpwent() of Mountain Lion seems buggy. see below:

test_getpwent.c
-----------------------------------------
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>

int main(void)
{
  struct passwd *ent;

  while((ent = getpwent()) != NULL) {
    if (ent->pw_uid == 55)
  printf("%s:%d:%s\n", ent->pw_name, ent->pw_uid, ent->pw_gecos);
  }

  return 0;
}


result
Posted by Nobuyoshi Nakada (nobu)
on 2012-08-07 03:52
(Received via mailing list)
Issue #6831 has been updated by nobu (Nobuyoshi Nakada).


FYI, it raises ArgumentError which means "a matching entry is not 
found", on Lion.

----------------------------------------
Bug #6831: test_getpwuid() on Mountain Lion
https://bugs.ruby-lang.org/issues/6831#change-28692

Author: kosaki (Motohiro KOSAKI)
Status: Closed
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: ext
Target version: 2.0.0
ruby -v:  ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0]


When using Mountain Lion, following test failure occur.

  1) Failure:
test_getpwuid(TestEtc) [/ruby/git/test/etc/test_etc.rb:34]:
<#<struct Struct::Passwd
 name="_appleevents",
 passwd="*",
 uid=55,
 gid=55,
 gecos="AppleEvents Daemon",
 dir="/var/empty",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>> expected but was
<#<struct Struct::Passwd
 name="_pcastagent",
 passwd="*",
 uid=55,
 gid=55,
 gecos="Podcast Producer Agent",
 dir="/var/pcast/agent",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>>.
------------------------------------------

getpwent() of Mountain Lion seems buggy. see below:

test_getpwent.c
-----------------------------------------
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>

int main(void)
{
  struct passwd *ent;

  while((ent = getpwent()) != NULL) {
    if (ent->pw_uid == 55)
  printf("%s:%d:%s\n", ent->pw_name, ent->pw_uid, ent->pw_gecos);
  }

  return 0;
}


result
Posted by Nobuyoshi Nakada (nobu)
on 2012-08-07 03:58
(Received via mailing list)
Issue #6831 has been updated by nobu (Nobuyoshi Nakada).


BTW, I found the following statement in getpwnam(3) on Lion.

     The functions getpwnam() and getpwuid() search the password 
database for the given login name or user uid, respectively, always 
returning the first one encountered.

This definitely states which entry should be returned when multiple 
logins are sharing the same UID.
Has this changed on Mountain Lion?
----------------------------------------
Bug #6831: test_getpwuid() on Mountain Lion
https://bugs.ruby-lang.org/issues/6831#change-28693

Author: kosaki (Motohiro KOSAKI)
Status: Closed
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: ext
Target version: 2.0.0
ruby -v:  ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0]


When using Mountain Lion, following test failure occur.

  1) Failure:
test_getpwuid(TestEtc) [/ruby/git/test/etc/test_etc.rb:34]:
<#<struct Struct::Passwd
 name="_appleevents",
 passwd="*",
 uid=55,
 gid=55,
 gecos="AppleEvents Daemon",
 dir="/var/empty",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>> expected but was
<#<struct Struct::Passwd
 name="_pcastagent",
 passwd="*",
 uid=55,
 gid=55,
 gecos="Podcast Producer Agent",
 dir="/var/pcast/agent",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>>.
------------------------------------------

getpwent() of Mountain Lion seems buggy. see below:

test_getpwent.c
-----------------------------------------
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>

int main(void)
{
  struct passwd *ent;

  while((ent = getpwent()) != NULL) {
    if (ent->pw_uid == 55)
  printf("%s:%d:%s\n", ent->pw_name, ent->pw_uid, ent->pw_gecos);
  }

  return 0;
}


result
Posted by reeze (reeze xia) (Guest)
on 2012-08-07 04:41
(Received via mailing list)
Issue #6831 has been updated by reeze (reeze xia).


Hi nobu,

The man page about getpwnam didn't changed a lot, just a new function 
was added.

     The functions getpwnam(), getpwuid(), and getpwuuid() search the 
password database for the given
     login name, user uid, or user uuid respectively, always returning 
the first one encountered.

     Note that the password file /etc/master.passwd does not contain 
user UUIDs.  The UUID for a user
     may be found using mbr_uid_to_uuid().

Thanks
----------------------------------------
Bug #6831: test_getpwuid() on Mountain Lion
https://bugs.ruby-lang.org/issues/6831#change-28695

Author: kosaki (Motohiro KOSAKI)
Status: Closed
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: ext
Target version: 2.0.0
ruby -v:  ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0]


When using Mountain Lion, following test failure occur.

  1) Failure:
test_getpwuid(TestEtc) [/ruby/git/test/etc/test_etc.rb:34]:
<#<struct Struct::Passwd
 name="_appleevents",
 passwd="*",
 uid=55,
 gid=55,
 gecos="AppleEvents Daemon",
 dir="/var/empty",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>> expected but was
<#<struct Struct::Passwd
 name="_pcastagent",
 passwd="*",
 uid=55,
 gid=55,
 gecos="Podcast Producer Agent",
 dir="/var/pcast/agent",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>>.
------------------------------------------

getpwent() of Mountain Lion seems buggy. see below:

test_getpwent.c
-----------------------------------------
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>

int main(void)
{
  struct passwd *ent;

  while((ent = getpwent()) != NULL) {
    if (ent->pw_uid == 55)
  printf("%s:%d:%s\n", ent->pw_name, ent->pw_uid, ent->pw_gecos);
  }

  return 0;
}


result
Posted by reeze (reeze xia) (Guest)
on 2012-08-07 04:45
(Received via mailing list)
Issue #6831 has been updated by reeze (reeze xia).


kosaki (Motohiro KOSAKI) wrote:
> > This didn't happen in other OS, Does OSX have an empty user and group ?
>
> Only Apple can answer this. we can't. Etc extension is just wrapper 
functionality of OS feature.
> So, I suggest you report it to apple.
Thanks kosaki, I will try to report it apple.

thank:)
>
> thanks.


----------------------------------------
Bug #6831: test_getpwuid() on Mountain Lion
https://bugs.ruby-lang.org/issues/6831#change-28696

Author: kosaki (Motohiro KOSAKI)
Status: Closed
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: ext
Target version: 2.0.0
ruby -v:  ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0]


When using Mountain Lion, following test failure occur.

  1) Failure:
test_getpwuid(TestEtc) [/ruby/git/test/etc/test_etc.rb:34]:
<#<struct Struct::Passwd
 name="_appleevents",
 passwd="*",
 uid=55,
 gid=55,
 gecos="AppleEvents Daemon",
 dir="/var/empty",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>> expected but was
<#<struct Struct::Passwd
 name="_pcastagent",
 passwd="*",
 uid=55,
 gid=55,
 gecos="Podcast Producer Agent",
 dir="/var/pcast/agent",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>>.
------------------------------------------

getpwent() of Mountain Lion seems buggy. see below:

test_getpwent.c
-----------------------------------------
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>

int main(void)
{
  struct passwd *ent;

  while((ent = getpwent()) != NULL) {
    if (ent->pw_uid == 55)
  printf("%s:%d:%s\n", ent->pw_name, ent->pw_uid, ent->pw_gecos);
  }

  return 0;
}


result
Posted by Nobuyoshi Nakada (nobu)
on 2012-08-07 05:58
(Received via mailing list)
Issue #6831 has been updated by nobu (Nobuyoshi Nakada).


reeze (reeze xia) wrote:
> The man page about getpwnam didn't changed a lot, just a new function was added.

Thank you.
It obviously differs from the result in your original post.
You may want to report it to Apple.

Certainly getpwname() on MacOS X 10.8 seems buggy, still I think the 
test should be kept as the recent, since other platforms (e.g., Linux) 
don't state the result in such case.
----------------------------------------
Bug #6831: test_getpwuid() on Mountain Lion
https://bugs.ruby-lang.org/issues/6831#change-28698

Author: kosaki (Motohiro KOSAKI)
Status: Closed
Priority: Normal
Assignee: nobu (Nobuyoshi Nakada)
Category: ext
Target version: 2.0.0
ruby -v:  ruby 2.0.0dev (2012-08-04 trunk 36617) [x86_64-darwin12.0.0]


When using Mountain Lion, following test failure occur.

  1) Failure:
test_getpwuid(TestEtc) [/ruby/git/test/etc/test_etc.rb:34]:
<#<struct Struct::Passwd
 name="_appleevents",
 passwd="*",
 uid=55,
 gid=55,
 gecos="AppleEvents Daemon",
 dir="/var/empty",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>> expected but was
<#<struct Struct::Passwd
 name="_pcastagent",
 passwd="*",
 uid=55,
 gid=55,
 gecos="Podcast Producer Agent",
 dir="/var/pcast/agent",
 shell="/usr/bin/false",
 change=0,
 uclass="",
 expire=0>>.
------------------------------------------

getpwent() of Mountain Lion seems buggy. see below:

test_getpwent.c
-----------------------------------------
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <pwd.h>

int main(void)
{
  struct passwd *ent;

  while((ent = getpwent()) != NULL) {
    if (ent->pw_uid == 55)
  printf("%s:%d:%s\n", ent->pw_name, ent->pw_uid, ent->pw_gecos);
  }

  return 0;
}


result
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.