From c54e6b19e395724eb84f6e7157073e8772bc8594 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 6 Aug 2009 13:22:33 +0200 Subject: s3:smbd: add a smbd_server_connection pointer to connection_struct This can be NULL for faked connection structs used in the rpc server or printing code. metze --- source3/smbd/reply.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source3/smbd/reply.c') diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 77e122a90c..750915b1cb 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -703,7 +703,7 @@ void reply_tcon_and_X(struct smb_request *req) /* we might have to close an old one */ if ((tcon_flags & 0x1) && conn) { - close_cnum(sconn, conn,req->vuid); + close_cnum(conn,req->vuid); req->conn = NULL; conn = NULL; } @@ -4868,7 +4868,6 @@ void reply_unlock(struct smb_request *req) void reply_tdis(struct smb_request *req) { - struct smbd_server_connection *sconn = smbd_server_conn; connection_struct *conn = req->conn; START_PROFILE(SMBtdis); @@ -4881,7 +4880,7 @@ void reply_tdis(struct smb_request *req) conn->used = False; - close_cnum(sconn, conn,req->vuid); + close_cnum(conn,req->vuid); req->conn = NULL; reply_outbuf(req, 0, 0); -- cgit From c50a03e4e2c47b828f81f2e4dc214ec84d9cae63 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 7 Aug 2009 09:31:45 +0200 Subject: s3:smbd: remove dirptr and dirpath from connection_struct They're both only used in the context of a function, so we can make them stack variables. metze --- source3/smbd/reply.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'source3/smbd/reply.c') diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 750915b1cb..f6028a3eef 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -1366,6 +1366,7 @@ void reply_search(struct smb_request *req) bool allow_long_path_components = (req->flags2 & FLAGS2_LONG_PATH_COMPONENTS) ? True : False; TALLOC_CTX *ctx = talloc_tos(); bool ask_sharemode = lp_parm_bool(SNUM(conn), "smbd", "search ask sharemode", true); + struct dptr_struct *dirptr = NULL; START_PROFILE(SMBsearch); @@ -1446,14 +1447,15 @@ void reply_search(struct smb_request *req) mask, mask_contains_wcard, dirtype, - &conn->dirptr); + &dirptr); if (!NT_STATUS_IS_OK(nt_status)) { reply_nterror(req, nt_status); goto out; } - dptr_num = dptr_dnum(conn->dirptr); + dptr_num = dptr_dnum(dirptr); } else { int status_dirtype; + const char *dirpath; memcpy(status,p,21); status_dirtype = CVAL(status,0) & 0x1F; @@ -1461,11 +1463,17 @@ void reply_search(struct smb_request *req) dirtype = status_dirtype; } - conn->dirptr = dptr_fetch(status+12,&dptr_num); - if (!conn->dirptr) { + dirptr = dptr_fetch(status+12,&dptr_num); + if (!dirptr) { goto SearchEmpty; } - string_set(&conn->dirpath,dptr_path(dptr_num)); + dirpath = dptr_path(dptr_num); + directory = talloc_strdup(ctx, dirpath); + if (!directory) { + reply_nterror(req, NT_STATUS_NO_MEMORY); + goto out; + } + mask = dptr_wcard(dptr_num); if (!mask) { goto SearchEmpty; @@ -1481,7 +1489,7 @@ void reply_search(struct smb_request *req) DEBUG(4,("dptr_num is %d\n",dptr_num)); /* Initialize per SMBsearch/SMBffirst/SMBfunique operation data */ - dptr_init_search_op(conn->dirptr); + dptr_init_search_op(dirptr); if ((dirtype&0x1F) == aVOLID) { char buf[DIR_STRUCT_SIZE]; @@ -1512,14 +1520,14 @@ void reply_search(struct smb_request *req) /DIR_STRUCT_SIZE)); DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n", - conn->dirpath,lp_dontdescend(SNUM(conn)))); - if (in_list(conn->dirpath, lp_dontdescend(SNUM(conn)),True)) { + directory,lp_dontdescend(SNUM(conn)))); + if (in_list(directory, lp_dontdescend(SNUM(conn)),True)) { check_descend = True; } for (i=numentries;(ioutbuf, smb_flg2, (SVAL(req->outbuf, smb_flg2) & (~FLAGS2_UNICODE_STRINGS))); - if (!directory) { - directory = dptr_path(dptr_num); - } - DEBUG(4,("%s mask=%s path=%s dtype=%d nument=%u of %u\n", smb_fn_name(req->cmd), mask, - directory ? directory : "./", + directory, dirtype, numentries, maxentries )); out: + TALLOC_FREE(directory); TALLOC_FREE(smb_fname); END_PROFILE(SMBsearch); return; -- cgit From 59c3f5e3ca8885266fef65261ecae3f51ce78729 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Thu, 6 Aug 2009 12:15:51 +0200 Subject: s3:smbd: move dptr globals into struct smbd_server_connection metze --- source3/smbd/reply.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'source3/smbd/reply.c') 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); -- cgit