Uploaded image for project: 'Hadoop Common'
  1. Hadoop Common
  2. HADOOP-10781

Unportable getgrouplist() usage breaks FreeBSD

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.1
    • 2.6.0
    • None
    • None

    Description

      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.

      Attachments

        1. getgrouplist.patch
          0.5 kB
          Dmitry Sivachenko

        Issue Links

          Activity

            People

              trtrmitya Dmitry Sivachenko
              trtrmitya Dmitry Sivachenko
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: