mirror of
https://github.com/samba-team/samba.git
synced 2025-03-08 04:58:40 +03:00
s3: Convert some callers of vfs_lstat_smb_fname to SMB_VFS_LSTAT()
This commit is contained in:
parent
4b42927ec3
commit
83284e13f9
@ -411,7 +411,6 @@ static bool is_msdfs_link_internal(TALLOC_CTX *ctx,
|
||||
char **pp_link_target,
|
||||
SMB_STRUCT_STAT *sbufp)
|
||||
{
|
||||
SMB_STRUCT_STAT st;
|
||||
int referral_len = 0;
|
||||
#if defined(HAVE_BROKEN_READLINK)
|
||||
char link_target_buf[PATH_MAX];
|
||||
@ -420,6 +419,8 @@ static bool is_msdfs_link_internal(TALLOC_CTX *ctx,
|
||||
#endif
|
||||
size_t bufsize = 0;
|
||||
char *link_target = NULL;
|
||||
struct smb_filename *smb_fname = NULL;
|
||||
NTSTATUS status;
|
||||
|
||||
if (pp_link_target) {
|
||||
bufsize = 1024;
|
||||
@ -433,21 +434,28 @@ static bool is_msdfs_link_internal(TALLOC_CTX *ctx,
|
||||
link_target = link_target_buf;
|
||||
}
|
||||
|
||||
if (sbufp == NULL) {
|
||||
sbufp = &st;
|
||||
status = create_synthetic_smb_fname(talloc_tos(), path, NULL, NULL,
|
||||
&smb_fname);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (vfs_lstat_smb_fname(conn, path, sbufp) != 0) {
|
||||
if (SMB_VFS_LSTAT(conn, smb_fname) != 0) {
|
||||
DEBUG(5,("is_msdfs_link_read_target: %s does not exist.\n",
|
||||
path));
|
||||
TALLOC_FREE(smb_fname);
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (!S_ISLNK(sbufp->st_ex_mode)) {
|
||||
if (!S_ISLNK(smb_fname->st.st_ex_mode)) {
|
||||
DEBUG(5,("is_msdfs_link_read_target: %s is not a link.\n",
|
||||
path));
|
||||
TALLOC_FREE(smb_fname);
|
||||
goto err;
|
||||
}
|
||||
if (sbufp != NULL) {
|
||||
*sbufp = smb_fname->st;
|
||||
}
|
||||
TALLOC_FREE(smb_fname);
|
||||
|
||||
referral_len = SMB_VFS_READLINK(conn, path, link_target, bufsize - 1);
|
||||
if (referral_len == -1) {
|
||||
|
@ -972,15 +972,28 @@ NTSTATUS check_reduced_name(connection_struct *conn, const char *fname)
|
||||
|
||||
#ifdef S_ISLNK
|
||||
if (!lp_symlinks(SNUM(conn))) {
|
||||
SMB_STRUCT_STAT statbuf;
|
||||
if ( (vfs_lstat_smb_fname(conn,fname,&statbuf) != -1) &&
|
||||
(S_ISLNK(statbuf.st_ex_mode)) ) {
|
||||
struct smb_filename *smb_fname = NULL;
|
||||
NTSTATUS status;
|
||||
|
||||
status = create_synthetic_smb_fname(talloc_tos(), fname, NULL,
|
||||
NULL, &smb_fname);
|
||||
if (!NT_STATUS_IS_OK(status)) {
|
||||
if (free_resolved_name) {
|
||||
SAFE_FREE(resolved_name);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
if ( (SMB_VFS_LSTAT(conn, smb_fname) != -1) &&
|
||||
(S_ISLNK(smb_fname->st.st_ex_mode)) ) {
|
||||
if (free_resolved_name) {
|
||||
SAFE_FREE(resolved_name);
|
||||
}
|
||||
DEBUG(3,("reduce_name: denied: file path name %s is a symlink\n",resolved_name));
|
||||
TALLOC_FREE(smb_fname);
|
||||
return NT_STATUS_ACCESS_DENIED;
|
||||
}
|
||||
TALLOC_FREE(smb_fname);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user