From 807546684988a174163e5b733e8197b67442553f Mon Sep 17 00:00:00 2001 From: Dan Walsh Date: Mon, 24 Oct 2011 14:30:05 -0400 Subject: [PATCH] Apply libselinux patch to handle large groups in seusers. --- libselinux-rhat.patch | 45 +++++++++++++++++++++++++++++++++++++++++++ libselinux.spec | 5 ++++- 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/libselinux-rhat.patch b/libselinux-rhat.patch index 78b225d..b3fbef9 100644 --- a/libselinux-rhat.patch +++ b/libselinux-rhat.patch @@ -317,3 +317,48 @@ index 5914afa..df83b30 100644 va_end(ap); } +diff --git a/libselinux/src/seusers.c b/libselinux/src/seusers.c +index fc75cb6..b653cad 100644 +--- a/libselinux/src/seusers.c ++++ b/libselinux/src/seusers.c +@@ -5,6 +5,7 @@ + #include + #include + #include ++#include + #include + #include + #include "selinux_internal.h" +@@ -118,13 +119,26 @@ static int check_group(const char *group, const char *name, const gid_t gid) { + long rbuflen = sysconf(_SC_GETGR_R_SIZE_MAX); + if (rbuflen <= 0) + return 0; +- char *rbuf = malloc(rbuflen); +- if (rbuf == NULL) +- return 0; ++ char *rbuf; + +- if (getgrnam_r(group, &gbuf, rbuf, rbuflen, +- &grent) != 0) +- goto done; ++ while(1) { ++ rbuf = malloc(rbuflen); ++ if (rbuf == NULL) ++ return 0; ++ int retval = getgrnam_r(group, &gbuf, rbuf, ++ rbuflen, &grent); ++ if ( retval == ERANGE ) ++ { ++ free(rbuf); ++ rbuflen = rbuflen * 2; ++ } else if ( retval != 0 || grent == NULL ) ++ { ++ goto done; ++ } else ++ { ++ break; ++ } ++ } + + if (getgrouplist(name, gid, NULL, &ng) < 0) { + groups = (gid_t *) malloc(sizeof (gid_t) * ng); diff --git a/libselinux.spec b/libselinux.spec index e46ab06..e727884 100644 --- a/libselinux.spec +++ b/libselinux.spec @@ -7,7 +7,7 @@ Summary: SELinux library and simple utilities Name: libselinux Version: 2.1.6 -Release: 3%{?dist} +Release: 4%{?dist} License: Public Domain Group: System Environment/Libraries Source: %{name}-%{version}.tgz @@ -231,6 +231,9 @@ rm -rf %{buildroot} %{ruby_sitearch}/selinux.so %changelog +* Mon Oct 24 2011 Dan Walsh - 2.1.6-4 +- Apply libselinux patch to handle large groups in seusers. + * Wed Oct 19 2011 Dan Walsh - 2.1.6-3 - Add selinux_check_access function. Needed for passwd, chfn, chsh