The branch, master has been updated via c8c3c547646 s3: smbd: In call_trans2qfilepathinfo(), remove unneeded vfs_stat(). via 6000d3408e3 s3: smbd: In call_trans2qfilepathinfo(), we must have an existing object in the QPATHINFO case. via 834aa7bb011 s3: smbd: Inside call_trans2setfilepathinfo(), for the TRANSACT2_SETPATHINFO case, we don't need to re-stat. via d508dff6345 s3: smbd: Inside call_trans2setfilepathinfo(), for the TRANSACT2_SETPATHINFO case, ensure we have a VALID_STAT return from filename_convert(). via eabcaa2e554 s3: smbd: call_trans2setfilepathinfo(), TRANSACT2_SETFILEINFO case, use helper function vfs_stat(). via de88369c358 s3: smbd: In call_trans2qfilepathinfo(), TRANSACT2_QPATHINFO, use helper function vfs_stat(). via 80e3f4e5ca6 s3: smbd: In call_trans2qfilepathinfo(), TRANSACT2_QPATHINFO on a named stream case, use helper function vfs_stat(). via 8c0f34f0570 s3: smbd: In call_trans2qfilepathinfo(), TRANSACT2_QFILEINFO case, use helper function vfs_stat(). via eb0e68d0e7a s3: smbd: In parent_dirname_compatible_open(), use helper function vfs_stat(). via 04a4cd2ada7 s3: smbd: In vfs_stat_smb_basename() use vfs_stat() helper function. via b0a41119f4c s3: smbd: In smbd_smb2_getinfo_send(), use vfs_stat() utility function. via da2d61ba80d s3: smbd: In stat_cache_lookup(), remove unused posix_paths param. via d8f09c1bf09 s3: smbd: In stat_cache_lookup(), use vfs_stat() utility function. via c94d919fd9c s3: smbd: In setup_close_full_information() the posix_open parameter is not needed anymore. via 89574ed33ba s3: smbd: In setup_close_full_information() use vfs_stat() helper function. via 8767f60a0a2 s3: smbd: In check_parent_exists() use utility function vfs_stat(). from 0f4eca775aa tests/krb5: Add tests for AS-REQ to self with FAST
https://git.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit c8c3c547646c2f91c63b5a195476d5bed88ae2a1 Author: Jeremy Allison <j...@samba.org> Date: Tue Dec 14 09:50:12 2021 -0800 s3: smbd: In call_trans2qfilepathinfo(), remove unneeded vfs_stat(). We know at this point that we have VALID_STAT(smb_fname->st). Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Wed Dec 15 19:26:50 UTC 2021 on sn-devel-184 commit 6000d3408e303936eaccdc06d4e7f3087834ce13 Author: Jeremy Allison <j...@samba.org> Date: Tue Dec 14 09:46:51 2021 -0800 s3: smbd: In call_trans2qfilepathinfo(), we must have an existing object in the QPATHINFO case. qpathinfo must operate on an existing file, so we can exit early if filename_convert() returned the "new file" NT_STATUS_OK, !VALID_STAT case. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> commit 834aa7bb0118ad3fab7cc2bb80d9be48f2e5b7e4 Author: Jeremy Allison <j...@samba.org> Date: Mon Dec 13 16:54:07 2021 -0800 s3: smbd: Inside call_trans2setfilepathinfo(), for the TRANSACT2_SETPATHINFO case, we don't need to re-stat. If we need a valid filesystem object, and we have a !VALID_STAT() return from filename_convert(), the previous commit has already errored out. We don't need a re-stat call here. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> commit d508dff634509eb9c3a69ef628f618eeeda34d9b Author: Jeremy Allison <j...@samba.org> Date: Mon Dec 13 16:48:14 2021 -0800 s3: smbd: Inside call_trans2setfilepathinfo(), for the TRANSACT2_SETPATHINFO case, ensure we have a VALID_STAT return from filename_convert(). Remember, filename_convert() can return NT_STATUS_OK with !VALID_STAT() if the last component doesn't exist, as this may be an object create. For call_trans2setfilepathinfo(), there are only 4 info levels for the TRANSACT2_SETPATHINFO (pathname) case that don't require an existing filesystem object (i.e. a VALID_STAT()) in the return from filename_convert() as they can create an object in the filesystem. If we don't get a VALID_STAT() and the info level isn't one of those 4, error out. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> commit eabcaa2e5545abce9363b729a8128046e10a6191 Author: Jeremy Allison <j...@samba.org> Date: Mon Dec 13 14:19:35 2021 -0800 s3: smbd: call_trans2setfilepathinfo(), TRANSACT2_SETFILEINFO case, use helper function vfs_stat(). This isn't a change in behavior, even though the old comment says: "Always do lstat for UNIX calls". A previous commit enforces POSIX pathname negotiation before allowing UNIX info levels to be processed here, so we can guarantee that SMB_FILENAME_POSIX_PATH is set on smb_fname if we're allowing a UNIX info level. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> commit de88369c358abee3f6991a99c2b6e6f1e589ce52 Author: Jeremy Allison <j...@samba.org> Date: Mon Dec 13 14:13:59 2021 -0800 s3: smbd: In call_trans2qfilepathinfo(), TRANSACT2_QPATHINFO, use helper function vfs_stat(). This isn't a change in behavior, even though the old comment says: "Always do lstat for UNIX calls". A previous commit enforces POSIX pathname negotiation before allowing UNIX info levels to be processed here, so we can guarantee that SMB_FILENAME_POSIX_PATH is set on smb_fname if we're allowing a UNIX info level. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> commit 80e3f4e5ca66cff1d078a8020c7de918824bb75a Author: Jeremy Allison <j...@samba.org> Date: Mon Dec 13 14:09:33 2021 -0800 s3: smbd: In call_trans2qfilepathinfo(), TRANSACT2_QPATHINFO on a named stream case, use helper function vfs_stat(). This isn't a change in behavior, even though the old comment says: "Always do lstat for UNIX calls". A previous commit enforces POSIX pathname negotiation before allowing UNIX info levels to be processed here, so we can guarantee that SMB_FILENAME_POSIX_PATH is set on smb_fname if we're allowing a UNIX info level. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> commit 8c0f34f05706f7e172c96f54e679d34962f67a2e Author: Jeremy Allison <j...@samba.org> Date: Mon Dec 13 14:05:32 2021 -0800 s3: smbd: In call_trans2qfilepathinfo(), TRANSACT2_QFILEINFO case, use helper function vfs_stat(). This isn't a change in behavior, even though the old comment says: "Always do lstat for UNIX calls". A previous commit enforces POSIX pathname negotiation before allowing UNIX info levels to be processed here, so we can guarantee that SMB_FILENAME_POSIX_PATH is set on smb_fname if we're allowing a UNIX info level. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> commit eb0e68d0e7a22f0cc2a53757d7daf87489406282 Author: Jeremy Allison <j...@samba.org> Date: Mon Dec 13 16:08:14 2021 -0800 s3: smbd: In parent_dirname_compatible_open(), use helper function vfs_stat(). This is a change in behavior, but the old behavior was incorrect. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> commit 04a4cd2ada7557f0db5bd32e7459b146567d2240 Author: Jeremy Allison <j...@samba.org> Date: Mon Dec 13 14:02:51 2021 -0800 s3: smbd: In vfs_stat_smb_basename() use vfs_stat() helper function. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> commit b0a41119f4ccebd8930cc79d6fe381ab4b363058 Author: Jeremy Allison <j...@samba.org> Date: Mon Dec 13 13:45:13 2021 -0800 s3: smbd: In smbd_smb2_getinfo_send(), use vfs_stat() utility function. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <noel.po...@suse.com> commit da2d61ba80d5b7cc87e52e373cdb2f2270b86c12 Author: Noel Power <noel.po...@suse.com> Date: Wed Dec 15 15:55:02 2021 +0000 s3: smbd: In stat_cache_lookup(), remove unused posix_paths param. Signed-off-by: Noel Power <npo...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit d8f09c1bf097087f287d39b660f135793b652d2d Author: Jeremy Allison <j...@samba.org> Date: Mon Dec 13 13:44:25 2021 -0800 s3: smbd: In stat_cache_lookup(), use vfs_stat() utility function. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <noel.po...@suse.com> commit c94d919fd9c93f6d8987e2a0d6fa4ba066497d99 Author: Noel Power <noel.po...@suse.com> Date: Wed Dec 15 15:36:22 2021 +0000 s3: smbd: In setup_close_full_information() the posix_open parameter is not needed anymore. Signed-off-by: Noel Power <npo...@samba.org> Reviewed-by: Jeremy Allison <j...@samba.org> commit 89574ed33ba5b22c05e8f1911f663e4f7026a78f Author: Jeremy Allison <j...@samba.org> Date: Mon Dec 13 13:43:06 2021 -0800 s3: smbd: In setup_close_full_information() use vfs_stat() helper function. Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> commit 8767f60a0a2db0bd9c0de2a36b9cef64efef6ada Author: Jeremy Allison <j...@samba.org> Date: Mon Dec 13 13:42:35 2021 -0800 s3: smbd: In check_parent_exists() use utility function vfs_stat(). Signed-off-by: Jeremy Allison <j...@samba.org> Reviewed-by: Noel Power <npo...@samba.org> ----------------------------------------------------------------------- Summary of changes: source3/smbd/filename.c | 7 +- source3/smbd/proto.h | 1 - source3/smbd/reply.c | 2 +- source3/smbd/smb2_close.c | 11 +-- source3/smbd/smb2_getinfo.c | 20 ++---- source3/smbd/statcache.c | 8 +-- source3/smbd/trans2.c | 160 ++++++++++++++++---------------------------- source3/smbd/vfs.c | 7 +- 8 files changed, 68 insertions(+), 148 deletions(-) Changeset truncated at 500 lines: diff --git a/source3/smbd/filename.c b/source3/smbd/filename.c index 19eea2d6a77..4c5dbbfacbd 100644 --- a/source3/smbd/filename.c +++ b/source3/smbd/filename.c @@ -169,11 +169,7 @@ static NTSTATUS check_parent_exists(TALLOC_CTX *ctx, return NT_STATUS_NO_MEMORY; } - if (posix_pathnames) { - ret = SMB_VFS_LSTAT(conn, parent_fname); - } else { - ret = SMB_VFS_STAT(conn, parent_fname); - } + ret = vfs_stat(conn, parent_fname); /* If the parent stat failed, just continue with the normal tree walk. */ @@ -1096,7 +1092,6 @@ NTSTATUS unix_convert(TALLOC_CTX *mem_ctx, bool found; found = stat_cache_lookup(state->conn, - state->posix_pathnames, &state->smb_fname->base_name, &state->dirpath, &state->name, diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 1e31ded1b1a..4c1792d3932 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1165,7 +1165,6 @@ void stat_cache_add( const char *full_orig_name, NTTIME twrp, bool case_sensitive); bool stat_cache_lookup(connection_struct *conn, - bool posix_paths, char **pp_name, char **pp_dirpath, char **pp_start, diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index d7c5b962ca7..eeae563766a 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -7072,7 +7072,7 @@ static NTSTATUS parent_dirname_compatible_open(connection_struct *conn, return status; } - ret = SMB_VFS_LSTAT(conn, smb_fname_parent); + ret = vfs_stat(conn, smb_fname_parent); if (ret == -1) { return map_nt_error_from_unix(errno); } diff --git a/source3/smbd/smb2_close.c b/source3/smbd/smb2_close.c index da2a8fa59c8..c218d12b668 100644 --- a/source3/smbd/smb2_close.c +++ b/source3/smbd/smb2_close.c @@ -153,7 +153,6 @@ static void smbd_smb2_request_close_done(struct tevent_req *subreq) static void setup_close_full_information(connection_struct *conn, struct smb_filename *smb_fname, - bool posix_open, struct timespec *out_creation_ts, struct timespec *out_last_access_ts, struct timespec *out_last_write_ts, @@ -177,11 +176,7 @@ static void setup_close_full_information(connection_struct *conn, return; } - if (posix_open) { - ret = SMB_VFS_LSTAT(conn, smb_fname); - } else { - ret = SMB_VFS_STAT(conn, smb_fname); - } + ret = vfs_stat(conn, smb_fname); if (ret != 0) { return; } @@ -226,7 +221,6 @@ static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req, uint64_t file_size = 0; uint32_t dos_attrs = 0; uint16_t flags = 0; - bool posix_open = false; *out_creation_ts = (struct timespec){0, SAMBA_UTIME_OMIT}; *out_last_access_ts = (struct timespec){0, SAMBA_UTIME_OMIT}; @@ -246,7 +240,6 @@ static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req, return NT_STATUS_NO_MEMORY; } - posix_open = (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN); smb_fname = cp_smb_filename(talloc_tos(), fsp->fsp_name); if (smb_fname == NULL) { return NT_STATUS_NO_MEMORY; @@ -263,7 +256,6 @@ static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req, */ setup_close_full_information(conn, smb_fname, - posix_open, out_creation_ts, out_last_access_ts, out_last_write_ts, @@ -284,7 +276,6 @@ static NTSTATUS smbd_smb2_close(struct smbd_smb2_request *req, if (in_flags & SMB2_CLOSE_FLAGS_FULL_INFORMATION) { setup_close_full_information(conn, smb_fname, - posix_open, out_creation_ts, out_last_access_ts, out_last_write_ts, diff --git a/source3/smbd/smb2_getinfo.c b/source3/smbd/smb2_getinfo.c index 6df4a37af17..a918cc03385 100644 --- a/source3/smbd/smb2_getinfo.c +++ b/source3/smbd/smb2_getinfo.c @@ -340,23 +340,11 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx, * handle (returned from an NT SMB). NT5.0 seems * to do this call. JRA. */ - - if (fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH) { - /* Always do lstat for UNIX calls. */ - if (SMB_VFS_LSTAT(conn, fsp->fsp_name)) { - DEBUG(3,("smbd_smb2_getinfo_send: " - "SMB_VFS_LSTAT of %s failed " - "(%s)\n", fsp_str_dbg(fsp), - strerror(errno))); - status = map_nt_error_from_unix(errno); - tevent_req_nterror(req, status); - return tevent_req_post(req, ev); - } - } else if (SMB_VFS_STAT(conn, fsp->fsp_name)) { - DEBUG(3,("smbd_smb2_getinfo_send: " - "SMB_VFS_STAT of %s failed (%s)\n", + int ret = vfs_stat(conn, fsp->fsp_name); + if (ret != 0) { + DBG_NOTICE("vfs_stat of %s failed (%s)\n", fsp_str_dbg(fsp), - strerror(errno))); + strerror(errno)); status = map_nt_error_from_unix(errno); tevent_req_nterror(req, status); return tevent_req_post(req, ev); diff --git a/source3/smbd/statcache.c b/source3/smbd/statcache.c index ddbd663ad5b..3b7a3c4f4f0 100644 --- a/source3/smbd/statcache.c +++ b/source3/smbd/statcache.c @@ -196,7 +196,6 @@ void stat_cache_add( const char *full_orig_name, */ bool stat_cache_lookup(connection_struct *conn, - bool posix_paths, char **pp_name, char **pp_dirpath, char **pp_start, @@ -331,12 +330,7 @@ bool stat_cache_lookup(connection_struct *conn, .twrp = twrp, }; - if (posix_paths) { - ret = SMB_VFS_LSTAT(conn, &smb_fname); - } else { - ret = SMB_VFS_STAT(conn, &smb_fname); - } - + ret = vfs_stat(conn, &smb_fname); if (ret != 0) { /* Discard this entry - it doesn't exist in the filesystem. */ memcache_delete(smbd_memcache(), STAT_CACHE, diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index eb6a66d553d..dad9d7b18a4 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -5947,6 +5947,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn, char *lock_data = NULL; size_t fixed_portion; NTSTATUS status = NT_STATUS_OK; + int ret; if (!params) { reply_nterror(req, NT_STATUS_INVALID_PARAMETER); @@ -6005,24 +6006,11 @@ static void call_trans2qfilepathinfo(connection_struct *conn, * handle (returned from an NT SMB). NT5.0 seems * to do this call. JRA. */ - - if (INFO_LEVEL_IS_UNIX(info_level)) { - /* Always do lstat for UNIX calls. */ - if (SMB_VFS_LSTAT(conn, smb_fname)) { - DEBUG(3,("call_trans2qfilepathinfo: " - "SMB_VFS_LSTAT of %s failed " - "(%s)\n", - smb_fname_str_dbg(smb_fname), - strerror(errno))); - reply_nterror(req, - map_nt_error_from_unix(errno)); - return; - } - } else if (SMB_VFS_STAT(conn, smb_fname)) { - DEBUG(3,("call_trans2qfilepathinfo: " - "SMB_VFS_STAT of %s failed (%s)\n", + ret = vfs_stat(conn, smb_fname); + if (ret != 0) { + DBG_NOTICE("vfs_stat of %s failed (%s)\n", smb_fname_str_dbg(smb_fname), - strerror(errno))); + strerror(errno)); reply_nterror(req, map_nt_error_from_unix(errno)); return; @@ -6122,6 +6110,17 @@ static void call_trans2qfilepathinfo(connection_struct *conn, return; } + /* + * qpathinfo must operate on an existing file, so we + * can exit early if filename_convert() returned the "new file" + * NT_STATUS_OK, !VALID_STAT case. + */ + + if (!VALID_STAT(smb_fname->st)) { + reply_nterror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND); + return; + } + /* * smb_fname->fsp may be NULL if smb_fname points at a symlink * and we're in POSIX context, so be careful when using fsp @@ -6147,31 +6146,16 @@ static void call_trans2qfilepathinfo(connection_struct *conn, return; } - if (INFO_LEVEL_IS_UNIX(info_level) || req->posix_pathnames) { - /* Always do lstat for UNIX calls. */ - if (SMB_VFS_LSTAT(conn, smb_fname_base) != 0) { - DEBUG(3,("call_trans2qfilepathinfo: " - "SMB_VFS_LSTAT of %s failed " - "(%s)\n", - smb_fname_str_dbg(smb_fname_base), - strerror(errno))); - TALLOC_FREE(smb_fname_base); - reply_nterror(req, - map_nt_error_from_unix(errno)); - return; - } - } else { - if (SMB_VFS_STAT(conn, smb_fname_base) != 0) { - DEBUG(3,("call_trans2qfilepathinfo: " - "fileinfo of %s failed " - "(%s)\n", - smb_fname_str_dbg(smb_fname_base), - strerror(errno))); - TALLOC_FREE(smb_fname_base); - reply_nterror(req, - map_nt_error_from_unix(errno)); - return; - } + ret = vfs_stat(conn, smb_fname_base); + if (ret != 0) { + DBG_NOTICE("vfs_stat of %s failed " + "(%s)\n", + smb_fname_str_dbg(smb_fname_base), + strerror(errno)); + TALLOC_FREE(smb_fname_base); + reply_nterror(req, + map_nt_error_from_unix(errno)); + return; } status = file_name_hash(conn, @@ -6193,30 +6177,6 @@ static void call_trans2qfilepathinfo(connection_struct *conn, } } - if (INFO_LEVEL_IS_UNIX(info_level) || req->posix_pathnames) { - /* Always do lstat for UNIX calls. */ - if (SMB_VFS_LSTAT(conn, smb_fname)) { - DEBUG(3,("call_trans2qfilepathinfo: " - "SMB_VFS_LSTAT of %s failed (%s)\n", - smb_fname_str_dbg(smb_fname), - strerror(errno))); - reply_nterror(req, - map_nt_error_from_unix(errno)); - return; - } - - } else { - if (SMB_VFS_STAT(conn, smb_fname) != 0) { - DEBUG(3,("call_trans2qfilepathinfo: " - "SMB_VFS_STAT of %s failed (%s)\n", - smb_fname_str_dbg(smb_fname), - strerror(errno))); - reply_nterror(req, - map_nt_error_from_unix(errno)); - return; - } - } - status = file_name_hash(conn, smb_fname_str_dbg(smb_fname), &name_hash); @@ -9291,6 +9251,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn, files_struct *fsp = NULL; NTSTATUS status = NT_STATUS_OK; int data_return_size = 0; + int ret; if (!params) { reply_nterror(req, NT_STATUS_INVALID_PARAMETER); @@ -9329,26 +9290,14 @@ static void call_trans2setfilepathinfo(connection_struct *conn, * handle (returned from an NT SMB). NT5.0 seems * to do this call. JRA. */ - if (INFO_LEVEL_IS_UNIX(info_level)) { - /* Always do lstat for UNIX calls. */ - if (SMB_VFS_LSTAT(conn, smb_fname)) { - DEBUG(3,("call_trans2setfilepathinfo: " - "SMB_VFS_LSTAT of %s failed " - "(%s)\n", - smb_fname_str_dbg(smb_fname), - strerror(errno))); - reply_nterror(req, map_nt_error_from_unix(errno)); - return; - } - } else { - if (SMB_VFS_STAT(conn, smb_fname) != 0) { - DEBUG(3,("call_trans2setfilepathinfo: " - "fileinfo of %s failed (%s)\n", - smb_fname_str_dbg(smb_fname), - strerror(errno))); - reply_nterror(req, map_nt_error_from_unix(errno)); - return; - } + ret = vfs_stat(conn, smb_fname); + if (ret != 0) { + DBG_NOTICE("vfs_stat of %s failed (%s)\n", + smb_fname_str_dbg(smb_fname), + strerror(errno)); + reply_nterror(req, + map_nt_error_from_unix(errno)); + return; } } else if (fsp->print_file) { /* @@ -9391,6 +9340,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn, } else { char *fname = NULL; uint32_t ucf_flags = ucf_flags_from_smb_request(req); + bool require_existing_object = true; /* set path info */ if (total_params < 7) { @@ -9458,22 +9408,30 @@ static void call_trans2setfilepathinfo(connection_struct *conn, */ fsp = smb_fname->fsp; - if (INFO_LEVEL_IS_UNIX(info_level)) { - /* - * For CIFS UNIX extensions the target name may not exist. - */ - - /* Always do lstat for UNIX calls. */ - SMB_VFS_LSTAT(conn, smb_fname); + /* + * There are 4 info levels which can + * create a new object in the filesystem. + * They are: + * SMB_SET_FILE_UNIX_LINK -> creates POSIX symlink. + * SMB_POSIX_PATH_OPEN -> creates POSIX file or directory. + * SMB_SET_FILE_UNIX_BASIC: + * SMB_SET_FILE_UNIX_INFO2: can create a POSIX special file. + * + * These info levels do not require an existing object. + */ + switch (info_level) { + case SMB_SET_FILE_UNIX_LINK: + case SMB_POSIX_PATH_OPEN: + case SMB_SET_FILE_UNIX_BASIC: + case SMB_SET_FILE_UNIX_INFO2: + require_existing_object = false; + break; + default: + break; + } - } else if (!VALID_STAT(smb_fname->st) && - SMB_VFS_STAT(conn, smb_fname)) { - DEBUG(3,("call_trans2setfilepathinfo: SMB_VFS_STAT of " - "%s failed (%s)\n", - smb_fname_str_dbg(smb_fname), - strerror(errno))); - reply_nterror(req, map_nt_error_from_unix(errno)); - return; + if (!VALID_STAT(smb_fname->st) && require_existing_object) { + reply_nterror(req, NT_STATUS_OBJECT_NAME_NOT_FOUND); } } diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index 4091aa304d4..9bc528837d7 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1352,12 +1352,7 @@ int vfs_stat_smb_basename(struct connection_struct *conn, }; int ret; - if (smb_fname.flags & SMB_FILENAME_POSIX_PATH) { - ret = SMB_VFS_LSTAT(conn, &smb_fname); - } else { - ret = SMB_VFS_STAT(conn, &smb_fname); - } - + ret = vfs_stat(conn, &smb_fname); if (ret != -1) { *psbuf = smb_fname.st; } -- Samba Shared Repository