Package: openbox Version: 3.5.2-8 Severity: normal Tags: upstream patch Forwarded: https://bugzilla.icculus.org/show_bug.cgi?id=5978
Dear Maintainer, Openbox iterates through all groups on startup. In our LDAP environment with activated user private groups, this slows down the startup of openbox significantly. The usage of getgrent is responsible for these delays. The patch supplied uses getgroups instead of getgrent, with performs much better and respects local nscd caches. Best Simon -- System Information: Debian Release: 8.2 APT prefers stable APT policy: (500, 'stable') Architecture: amd64 (x86_64) Kernel: Linux 3.16.0-4-amd64 (SMP w/4 CPU cores) Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) Versions of packages openbox depends on: ii libc6 2.19-18+deb8u1 ii libglib2.0-0 2.42.1-1 ii libice6 2:1.0.9-1+b1 ii libobrender29 3.5.2-8 ii libobt2 3.5.2-8 ii libsm6 2:1.2.2-1+b1 ii libstartup-notification0 0.12-4 ii libx11-6 2:1.6.2-3 ii libxau6 1:1.0.8-1 ii libxext6 2:1.3.3-1 ii libxi6 2:1.7.4-1+b2 ii libxinerama1 2:1.1.3-1+b1 ii libxrandr2 2:1.4.2-1+b1 Versions of packages openbox recommends: ii obconf 1:2.0.4-2 ii python-xdg 0.25-4 ii scrot 0.8-13 Versions of packages openbox suggests: ii fonts-dejavu 2.34-1 ii libxml2-dev 2.9.1+dfsg1-5 ii menu 2.1.47 pn openbox-gnome-session <none> pn openbox-kde-session <none> pn openbox-menu <none> ii python 2.7.9-1 ii tint2 0.11+svn20121014-3 -- no debconf information
>From e0cb404f53c9b21a521ea2f14c8cd66fdfb68ea7 Mon Sep 17 00:00:00 2001 From: Simon <simondob...@gmail.com> 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