[PATCH] More smb_filename cleanups.
Jeremy Allison
jra at samba.org
Fri Mar 11 03:15:52 UTC 2016
Here is a short, easy to review patchset
that removes one lp_posix_pathname, fixes
on VFS module that got missed in the get_nt_acl_fn
changes, and finally fixes up some of the functions that
call into utility functions that call
lp_posix_pathnames() to take a const
struct smb_filename * instead of a
const char *.
Passes local make test.
Please review and push if happy !
Jeremy.
-------------- next part --------------
>From 0c1d10832b3282a8557692ec2a7ac082c5d36a30 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Thu, 10 Mar 2016 15:15:34 -0800
Subject: [PATCH 1/5] s3: smbd: Remove the last lp_posix_pathnames() in the
rename path.
Signed-off-by: Jeremy Allison <jra at samba.org>
---
source3/smbd/reply.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index b88c2cf..c18eb38 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -6808,7 +6808,7 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
smb_fname_str_dbg(smb_fname_dst)));
if (!fsp->is_directory &&
- !lp_posix_pathnames() &&
+ !(fsp->posix_flags & FSP_POSIX_FLAGS_PATHNAMES) &&
(lp_map_archive(SNUM(conn)) ||
lp_store_dos_attributes(SNUM(conn)))) {
/* We must set the archive bit on the newly
--
2.5.0
>From 4060bcf8f4c5ca8eccefbf642b4754f9905defdd Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Thu, 10 Mar 2016 15:34:58 -0800
Subject: [PATCH 2/5] s3:smbd: Fix build for vfs_aixacl2.c.
Missed conversion of get_nt_acl_fn from const char *
to const struct smb_filename *.
Signed-off-by: Jeremy Allison <jra at samba.org>
---
source3/modules/vfs_aixacl2.c | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c
index a70013d..b956d4d 100644
--- a/source3/modules/vfs_aixacl2.c
+++ b/source3/modules/vfs_aixacl2.c
@@ -186,7 +186,7 @@ static NTSTATUS aixjfs2_fget_nt_acl(vfs_handle_struct *handle,
}
static NTSTATUS aixjfs2_get_nt_acl(vfs_handle_struct *handle,
- const char *name,
+ const struct smb_filename *smb_fname,
uint32_t security_info,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc)
@@ -196,19 +196,28 @@ static NTSTATUS aixjfs2_get_nt_acl(vfs_handle_struct *handle,
bool retryPosix = False;
*ppdesc = NULL;
- result = aixjfs2_get_nfs4_acl(mem_ctx, name, &pacl, &retryPosix);
+ result = aixjfs2_get_nfs4_acl(mem_ctx,
+ smb_fname->base_name,
+ &pacl,
+ &retryPosix);
if (retryPosix)
{
DEBUG(10, ("retrying with posix acl...\n"));
- return posix_get_nt_acl(handle->conn, name, security_info,
- mem_ctx, ppdesc);
+ return posix_get_nt_acl(handle->conn,
+ smb_fname->base_name,
+ security_info,
+ mem_ctx,
+ ppdesc);
}
if (result==False)
return NT_STATUS_ACCESS_DENIED;
- return smb_get_nt_acl_nfs4(handle->conn, name, security_info,
- mem_ctx, ppdesc,
- pacl);
+ return smb_get_nt_acl_nfs4(handle->conn,
+ smb_fname->base_name,
+ security_info,
+ mem_ctx,
+ ppdesc,
+ pacl);
}
static int aixjfs2_sys_acl_blob_get_file(vfs_handle_struct *handle, const char *path_p, TALLOC_CTX *mem_ctx, char **blob_description, DATA_BLOB *blob)
--
2.5.0
>From efb765bf593bb9efb93b5ce6909550ed6b26410c Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Thu, 10 Mar 2016 15:56:51 -0800
Subject: [PATCH 3/5] s3:smbd:vfs: Change smb_get_nt_acl_nfs4() to take a const
struct smb_filename *.
Push the struct further down closer to places that use
lp_posix_pathname() functions.
Signed-off-by: Jeremy Allison <jra at samba.org>
---
source3/modules/nfs4_acls.c | 7 ++++---
source3/modules/nfs4_acls.h | 2 +-
source3/modules/vfs_aixacl2.c | 2 +-
source3/modules/vfs_gpfs.c | 2 +-
source3/modules/vfs_nfs4acl_xattr.c | 2 +-
source3/modules/vfs_zfsacl.c | 2 +-
6 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index 26a98b7..c3c1528 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -557,7 +557,7 @@ NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
}
NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
- const char *name,
+ const struct smb_filename *smb_fname,
uint32_t security_info,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc,
@@ -566,9 +566,10 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
SMB_STRUCT_STAT sbuf;
smbacl4_vfs_params params;
- DEBUG(10, ("smb_get_nt_acl_nfs4 invoked for %s\n", name));
+ DEBUG(10, ("smb_get_nt_acl_nfs4 invoked for %s\n",
+ smb_fname->base_name));
- if (smbacl4_GetFileOwner(conn, name, &sbuf)) {
+ if (smbacl4_GetFileOwner(conn, smb_fname->base_name, &sbuf)) {
return map_nt_error_from_unix(errno);
}
diff --git a/source3/modules/nfs4_acls.h b/source3/modules/nfs4_acls.h
index e11845e..588e8ea 100644
--- a/source3/modules/nfs4_acls.h
+++ b/source3/modules/nfs4_acls.h
@@ -136,7 +136,7 @@ NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
struct security_descriptor **ppdesc, struct SMB4ACL_T *theacl);
NTSTATUS smb_get_nt_acl_nfs4(connection_struct *conn,
- const char *name,
+ const struct smb_filename *smb_fname,
uint32_t security_info,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc, struct SMB4ACL_T *theacl);
diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c
index b956d4d..0efcc00 100644
--- a/source3/modules/vfs_aixacl2.c
+++ b/source3/modules/vfs_aixacl2.c
@@ -213,7 +213,7 @@ static NTSTATUS aixjfs2_get_nt_acl(vfs_handle_struct *handle,
return NT_STATUS_ACCESS_DENIED;
return smb_get_nt_acl_nfs4(handle->conn,
- smb_fname->base_name,
+ smb_fname,
security_info,
mem_ctx,
ppdesc,
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index cc17d2a..c9cc88d 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -613,7 +613,7 @@ static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle,
result = gpfs_get_nfs4_acl(frame, smb_fname->base_name, &pacl);
if (result == 0) {
- status = smb_get_nt_acl_nfs4(handle->conn, smb_fname->base_name,
+ status = smb_get_nt_acl_nfs4(handle->conn, smb_fname,
security_info, mem_ctx, ppdesc,
pacl);
TALLOC_FREE(frame);
diff --git a/source3/modules/vfs_nfs4acl_xattr.c b/source3/modules/vfs_nfs4acl_xattr.c
index c02fd6a..af84b8b 100644
--- a/source3/modules/vfs_nfs4acl_xattr.c
+++ b/source3/modules/vfs_nfs4acl_xattr.c
@@ -560,7 +560,7 @@ static NTSTATUS nfs4acl_xattr_get_nt_acl(struct vfs_handle_struct *handle,
return status;
}
- status = smb_get_nt_acl_nfs4(handle->conn, name, security_info,
+ status = smb_get_nt_acl_nfs4(handle->conn, smb_fname, security_info,
mem_ctx, ppdesc,
pacl);
TALLOC_FREE(frame);
diff --git a/source3/modules/vfs_zfsacl.c b/source3/modules/vfs_zfsacl.c
index 7dc7cec..18f1356 100644
--- a/source3/modules/vfs_zfsacl.c
+++ b/source3/modules/vfs_zfsacl.c
@@ -233,7 +233,7 @@ static NTSTATUS zfsacl_get_nt_acl(struct vfs_handle_struct *handle,
}
status = smb_get_nt_acl_nfs4(handle->conn,
- smb_fname->base_name,
+ smb_fname,
security_info,
mem_ctx,
ppdesc,
--
2.5.0
>From e6d1df132cf39279c2baba9935c072dc41d7d8d1 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Thu, 10 Mar 2016 16:05:48 -0800
Subject: [PATCH 4/5] s3:smbd:vfs: Change posix_get_nt_acl() from const char *
to const struct smb_filename *.
Signed-off-by: Jeremy Allison <jra at samba.org>
---
source3/modules/vfs_aixacl2.c | 2 +-
source3/modules/vfs_default.c | 2 +-
source3/modules/vfs_gpfs.c | 2 +-
source3/smbd/posix_acls.c | 48 ++++++++++++++++++++++++++-----------------
source3/smbd/proto.h | 9 ++++----
5 files changed, 37 insertions(+), 26 deletions(-)
diff --git a/source3/modules/vfs_aixacl2.c b/source3/modules/vfs_aixacl2.c
index 0efcc00..1c9f84b 100644
--- a/source3/modules/vfs_aixacl2.c
+++ b/source3/modules/vfs_aixacl2.c
@@ -204,7 +204,7 @@ static NTSTATUS aixjfs2_get_nt_acl(vfs_handle_struct *handle,
{
DEBUG(10, ("retrying with posix acl...\n"));
return posix_get_nt_acl(handle->conn,
- smb_fname->base_name,
+ smb_fname,
security_info,
mem_ctx,
ppdesc);
diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index ee9ddb2..ea7dc2c 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -2344,7 +2344,7 @@ static NTSTATUS vfswrap_get_nt_acl(vfs_handle_struct *handle,
START_PROFILE(get_nt_acl);
result = posix_get_nt_acl(handle->conn,
- smb_fname->base_name,
+ smb_fname,
security_info,
mem_ctx,
ppdesc);
diff --git a/source3/modules/vfs_gpfs.c b/source3/modules/vfs_gpfs.c
index c9cc88d..09e37fa 100644
--- a/source3/modules/vfs_gpfs.c
+++ b/source3/modules/vfs_gpfs.c
@@ -622,7 +622,7 @@ static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle,
if (result > 0) {
DEBUG(10, ("retrying with posix acl...\n"));
- status = posix_get_nt_acl(handle->conn, smb_fname->base_name,
+ status = posix_get_nt_acl(handle->conn, smb_fname,
security_info, mem_ctx, ppdesc);
TALLOC_FREE(frame);
return status;
diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c
index ac296e2..c4eeb9c 100644
--- a/source3/smbd/posix_acls.c
+++ b/source3/smbd/posix_acls.c
@@ -3516,7 +3516,7 @@ NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info,
/* can it happen that fsp_name == NULL ? */
if (fsp->is_directory || fsp->fh->fd == -1) {
- status = posix_get_nt_acl(fsp->conn, fsp->fsp_name->base_name,
+ status = posix_get_nt_acl(fsp->conn, fsp->fsp_name,
security_info, mem_ctx, ppdesc);
TALLOC_FREE(frame);
return status;
@@ -3540,31 +3540,36 @@ NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info,
return status;
}
-NTSTATUS posix_get_nt_acl(struct connection_struct *conn, const char *name,
- uint32_t security_info,
- TALLOC_CTX *mem_ctx,
- struct security_descriptor **ppdesc)
+NTSTATUS posix_get_nt_acl(struct connection_struct *conn,
+ const struct smb_filename *smb_fname_in,
+ uint32_t security_info,
+ TALLOC_CTX *mem_ctx,
+ struct security_descriptor **ppdesc)
{
SMB_ACL_T posix_acl = NULL;
SMB_ACL_T def_acl = NULL;
struct pai_val *pal;
- struct smb_filename smb_fname;
+ struct smb_filename *smb_fname = NULL;
int ret;
TALLOC_CTX *frame = talloc_stackframe();
NTSTATUS status;
*ppdesc = NULL;
- DEBUG(10,("posix_get_nt_acl: called for file %s\n", name ));
+ DEBUG(10,("posix_get_nt_acl: called for file %s\n",
+ smb_fname_in->base_name ));
- ZERO_STRUCT(smb_fname);
- smb_fname.base_name = discard_const_p(char, name);
+ smb_fname = cp_smb_filename(talloc_tos(), smb_fname_in);
+ if (smb_fname == NULL) {
+ TALLOC_FREE(frame);
+ return NT_STATUS_NO_MEMORY;
+ }
/* Get the stat struct for the owner info. */
if (lp_posix_pathnames()) {
- ret = SMB_VFS_LSTAT(conn, &smb_fname);
+ ret = SMB_VFS_LSTAT(conn, smb_fname);
} else {
- ret = SMB_VFS_STAT(conn, &smb_fname);
+ ret = SMB_VFS_STAT(conn, smb_fname);
}
if (ret == -1) {
@@ -3573,22 +3578,27 @@ NTSTATUS posix_get_nt_acl(struct connection_struct *conn, const char *name,
}
/* Get the ACL from the path. */
- posix_acl = SMB_VFS_SYS_ACL_GET_FILE(conn, name,
+ posix_acl = SMB_VFS_SYS_ACL_GET_FILE(conn, smb_fname->base_name,
SMB_ACL_TYPE_ACCESS, frame);
/* If it's a directory get the default POSIX ACL. */
- if(S_ISDIR(smb_fname.st.st_ex_mode)) {
- def_acl = SMB_VFS_SYS_ACL_GET_FILE(conn, name,
+ if(S_ISDIR(smb_fname->st.st_ex_mode)) {
+ def_acl = SMB_VFS_SYS_ACL_GET_FILE(conn, smb_fname->base_name,
SMB_ACL_TYPE_DEFAULT, frame);
def_acl = free_empty_sys_acl(conn, def_acl);
}
- pal = load_inherited_info(conn, name);
+ pal = load_inherited_info(conn, smb_fname->base_name);
- status = posix_get_nt_acl_common(conn, name, &smb_fname.st, pal,
- posix_acl, def_acl, security_info,
- mem_ctx,
- ppdesc);
+ status = posix_get_nt_acl_common(conn,
+ smb_fname->base_name,
+ &smb_fname->st,
+ pal,
+ posix_acl,
+ def_acl,
+ security_info,
+ mem_ctx,
+ ppdesc);
TALLOC_FREE(frame);
return status;
}
diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h
index e1ec063..f9ae4a3 100644
--- a/source3/smbd/proto.h
+++ b/source3/smbd/proto.h
@@ -751,10 +751,11 @@ SMB_ACL_T free_empty_sys_acl(connection_struct *conn, SMB_ACL_T the_acl);
NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info,
TALLOC_CTX *mem_ctx,
struct security_descriptor **ppdesc);
-NTSTATUS posix_get_nt_acl(struct connection_struct *conn, const char *name,
- uint32_t security_info,
- TALLOC_CTX *mem_ctx,
- struct security_descriptor **ppdesc);
+NTSTATUS posix_get_nt_acl(struct connection_struct *conn,
+ const struct smb_filename *smb_fname_in,
+ uint32_t security_info,
+ TALLOC_CTX *mem_ctx,
+ struct security_descriptor **ppdesc);
NTSTATUS try_chown(files_struct *fsp, uid_t uid, gid_t gid);
NTSTATUS set_nt_acl(files_struct *fsp, uint32_t security_info_sent, const struct security_descriptor *psd);
int get_acl_group_bits( connection_struct *conn, const char *fname, mode_t *mode );
--
2.5.0
>From 5448049a18a3b5694b6ede92d1aad7c8d59025d2 Mon Sep 17 00:00:00 2001
From: Jeremy Allison <jra at samba.org>
Date: Thu, 10 Mar 2016 16:17:32 -0800
Subject: [PATCH 5/5] s3:vfs: Change smbacl4_GetFileOwner() to take const
struct smb_filename * from const char *.
Preparing to remove vfs_stat_smb_basename() call.
Signed-off-by: Jeremy Allison <jra at samba.org>
---
source3/modules/nfs4_acls.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/source3/modules/nfs4_acls.c b/source3/modules/nfs4_acls.c
index c3c1528..349b26b 100644
--- a/source3/modules/nfs4_acls.c
+++ b/source3/modules/nfs4_acls.c
@@ -268,13 +268,13 @@ bool smbacl4_set_controlflags(struct SMB4ACL_T *acl, uint16_t controlflags)
}
static int smbacl4_GetFileOwner(struct connection_struct *conn,
- const char *filename,
+ const struct smb_filename *smb_fname,
SMB_STRUCT_STAT *psbuf)
{
ZERO_STRUCTP(psbuf);
/* Get the stat struct for the owner info. */
- if (vfs_stat_smb_basename(conn, filename, psbuf) != 0)
+ if (vfs_stat_smb_basename(conn, smb_fname->base_name, psbuf) != 0)
{
DEBUG(8, ("vfs_stat_smb_basename failed with error %s\n",
strerror(errno)));
@@ -290,7 +290,7 @@ static int smbacl4_fGetFileOwner(files_struct *fsp, SMB_STRUCT_STAT *psbuf)
if (fsp->fh->fd == -1) {
return smbacl4_GetFileOwner(fsp->conn,
- fsp->fsp_name->base_name, psbuf);
+ fsp->fsp_name, psbuf);
}
if (SMB_VFS_FSTAT(fsp, psbuf) != 0)
{
@@ -569,7 +569,7 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
DEBUG(10, ("smb_get_nt_acl_nfs4 invoked for %s\n",
smb_fname->base_name));
- if (smbacl4_GetFileOwner(conn, smb_fname->base_name, &sbuf)) {
+ if (smbacl4_GetFileOwner(conn, smb_fname, &sbuf)) {
return map_nt_error_from_unix(errno);
}
@@ -968,7 +968,7 @@ NTSTATUS smb_set_nt_acl_nfs4(vfs_handle_struct *handle, files_struct *fsp,
fsp_str_dbg(fsp), (unsigned int)newUID,
(unsigned int)newGID));
if (smbacl4_GetFileOwner(fsp->conn,
- fsp->fsp_name->base_name,
+ fsp->fsp_name,
&sbuf)){
TALLOC_FREE(frame);
return map_nt_error_from_unix(errno);
--
2.5.0
More information about the samba-technical
mailing list