From 4f5d02f8c0efc1520b2113ce656c78483deb7826 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Tue, 9 Aug 2022 10:49:46 -0700 Subject: [PATCH] s3: smbd: Add helper function msdfs_servicename_matches_connection(). Not yet used so commented out. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15144 Signed-off-by: Jeremy Allison Reviewed-by: Ralph Boehme --- source3/smbd/msdfs.c | 46 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index 21288aaf664..463601cf1ee 100644 --- a/source3/smbd/msdfs.c +++ b/source3/smbd/msdfs.c @@ -36,6 +36,52 @@ #include "lib/global_contexts.h" #include "source3/lib/substitute.h" +#if 0 +/********************************************************************** + Function to determine if a given sharename matches a connection. +**********************************************************************/ + +static bool msdfs_servicename_matches_connection(struct connection_struct *conn, + const char *servicename, + const char *vfs_user) +{ + const struct loadparm_substitution *lp_sub = + loadparm_s3_global_substitution(); + char *conn_servicename = NULL; + int snum; + bool match = false; + + if (conn == NULL) { + /* No connection always matches. */ + return true; + } + + snum = SNUM(conn); + + conn_servicename = lp_servicename(talloc_tos(), lp_sub, snum); + if (conn_servicename == NULL) { + DBG_ERR("lp_servicename() failed, OOM!\n"); + return false; + } + + if (strequal(servicename, conn_servicename)) { + match = true; + goto done; + } + if (strequal(servicename, HOMES_NAME)) { + match = true; + goto done; + } + if (strequal(vfs_user, conn_servicename)) { + match = true; + goto done; + } +done: + TALLOC_FREE(conn_servicename); + return match; +} +#endif + /********************************************************************** Parse a DFS pathname of the form /hostname/service/reqpath into the dfs_path structure. -- 2.47.3