diff options
author | Stefan Metzmacher <metze@samba.org> | 2009-08-06 12:15:51 +0200 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2009-08-07 14:18:17 +0200 |
commit | 59c3f5e3ca8885266fef65261ecae3f51ce78729 (patch) | |
tree | 2972ced82e7a8bcb607cedb25cd4827ba29063e4 /source3/smbd | |
parent | c50a03e4e2c47b828f81f2e4dc214ec84d9cae63 (diff) | |
download | samba-59c3f5e3ca8885266fef65261ecae3f51ce78729.tar.gz samba-59c3f5e3ca8885266fef65261ecae3f51ce78729.tar.bz2 samba-59c3f5e3ca8885266fef65261ecae3f51ce78729.zip |
s3:smbd: move dptr globals into struct smbd_server_connection
metze
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/dir.c | 153 | ||||
-rw-r--r-- | source3/smbd/globals.c | 4 | ||||
-rw-r--r-- | source3/smbd/globals.h | 11 | ||||
-rw-r--r-- | source3/smbd/process.c | 3 | ||||
-rw-r--r-- | source3/smbd/reply.c | 27 | ||||
-rw-r--r-- | source3/smbd/server.c | 2 | ||||
-rw-r--r-- | source3/smbd/trans2.c | 23 |
7 files changed, 135 insertions, 88 deletions
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 1c84decbde..73c4cbb3e7 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -115,15 +115,19 @@ bool make_dir_struct(TALLOC_CTX *ctx, Initialise the dir bitmap. ****************************************************************************/ -void init_dptrs(void) +bool init_dptrs(struct smbd_server_connection *sconn) { - if (dptr_bmap) - return; + if (sconn->smb1.searches.dptr_bmap) { + return true; + } - dptr_bmap = bitmap_allocate(MAX_DIRECTORY_HANDLES); + sconn->smb1.searches.dptr_bmap = bitmap_allocate(MAX_DIRECTORY_HANDLES); + + if (sconn->smb1.searches.dptr_bmap == NULL) { + return false; + } - if (!dptr_bmap) - exit_server("out of memory in init_dptrs"); + return true; } /**************************************************************************** @@ -142,14 +146,14 @@ static void dptr_idle(struct dptr_struct *dptr) Idle the oldest dptr. ****************************************************************************/ -static void dptr_idleoldest(void) +static void dptr_idleoldest(struct smbd_server_connection *sconn) { struct dptr_struct *dptr; /* * Go to the end of the list. */ - for(dptr = dirptrs; dptr && dptr->next; dptr = dptr->next) + for(dptr = sconn->smb1.searches.dirptrs; dptr && dptr->next; dptr = dptr->next) ; if(!dptr) { @@ -173,15 +177,16 @@ static void dptr_idleoldest(void) Get the struct dptr_struct for a dir index. ****************************************************************************/ -static struct dptr_struct *dptr_get(int key, bool forclose) +static struct dptr_struct *dptr_get(struct smbd_server_connection *sconn, + int key, bool forclose) { struct dptr_struct *dptr; - for(dptr = dirptrs; dptr; dptr = dptr->next) { + for(dptr = sconn->smb1.searches.dirptrs; dptr; dptr = dptr->next) { if(dptr->dnum == key) { if (!forclose && !dptr->dir_hnd) { - if (dirhandles_open >= MAX_OPEN_DIRECTORIES) - dptr_idleoldest(); + if (sconn->smb1.searches.dirhandles_open >= MAX_OPEN_DIRECTORIES) + dptr_idleoldest(sconn); DEBUG(4,("dptr_get: Reopening dptr key %d\n",key)); if (!(dptr->dir_hnd = OpenDir( NULL, dptr->conn, dptr->path, @@ -191,7 +196,7 @@ static struct dptr_struct *dptr_get(int key, bool forclose) return False; } } - DLIST_PROMOTE(dirptrs,dptr); + DLIST_PROMOTE(sconn->smb1.searches.dirptrs,dptr); return dptr; } } @@ -202,9 +207,9 @@ static struct dptr_struct *dptr_get(int key, bool forclose) Get the dir path for a dir index. ****************************************************************************/ -char *dptr_path(int key) +char *dptr_path(struct smbd_server_connection *sconn, int key) { - struct dptr_struct *dptr = dptr_get(key, False); + struct dptr_struct *dptr = dptr_get(sconn, key, false); if (dptr) return(dptr->path); return(NULL); @@ -214,9 +219,9 @@ char *dptr_path(int key) Get the dir wcard for a dir index. ****************************************************************************/ -char *dptr_wcard(int key) +char *dptr_wcard(struct smbd_server_connection *sconn, int key) { - struct dptr_struct *dptr = dptr_get(key, False); + struct dptr_struct *dptr = dptr_get(sconn, key, false); if (dptr) return(dptr->wcard); return(NULL); @@ -226,9 +231,9 @@ char *dptr_wcard(int key) Get the dir attrib for a dir index. ****************************************************************************/ -uint16 dptr_attr(int key) +uint16 dptr_attr(struct smbd_server_connection *sconn, int key) { - struct dptr_struct *dptr = dptr_get(key, False); + struct dptr_struct *dptr = dptr_get(sconn, key, false); if (dptr) return(dptr->attr); return(0); @@ -240,22 +245,29 @@ uint16 dptr_attr(int key) static void dptr_close_internal(struct dptr_struct *dptr) { + struct smbd_server_connection *sconn = dptr->conn->sconn; + DEBUG(4,("closing dptr key %d\n",dptr->dnum)); - DLIST_REMOVE(dirptrs, dptr); + if (sconn == NULL) { + goto done; + } + + DLIST_REMOVE(sconn->smb1.searches.dirptrs, dptr); /* * Free the dnum in the bitmap. Remember the dnum value is always * biased by one with respect to the bitmap. */ - if(bitmap_query( dptr_bmap, dptr->dnum - 1) != True) { + if(bitmap_query(sconn->smb1.searches.dptr_bmap, dptr->dnum - 1) != true) { DEBUG(0,("dptr_close_internal : Error - closing dnum = %d and bitmap not set !\n", dptr->dnum )); } - bitmap_clear(dptr_bmap, dptr->dnum - 1); + bitmap_clear(sconn->smb1.searches.dptr_bmap, dptr->dnum - 1); +done: TALLOC_FREE(dptr->dir_hnd); /* Lanman 2 specific code */ @@ -268,7 +280,7 @@ static void dptr_close_internal(struct dptr_struct *dptr) Close a dptr given a key. ****************************************************************************/ -void dptr_close(int *key) +void dptr_close(struct smbd_server_connection *sconn, int *key) { struct dptr_struct *dptr; @@ -278,7 +290,7 @@ void dptr_close(int *key) /* OS/2 seems to use -1 to indicate "close all directories" */ if (*key == -1) { struct dptr_struct *next; - for(dptr = dirptrs; dptr; dptr = next) { + for(dptr = sconn->smb1.searches.dirptrs; dptr; dptr = next) { next = dptr->next; dptr_close_internal(dptr); } @@ -286,7 +298,7 @@ void dptr_close(int *key) return; } - dptr = dptr_get(*key, True); + dptr = dptr_get(sconn, *key, true); if (!dptr) { DEBUG(0,("Invalid key %d given to dptr_close\n", *key)); @@ -305,10 +317,17 @@ void dptr_close(int *key) void dptr_closecnum(connection_struct *conn) { struct dptr_struct *dptr, *next; - for(dptr = dirptrs; dptr; dptr = next) { + struct smbd_server_connection *sconn = conn->sconn; + + if (sconn == NULL) { + return; + } + + for(dptr = sconn->smb1.searches.dirptrs; dptr; dptr = next) { next = dptr->next; - if (dptr->conn == conn) + if (dptr->conn == conn) { dptr_close_internal(dptr); + } } } @@ -319,9 +338,16 @@ void dptr_closecnum(connection_struct *conn) void dptr_idlecnum(connection_struct *conn) { struct dptr_struct *dptr; - for(dptr = dirptrs; dptr; dptr = dptr->next) { - if (dptr->conn == conn && dptr->dir_hnd) + struct smbd_server_connection *sconn = conn->sconn; + + if (sconn == NULL) { + return; + } + + for(dptr = sconn->smb1.searches.dirptrs; dptr; dptr = dptr->next) { + if (dptr->conn == conn && dptr->dir_hnd) { dptr_idle(dptr); + } } } @@ -329,10 +355,11 @@ void dptr_idlecnum(connection_struct *conn) Close a dptr that matches a given path, only if it matches the spid also. ****************************************************************************/ -void dptr_closepath(char *path,uint16 spid) +void dptr_closepath(struct smbd_server_connection *sconn, + char *path,uint16 spid) { struct dptr_struct *dptr, *next; - for(dptr = dirptrs; dptr; dptr = next) { + for(dptr = sconn->smb1.searches.dirptrs; dptr; dptr = next) { next = dptr->next; if (spid == dptr->spid && strequal(dptr->path,path)) dptr_close_internal(dptr); @@ -345,14 +372,15 @@ void dptr_closepath(char *path,uint16 spid) finished with that one. ****************************************************************************/ -static void dptr_close_oldest(bool old) +static void dptr_close_oldest(struct smbd_server_connection *sconn, + bool old) { struct dptr_struct *dptr; /* * Go to the end of the list. */ - for(dptr = dirptrs; dptr && dptr->next; dptr = dptr->next) + for(dptr = sconn->smb1.searches.dirptrs; dptr && dptr->next; dptr = dptr->next) ; if(!dptr) { @@ -387,12 +415,18 @@ static void dptr_close_oldest(bool old) NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle, bool expect_close,uint16 spid, const char *wcard, bool wcard_has_wild, uint32 attr, struct dptr_struct **dptr_ret) { + struct smbd_server_connection *sconn = conn->sconn; struct dptr_struct *dptr = NULL; struct smb_Dir *dir_hnd; NTSTATUS status; DEBUG(5,("dptr_create dir=%s\n", path)); + if (sconn == NULL) { + DEBUG(0,("dptr_create: called with fake connection_struct\n")); + return NT_STATUS_INTERNAL_ERROR; + } + if (!wcard) { return NT_STATUS_INVALID_PARAMETER; } @@ -407,8 +441,8 @@ NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle, return map_nt_error_from_unix(errno); } - if (dirhandles_open >= MAX_OPEN_DIRECTORIES) { - dptr_idleoldest(); + if (sconn->smb1.searches.dirhandles_open >= MAX_OPEN_DIRECTORIES) { + dptr_idleoldest(sconn); } dptr = SMB_MALLOC_P(struct dptr_struct); @@ -427,7 +461,7 @@ NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle, * value we return will fit in the range 1-255. */ - dptr->dnum = bitmap_find(dptr_bmap, 0); + dptr->dnum = bitmap_find(sconn->smb1.searches.dptr_bmap, 0); if(dptr->dnum == -1 || dptr->dnum > 254) { @@ -437,10 +471,10 @@ NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle, * finished with that one. */ - dptr_close_oldest(True); + dptr_close_oldest(sconn, true); /* Now try again... */ - dptr->dnum = bitmap_find(dptr_bmap, 0); + dptr->dnum = bitmap_find(sconn->smb1.searches.dptr_bmap, 0); if(dptr->dnum == -1 || dptr->dnum > 254) { DEBUG(0,("dptr_create: returned %d: Error - all old dirptrs in use ?\n", dptr->dnum)); SAFE_FREE(dptr); @@ -455,7 +489,7 @@ NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle, * a range that will return 256 - MAX_DIRECTORY_HANDLES. */ - dptr->dnum = bitmap_find(dptr_bmap, 255); + dptr->dnum = bitmap_find(sconn->smb1.searches.dptr_bmap, 255); if(dptr->dnum == -1 || dptr->dnum < 255) { @@ -466,10 +500,10 @@ NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle, * directory handles. */ - dptr_close_oldest(False); + dptr_close_oldest(sconn, false); /* Now try again... */ - dptr->dnum = bitmap_find(dptr_bmap, 255); + dptr->dnum = bitmap_find(sconn->smb1.searches.dptr_bmap, 255); if(dptr->dnum == -1 || dptr->dnum < 255) { DEBUG(0,("dptr_create: returned %d: Error - all new dirptrs in use ?\n", dptr->dnum)); @@ -480,7 +514,7 @@ NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle, } } - bitmap_set(dptr_bmap, dptr->dnum); + bitmap_set(sconn->smb1.searches.dptr_bmap, dptr->dnum); dptr->dnum += 1; /* Always bias the dnum by one - no zero dnums allowed. */ @@ -491,7 +525,7 @@ NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle, dptr->expect_close = expect_close; dptr->wcard = SMB_STRDUP(wcard); if (!dptr->wcard) { - bitmap_clear(dptr_bmap, dptr->dnum - 1); + bitmap_clear(sconn->smb1.searches.dptr_bmap, dptr->dnum - 1); SAFE_FREE(dptr); TALLOC_FREE(dir_hnd); return NT_STATUS_NO_MEMORY; @@ -504,7 +538,7 @@ NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle, dptr->attr = attr; - DLIST_ADD(dirptrs, dptr); + DLIST_ADD(sconn->smb1.searches.dirptrs, dptr); DEBUG(3,("creating new dirptr %d for path %s, expect_close = %d\n", dptr->dnum,path,expect_close)); @@ -521,7 +555,8 @@ NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle, int dptr_CloseDir(struct dptr_struct *dptr) { - DLIST_REMOVE(dirptrs, dptr); + struct smbd_server_connection *sconn = dptr->conn->sconn; + DLIST_REMOVE(sconn->smb1.searches.dirptrs, dptr); TALLOC_FREE(dptr->dir_hnd); return 0; } @@ -724,10 +759,11 @@ void dptr_init_search_op(struct dptr_struct *dptr) Fill the 5 byte server reserved dptr field. ****************************************************************************/ -bool dptr_fill(char *buf1,unsigned int key) +bool dptr_fill(struct smbd_server_connection *sconn, + char *buf1,unsigned int key) { unsigned char *buf = (unsigned char *)buf1; - struct dptr_struct *dptr = dptr_get(key, False); + struct dptr_struct *dptr = dptr_get(sconn, key, false); uint32 offset; if (!dptr) { DEBUG(1,("filling null dirptr %d\n",key)); @@ -745,10 +781,11 @@ bool dptr_fill(char *buf1,unsigned int key) Fetch the dir ptr and seek it given the 5 byte server field. ****************************************************************************/ -struct dptr_struct *dptr_fetch(char *buf,int *num) +struct dptr_struct *dptr_fetch(struct smbd_server_connection *sconn, + char *buf, int *num) { unsigned int key = *(unsigned char *)buf; - struct dptr_struct *dptr = dptr_get(key, False); + struct dptr_struct *dptr = dptr_get(sconn, key, false); uint32 offset; long seekoff; @@ -765,7 +802,7 @@ struct dptr_struct *dptr_fetch(char *buf,int *num) } SeekDir(dptr->dir_hnd,seekoff); DEBUG(3,("fetching dirptr %d for path %s at offset %d\n", - key,dptr_path(key),(int)seekoff)); + key, dptr->path, (int)seekoff)); return(dptr); } @@ -773,15 +810,16 @@ struct dptr_struct *dptr_fetch(char *buf,int *num) Fetch the dir ptr. ****************************************************************************/ -struct dptr_struct *dptr_fetch_lanman2(int dptr_num) +struct dptr_struct *dptr_fetch_lanman2(struct smbd_server_connection *sconn, + int dptr_num) { - struct dptr_struct *dptr = dptr_get(dptr_num, False); + struct dptr_struct *dptr = dptr_get(sconn, dptr_num, false); if (!dptr) { DEBUG(3,("fetched null dirptr %d\n",dptr_num)); return(NULL); } - DEBUG(3,("fetching dirptr %d for path %s\n",dptr_num,dptr_path(dptr_num))); + DEBUG(3,("fetching dirptr %d for path %s\n",dptr_num,dptr->path)); return(dptr); } @@ -1245,7 +1283,9 @@ static int smb_Dir_destructor(struct smb_Dir *dirp) if (dirp->dir) { SMB_VFS_CLOSEDIR(dirp->conn,dirp->dir); } - dirhandles_open--; + if (dirp->conn->sconn) { + dirp->conn->sconn->smb1.searches.dirhandles_open--; + } return 0; } @@ -1257,6 +1297,7 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, connection_struct *conn, const char *name, const char *mask, uint32 attr) { struct smb_Dir *dirp = TALLOC_ZERO_P(mem_ctx, struct smb_Dir); + struct smbd_server_connection *sconn = conn->sconn; if (!dirp) { return NULL; @@ -1271,7 +1312,9 @@ struct smb_Dir *OpenDir(TALLOC_CTX *mem_ctx, connection_struct *conn, goto fail; } - dirhandles_open++; + if (sconn) { + sconn->smb1.searches.dirhandles_open++; + } talloc_set_destructor(dirp, smb_Dir_destructor); dirp->dir = SMB_VFS_OPENDIR(conn, dirp->dir_path, mask, attr); diff --git a/source3/smbd/globals.c b/source3/smbd/globals.c index 317304a86d..f680b76369 100644 --- a/source3/smbd/globals.c +++ b/source3/smbd/globals.c @@ -46,10 +46,6 @@ struct smbd_dmapi_context *dmapi_ctx = NULL; bool dfree_broken = false; -struct bitmap *dptr_bmap = NULL; -struct dptr_struct *dirptrs = NULL; -int dirhandles_open = 0; - /* how many write cache buffers have been allocated */ unsigned int allocated_write_caches = 0; diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 6a62cf6a21..338398968a 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -44,11 +44,6 @@ extern struct smbd_dmapi_context *dmapi_ctx; extern bool dfree_broken; -extern struct bitmap *dptr_bmap; -//struct dptr_struct; -extern struct dptr_struct *dirptrs; -extern int dirhandles_open; - /* how many write cache buffers have been allocated */ extern unsigned int allocated_write_caches; @@ -453,6 +448,12 @@ struct smbd_server_connection { struct pending_auth_data *pd_list; struct notify_mid_map *notify_mid_maps; + + struct { + struct bitmap *dptr_bmap; + struct dptr_struct *dirptrs; + int dirhandles_open; + } searches; } smb1; struct { struct tevent_context *event_ctx; diff --git a/source3/smbd/process.c b/source3/smbd/process.c index 99c862300d..6ec46071ff 100644 --- a/source3/smbd/process.c +++ b/source3/smbd/process.c @@ -2206,6 +2206,9 @@ void smbd_process(void) #endif conn_init(smbd_server_conn); + if (!init_dptrs(smbd_server_conn)) { + exit_server("init_dptrs() failed"); + } smbd_server_conn->smb1.fde = event_add_fd(smbd_event_context(), smbd_server_conn, diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index f6028a3eef..3498109f12 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -1367,6 +1367,7 @@ void reply_search(struct smb_request *req) TALLOC_CTX *ctx = talloc_tos(); bool ask_sharemode = lp_parm_bool(SNUM(conn), "smbd", "search ask sharemode", true); struct dptr_struct *dirptr = NULL; + struct smbd_server_connection *sconn = smbd_server_conn; START_PROFILE(SMBsearch); @@ -1463,18 +1464,18 @@ void reply_search(struct smb_request *req) dirtype = status_dirtype; } - dirptr = dptr_fetch(status+12,&dptr_num); + dirptr = dptr_fetch(sconn, status+12,&dptr_num); if (!dirptr) { goto SearchEmpty; } - dirpath = dptr_path(dptr_num); + dirpath = dptr_path(sconn, dptr_num); directory = talloc_strdup(ctx, dirpath); if (!directory) { reply_nterror(req, NT_STATUS_NO_MEMORY); goto out; } - mask = dptr_wcard(dptr_num); + mask = dptr_wcard(sconn, dptr_num); if (!mask) { goto SearchEmpty; } @@ -1483,7 +1484,7 @@ void reply_search(struct smb_request *req) * check from the initial saved string. */ mask_contains_wcard = ms_has_wild(mask); - dirtype = dptr_attr(dptr_num); + dirtype = dptr_attr(sconn, dptr_num); } DEBUG(4,("dptr_num is %d\n",dptr_num)); @@ -1499,7 +1500,7 @@ void reply_search(struct smb_request *req) reply_nterror(req, NT_STATUS_NO_MEMORY); goto out; } - dptr_fill(buf+12,dptr_num); + dptr_fill(sconn, buf+12,dptr_num); if (dptr_zero(buf+12) && (status_len==0)) { numentries = 1; } else { @@ -1550,7 +1551,7 @@ void reply_search(struct smb_request *req) reply_nterror(req, NT_STATUS_NO_MEMORY); goto out; } - if (!dptr_fill(buf+12,dptr_num)) { + if (!dptr_fill(sconn, buf+12,dptr_num)) { break; } if (message_push_blob(&req->outbuf, @@ -1571,15 +1572,15 @@ void reply_search(struct smb_request *req) (X/Open spec) */ if (numentries == 0) { - dptr_close(&dptr_num); + dptr_close(sconn, &dptr_num); } else if(expect_close && status_len == 0) { /* Close the dptr - we know it's gone */ - dptr_close(&dptr_num); + dptr_close(sconn, &dptr_num); } /* If we were called as SMBfunique, then we can close the dirptr now ! */ if(dptr_num >= 0 && req->cmd == SMBfunique) { - dptr_close(&dptr_num); + dptr_close(sconn, &dptr_num); } if ((numentries == 0) && !mask_contains_wcard) { @@ -1633,6 +1634,7 @@ void reply_fclose(struct smb_request *req) NTSTATUS err; bool path_contains_wcard = False; TALLOC_CTX *ctx = talloc_tos(); + struct smbd_server_connection *sconn = smbd_server_conn; START_PROFILE(SMBfclose); @@ -1662,9 +1664,9 @@ void reply_fclose(struct smb_request *req) memcpy(status,p,21); - if(dptr_fetch(status+12,&dptr_num)) { + if(dptr_fetch(sconn, status+12,&dptr_num)) { /* Close the dptr - we know it's gone */ - dptr_close(&dptr_num); + dptr_close(sconn, &dptr_num); } reply_outbuf(req, 1, 0); @@ -5532,6 +5534,7 @@ void reply_rmdir(struct smb_request *req) char *directory = NULL; NTSTATUS status; TALLOC_CTX *ctx = talloc_tos(); + struct smbd_server_connection *sconn = smbd_server_conn; START_PROFILE(SMBrmdir); @@ -5563,7 +5566,7 @@ void reply_rmdir(struct smb_request *req) goto out; } - dptr_closepath(smb_dname->base_name, req->smbpid); + dptr_closepath(sconn, smb_dname->base_name, req->smbpid); status = rmdir_internals(ctx, conn, smb_dname); if (!NT_STATUS_IS_OK(status)) { reply_nterror(req, status); diff --git a/source3/smbd/server.c b/source3/smbd/server.c index 4b1c803d75..ace3124842 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -914,8 +914,6 @@ static bool init_structs(void ) file_init(); - init_dptrs(); - if (!secrets_init()) return False; diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index 3f93b3d571..9273339b71 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -2018,6 +2018,7 @@ static void call_trans2findfirst(connection_struct *conn, bool ask_sharemode = lp_parm_bool(SNUM(conn), "smbd", "search ask sharemode", true); TALLOC_CTX *ctx = talloc_tos(); struct dptr_struct *dirptr = NULL; + struct smbd_server_connection *sconn = smbd_server_conn; if (total_params < 13) { reply_nterror(req, NT_STATUS_INVALID_PARAMETER); @@ -2250,7 +2251,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd /* Check if we can close the dirptr */ if(close_after_first || (finished && close_if_end)) { DEBUG(5,("call_trans2findfirst - (2) closing dptr_num %d\n", dptr_num)); - dptr_close(&dptr_num); + dptr_close(sconn, &dptr_num); } /* @@ -2261,7 +2262,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd */ if(numentries == 0) { - dptr_close(&dptr_num); + dptr_close(sconn, &dptr_num); if (Protocol < PROTOCOL_NT1) { reply_doserror(req, ERRDOS, ERRnofiles); goto out; @@ -2284,8 +2285,8 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd send_trans2_replies(conn, req, params, 10, pdata, PTR_DIFF(p,pdata), max_data_bytes); - if ((! *directory) && dptr_path(dptr_num)) { - directory = talloc_strdup(talloc_tos(),dptr_path(dptr_num)); + if ((! *directory) && dptr_path(sconn, dptr_num)) { + directory = talloc_strdup(talloc_tos(),dptr_path(sconn, dptr_num)); if (!directory) { reply_nterror(req, NT_STATUS_NO_MEMORY); } @@ -2356,6 +2357,7 @@ static void call_trans2findnext(connection_struct *conn, bool ask_sharemode = lp_parm_bool(SNUM(conn), "smbd", "search ask sharemode", true); TALLOC_CTX *ctx = talloc_tos(); struct dptr_struct *dirptr; + struct smbd_server_connection *sconn = smbd_server_conn; if (total_params < 13) { reply_nterror(req, NT_STATUS_INVALID_PARAMETER); @@ -2477,15 +2479,15 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd params = *pparams; /* Check that the dptr is valid */ - if(!(dirptr = dptr_fetch_lanman2(dptr_num))) { + if(!(dirptr = dptr_fetch_lanman2(sconn, dptr_num))) { reply_doserror(req, ERRDOS, ERRnofiles); return; } - directory = dptr_path(dptr_num); + directory = dptr_path(sconn, dptr_num); /* Get the wildcard mask from the dptr */ - if((p = dptr_wcard(dptr_num))== NULL) { + if((p = dptr_wcard(sconn, dptr_num))== NULL) { DEBUG(2,("dptr_num %d has no wildcard\n", dptr_num)); reply_doserror(req, ERRDOS, ERRnofiles); return; @@ -2494,7 +2496,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd mask = p; /* Get the attr mask from the dptr */ - dirtype = dptr_attr(dptr_num); + dirtype = dptr_attr(sconn, dptr_num); DEBUG(3,("dptr_num is %d, mask = %s, attr = %x, dirptr=(0x%lX,%ld)\n", dptr_num, mask, dirtype, @@ -2602,7 +2604,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd /* Check if we can close the dirptr */ if(close_after_request || (finished && close_if_end)) { DEBUG(5,("call_trans2findnext: closing dptr_num = %d\n", dptr_num)); - dptr_close(&dptr_num); /* This frees up the saved mask */ + dptr_close(sconn, &dptr_num); /* This frees up the saved mask */ } /* Set up the return parameter block */ @@ -7851,6 +7853,7 @@ static void call_trans2ioctl(connection_struct *conn, void reply_findclose(struct smb_request *req) { int dptr_num; + struct smbd_server_connection *sconn = smbd_server_conn; START_PROFILE(SMBfindclose); @@ -7864,7 +7867,7 @@ void reply_findclose(struct smb_request *req) DEBUG(3,("reply_findclose, dptr_num = %d\n", dptr_num)); - dptr_close(&dptr_num); + dptr_close(sconn, &dptr_num); reply_outbuf(req, 0, 0); |