Fix bug #6155 - "force group" is no longer working as expected.
authorJeremy Allison <jra@samba.org>
Wed, 4 Mar 2009 00:05:47 +0000 (16:05 -0800)
committerJeremy Allison <jra@samba.org>
Wed, 4 Mar 2009 00:10:17 +0000 (16:10 -0800)
We need to store the "force group" uid separately from the
conn->server_info token as we need to apply it separately also.
Volker PLEASE CHECK !
Jeremy.

source/include/smb.h
source/smbd/conn.c
source/smbd/service.c
source/smbd/uid.c

index a98d151e5f363214321d5583a667613cb2343d3e..56d9461527d58013dc22c57da3162ce7cc953cc7 100644 (file)
@@ -597,6 +597,12 @@ typedef struct connection_struct {
         */
        struct auth_serversupplied_info *server_info;
 
+       /*
+        * If the "force group" parameter is set, this is the primary gid that
+        * may be used in the users token, depending on the vuid using this tid.
+        */
+       gid_t force_group_gid;
+
        char client_address[INET6_ADDRSTRLEN]; /* String version of client IP address. */
 
        uint16 vuid; /* vuid of user who *opened* this connection, or UID_FIELD_INVALID */
index 7f34d2b8e2b3e9d1971c2bd9cb9a9e5057b1c32c..a6eafcf02ee99d29b5e50623882932089338b10b 100644 (file)
@@ -145,6 +145,7 @@ find_again:
                return NULL;
        }
        conn->cnum = i;
+       conn->force_group_gid = (gid_t)-1;
 
        bitmap_set(bmap, i);
 
index c39584ab4a6721e5ef62302ccfaf6096450851a6..5e75fce0ff43144131ebf5944fd021b586fb887c 100644 (file)
@@ -834,6 +834,14 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
                        *pstatus = status;
                        return NULL;
                }
+
+               /*
+                * We need to cache this gid, to use within
+                * change_to_user() separately from the conn->server_info
+                * struct. We only use conn->server_info directly if
+                * "force_user" was set.
+                */
+               conn->force_group_gid = conn->server_info->utok.gid;
        }
 
        conn->vuid = (vuser != NULL) ? vuser->vuid : UID_FIELD_INVALID;
index 119a1555f6193ee246ed8aca4609cde2dcaf7cac..02f8cc950e9ce24872512301913d3904c0a31022 100644 (file)
@@ -256,6 +256,8 @@ bool change_to_user(connection_struct *conn, uint16 vuid)
 
        if((group_c = *lp_force_group(snum))) {
 
+               SMB_ASSERT(conn->force_group_gid != (gid_t)-1);
+
                if(group_c == '+') {
 
                        /*
@@ -268,15 +270,18 @@ bool change_to_user(connection_struct *conn, uint16 vuid)
                        int i;
                        for (i = 0; i < num_groups; i++) {
                                if (group_list[i]
-                                   == conn->server_info->utok.gid) {
-                                       gid = conn->server_info->utok.gid;
+                                   == conn->force_group_gid) {
+                                       conn->server_info->utok.gid =
+                                               conn->force_group_gid;
+                                       gid = conn->force_group_gid;
                                        gid_to_sid(&conn->server_info->ptok
                                                   ->user_sids[1], gid);
                                        break;
                                }
                        }
                } else {
-                       gid = conn->server_info->utok.gid;
+                       conn->server_info->utok.gid = conn->force_group_gid;
+                       gid = conn->force_group_gid;
                        gid_to_sid(&conn->server_info->ptok->user_sids[1],
                                   gid);
                }