[X2Go-Commits] [x2goserver] 01/01: x2goserver/bin/x2gosessionlimit: don't iterate over the whole groups file.

git-admin at x2go.org git-admin at x2go.org
Sat Jun 6 15:11:01 CEST 2015


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2goserver.

commit dd39de9d587747ab99121887524dc29726c293d7
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Sat Jun 6 03:44:18 2015 +0200

    x2goserver/bin/x2gosessionlimit: don't iterate over the whole groups file.
    
    Only check the primary and secondary groups as returned by
    getgid()/getgroups().
    
    Fixes long delays in session startup on machines with a gazillion of
    groups.
---
 debian/changelog                |    4 ++++
 x2goserver/bin/x2gosessionlimit |   21 +++++++--------------
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index b9432d5..fecc8ff 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -183,6 +183,10 @@ x2goserver (4.0.1.20-0x2go1) UNRELEASED; urgency=low
     - x2goserver/bin/x2gogetapps: do not print spurious newlines.
     - Change string "X2go" to "X2Go" where appropriate.
     - Add runcommand.d hooks to x2goserver-extensions Makefile.
+    - x2goserver/bin/x2gosessionlimit: don't iterate over the whole groups
+      file. Only check the primary and secondary groups as returned by
+      getgid()/getgroups(). Fixes long delays in session startup on machines
+      with a gazillion of groups.
   * x2goserver.spec:
     - Add sudo and logcheck as BuildRequires and Requires. Don't own
       directories that are owned by sudo and logcheck. Logcheck is not
diff --git a/x2goserver/bin/x2gosessionlimit b/x2goserver/bin/x2gosessionlimit
index cafc786..0f57135 100755
--- a/x2goserver/bin/x2gosessionlimit
+++ b/x2goserver/bin/x2gosessionlimit
@@ -27,6 +27,8 @@ use X2Go::Config qw( get_config);
 use X2Go::Log qw( loglevel );
 use X2Go::Utils qw( system_capture_merged_output );
 
+use English;
+
 openlog($0,'cons,pid','user');
 setlogmask( LOG_UPTO(loglevel()) );
 
@@ -81,25 +83,16 @@ if($strlimit ne "")
 }
 
 
-my ($name, $pass, $uid, $pgid, $quota, $comment, $gcos, $dir, $shell, $expire) = getpwnam($uname);
+my @assigned_groups = split (" ", $REAL_GROUP_ID);
 
-while (my ($name, $passwd, $gid, $members)  = getgrent()) 
-{
-	if ( $pgid eq $gid)
-	{
+foreach my $current_group (@assigned_groups) {
+	my $name = getgrgid ($current_group);
+
+	if (defined ($name)) {
 		getGroupLimit $name;
 	}
-	my @memebers=split(" ",$members);
-	foreach my $member (@memebers) 
-	{
-		if ($uname eq $member  )
-		{
-			getGroupLimit $name;
-		}
-	}
 }
 
-
 if ($scount < $maxlimit)
 {
 	print "$maxlimit\n";

--
Alioth's /srv/git/code.x2go.org/x2goserver.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goserver.git


More information about the x2go-commits mailing list