)]}'
{
  "commit": "6a458848514a1816c95f11c6baa30dfdfcbf2d34",
  "tree": "b7f5f413315b8df369d3657a243e3ae59830f549",
  "parents": [
    "469568b94ab7f6b36c0b753f029c7e3d04b6f40d"
  ],
  "author": {
    "name": "Elliott Hughes",
    "email": "enh@google.com",
    "time": "Wed Feb 14 17:10:54 2024 -0800"
  },
  "committer": {
    "name": "Elliott Hughes",
    "email": "enh@google.com",
    "time": "Wed Feb 14 17:19:14 2024 -0800"
  },
  "message": "Simplify our trivial initgroups(), and add a test.\n\ninitgroups() is just a call to getgrouplist() followed by a call to\nsetgroups(). The tricky part is memory allocation. OpenBSD allocates an\nNGROUPS_MAX-sized array of gid_t on the stack. FreeBSD allocates a\nsysconf(_SC_NGROUPS_MAX)-sized array of gid_t on the heap. bionic had a\nmix where it would try a 2-element stack array but fall back to a heap\nallocation, which sounds reasonable if you want to avoid a 256KiB\n(64Ki*4 bytes) allocation on either stack or heap. But that constant 2?\nThat\u0027s weird in two ways... It\u0027s really small (musl has an NGROUPS_MAX\nof 32 unlike the Linux kernel\u0027s 64Ki, but 32 is still a lot larger than\n2), but at the same time it\u0027s too big --- bionic\u0027s getgrouplist() always\nreturns a single element.\n\nSo although the FreeBSD \"what the hell, let\u0027s just allocate 256KiB on\nthe heap\" implementation would have been fine, there\u0027s really no point,\nand anyone who\u0027s trying to understand initgroups() on Android really\nneeds to read getgroupslist() anyway, so let\u0027s just have the most\ntrivial implementation -- a single-element array -- and let\u0027s have it\nright next to getgroupslist() in the same file as all the other \u003cgrp.h\u003e\nfunctions.\n\nAlso add a trivial smoke test. You mostly won\u0027t have permission to do\nanything interesting with initgroups(), and it\u0027s basically unused save\nfor privilege dropping tcpdump and strace, but we may as well make an\neffort. (I tested tcpdump before and after too.)\n\nTest: treehugger\nChange-Id: I67fe02e309ed1dbefc490c01733738363ca606be\n",
  "tree_diff": [
    {
      "type": "modify",
      "old_id": "048cd73948db01b0492863d7bcf86d068081d522",
      "old_mode": 33188,
      "old_path": "libc/Android.bp",
      "new_id": "071f309fa3a40a7cc8d2fafb23433ee3f814bde4",
      "new_mode": 33188,
      "new_path": "libc/Android.bp"
    },
    {
      "type": "modify",
      "old_id": "600693c7420790b4a46fd484a71c823d12fd8973",
      "old_mode": 33188,
      "old_path": "libc/bionic/grp_pwd.cpp",
      "new_id": "82ee7bae9d7c6c89a73170d4a22ec1e7a1dc6e7e",
      "new_mode": 33188,
      "new_path": "libc/bionic/grp_pwd.cpp"
    },
    {
      "type": "delete",
      "old_id": "dea6d966d121b8c978e8adb4a412431f982710cb",
      "old_mode": 33188,
      "old_path": "libc/bionic/initgroups.c",
      "new_id": "0000000000000000000000000000000000000000",
      "new_mode": 0,
      "new_path": "/dev/null"
    },
    {
      "type": "modify",
      "old_id": "d3acf03d1eaf4e52c92bab065364f18419fe8058",
      "old_mode": 33188,
      "old_path": "tests/grp_pwd_test.cpp",
      "new_id": "16b8d5ac5a8c3009ad768ce6c23d08ae242fb512",
      "new_mode": 33188,
      "new_path": "tests/grp_pwd_test.cpp"
    }
  ]
}
