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
----------------
_appleevents:55:AppleEvents Daemon
_pcastagent:55:Podcast Producer Agent


mrkn, what do you think?




-- 
http://bugs.ruby-lang.org/