The branch, v4-20-test has been updated
via 7123833ab49 sharesec: Check if share exists in configuration
via 017f90a03d0 sharesec: Add function to check existence of share from
config
via 91410773497 param: Add API to load registry without share info
via 839b32b1d14 sharesec: Fix warning frame not freed in order
via 6fb64f70203 s3-sharesec: Add Test to verify command option
"--view-all"
from 36f514f9079 s4:dsdb: fix logic of dsdb_trust_routing_by_name()
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-20-test
- Log -----------------------------------------------------------------
commit 7123833ab494811c83a1e95e10a617daddcff89c
Author: Vinit Agnihotri <[email protected]>
Date: Tue Dec 3 11:21:09 2024 +0530
sharesec: Check if share exists in configuration
Load config from registry without share info and check if sharename
exists from configuration. This results into lesser delay for the same.
In case of view we load config with all shares to ensure we get all
shares for diplay purpose.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15780
Signed-off-by: Vinit Agnihotri <[email protected]>
Reviewed-by: John Mulligan <[email protected]>
Reviewed-by: Guenther Deschner <[email protected]>
Autobuild-User(master): Günther Deschner <[email protected]>
Autobuild-Date(master): Fri Jan 10 10:45:30 UTC 2025 on atb-devel-224
(cherry picked from commit 1410803713440caf29a40aec30516489d1944665)
Autobuild-User(v4-20-test): Jule Anger <[email protected]>
Autobuild-Date(v4-20-test): Tue Jan 21 08:42:09 UTC 2025 on atb-devel-224
commit 017f90a03d0ab69641880d4fc2504c02259fa04e
Author: Vinit Agnihotri <[email protected]>
Date: Tue Dec 3 11:19:09 2024 +0530
sharesec: Add function to check existence of share from config
Add function to detect if a share name exists in the registry or config
file.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15780
Signed-off-by: Vinit Agnihotri <[email protected]>
Reviewed-by: John Mulligan <[email protected]>
Reviewed-by: Guenther Deschner <[email protected]>
(cherry picked from commit 78eb293e1cdd3635de0bcf46ffb9d842f27bcc9f)
commit 91410773497916f0cfcb453faafa1fea59e09eb6
Author: Vinit Agnihotri <[email protected]>
Date: Tue Dec 3 11:12:34 2024 +0530
param: Add API to load registry without share info
As number of shares increases loading entire registry configuration along
with
share information becomes very costly operation.
Since we may not require share information all time, we can optimise
this by using API just loading configuration without any share info.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15780
Signed-off-by: Vinit Agnihotri <[email protected]>
Reviewed-by: John Mulligan <[email protected]>
Reviewed-by: Guenther Deschner <[email protected]>
(cherry picked from commit 2927dba0434b960e4c381329bdc9fe474fb930ce)
commit 839b32b1d14c8a45d58a75ef45d145d20744604a
Author: Vinit Agnihotri <[email protected]>
Date: Thu Dec 12 19:05:24 2024 +0530
sharesec: Fix warning frame not freed in order
This change should fix following warning:
Freed frame ../../source3/utils/sharesec.c:515, expected
../../source3/utils/sharesec.c:637
Frame was not getting freed in case of servicename is NULL.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15780
Signed-off-by: Vinit Agnihotri <[email protected]>
Reviewed-by: John Mulligan <[email protected]>
Reviewed-by: Guenther Deschner <[email protected]>
(cherry picked from commit 04531e1b1d25d114c470922547bee769b07e5e60)
commit 6fb64f70203f8aaf57dcf8cf7800e3640c012346
Author: Guenther Deschner <[email protected]>
Date: Wed Dec 11 15:33:47 2024 +0530
s3-sharesec: Add Test to verify command option "--view-all"
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15780
Signed-off-by: Guenther Deschner <[email protected]>
Signed-off-by: Vinit Agnihotri <[email protected]>
Reviewed-by: John Mulligan <[email protected]>
(cherry picked from commit 0a12254ea8b3414deebc3e6329025052c650356e)
-----------------------------------------------------------------------
Summary of changes:
source3/param/loadparm.c | 11 +++++
source3/param/loadparm.h | 1 +
source3/script/tests/test_sharesec.sh | 8 ++++
source3/utils/sharesec.c | 88 ++++++++++++++++++++++++++++++++---
4 files changed, 102 insertions(+), 6 deletions(-)
Changeset truncated at 500 lines:
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 797baa66309..f1a509f87b5 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -4250,6 +4250,17 @@ bool lp_load_with_registry_shares(const char *pszFname)
true); /* load_all_shares*/
}
+bool lp_load_with_registry_without_shares(const char *pszFname)
+{
+ return lp_load_ex(pszFname,
+ false, /* global_only */
+ true, /* save_defaults */
+ false, /* add_ipc */
+ true, /* reinit_globals */
+ true, /* allow_include_registry */
+ false); /* load_all_shares*/
+}
+
/***************************************************************************
Return the max number of services.
***************************************************************************/
diff --git a/source3/param/loadparm.h b/source3/param/loadparm.h
index 78162911953..5aaf8d9ead7 100644
--- a/source3/param/loadparm.h
+++ b/source3/param/loadparm.h
@@ -155,6 +155,7 @@ bool lp_load_global_no_reinit(const char *file_name);
bool lp_load_no_reinit(const char *file_name);
bool lp_load_client_no_reinit(const char *file_name);
bool lp_load_with_registry_shares(const char *pszFname);
+bool lp_load_with_registry_without_shares(const char *pszFname);
int lp_numservices(void);
void lp_dump(FILE *f, bool show_defaults, int maxtoprint);
void lp_dump_one(FILE * f, bool show_defaults, int snum);
diff --git a/source3/script/tests/test_sharesec.sh
b/source3/script/tests/test_sharesec.sh
index a083a56545a..b44ffcb4d58 100755
--- a/source3/script/tests/test_sharesec.sh
+++ b/source3/script/tests/test_sharesec.sh
@@ -137,4 +137,12 @@ testit "Check for default ACL" \
test "$ACL" = "ACL:S-1-1-0:ALLOWED/0x0/FULL" ||
failed=$(expr $failed + 1)
+testit "Create 2nd share" $NET_CMD conf addshare tmp_share2 /tmp ||
+ failed=$(expr $failed + 1)
+COUNT=$($CMD --view-all | grep ACL: | sed -e 's/^ACL://' | wc -l)
+testit "Verify standard ACL counts" test $COUNT -gt 2 ||
+ failed=$(expr $failed + 1)
+testit "Delete share" $NET_CMD conf delshare tmp_share2 ||
+ failed=$(expr $failed + 1)
+
testok $0 $failed
diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c
index 417572954c8..47182894a66 100644
--- a/source3/utils/sharesec.c
+++ b/source3/utils/sharesec.c
@@ -31,6 +31,8 @@ struct cli_state;
#include "cmdline_contexts.h"
#include "lib/util/string_wrappers.h"
#include "lib/param/param.h"
+#include "lib/smbconf/smbconf.h"
+#include "lib/smbconf/smbconf_init.h"
static TALLOC_CTX *ctx;
@@ -316,6 +318,80 @@ static int view_sharesec_sddl(const char *sharename)
return 0;
}
+static bool registry_share(const char *sharename)
+{
+ sbcErr err;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
+ struct smbconf_ctx *conf_ctx;
+ bool ret_status = true;
+
+ err = smbconf_init(mem_ctx, &conf_ctx, "registry:");
+ if (!SBC_ERROR_IS_OK(err)) {
+ DEBUG(0, ("Unable to init smbconf registry. Err:%s\n",
+ sbcErrorString(err)));
+ ret_status = false;
+ goto out;
+ }
+
+ if(!smbconf_share_exists(conf_ctx, sharename)) {
+ ret_status = false;
+ goto done;
+ }
+done:
+ smbconf_shutdown(conf_ctx);
+out:
+ talloc_free(mem_ctx);
+ return ret_status;
+}
+
+static bool txt_share(const char *sharename)
+{
+ sbcErr err;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
+ struct smbconf_ctx *conf_ctx;
+ bool ret_status = true;
+ char *fconf_path;
+
+ fconf_path = talloc_asprintf(mem_ctx, "file:%s", get_dyn_CONFIGFILE());
+ if (fconf_path == NULL) {
+ DEBUG(0, ("Not enough memory for conf file path"));
+ ret_status = false;
+ goto out;
+ }
+
+ err = smbconf_init(mem_ctx, &conf_ctx, fconf_path);
+ if (!SBC_ERROR_IS_OK(err)) {
+ DEBUG(0, ("Unable to init smbconf file. Err:%s\n",
+ sbcErrorString(err)));
+ ret_status = false;
+ goto out;
+ }
+
+ if(!smbconf_share_exists(conf_ctx, sharename)) {
+ ret_status = false;
+ goto done;
+ }
+done:
+ smbconf_shutdown(conf_ctx);
+out:
+ talloc_free(mem_ctx);
+ return ret_status;
+}
+
+static bool share_exists(const char *sharename)
+{
+ bool ret_status = false;
+
+ if ((lp_config_backend() == CONFIG_BACKEND_REGISTRY) ||
+ (lp_registry_shares() == true))
+ ret_status = registry_share(sharename);
+
+ if (!ret_status) {
+ ret_status = txt_share(sharename);
+ }
+ return ret_status;
+}
+
/********************************************************************
main program
********************************************************************/
@@ -333,7 +409,6 @@ int main(int argc, const char *argv[])
static char *the_acl = NULL;
fstring sharename;
bool force_acl = False;
- int snum;
poptContext pc;
bool initialize_sid = False;
bool ok;
@@ -528,7 +603,10 @@ int main(int argc, const char *argv[])
setlinebuf(stdout);
- lp_load_with_registry_shares(get_dyn_CONFIGFILE());
+ if (mode == SMB_ACL_VIEW_ALL)
+ lp_load_with_registry_shares(get_dyn_CONFIGFILE());
+ else
+ lp_load_with_registry_without_shares(get_dyn_CONFIGFILE());
/* check for initializing secrets.tdb first */
@@ -555,7 +633,6 @@ int main(int argc, const char *argv[])
if (mode == SMB_ACL_VIEW_ALL) {
int i;
-
for (i=0; i<lp_numservices(); i++) {
TALLOC_CTX *frame = talloc_stackframe();
const struct loadparm_substitution *lp_sub =
@@ -563,6 +640,7 @@ int main(int argc, const char *argv[])
const char *service = lp_servicename(frame, lp_sub, i);
if (service == NULL) {
+ TALLOC_FREE(frame);
continue;
}
@@ -584,9 +662,7 @@ int main(int argc, const char *argv[])
fstrcpy(sharename, poptGetArg(pc));
- snum = lp_servicenumber( sharename );
-
- if ( snum == -1 && !force_acl ) {
+ if (!share_exists(sharename)) {
fprintf( stderr, "Invalid sharename: %s\n", sharename);
retval = -1;
goto done;
--
Samba Shared Repository