From: Volker Lendecke Date: Sat, 3 Jan 2026 09:12:49 +0000 (+0100) Subject: srvsvc: Move valid_share_pathname() to where it's used X-Git-Tag: tdb-1.4.15~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7efa529a659c29bb83cc7e71257241763605a2e1;p=thirdparty%2Fsamba.git srvsvc: Move valid_share_pathname() to where it's used Signed-off-by: Volker Lendecke Reviewed-by: Anoop C S --- diff --git a/source3/include/proto.h b/source3/include/proto.h index c93c521ae67..d851caefb1d 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -367,7 +367,6 @@ bool split_domain_user(TALLOC_CTX *mem_ctx, const char *strip_hostname(const char *s); bool any_nt_status_not_ok(NTSTATUS err1, NTSTATUS err2, NTSTATUS *result); int timeval_to_msec(struct timeval t); -char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname); bool is_executable(const char *fname); bool map_open_params_to_ntcreate(const char *smb_base_fname, int deny_mode, int open_func, diff --git a/source3/lib/util.c b/source3/lib/util.c index 11c0425c151..8f65f6866a5 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -1536,39 +1536,6 @@ int timeval_to_msec(struct timeval t) return t.tv_sec * 1000 + (t.tv_usec+999) / 1000; } -/******************************************************************* - Check a given DOS pathname is valid for a share. -********************************************************************/ - -char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname) -{ - char *ptr = NULL; - - if (!dos_pathname) { - return NULL; - } - - ptr = talloc_strdup(ctx, dos_pathname); - if (!ptr) { - return NULL; - } - string_replace(ptr, '\\', '/'); - ptr = unix_clean_name(ctx, ptr); - if (!ptr) { - return NULL; - } - - /* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */ - if (strlen(ptr) > 2 && ptr[1] == ':' && ptr[0] != '/') - ptr += 2; - - /* Only absolute paths allowed. */ - if (*ptr != '/') - return NULL; - - return ptr; -} - /******************************************************************* Return True if the filename is one of the special executable types. ********************************************************************/ diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c index 09ec334d5a9..8019827108e 100644 --- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c +++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c @@ -1873,6 +1873,39 @@ WERROR _srvsvc_NetShareGetInfo(struct pipes_struct *p, return status; } +/******************************************************************* + Check a given DOS pathname is valid for a share. +********************************************************************/ + +static char *valid_share_pathname(TALLOC_CTX *ctx, const char *dos_pathname) +{ + char *ptr = NULL; + + if (!dos_pathname) { + return NULL; + } + + ptr = talloc_strdup(ctx, dos_pathname); + if (!ptr) { + return NULL; + } + string_replace(ptr, '\\', '/'); + ptr = unix_clean_name(ctx, ptr); + if (!ptr) { + return NULL; + } + + /* NT is braindead - it wants a C: prefix to a pathname ! So strip it. */ + if (strlen(ptr) > 2 && ptr[1] == ':' && ptr[0] != '/') + ptr += 2; + + /* Only absolute paths allowed. */ + if (*ptr != '/') + return NULL; + + return ptr; +} + /******************************************************************* _srvsvc_NetShareSetInfo. Modify share details. ********************************************************************/