Changeset 274 for branches/samba-3.3.x/source/smbd/uid.c
- Timestamp:
- Jun 17, 2009, 2:19:52 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/samba-3.3.x/source/smbd/uid.c
r224 r274 55 55 } 56 56 57 /**************************************************************************** 58 talloc free the conn->server_info if not used in the vuid cache. 59 ****************************************************************************/ 60 61 static void free_conn_server_info_if_unused(connection_struct *conn) 62 { 63 unsigned int i; 64 65 for (i = 0; i < VUID_CACHE_SIZE; i++) { 66 struct vuid_cache_entry *ent; 67 ent = &conn->vuid_cache.array[i]; 68 if (ent->vuid != UID_FIELD_INVALID && 69 conn->server_info == ent->server_info) { 70 return; 71 } 72 } 73 /* Not used, safe to free. */ 74 TALLOC_FREE(conn->server_info); 75 } 76 57 77 /******************************************************************* 58 78 Check if a username is OK. … … 78 98 ent = &conn->vuid_cache.array[i]; 79 99 if (ent->vuid == vuid) { 100 free_conn_server_info_if_unused(conn); 80 101 conn->server_info = ent->server_info; 81 102 conn->read_only = ent->read_only; … … 143 164 ent->read_only = readonly_share; 144 165 ent->admin_user = admin_user; 166 free_conn_server_info_if_unused(conn); 145 167 conn->server_info = ent->server_info; 146 168 } … … 154 176 /**************************************************************************** 155 177 Clear a vuid out of the connection's vuid cache 178 This is only called on SMBulogoff. 156 179 ****************************************************************************/ 157 180 … … 167 190 if (ent->vuid == vuid) { 168 191 ent->vuid = UID_FIELD_INVALID; 169 /* Ensure we're not freeing an active pointer. */ 192 /* 193 * We need to keep conn->server_info around 194 * if it's equal to ent->server_info as a SMBulogoff 195 * is often followed by a SMBtdis (with an invalid 196 * vuid). The debug code (or regular code in 197 * vfs_full_audit) wants to refer to the 198 * conn->server_info pointer to print debug 199 * statements. Theoretically this is a bug, 200 * as once the vuid is gone the server_info 201 * on the conn struct isn't valid any more, 202 * but there's enough code that assumes 203 * conn->server_info is never null that 204 * it's easier to hold onto the old pointer 205 * until we get a new sessionsetupX. 206 * As everything is hung off the 207 * conn pointer as a talloc context we're not 208 * leaking memory here. See bug #6315. JRA. 209 */ 170 210 if (conn->server_info == ent->server_info) { 171 conn->server_info = NULL; 211 ent->server_info = NULL; 212 } else { 213 TALLOC_FREE(ent->server_info); 172 214 } 173 TALLOC_FREE(ent->server_info);174 215 ent->read_only = False; 175 216 ent->admin_user = False;
Note:
See TracChangeset
for help on using the changeset viewer.