commit:     c7ad157920317e70d19389d9f3601d3cc7f599be
Author:     Jimi Huotari <chiitoo <AT> gentoo <DOT> org>
AuthorDate: Thu Mar  9 14:22:09 2023 +0000
Commit:     Jimi Huotari <chiitoo <AT> gentoo <DOT> org>
CommitDate: Thu Mar  9 16:29:48 2023 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=c7ad1579

x11-wm/openbox: patch getgrent to getgroups

Upstream: https://bugzilla.icculus.org/show_bug.cgi?id=5978
Closes: https://bugs.gentoo.org/827227
Signed-off-by: Jimi Huotari <chiitoo <AT> gentoo.org>

 .../openbox-3.6.1-getgrent-to-getgroups.patch      | 67 ++++++++++++++++++++++
 ...openbox-9999.ebuild => openbox-3.6.1-r4.ebuild} |  4 +-
 x11-wm/openbox/openbox-9999.ebuild                 |  4 +-
 3 files changed, 73 insertions(+), 2 deletions(-)

diff --git a/x11-wm/openbox/files/openbox-3.6.1-getgrent-to-getgroups.patch 
b/x11-wm/openbox/files/openbox-3.6.1-getgrent-to-getgroups.patch
new file mode 100644
index 000000000000..4634b5a03028
--- /dev/null
+++ b/x11-wm/openbox/files/openbox-3.6.1-getgrent-to-getgroups.patch
@@ -0,0 +1,67 @@
+Gentoo: https://bugs.gentoo.org/827227
+Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=808138
+Upstream: https://bugzilla.icculus.org/show_bug.cgi?id=5978
+
+>From e0cb404f53c9b21a521ea2f14c8cd66fdfb68ea7 Mon Sep 17 00:00:00 2001
+From: Simon <[email protected]>
+Date: Tue, 15 Dec 2015 15:46:18 +0100
+Subject: [PATCH] Replace getgrent with getgroups. Fixes #5978.
+
+---
+ obt/paths.c | 34 +++++++++++++++++++++-------------
+ 1 file changed, 21 insertions(+), 13 deletions(-)
+
+diff --git a/obt/paths.c b/obt/paths.c
+index 25cb6b0..d526936 100644
+--- a/obt/paths.c
++++ b/obt/paths.c
+@@ -108,25 +108,33 @@ static void find_uid_gid(uid_t *u, gid_t **g, guint *n)
+     const gchar *name;
+     struct group *gr;
+ 
++    gid_t gmain;
++    unsigned int maininc;
++    int i;
++
+     *u = getuid();
+     pw = getpwuid(*u);
+     name = pw->pw_name;
+ 
+-    *g = g_new(gid_t, *n=1);
+-    (*g)[0] = getgid();
+-
+-    while ((gr = getgrent())) {
+-        if (gr->gr_gid != (*g)[0]) { /* skip the main group */
+-            gchar **c;
+-            for (c = gr->gr_mem; *c; ++c)
+-                if (strcmp(*c, name) == 0) {
+-                    *g = g_renew(gid_t, *g, ++(*n)); /* save the group */
+-                    (*g)[*n-1] = gr->gr_gid;
+-                    break;
+-                }
++    gmain = getgid();
++
++    *n = getgroups(0, *g);
++    *g = g_new(gid_t, *n);
++    *n = getgroups(*n, *g);
++
++    /* Check if the effective group ID of the calling process is already
++       included in the returned list. Add it otherwise. */
++    maininc = 0;
++    for (i = 0; i < *n; i++) {
++        if ( (*g)[i] == gmain ) {
++            maininc = 1;
++            break;
+         }
+     }
+-    endgrent();
++    if (!maininc) {
++        *g = g_renew(gid_t, *g, ++(*n));
++        (*g)[*n-1] = gmain;
++    }
+ 
+     qsort(*g, *n, sizeof(gid_t), gid_cmp);
+ }
+-- 
+2.1.4
+

diff --git a/x11-wm/openbox/openbox-9999.ebuild 
b/x11-wm/openbox/openbox-3.6.1-r4.ebuild
similarity index 95%
copy from x11-wm/openbox/openbox-9999.ebuild
copy to x11-wm/openbox/openbox-3.6.1-r4.ebuild
index 261d9e75d33f..e569dd1af6b1 100644
--- a/x11-wm/openbox/openbox-9999.ebuild
+++ b/x11-wm/openbox/openbox-3.6.1-r4.ebuild
@@ -14,7 +14,7 @@ if [[ ${PV} == *9999* ]]; then
        EGIT_REPO_URI="git://git.openbox.org/dana/openbox"
 else
        SRC_URI="http://openbox.org/dist/openbox/${P}.tar.gz";
-       KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~mips ~ppc ~ppc64 
~sparc ~x86 ~x86-linux"
+       KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~mips ~ppc ~ppc64 
~riscv ~sparc ~x86 ~x86-linux"
 fi
 
 SRC_URI+=" branding? ( 
https://dev.gentoo.org/~hwoarang/distfiles/surreal-gentoo.tar.gz )"
@@ -59,6 +59,8 @@ PATCHES=(
        "${FILESDIR}/${PN}-3.5.2-gnome-session.patch"
        # see https://github.com/danakj/openbox/pull/35
        "${FILESDIR}/${PN}-3.6.1-py3-xdg.patch"
+       # https://bugs.gentoo.org/827227
+       "${FILESDIR}/${PN}-3.6.1-getgrent-to-getgroups.patch"
 )
 
 pkg_setup() {

diff --git a/x11-wm/openbox/openbox-9999.ebuild 
b/x11-wm/openbox/openbox-9999.ebuild
index 261d9e75d33f..e569dd1af6b1 100644
--- a/x11-wm/openbox/openbox-9999.ebuild
+++ b/x11-wm/openbox/openbox-9999.ebuild
@@ -14,7 +14,7 @@ if [[ ${PV} == *9999* ]]; then
        EGIT_REPO_URI="git://git.openbox.org/dana/openbox"
 else
        SRC_URI="http://openbox.org/dist/openbox/${P}.tar.gz";
-       KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~mips ~ppc ~ppc64 
~sparc ~x86 ~x86-linux"
+       KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~mips ~ppc ~ppc64 
~riscv ~sparc ~x86 ~x86-linux"
 fi
 
 SRC_URI+=" branding? ( 
https://dev.gentoo.org/~hwoarang/distfiles/surreal-gentoo.tar.gz )"
@@ -59,6 +59,8 @@ PATCHES=(
        "${FILESDIR}/${PN}-3.5.2-gnome-session.patch"
        # see https://github.com/danakj/openbox/pull/35
        "${FILESDIR}/${PN}-3.6.1-py3-xdg.patch"
+       # https://bugs.gentoo.org/827227
+       "${FILESDIR}/${PN}-3.6.1-getgrent-to-getgroups.patch"
 )
 
 pkg_setup() {

Reply via email to