Patch for the "Too many session users" error

Pat.Hayward at propero.net Pat.Hayward at propero.net
Wed Apr 7 14:13:56 GMT 2004


Hi List,

I was hitting the "smbd/password.c:add_session_user(367)  Too many session
users??" error in load-testing so I thought I'd better fix it.  We use
Windows terminal services a lot and I see from past postings that others
have had this problem when lots of users connect from one machine.

Based on the code from samba-3.0.2a I've built and tested this on RedHat
7.3 and also tested it briefly on RedHat Enterprise 2.1

Here's the patch to smbd/password.c , hope it can be of use to others?

--- samba-3.0.2a/./source/smbd/password.c     Thu Feb 12 15:02:54 2004
+++ password.c Wed Apr  7 10:32:13 2004
@@ -21,7 +21,14 @@
 #include "includes.h"

 /* users from session setup */
+
+/* PWH VVV
 static pstring session_users="";
+Remove old variable and use new name to avoid confusion
+*/
+static char *session_userlist = NULL;
+static int len_session_userlist = 0;
+/* PWH ^^^ */

 /* this holds info on user ids that are already validated for this VC */
 static user_struct *validated_users;
@@ -291,6 +298,29 @@

     fstrcpy(suser,passwd->pw_name);

+    /* PWH VVV */
+    if( !suser || !(*suser) )
+         return;
+
+    if( session_userlist && in_list(suser,session_userlist,False) )
+         return;
+
+    if( !session_userlist || (strlen(suser) + strlen(session_userlist) + 2
>= len_session_userlist) )
+    {
+         char *newlist = realloc( session_userlist, len_session_userlist +
PSTRING_LEN );
+         if( newlist == NULL )
+         {
+              DEBUG(1,("Unable to resize session_userlist\n"));
+              return;
+         }
+         session_userlist = newlist;
+         len_session_userlist += PSTRING_LEN;
+    }
+
+    safe_strcat(session_userlist," ",len_session_userlist-1);
+    safe_strcat(session_userlist,suser,len_session_userlist-1);
+
+    /*
     if (suser && *suser && !in_list(suser,session_users,False)) {
          if (strlen(suser) + strlen(session_users) + 2 >= sizeof(pstring))
{
               DEBUG(1,("Too many session users??\n"));
@@ -299,6 +329,7 @@
               pstrcat(session_users,suser);
          }
     }
+    PWH ^^^ */
 }


/****************************************************************************
@@ -464,7 +495,13 @@
     /* now check the list of session users */
     if (!ok) {
          char *auser;
+
+         /* PWH VVV
          char *user_list = strdup(session_users);
+         */
+         char *user_list = strdup(session_userlist);
+         /* PWH ^^^ */
+
          if (!user_list)
               return(False);





More information about the samba-technical mailing list