summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/include/proto.h2
-rw-r--r--source3/include/smb.h2
-rw-r--r--source3/smbd/conn.c2
-rw-r--r--source3/smbd/dir.c11
-rw-r--r--source3/smbd/reply.c33
-rw-r--r--source3/smbd/service.c2
-rw-r--r--source3/smbd/trans2.c46
7 files changed, 47 insertions, 51 deletions
diff --git a/source3/include/proto.h b/source3/include/proto.h
index e4523a1625..b00a08446a 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -6208,7 +6208,7 @@ struct dptr_struct *dptr_fetch(char *buf,int *num);
struct dptr_struct *dptr_fetch_lanman2(int dptr_num);
bool dir_check_ftype(connection_struct *conn, uint32 mode, uint32 dirtype);
bool get_dir_entry(TALLOC_CTX *ctx,
- connection_struct *conn,
+ struct dptr_struct *dirptr,
const char *mask,
uint32 dirtype,
char **pp_fname_out,
diff --git a/source3/include/smb.h b/source3/include/smb.h
index c33c5363f3..b53735d36d 100644
--- a/source3/include/smb.h
+++ b/source3/include/smb.h
@@ -551,12 +551,10 @@ typedef struct connection_struct {
struct share_params *params;
bool force_user;
struct vuid_cache vuid_cache;
- struct dptr_struct *dirptr;
bool printer;
bool ipc;
bool read_only; /* Attributes for the current user of the share. */
bool admin_user; /* Attributes for the current user of the share. */
- char *dirpath;
char *connectpath;
char *origpath;
diff --git a/source3/smbd/conn.c b/source3/smbd/conn.c
index da67db978b..959fcd7754 100644
--- a/source3/smbd/conn.c
+++ b/source3/smbd/conn.c
@@ -163,7 +163,6 @@ find_again:
sconn->smb1.tcons.num_open++;
- string_set(&conn->dirpath,"");
string_set(&conn->connectpath,"");
string_set(&conn->origpath,"");
@@ -284,7 +283,6 @@ static void conn_free_internal(connection_struct *conn)
free_namearray(conn->veto_oplock_list);
free_namearray(conn->aio_write_behind_list);
- string_free(&conn->dirpath);
string_free(&conn->connectpath);
string_free(&conn->origpath);
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index e2f8e69449..1c84decbde 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -407,8 +407,6 @@ NTSTATUS dptr_create(connection_struct *conn, const char *path, bool old_handle,
return map_nt_error_from_unix(errno);
}
- string_set(&conn->dirpath,path);
-
if (dirhandles_open >= MAX_OPEN_DIRECTORIES) {
dptr_idleoldest();
}
@@ -1030,7 +1028,7 @@ static bool smbd_dirptr_8_3_mode_fn(TALLOC_CTX *ctx,
}
bool get_dir_entry(TALLOC_CTX *ctx,
- connection_struct *conn,
+ struct dptr_struct *dirptr,
const char *mask,
uint32_t dirtype,
char **_fname,
@@ -1040,18 +1038,15 @@ bool get_dir_entry(TALLOC_CTX *ctx,
bool check_descend,
bool ask_sharemode)
{
+ connection_struct *conn = dirptr->conn;
char *fname = NULL;
struct smb_filename *smb_fname = NULL;
uint32_t mode = 0;
long prev_offset;
bool ok;
- if (!conn->dirptr) {
- return false;
- }
-
ok = smbd_dirptr_get_entry(ctx,
- conn->dirptr,
+ dirptr,
mask,
dirtype,
check_descend,
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;(i<maxentries) && !finished;i++) {
finished = !get_dir_entry(ctx,
- conn,
+ dirptr,
mask,
dirtype,
&fname,
@@ -1597,18 +1605,15 @@ void reply_search(struct smb_request *req)
SSVAL(req->outbuf, 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;
diff --git a/source3/smbd/service.c b/source3/smbd/service.c
index c24b2264c1..fc56105adf 100644
--- a/source3/smbd/service.c
+++ b/source3/smbd/service.c
@@ -692,7 +692,6 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
conn->printer = (strncmp(dev,"LPT",3) == 0);
conn->ipc = ( (strncmp(dev,"IPC",3) == 0) ||
( lp_enable_asu_support() && strequal(dev,"ADMIN$")) );
- conn->dirptr = NULL;
/* Case options for the share. */
if (lp_casesensitive(snum) == Auto) {
@@ -712,7 +711,6 @@ connection_struct *make_connection_snum(struct smbd_server_connection *sconn,
conn->hide_list = NULL;
conn->veto_oplock_list = NULL;
conn->aio_write_behind_list = NULL;
- string_set(&conn->dirpath,"");
conn->read_only = lp_readonly(SNUM(conn));
conn->admin_user = False;
diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
index e48ffac150..3f93b3d571 100644
--- a/source3/smbd/trans2.c
+++ b/source3/smbd/trans2.c
@@ -1448,6 +1448,7 @@ static bool smbd_dirptr_lanman2_mode_fn(TALLOC_CTX *ctx,
static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
connection_struct *conn,
+ struct dptr_struct *dirptr,
uint16 flags2,
const char *path_mask,
uint32 dirtype,
@@ -1487,7 +1488,7 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
state.conn = conn;
state.info_level = info_level;
state.check_mangled_names = lp_manglednames(conn->params);
- state.has_wild = dptr_has_wild(conn->dirptr);
+ state.has_wild = dptr_has_wild(dirptr);
state.got_exact_match = false;
*out_of_space = False;
@@ -1497,10 +1498,6 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
ZERO_STRUCT(adate_ts);
ZERO_STRUCT(create_date_ts);
- if (!conn->dirptr) {
- return false;
- }
-
p = strrchr_m(path_mask,'/');
if(p != NULL) {
if(p[1] == '\0') {
@@ -1513,7 +1510,7 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
}
ok = smbd_dirptr_get_entry(ctx,
- conn->dirptr,
+ dirptr,
mask,
dirtype,
dont_descend,
@@ -1666,7 +1663,7 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
TALLOC_FREE(fname);
TALLOC_FREE(smb_fname);
/* Move the dirptr back to prev_dirpos */
- dptr_SeekDir(conn->dirptr, prev_dirpos);
+ dptr_SeekDir(dirptr, prev_dirpos);
*out_of_space = True;
DEBUG(9,("get_lanman2_dir_entry: out of space\n"));
return False; /* Not finished - just out of space */
@@ -1964,7 +1961,7 @@ static bool get_lanman2_dir_entry(TALLOC_CTX *ctx,
if (PTR_DIFF(p,pdata) > space_remaining) {
/* Move the dirptr back to prev_dirpos */
- dptr_SeekDir(conn->dirptr, prev_dirpos);
+ dptr_SeekDir(dirptr, prev_dirpos);
*out_of_space = True;
DEBUG(9,("get_lanman2_dir_entry: out of space\n"));
return False; /* Not finished - just out of space */
@@ -2020,6 +2017,7 @@ static void call_trans2findfirst(connection_struct *conn,
NTSTATUS ntstatus = NT_STATUS_OK;
bool ask_sharemode = lp_parm_bool(SNUM(conn), "smbd", "search ask sharemode", true);
TALLOC_CTX *ctx = talloc_tos();
+ struct dptr_struct *dirptr = NULL;
if (total_params < 13) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
@@ -2177,24 +2175,25 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
mask,
mask_contains_wcard,
dirtype,
- &conn->dirptr);
+ &dirptr);
if (!NT_STATUS_IS_OK(ntstatus)) {
reply_nterror(req, ntstatus);
goto out;
}
- dptr_num = dptr_dnum(conn->dirptr);
+ dptr_num = dptr_dnum(dirptr);
DEBUG(4,("dptr_num is %d, wcard = %s, attr = %d\n", dptr_num, mask, dirtype));
/* Initialize per TRANS2_FIND_FIRST operation data */
- dptr_init_search_op(conn->dirptr);
+ dptr_init_search_op(dirptr);
/* We don't need to check for VOL here as this is returned by
a different TRANS2 call. */
- DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n", conn->dirpath,lp_dontdescend(SNUM(conn))));
- if (in_list(conn->dirpath,lp_dontdescend(SNUM(conn)),conn->case_sensitive))
+ DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",
+ directory,lp_dontdescend(SNUM(conn))));
+ if (in_list(directory,lp_dontdescend(SNUM(conn)),conn->case_sensitive))
dont_descend = True;
p = pdata;
@@ -2212,6 +2211,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
} else {
finished = !get_lanman2_dir_entry(ctx,
conn,
+ dirptr,
req->flags2,
mask,dirtype,info_level,
requires_resume_key,dont_descend,
@@ -2355,6 +2355,7 @@ static void call_trans2findnext(connection_struct *conn,
NTSTATUS ntstatus = NT_STATUS_OK;
bool ask_sharemode = lp_parm_bool(SNUM(conn), "smbd", "search ask sharemode", true);
TALLOC_CTX *ctx = talloc_tos();
+ struct dptr_struct *dirptr;
if (total_params < 13) {
reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
@@ -2476,12 +2477,12 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
params = *pparams;
/* Check that the dptr is valid */
- if(!(conn->dirptr = dptr_fetch_lanman2(dptr_num))) {
+ if(!(dirptr = dptr_fetch_lanman2(dptr_num))) {
reply_doserror(req, ERRDOS, ERRnofiles);
return;
}
- string_set(&conn->dirpath,dptr_path(dptr_num));
+ directory = dptr_path(dptr_num);
/* Get the wildcard mask from the dptr */
if((p = dptr_wcard(dptr_num))== NULL) {
@@ -2491,24 +2492,24 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
}
mask = p;
- directory = conn->dirpath;
/* Get the attr mask from the dptr */
dirtype = dptr_attr(dptr_num);
DEBUG(3,("dptr_num is %d, mask = %s, attr = %x, dirptr=(0x%lX,%ld)\n",
dptr_num, mask, dirtype,
- (long)conn->dirptr,
- dptr_TellDir(conn->dirptr)));
+ (long)dirptr,
+ dptr_TellDir(dirptr)));
/* Initialize per TRANS2_FIND_NEXT operation data */
- dptr_init_search_op(conn->dirptr);
+ dptr_init_search_op(dirptr);
/* We don't need to check for VOL here as this is returned by
a different TRANS2 call. */
- DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",conn->dirpath,lp_dontdescend(SNUM(conn))));
- if (in_list(conn->dirpath,lp_dontdescend(SNUM(conn)),conn->case_sensitive))
+ DEBUG(8,("dirpath=<%s> dontdescend=<%s>\n",
+ directory,lp_dontdescend(SNUM(conn))));
+ if (in_list(directory,lp_dontdescend(SNUM(conn)),conn->case_sensitive))
dont_descend = True;
p = pdata;
@@ -2550,7 +2551,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
* should already be at the correct place.
*/
- finished = !dptr_SearchDir(conn->dirptr, resume_name, &current_pos, &st);
+ finished = !dptr_SearchDir(dirptr, resume_name, &current_pos, &st);
} /* end if resume_name && !continue_bit */
for (i=0;(i<(int)maxentries) && !finished && !out_of_space ;i++) {
@@ -2564,6 +2565,7 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
} else {
finished = !get_lanman2_dir_entry(ctx,
conn,
+ dirptr,
req->flags2,
mask,dirtype,info_level,
requires_resume_key,dont_descend,