[ 
https://issues.apache.org/jira/browse/HADOOP-10781?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14055256#comment-14055256
 ] 

Chris Nauroth commented on HADOOP-10781:
----------------------------------------

Oops, looks like I was too late.  :-)  No worries.

I wanted to bring up that this changes the error handling behavior on Linux 
too, and I wonder if it has reintroduced the segfault that had been seen 
earlier.  I believe the problem is that we'd get a 0 return code from 
{{getgrouplist}}, we'd treat that as success, and then that would drive us into 
a {{realloc}} based on {{ngroups}}.  However, {{ngroups}} could be 0 at that 
point (or perhaps random uninitialized memory), and then we'd get the segfault. 
 Admittedly, this was happening with buggy implementations of nscd, but we 
wanted to be conservative in the error handling.

[~kihwal], I know you had spent the most time looking at these problems.  Do 
you think we need to revert HADOOP-10781 and find a different way to do this 
patch for FreeBSD?

> Unportable getgrouplist() usage breaks FreeBSD
> ----------------------------------------------
>
>                 Key: HADOOP-10781
>                 URL: https://issues.apache.org/jira/browse/HADOOP-10781
>             Project: Hadoop Common
>          Issue Type: Bug
>    Affects Versions: 2.4.1
>            Reporter: Dmitry Sivachenko
>            Assignee: Dmitry Sivachenko
>             Fix For: 2.5.0
>
>         Attachments: getgrouplist.patch
>
>
> getgrouplist() has different return values on Linux and FreeBSD:
> Linux: either the number of groups (positive) or -1 on error
> FreeBSD: 0 on success or -1 on error
> The return value of getgrouplist() is analyzed in Linux-specific way in 
> hadoop-common-project/hadoop-common/src/main/native/src/org/apache/hadoop/security/hadoop_user_info.c,
>  in function hadoop_user_info_getgroups() which breaks FreeBSD.
> In this function you have 3 choices for the return value 
> ret = getgrouplist(uinfo->pwd.pw_name, uinfo->pwd.pw_gid,
>                          uinfo->gids, &ngroups);
> 1) ret > 0 : OK for Linux, it will be zero on FreeBSD.  I propose to change 
> this to ret >= 0
> 2) First condition is false and ret != -1:  impossible according to manpage
> 3) ret == 1 -- OK for both Linux and FreeBSD
> So I propose to change "ret > 0" to "ret >= 0" and (optionally) return 2nd 
> case.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to