1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-03 01:18:10 +03:00

smbd: add a directory argument to safe_symlink_target_path()

Existing caller passes NULL, no change in behaviour. Prepares for
replacing symlink_target_below_conn() in open.c.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15549

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
(cherry picked from commit fc80c72d65)
This commit is contained in:
Ralph Boehme 2024-01-02 13:25:25 +01:00 committed by Jule Anger
parent f495f6d277
commit 0086f3d4b7
2 changed files with 15 additions and 1 deletions

View File

@ -720,6 +720,7 @@ struct smb_filename *synthetic_smb_fname(TALLOC_CTX *mem_ctx,
uint32_t flags);
NTSTATUS safe_symlink_target_path(TALLOC_CTX *mem_ctx,
const char *connectpath,
const char *dir,
const char *target,
size_t unparsed,
char **_relative);

View File

@ -945,6 +945,7 @@ static char *symlink_target_path(
NTSTATUS safe_symlink_target_path(TALLOC_CTX *mem_ctx,
const char *connectpath,
const char *dir,
const char *target,
size_t unparsed,
char **_relative)
@ -960,11 +961,22 @@ NTSTATUS safe_symlink_target_path(TALLOC_CTX *mem_ctx,
if (target[0] == '/') {
abs_target = talloc_strdup(mem_ctx, target);
} else {
} else if (dir == NULL) {
abs_target = talloc_asprintf(mem_ctx,
"%s/%s",
connectpath,
target);
} else if (dir[0] == '/') {
abs_target = talloc_asprintf(mem_ctx,
"%s/%s",
dir,
target);
} else {
abs_target = talloc_asprintf(mem_ctx,
"%s/%s/%s",
connectpath,
dir,
target);
}
if (abs_target == NULL) {
goto fail;
@ -1491,6 +1503,7 @@ next:
status = safe_symlink_target_path(mem_ctx,
conn->connectpath,
NULL,
target,
unparsed,
&safe_target);