coreutils-getgrouplist.patch: drop a patch no longer needed

This patch was obseleted by te following upstream commit back in 2008:
https://git.savannah.gnu.org/gitweb/?p=coreutils.git;a=commitdiff;h=v6.10-79-g49f7ebaac45
This commit is contained in:
Kamil Dudka 2023-03-22 12:51:59 +01:00
parent 43d181cda7
commit 2c4d4b8151
2 changed files with 4 additions and 98 deletions

View File

@ -1,94 +0,0 @@
diff --git a/lib/getugroups.c b/lib/getugroups.c
index 299bae6..8ece29b 100644
--- a/lib/getugroups.c
+++ b/lib/getugroups.c
@@ -19,6 +19,9 @@
#include <config.h>
+/* We do not need this code if getgrouplist(3) is available. */
+#ifndef HAVE_GETGROUPLIST
+
#include "getugroups.h"
#include <errno.h>
@@ -126,3 +129,4 @@ getugroups (int maxcount, gid_t *grouplist, char const *username,
}
#endif /* HAVE_GRP_H */
+#endif /* have getgrouplist */
diff --git a/lib/mgetgroups.c b/lib/mgetgroups.c
index 76474c2..0a9d221 100644
--- a/lib/mgetgroups.c
+++ b/lib/mgetgroups.c
@@ -31,6 +31,7 @@
#endif
#include "getugroups.h"
+#include "xalloc.h"
#include "xalloc-oversized.h"
/* Work around an incompatibility of OS X 10.11: getgrouplist
@@ -119,9 +120,17 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups)
/* else no username, so fall through and use getgroups. */
#endif
- max_n_groups = (username
- ? getugroups (0, NULL, username, gid)
- : getgroups (0, NULL));
+ if (!username)
+ max_n_groups = getgroups(0, NULL);
+ else
+ {
+#ifdef HAVE_GETGROUPLIST
+ max_n_groups = 0;
+ getgrouplist (username, gid, NULL, &max_n_groups);
+#else
+ max_n_groups = getugroups (0, NULL, username, gid);
+#endif
+ }
/* If we failed to count groups because there is no supplemental
group support, then return an array containing just GID.
@@ -143,10 +152,25 @@ mgetgroups (char const *username, gid_t gid, gid_t **groups)
if (g == NULL)
return -1;
- ng = (username
- ? getugroups (max_n_groups, g, username, gid)
- : getgroups (max_n_groups - (gid != (gid_t) -1),
- g + (gid != (gid_t) -1)));
+ if (!username)
+ ng = getgroups (max_n_groups - (gid != (gid_t)-1), g + (gid != (gid_t)-1));
+ else
+ {
+#ifdef HAVE_GETGROUPLIST
+ int e;
+ ng = max_n_groups;
+ while ((e = getgrouplist (username, gid, g, &ng)) == -1
+ && ng > max_n_groups)
+ {
+ max_n_groups = ng;
+ g = xrealloc (g, max_n_groups * sizeof (GETGROUPS_T));
+ }
+ if (e == -1)
+ ng = -1;
+#else
+ ng = getugroups (max_n_groups, g, username, gid);
+#endif
+ }
if (ng < 0)
{
diff --git a/m4/jm-macros.m4 b/m4/jm-macros.m4
index 62777c7..5180243 100644
--- a/m4/jm-macros.m4
+++ b/m4/jm-macros.m4
@@ -68,6 +68,7 @@ AC_DEFUN([coreutils_MACROS],
fchown
fchmod
ftruncate
+ getgrouplist
iswspace
mkfifo
mbrlen

View File

@ -1,7 +1,7 @@
Summary: A set of basic GNU tools commonly used in shell scripts
Name: coreutils
Version: 9.2
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv3+
Url: https://www.gnu.org/software/coreutils/
Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
@ -32,9 +32,6 @@ Patch104: coreutils-df-direct.patch
# (sb) lin18nux/lsb compliance - multibyte functionality patch
Patch800: coreutils-i18n.patch
# getgrouplist() patch from Ulrich Drepper.
Patch908: coreutils-getgrouplist.patch
# downstream SELinux options deprecated since 2009
Patch950: coreutils-selinux.patch
@ -255,6 +252,9 @@ rm -f $RPM_BUILD_ROOT%{_infodir}/dir
%license COPYING
%changelog
* Wed Mar 22 2023 Kamil Dudka <kdudka@redhat.com> - 9.2-2
- coreutils-getgrouplist.patch: drop a patch no longer needed
* Wed Mar 22 2023 Kamil Dudka <kdudka@redhat.com> - 9.2-1
- new upstream release 9.2