s3:smbd make yp cache local.
authorSimo Sorce <ssorce@redhat.com>
Mon, 31 May 2010 14:36:02 +0000 (10:36 -0400)
committerSimo Sorce <ssorce@redhat.com>
Mon, 31 May 2010 15:14:38 +0000 (11:14 -0400)
The my_yp_domain variable is just a static cache needed to avoid
making over and over expensive and potentially blocking calls to
yp_get_default_domain().
Instead of keeping this onto the smbd_server_connection struct, just
keep it local to the only function ever using this variable.

This disentagle this function (and a number of calling functions)
from having to passa round smbd_server_connection and thus having
to link against smbd. It also removes a few ifdefs.

Nothing changes from a global/local pov, as the smbd_server_connection
variable passed around is also a global one.

source3/smbd/globals.h
source3/smbd/password.c
source3/smbd/process.c

index cd4516501be69df32a22329cc2181f505bce64b0..36661482ce017dbbd81063447b39d5cb598c97b1 100644 (file)
@@ -515,9 +515,6 @@ struct smbd_server_connection {
                        user_struct *validated_users;
                        uint16_t next_vuid;
                        int num_validated_vuids;
-#ifdef HAVE_NETGROUP
-                       char *my_yp_domain;
-#endif
                } sessions;
                struct {
                        connection_struct *Connections;
index 809a913d6c7f5a2c320eea9ab68151aa23d57751..7101f7c8c4775be69606e55fbb222dfe5cf5814c 100644 (file)
@@ -412,24 +412,22 @@ bool user_in_netgroup(struct smbd_server_connection *sconn,
                      const char *user, const char *ngname)
 {
 #ifdef HAVE_NETGROUP
+       static char *my_yp_domain = NULL;
        fstring lowercase_user;
 
-       if (sconn->smb1.sessions.my_yp_domain == NULL) {
-               yp_get_default_domain(&sconn->smb1.sessions.my_yp_domain);
+       if (my_yp_domain == NULL) {
+               yp_get_default_domain(&my_yp_domain);
        }
 
-       if (sconn->smb1.sessions.my_yp_domain == NULL) {
+       if (my_yp_domain == NULL) {
                DEBUG(5,("Unable to get default yp domain, "
                        "let's try without specifying it\n"));
        }
 
        DEBUG(5,("looking for user %s of domain %s in netgroup %s\n",
-               user,
-               sconn->smb1.sessions.my_yp_domain?
-               sconn->smb1.sessions.my_yp_domain:"(ANY)",
-               ngname));
+               user, my_yp_domain?my_yp_domain:"(ANY)", ngname));
 
-       if (innetgr(ngname, NULL, user, sconn->smb1.sessions.my_yp_domain)) {
+       if (innetgr(ngname, NULL, user, my_yp_domain)) {
                DEBUG(5,("user_in_netgroup: Found\n"));
                return true;
        }
@@ -447,13 +445,9 @@ bool user_in_netgroup(struct smbd_server_connection *sconn,
        }
 
        DEBUG(5,("looking for user %s of domain %s in netgroup %s\n",
-               lowercase_user,
-               sconn->smb1.sessions.my_yp_domain?
-               sconn->smb1.sessions.my_yp_domain:"(ANY)",
-               ngname));
+               lowercase_user, my_yp_domain?my_yp_domain:"(ANY)", ngname));
 
-       if (innetgr(ngname, NULL, lowercase_user,
-                   sconn->smb1.sessions.my_yp_domain)) {
+       if (innetgr(ngname, NULL, lowercase_user, my_yp_domain)) {
                DEBUG(5,("user_in_netgroup: Found\n"));
                return true;
        }
index c8497577a448020a5e17093015841b0d123023b1..3396f89bc17beed66cc8663888e9ddf1881f4933 100644 (file)
@@ -3061,9 +3061,6 @@ void smbd_process(void)
        smbd_server_conn->smb1.sessions.validated_users = NULL;
        smbd_server_conn->smb1.sessions.next_vuid = VUID_OFFSET;
        smbd_server_conn->smb1.sessions.num_validated_vuids = 0;
-#ifdef HAVE_NETGROUP
-       smbd_server_conn->smb1.sessions.my_yp_domain = NULL;
-#endif
 
        conn_init(smbd_server_conn);
        if (!init_dptrs(smbd_server_conn)) {