summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2008-02-28 23:16:04 +1100
committerDarren Tucker <dtucker@zip.com.au>2008-02-28 23:16:04 +1100
commit0f26b1386a8beaa1884178f8793c91d84274ea7d (patch)
tree7c94a0d48e39fd8d10f6bc68f985b048893a31b7
parent3d295a6cf0c4e240509f035d514393eec4abd43d (diff)
- (dtucker) [configure.ac openbsd-compat/port-aix.{c,h}] Bug #1081: Implement
getgrouplist via getgrset on AIX, rather than iterating over getgrent. This allows, eg, Match and AllowGroups directives to work with NIS and LDAP groups.
-rw-r--r--ChangeLog6
-rw-r--r--configure.ac6
-rw-r--r--openbsd-compat/port-aix.c56
-rw-r--r--openbsd-compat/port-aix.h16
4 files changed, 77 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index 660c1b873..09e7adacc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,10 @@
7 SSLeay_add_all_algorithms as a macro already. 7 SSLeay_add_all_algorithms as a macro already.
8 - (dtucker) [key.c defines.h openbsd-compat/openssl-compat.h] Move old OpenSSL 8 - (dtucker) [key.c defines.h openbsd-compat/openssl-compat.h] Move old OpenSSL
9 compat glue into openssl-compat.h. 9 compat glue into openssl-compat.h.
10 - (dtucker) [configure.ac openbsd-compat/port-aix.{c,h}] Bug #1081: Implement
11 getgrouplist via getgrset on AIX, rather than iterating over getgrent.
12 This allows, eg, Match and AllowGroups directives to work with NIS and
13 LDAP groups.
10 14
1120080225 1520080225
12 - (dtucker) [openbsd-compat/fake-rfc2553.h] rename ssh_gai_strerror hack 16 - (dtucker) [openbsd-compat/fake-rfc2553.h] rename ssh_gai_strerror hack
@@ -3637,4 +3641,4 @@
3637 OpenServer 6 and add osr5bigcrypt support so when someone migrates 3641 OpenServer 6 and add osr5bigcrypt support so when someone migrates
3638 passwords between UnixWare and OpenServer they will still work. OK dtucker@ 3642 passwords between UnixWare and OpenServer they will still work. OK dtucker@
3639 3643
3640$Id: ChangeLog,v 1.4844 2008/02/28 08:22:04 dtucker Exp $ 3644$Id: ChangeLog,v 1.4845 2008/02/28 12:16:04 dtucker Exp $
diff --git a/configure.ac b/configure.ac
index eaa1f845a..f84054321 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
1# $Id: configure.ac,v 1.391 2008/02/28 04:01:13 dtucker Exp $ 1# $Id: configure.ac,v 1.392 2008/02/28 12:16:04 dtucker Exp $
2# 2#
3# Copyright (c) 1999-2004 Damien Miller 3# Copyright (c) 1999-2004 Damien Miller
4# 4#
@@ -15,7 +15,7 @@
15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 15# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 16
17AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org) 17AC_INIT(OpenSSH, Portable, openssh-unix-dev@mindrot.org)
18AC_REVISION($Revision: 1.391 $) 18AC_REVISION($Revision: 1.392 $)
19AC_CONFIG_SRCDIR([ssh.c]) 19AC_CONFIG_SRCDIR([ssh.c])
20 20
21AC_CONFIG_HEADER(config.h) 21AC_CONFIG_HEADER(config.h)
@@ -357,7 +357,7 @@ int main(void) { exit(0); }
357 [], 357 [],
358 [#include <usersec.h>] 358 [#include <usersec.h>]
359 ) 359 )
360 AC_CHECK_FUNCS(setauthdb) 360 AC_CHECK_FUNCS(getgrset setauthdb)
361 AC_CHECK_DECL(F_CLOSEM, 361 AC_CHECK_DECL(F_CLOSEM,
362 AC_DEFINE(HAVE_FCNTL_CLOSEM, 1, [Use F_CLOSEM fcntl for closefrom]), 362 AC_DEFINE(HAVE_FCNTL_CLOSEM, 1, [Use F_CLOSEM fcntl for closefrom]),
363 [], 363 [],
diff --git a/openbsd-compat/port-aix.c b/openbsd-compat/port-aix.c
index 94faec670..b19d2296e 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,58 @@ 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
439int
440ssh_initgroups(const char *user, gid_t group)
441{
442 gid_t grps[NGROUPS_MAX];
443 int grpcnt = NGROUPS_MAX;
444
445 if (getgrouplist(user, group, grps, &grpcnt) == -1)
446 return -1;
447 return setgroups(grpcnt, grps);
448}
449# endif /* USE_GETGRSET */
450
397#endif /* _AIX */ 451#endif /* _AIX */
diff --git a/openbsd-compat/port-aix.h b/openbsd-compat/port-aix.h
index 5a04bedad..14024d417 100644
--- a/openbsd-compat/port-aix.h
+++ b/openbsd-compat/port-aix.h
@@ -1,9 +1,9 @@
1/* $Id: port-aix.h,v 1.27 2006/09/18 13:54:33 dtucker Exp $ */ 1/* $Id: port-aix.h,v 1.28 2008/02/28 12:16:04 dtucker Exp $ */
2 2
3/* 3/*
4 * 4 *
5 * Copyright (c) 2001 Gert Doering. All rights reserved. 5 * Copyright (c) 2001 Gert Doering. All rights reserved.
6 * Copyright (c) 2004, 2005 Darren Tucker. All rights reserved. 6 * Copyright (c) 2004,2005,2006 Darren Tucker. All rights reserved.
7 * 7 *
8 * Redistribution and use in source and binary forms, with or without 8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions 9 * modification, are permitted provided that the following conditions
@@ -103,4 +103,16 @@ int sshaix_getnameinfo(const struct sockaddr *, size_t, char *, size_t,
103# define getnameinfo(a,b,c,d,e,f,g) (sshaix_getnameinfo(a,b,c,d,e,f,g)) 103# define getnameinfo(a,b,c,d,e,f,g) (sshaix_getnameinfo(a,b,c,d,e,f,g))
104#endif 104#endif
105 105
106/*
107 * We use getgrset in preference to multiple getgrent calls for efficiency
108 * plus it supports NIS and LDAP groups.
109 */
110#if !defined(HAVE_GETGROUPLIST) && defined(HAVE_GETGRSET)
111# define HAVE_GETGROUPLIST
112# define USE_GETGRSET
113int getgrouplist(const char *, gid_t, gid_t *, int *);
114int ssh_initgroups(const char *, gid_t);
115# define initgroups(a, b) ssh_initgroups((a), (b))
116#endif
117
106#endif /* _AIX */ 118#endif /* _AIX */