mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
smbd: prepare for replacing SMB_VFS_READLINKAT() with SMB_VFS_STATX() in the future
Add a large comment inside process_symlink_open() explaining why we need to call SMB_VFS_READLINKAT(). As we don't make use of the returned name and just rely on SMB_VFS_REALPATH() doing its job, remove target_fname Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
60c47a5d13
commit
15303ee19b
@ -481,7 +481,6 @@ static int process_symlink_open(struct connection_struct *conn,
|
||||
{
|
||||
int fd = -1;
|
||||
char *link_target = NULL;
|
||||
struct smb_filename target_fname = {0};
|
||||
int link_len = -1;
|
||||
struct smb_filename *oldwd_fname = NULL;
|
||||
size_t rootdir_len = 0;
|
||||
@ -506,7 +505,19 @@ static int process_symlink_open(struct connection_struct *conn,
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Read the link target. */
|
||||
/*
|
||||
* Read the link target. We do this just to verify that smb_fname indeed
|
||||
* points at a symbolic link and return the SMB_VFS_READLINKAT() errno
|
||||
* and failure in case smb_fname is NOT a symlink.
|
||||
*
|
||||
* The caller needs this piece of information to distinguish two cases
|
||||
* where open() fails with errno=ENOTDIR, cf the comment in
|
||||
* non_widelink_open().
|
||||
*
|
||||
* We rely on SMB_VFS_REALPATH() to resolve the path including the
|
||||
* symlink. Once we have SMB_VFS_STATX() or something similar in our VFS
|
||||
* we may want to use that instead of SMB_VFS_READLINKAT().
|
||||
*/
|
||||
link_len = SMB_VFS_READLINKAT(conn,
|
||||
conn->cwd_fsp,
|
||||
smb_fname,
|
||||
@ -516,15 +527,8 @@ static int process_symlink_open(struct connection_struct *conn,
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* Ensure it's at least null terminated. */
|
||||
link_target[link_len] = '\0';
|
||||
target_fname = (struct smb_filename) {
|
||||
.base_name = link_target,
|
||||
.twrp = smb_fname->twrp,
|
||||
};
|
||||
|
||||
/* Convert to an absolute path. */
|
||||
resolved_fname = SMB_VFS_REALPATH(conn, talloc_tos(), &target_fname);
|
||||
resolved_fname = SMB_VFS_REALPATH(conn, talloc_tos(), smb_fname);
|
||||
if (resolved_fname == NULL) {
|
||||
goto out;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user