summaryrefslogtreecommitdiff
path: root/openbsd-compat/port-aix.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2009-12-29 21:42:53 +0000
committerColin Watson <cjwatson@debian.org>2009-12-29 21:42:53 +0000
commit87552344215a38d3a2b0d4d63dc151e05978bbe1 (patch)
tree9f4b96055e6ccaa915e8d59d9f2805e9e119371d /openbsd-compat/port-aix.c
parenta25ec0b132c44c9e341e08464ff830de06b81126 (diff)
parentef94e5613d37bcbf880f21ee6094e4b1c7683a4c (diff)
import openssh-5.1p1-gsskex-cjwatson-20080722.patch
Diffstat (limited to 'openbsd-compat/port-aix.c')
-rw-r--r--openbsd-compat/port-aix.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c
index 94faec670..5b1cb7387 100644
--- a/openbsd-compat/port-aix.c
+++ b/openbsd-compat/port-aix.c
@@ -1,7 +1,7 @@
1/* 1/*
2 * 2 *
3 * Copyright (c) 2001 Gert Doering. All rights reserved. 3 * Copyright (c) 2001 Gert Doering. All rights reserved.
4 * Copyright (c) 2003,2004,2005 Darren Tucker. All rights reserved. 4 * Copyright (c) 2003,2004,2005,2006 Darren Tucker. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
@@ -394,4 +394,47 @@ sshaix_getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
394} 394}
395# endif /* AIX_GETNAMEINFO_HACK */ 395# endif /* AIX_GETNAMEINFO_HACK */
396 396
397# if defined(USE_GETGRSET)
398# include <stdlib.h>
399int
400getgrouplist(const char *user, gid_t pgid, gid_t *groups, int *grpcnt)
401{
402 char *cp, *grplist, *grp;
403 gid_t gid;
404 int ret = 0, ngroups = 0, maxgroups;
405 long l;
406
407 maxgroups = *grpcnt;
408
409 if ((cp = grplist = getgrset(user)) == NULL)
410 return -1;
411
412 /* handle zero-length case */
413 if (maxgroups <= 0) {
414 *grpcnt = 0;
415 return -1;
416 }
417
418 /* copy primary group */
419 groups[ngroups++] = pgid;
420
421 /* copy each entry from getgrset into group list */
422 while ((grp = strsep(&grplist, ",")) != NULL) {
423 l = strtol(grp, NULL, 10);
424 if (ngroups >= maxgroups || l == LONG_MIN || l == LONG_MAX) {
425 ret = -1;
426 goto out;
427 }
428 gid = (gid_t)l;
429 if (gid == pgid)
430 continue; /* we have already added primary gid */
431 groups[ngroups++] = gid;
432 }
433out:
434 free(cp);
435 *grpcnt = ngroups;
436 return ret;
437}
438# endif /* USE_GETGRSET */
439
397#endif /* _AIX */ 440#endif /* _AIX */