|
|
发表于 2005-10-13 12:06:57
|
显示全部楼层
You're right, please have a look at the 5.3.0 version:
- 252 static bool
- 253 xgetgroups (const char *username, gid_t gid, int *n_groups,
- 254 GETGROUPS_T **groups)
- 255 {
- 256 int max_n_groups;
- 257 int ng;
- 258 GETGROUPS_T *g = NULL;
- 259
- 260 if (!username)
- 261 max_n_groups = getgroups (0, NULL);
- 262 else
- 263 max_n_groups = getugroups (0, NULL, username, gid);
- 264
- 265 if (max_n_groups < 0)
- 266 ng = -1;
- 267 else
- 268 {
- 269 g = xnmalloc (max_n_groups, sizeof *g);
- 270 if (!username)
- 271 ng = getgroups (max_n_groups, g);
- 272 else
- 273 ng = getugroups (max_n_groups, g, username, gid);
- 274 }
- 275
- 276 if (ng < 0)
- 277 {
- 278 error (0, errno, _("cannot get supplemental group list"));
- 279 free (g);
- 280 return false;
- 281 }
- 282 else
- 283 {
- 284 *n_groups = ng;
- 285 *groups = g;
- 286 return true;
- 287 }
- 288 }
复制代码 |
|