[SCM] Samba Shared Repository - branch master updated
Jeremy Allison
jra at samba.org
Mon Feb 13 21:24:01 UTC 2023
The branch, master has been updated
via 5d8647376fb vfs: Fix whitespace in vfs_aixacl_util.c
via 1a040c7f7ee smbd: Remove dptr_struct->expect_close
via a49edcd0d26 smbd: Remove dptr_struct->spid
via 5c19e6ca756 smbd: Simplify SeekDir() with an early return
via a1d348fd5e1 smbd: Simplify struct dptr_struct
via 8846b090079 lib: Fix a typo
via 4bbf2b1127b lib: Simplify ms_has_wild() with strpbrk()
via 6e856074b14 smbd: Use ISDOT() in dptr_create()
from 54a8da86407 vfs_ceph: use fsp_get_pathref_fd in ceph fstatat and close vfs calls
https://git.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 5d8647376fbfe0ad3b479be3a4479f1c9d5ecd7b
Author: Volker Lendecke <vl at samba.org>
Date: Tue Feb 7 09:49:54 2023 +0100
vfs: Fix whitespace in vfs_aixacl_util.c
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
Autobuild-User(master): Jeremy Allison <jra at samba.org>
Autobuild-Date(master): Mon Feb 13 21:23:43 UTC 2023 on atb-devel-224
commit 1a040c7f7eebb4ed549cc59f0b7bab461bf6d06d
Author: Volker Lendecke <vl at samba.org>
Date: Mon Feb 6 21:40:38 2023 +0100
smbd: Remove dptr_struct->expect_close
This was only set but never read
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit a49edcd0d26058e41712e3d069bfe36a463b76dc
Author: Volker Lendecke <vl at samba.org>
Date: Mon Feb 6 21:36:51 2023 +0100
smbd: Remove dptr_struct->spid
This was only set but never read
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 5c19e6ca756fda9dd66fa2cd484e54d0e3e221f0
Author: Volker Lendecke <vl at samba.org>
Date: Thu Feb 2 17:01:16 2023 +0100
smbd: Simplify SeekDir() with an early return
Review with git show -w
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit a1d348fd5e1b16ffc47e320d370a002dc9c9b8eb
Author: Volker Lendecke <vl at samba.org>
Date: Thu Feb 2 12:52:32 2023 +0100
smbd: Simplify struct dptr_struct
We can access the file name via "dir_hnd"
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 8846b0900794c717c6a9f72a743f600ae81f8406
Author: Volker Lendecke <vl at samba.org>
Date: Thu Feb 2 12:28:56 2023 +0100
lib: Fix a typo
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 4bbf2b1127b93efe655360a185567de080faa943
Author: Volker Lendecke <vl at samba.org>
Date: Thu Feb 2 12:25:05 2023 +0100
lib: Simplify ms_has_wild() with strpbrk()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
commit 6e856074b143ea595f3ab9e5184d21bec11b17ae
Author: Volker Lendecke <vl at samba.org>
Date: Thu Feb 2 12:19:46 2023 +0100
smbd: Use ISDOT() in dptr_create()
Signed-off-by: Volker Lendecke <vl at samba.org>
Reviewed-by: Jeremy Allison <jra at samba.org>
-----------------------------------------------------------------------
Summary of changes:
source3/lib/util.c | 17 +----
source3/modules/vfs_aixacl_util.c | 42 ++++++-------
source3/smbd/dir.c | 120 +++++++++++++++++-------------------
source3/smbd/proto.h | 2 -
source3/smbd/smb1_reply.c | 2 -
source3/smbd/smb1_trans2.c | 2 -
source3/smbd/smb2_query_directory.c | 2 -
7 files changed, 79 insertions(+), 108 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/lib/util.c b/source3/lib/util.c
index 83707b31e38..b010d035cdd 100644
--- a/source3/lib/util.c
+++ b/source3/lib/util.c
@@ -1443,19 +1443,8 @@ bool parent_dirname(TALLOC_CTX *mem_ctx, const char *dir, char **parent,
bool ms_has_wild(const char *s)
{
- char c;
-
- while ((c = *s++)) {
- switch (c) {
- case '*':
- case '?':
- case '<':
- case '>':
- case '"':
- return True;
- }
- }
- return False;
+ const char *found = strpbrk(s, "*?<>\"");
+ return (found != NULL);
}
bool ms_has_wild_w(const smb_ucs2_t *s)
@@ -1492,7 +1481,7 @@ bool mask_match(const char *string, const char *pattern, bool is_case_sensitive)
/*******************************************************************
A wrapper that handles case sensitivity and the special handling
- of the ".." name. Varient that is only called by old search code which requires
+ of the ".." name. Variant that is only called by old search code which requires
pattern translation.
*******************************************************************/
diff --git a/source3/modules/vfs_aixacl_util.c b/source3/modules/vfs_aixacl_util.c
index 1194d27df22..38b53eb3f53 100644
--- a/source3/modules/vfs_aixacl_util.c
+++ b/source3/modules/vfs_aixacl_util.c
@@ -26,20 +26,18 @@ SMB_ACL_T aixacl_to_smbacl(struct acl *file_acl, TALLOC_CTX *mem_ctx)
{
struct acl_entry *acl_entry;
struct ace_id *idp;
-
+
struct smb_acl_t *result = sys_acl_init(mem_ctx);
struct smb_acl_entry *ace;
int i;
-
+
if (result == NULL) {
return NULL;
}
-
+
/* Point to the first acl entry in the acl */
acl_entry = file_acl->acl_ext;
-
-
DEBUG(10,("acl_entry is %p\n",(void *)acl_entry));
DEBUG(10,("acl_last(file_acl) id %p\n",(void *)acl_last(file_acl)));
@@ -62,20 +60,19 @@ SMB_ACL_T aixacl_to_smbacl(struct acl *file_acl, TALLOC_CTX *mem_ctx)
idp = acl_entry->ace_id;
DEBUG(10,("idp->id_data is %d\n",idp->id_data[0]));
-
+
result->acl = talloc_realloc(result, result->acl, struct smb_acl_entry, result->count+1);
if (result == NULL) {
DEBUG(0, ("talloc_realloc failed\n"));
errno = ENOMEM;
return NULL;
}
-
DEBUG(10,("idp->id_type is %d\n",idp->id_type));
ace = &result->acl[result->count];
-
+
ace->a_type = idp->id_type;
-
+
switch(ace->a_type) {
case ACEID_USER: {
ace->info.user.uid = idp->id_data[0];
@@ -83,7 +80,7 @@ SMB_ACL_T aixacl_to_smbacl(struct acl *file_acl, TALLOC_CTX *mem_ctx)
ace->a_type = SMB_ACL_USER;
break;
}
-
+
case ACEID_GROUP: {
ace->info.group.gid = idp->id_data[0];
DEBUG(10,("case ACEID_GROUP ace->info.group.gid is %d\n",ace->info.group.gid));
@@ -117,16 +114,16 @@ SMB_ACL_T aixacl_to_smbacl(struct acl *file_acl, TALLOC_CTX *mem_ctx)
TALLOC_FREE(result);
return(0);
}
-
+
result->count++;
ace->a_perm |= (ace->a_perm & S_IRUSR) ? SMB_ACL_READ : 0;
ace->a_perm |= (ace->a_perm & S_IWUSR) ? SMB_ACL_WRITE : 0;
ace->a_perm |= (ace->a_perm & S_IXUSR) ? SMB_ACL_EXECUTE : 0;
DEBUG(10,("ace->a_perm is %d\n",ace->a_perm));
-
+
DEBUG(10,("acl_entry = %p\n",(void *)acl_entry));
DEBUG(10,("The ace_type is %d\n",acl_entry->ace_type));
-
+
acl_entry = acl_nxt(acl_entry);
}
} /* end of if enabled */
@@ -146,13 +143,13 @@ SMB_ACL_T aixacl_to_smbacl(struct acl *file_acl, TALLOC_CTX *mem_ctx)
DEBUG(0,("Error in AIX sys_acl_get_file is %d\n",errno));
return NULL;
}
-
+
ace = &result->acl[result->count];
-
+
ace->info.user.uid = 0;
ace->info.group.gid = 0;
DEBUG(10,("ace->info.user.uid = %d\n",ace->info.user.uid));
-
+
switch(i) {
case 2:
ace->a_perm = file_acl->g_access << 6;
@@ -163,12 +160,12 @@ SMB_ACL_T aixacl_to_smbacl(struct acl *file_acl, TALLOC_CTX *mem_ctx)
ace->a_perm = file_acl->o_access << 6;
ace->a_type = SMB_ACL_OTHER;
break;
-
+
case 1:
ace->a_perm = file_acl->u_access << 6;
ace->a_type = SMB_ACL_USER_OBJ;
break;
-
+
default:
return(NULL);
@@ -176,17 +173,14 @@ SMB_ACL_T aixacl_to_smbacl(struct acl *file_acl, TALLOC_CTX *mem_ctx)
ace->a_perm |= ((ace->a_perm & S_IRUSR) ? SMB_ACL_READ : 0);
ace->a_perm |= ((ace->a_perm & S_IWUSR) ? SMB_ACL_WRITE : 0);
ace->a_perm |= ((ace->a_perm & S_IXUSR) ? SMB_ACL_EXECUTE : 0);
-
+
memcpy(&result->acl[result->count],ace,sizeof(struct smb_acl_entry));
result->count++;
DEBUG(10,("ace->a_perm = %d\n",ace->a_perm));
DEBUG(10,("ace->a_type = %d\n",ace->a_type));
}
-
return result;
-
-
}
static ushort aixacl_smb_to_aixperm(SMB_ACL_PERM_T a_perm)
@@ -211,7 +205,7 @@ struct acl *aixacl_smb_to_aixacl(SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
unsigned int id_type;
unsigned int acl_length;
int i;
-
+
DEBUG(10,("Entering aixacl_smb_to_aixacl\n"));
/* AIX has no default ACL */
if(acltype == SMB_ACL_TYPE_DEFAULT)
@@ -226,7 +220,7 @@ struct acl *aixacl_smb_to_aixacl(SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl)
}
memset(file_acl,0,BUFSIZ);
-
+
file_acl->acl_len = ACL_SIZ;
file_acl->acl_mode = S_IXACL;
diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c
index eb263132adf..859c8f0dc83 100644
--- a/source3/smbd/dir.c
+++ b/source3/smbd/dir.c
@@ -67,13 +67,10 @@ struct smb_Dir {
struct dptr_struct {
struct dptr_struct *next, *prev;
int dnum;
- uint16_t spid;
struct connection_struct *conn;
struct smb_Dir *dir_hnd;
- bool expect_close;
char *wcard;
uint32_t attr;
- struct smb_filename *smb_dname;
bool has_wild; /* Set to true if the wcard entry has MS wildcard characters in it. */
bool did_stat; /* Optimisation for non-wcard searches. */
bool priv; /* Directory handle opened with privilege. */
@@ -144,7 +141,7 @@ const char *dptr_path(struct smbd_server_connection *sconn, int key)
{
struct dptr_struct *dptr = dptr_get(sconn, key);
if (dptr)
- return(dptr->smb_dname->base_name);
+ return(dptr->dir_hnd->dir_smb_fname->base_name);
return(NULL);
}
@@ -211,8 +208,6 @@ NTSTATUS dptr_create(connection_struct *conn,
struct smb_request *req,
files_struct *fsp,
bool old_handle,
- bool expect_close,
- uint16_t spid,
const char *wcard,
uint32_t attr,
struct dptr_struct **dptr_ret)
@@ -251,24 +246,15 @@ NTSTATUS dptr_create(connection_struct *conn,
return NT_STATUS_NO_MEMORY;
}
- dptr->smb_dname = cp_smb_filename(dptr, fsp->fsp_name);
- if (dptr->smb_dname == NULL) {
- TALLOC_FREE(dptr);
- TALLOC_FREE(dir_hnd);
- return NT_STATUS_NO_MEMORY;
- }
dptr->conn = conn;
dptr->dir_hnd = dir_hnd;
- dptr->spid = spid;
- dptr->expect_close = expect_close;
dptr->wcard = talloc_strdup(dptr, wcard);
if (!dptr->wcard) {
TALLOC_FREE(dptr);
TALLOC_FREE(dir_hnd);
return NT_STATUS_NO_MEMORY;
}
- if ((req != NULL && req->posix_pathnames) ||
- (wcard[0] == '.' && wcard[1] == 0)) {
+ if ((req != NULL && req->posix_pathnames) || ISDOT(wcard)) {
dptr->has_wild = True;
} else {
dptr->has_wild = ms_has_wild(dptr->wcard);
@@ -323,8 +309,8 @@ NTSTATUS dptr_create(connection_struct *conn,
DLIST_ADD(sconn->searches.dirptrs, dptr);
done:
- DBG_INFO("creating new dirptr [%d] for path [%s], expect_close = %d\n",
- dptr->dnum, fsp_str_dbg(fsp), expect_close);
+ DBG_INFO("creating new dirptr [%d] for path [%s]\n",
+ dptr->dnum, fsp_str_dbg(fsp));
*dptr_ret = dptr;
@@ -460,7 +446,7 @@ static char *dptr_ReadDirName(TALLOC_CTX *ctx,
pathreal = talloc_asprintf(ctx,
"%s/%s",
- dptr->smb_dname->base_name,
+ dptr->dir_hnd->dir_smb_fname->base_name,
dptr->wcard);
if (!pathreal)
return NULL;
@@ -469,7 +455,7 @@ static char *dptr_ReadDirName(TALLOC_CTX *ctx,
smb_fname_base = (struct smb_filename) {
.base_name = pathreal,
.flags = dptr->dir_hnd->fsp->fsp_name->flags,
- .twrp = dptr->smb_dname->twrp,
+ .twrp = dptr->dir_hnd->fsp->fsp_name->twrp,
};
if (vfs_stat(dptr->conn, &smb_fname_base) == 0) {
@@ -708,8 +694,10 @@ files_struct *dptr_fetch_fsp(struct smbd_server_connection *sconn,
wire_offset = IVAL(buf,1);
seekoff = map_wire_to_dir_offset(dptr, wire_offset);
SeekDir(dptr->dir_hnd,seekoff);
- DEBUG(3,("fetching dirptr %d for path %s at offset %d\n",
- key, dptr->smb_dname->base_name, (int)seekoff));
+ DBG_NOTICE("fetching dirptr %d for path %s at offset %ld\n",
+ key,
+ dptr->dir_hnd->dir_smb_fname->base_name,
+ seekoff);
return dptr->dir_hnd->fsp;
}
@@ -730,8 +718,8 @@ files_struct *dptr_fetch_lanman2_fsp(struct smbd_server_connection *sconn,
return NULL;
}
DBG_NOTICE("fetching dirptr %d for path %s\n",
- dptr_num,
- dptr->smb_dname->base_name);
+ dptr_num,
+ dptr->dir_hnd->dir_smb_fname->base_name);
return dptr->dir_hnd->fsp;
}
@@ -775,7 +763,7 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
connection_struct *conn = dirptr->conn;
size_t slashlen;
size_t pathlen;
- const char *dpath = dirptr->smb_dname->base_name;
+ const char *dpath = dirptr->dir_hnd->dir_smb_fname->base_name;
bool dirptr_path_is_dot = ISDOT(dpath);
NTSTATUS status;
int ret;
@@ -806,7 +794,8 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
dname = dptr_ReadDirName(ctx, dirptr, &cur_offset, &sbuf);
DBG_DEBUG("dir [%s] dirptr [0x%lx] offset [%ld] => dname [%s]\n",
- smb_fname_str_dbg(dirptr->smb_dname), (long)dirptr,
+ smb_fname_str_dbg(dirptr->dir_hnd->dir_smb_fname),
+ (long)dirptr,
cur_offset, dname ? dname : "(finished)");
if (dname == NULL) {
@@ -866,12 +855,13 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
}
/* Create smb_fname with NULL stream_name. */
- smb_fname = synthetic_smb_fname(talloc_tos(),
- pathreal,
- NULL,
- &sbuf,
- dirptr->smb_dname->twrp,
- dirptr->smb_dname->flags);
+ smb_fname = synthetic_smb_fname(
+ talloc_tos(),
+ pathreal,
+ NULL,
+ &sbuf,
+ dirptr->dir_hnd->dir_smb_fname->twrp,
+ dirptr->dir_hnd->dir_smb_fname->flags);
TALLOC_FREE(pathreal);
if (smb_fname == NULL) {
TALLOC_FREE(dname);
@@ -896,12 +886,13 @@ bool smbd_dirptr_get_entry(TALLOC_CTX *ctx,
}
/* Create smb_fname with NULL stream_name. */
- atname = synthetic_smb_fname(talloc_tos(),
- dname,
- NULL,
- &smb_fname->st,
- dirptr->smb_dname->twrp,
- dirptr->smb_dname->flags);
+ atname = synthetic_smb_fname(
+ talloc_tos(),
+ dname,
+ NULL,
+ &smb_fname->st,
+ dirptr->dir_hnd->dir_smb_fname->twrp,
+ dirptr->dir_hnd->dir_smb_fname->flags);
if (atname == NULL) {
TALLOC_FREE(dname);
TALLOC_FREE(fname);
@@ -1689,31 +1680,36 @@ void RewindDir(struct smb_Dir *dir_hnd, long *poffset)
void SeekDir(struct smb_Dir *dirp, long offset)
{
- if (offset != dirp->offset) {
- if (offset == START_OF_DIRECTORY_OFFSET) {
- RewindDir(dirp, &offset);
- /*
- * Ok we should really set the file number here
- * to 1 to enable ".." to be returned next. Trouble
- * is I'm worried about callers using SeekDir(dirp,0)
- * as equivalent to RewindDir(). So leave this alone
- * for now.
- */
- } else if (offset == DOT_DOT_DIRECTORY_OFFSET) {
- RewindDir(dirp, &offset);
- /*
- * Set the file number to 2 - we want to get the first
- * real file entry (the one we return after "..")
- * on the next ReadDir.
- */
- dirp->file_number = 2;
- } else if (offset == END_OF_DIRECTORY_OFFSET) {
- ; /* Don't seek in this case. */
- } else {
- SMB_VFS_SEEKDIR(dirp->conn, dirp->dir, offset);
- }
- dirp->offset = offset;
+ if (offset == dirp->offset) {
+ /*
+ * Nothing to do
+ */
+ return;
+ }
+
+ if (offset == START_OF_DIRECTORY_OFFSET) {
+ RewindDir(dirp, &offset);
+ /*
+ * Ok we should really set the file number here
+ * to 1 to enable ".." to be returned next. Trouble
+ * is I'm worried about callers using SeekDir(dirp,0)
+ * as equivalent to RewindDir(). So leave this alone
+ * for now.
+ */
+ } else if (offset == DOT_DOT_DIRECTORY_OFFSET) {
+ RewindDir(dirp, &offset);
+ /*
+ * Set the file number to 2 - we want to get the first
+ * real file entry (the one we return after "..")
+ * on the next ReadDir.
+ */
+ dirp->file_number = 2;
+ } else if (offset == END_OF_DIRECTORY_OFFSET) {
+ ; /* Don't seek in this case. */
+ } else {
+ SMB_VFS_SEEKDIR(dirp->conn, dirp->dir, offset);
}
+ dirp->offset = offset;
}
/*******************************************************************
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index 32e5c33896b..486d136bfbb 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -187,8 +187,6 @@ NTSTATUS dptr_create(connection_struct *conn,
struct smb_request *req,
files_struct *fsp,
bool old_handle,
- bool expect_close,
- uint16_t spid,
const char *wcard,
uint32_t attr,
struct dptr_struct **dptr_ret);
diff --git a/source3/smbd/smb1_reply.c b/source3/smbd/smb1_reply.c
index de6b4d99f79..1041e4f843b 100644
--- a/source3/smbd/smb1_reply.c
+++ b/source3/smbd/smb1_reply.c
@@ -1179,8 +1179,6 @@ void reply_search(struct smb_request *req)
NULL, /* req */
fsp, /* fsp */
True,
- expect_close,
- req->smbpid,
mask,
dirtype,
&fsp->dptr);
diff --git a/source3/smbd/smb1_trans2.c b/source3/smbd/smb1_trans2.c
index 336024c9456..87c5ec697b5 100644
--- a/source3/smbd/smb1_trans2.c
+++ b/source3/smbd/smb1_trans2.c
@@ -1059,8 +1059,6 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
req,
fsp, /* fsp */
False,
- True,
- req->smbpid,
mask,
dirtype,
&fsp->dptr);
diff --git a/source3/smbd/smb2_query_directory.c b/source3/smbd/smb2_query_directory.c
index 2d58741738c..250b56633bb 100644
--- a/source3/smbd/smb2_query_directory.c
+++ b/source3/smbd/smb2_query_directory.c
@@ -426,8 +426,6 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
NULL, /* req */
fsp,
false, /* old_handle */
- false, /* expect_close */
- 0, /* spid */
state->in_file_name, /* wcard */
state->dirtype,
&fsp->dptr);
--
Samba Shared Repository
More information about the samba-cvs
mailing list