[SCM] Samba Shared Repository - branch master updated

2023-01-12 Thread Jeremy Allison
The branch, master has been updated
   via  1421969b86b CI: add a test for @GMT mask in SMB1 find
  from  425aaf6f7eb lib: Fix a use-after-free in "net vfs getntacl"

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 1421969b86bf2eab2d192d4a071080b2d021cd38
Author: Ralph Boehme 
Date:   Thu Nov 24 16:59:49 2022 +0100

CI: add a test for @GMT mask in SMB1 find

Without FLAGS2_REPARSE_PATH a path containing an @GMT token can be used to
create a file including the @GMT token in the name and a directory list will
also return the file as result. Verified against Windows. Samba behaves 
exactly
the same.

Signed-off-by: Ralph Boehme 
Reviewed-by: Jeremy Allison 

Autobuild-User(master): Jeremy Allison 
Autobuild-Date(master): Fri Jan 13 01:13:01 UTC 2023 on sn-devel-184

---

Summary of changes:
 source4/torture/basic/base.c | 41 +
 1 file changed, 41 insertions(+)


Changeset truncated at 500 lines:

diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c
index 232ba9c5cb3..602eb226d0b 100644
--- a/source4/torture/basic/base.c
+++ b/source4/torture/basic/base.c
@@ -1979,6 +1979,44 @@ static bool torture_smb1_twrp_openroot(struct 
torture_context *tctx,
return ret;
 }
 
+static void torture_smb1_find_gmt_mask_list_fn(struct clilist_file_info *finfo,
+  const char *name,
+  void *state)
+{
+}
+
+/**
+ * SMB1 @GMT token as search mask is valid
+ */
+static bool torture_smb1_find_gmt_mask(struct torture_context *tctx,
+  struct smbcli_state *cli)
+{
+   const char *dname = "\\torture_smb1_find_gmt_mask";
+   const char *path = 
"\\torture_smb1_find_gmt_mask\\@GMT-2022.11.24-16.24.00";
+   int fnum;
+   int n;
+   NTSTATUS status;
+   bool ret = true;
+
+   smbcli_unlink(cli->tree, path);
+   smbcli_rmdir(cli->tree, dname);
+
+   status = smbcli_mkdir(cli->tree, dname);
+   torture_assert_ntstatus_ok_goto(tctx, status, ret, done,
+   "smbcli_mkdir() failed\n");
+   fnum = smbcli_open(cli->tree, path, O_RDWR | O_CREAT, DENY_NONE);
+   smbcli_close(cli->tree, fnum);
+
+   /* Note: we don't set FLAGS2_REPARSE_PATH, so this is just a path */
+   n = smbcli_list(cli->tree, path, 0, torture_smb1_find_gmt_mask_list_fn, 
cli);
+   torture_assert_int_equal_goto(tctx, n, 1, ret, done, "Wrong count\n");
+
+done:
+   smbcli_unlink(cli->tree, path);
+   smbcli_rmdir(cli->tree, dname);
+   return ret;
+}
+
 NTSTATUS torture_base_init(TALLOC_CTX *ctx)
 {
struct torture_suite *suite = torture_suite_create(ctx, "base");
@@ -2039,6 +2077,9 @@ NTSTATUS torture_base_init(TALLOC_CTX *ctx)
torture_suite_add_1smb_test(suite,
"smb1-twrp-openroot",
torture_smb1_twrp_openroot);
+   torture_suite_add_1smb_test(suite,
+   "smb1-find-gmt-mask",
+   torture_smb1_find_gmt_mask);
 
suite->description = talloc_strdup(suite, 
"Basic SMB tests (imported from the 
original smbtorture)");


-- 
Samba Shared Repository



[SCM] Samba Shared Repository - branch master updated

2023-01-12 Thread Ralph Böhme
The branch, master has been updated
   via  425aaf6f7eb lib: Fix a use-after-free in "net vfs getntacl"
   via  d278fe4a847 lib: Fix out-of-bounds access in print_ace_flags()
   via  3a458a8198e lib: Use talloc_asprintf_addbuf() in print_ace_flags()
   via  6dcbea9e0fb build: Don't compile source3/lib/util_sd.c four times
  from  98d84192a03 s3:utils:mdsearch go to cmdline_messaging_context_free

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 425aaf6f7ebecc33463f6ed2f39573e95a72bf55
Author: Volker Lendecke 
Date:   Thu Jan 12 12:00:26 2023 +0100

lib: Fix a use-after-free in "net vfs getntacl"

Don't hang "sd" off "fsp", which is free'ed before printing

Signed-off-by: Volker Lendecke 
Reviewed-by: Ralph Boehme 

Autobuild-User(master): Ralph Böhme 
Autobuild-Date(master): Thu Jan 12 16:41:07 UTC 2023 on sn-devel-184

commit d278fe4a8478c1108b0f95daa99eb0a4e8fa787c
Author: Volker Lendecke 
Date:   Thu Jan 12 11:55:04 2023 +0100

lib: Fix out-of-bounds access in print_ace_flags()

Signed-off-by: Volker Lendecke 
Reviewed-by: Ralph Boehme 

commit 3a458a8198eef40e4e58a6dc10525409188d573f
Author: Volker Lendecke 
Date:   Thu Jan 12 11:51:50 2023 +0100

lib: Use talloc_asprintf_addbuf() in print_ace_flags()

Simplifies code.

Signed-off-by: Volker Lendecke 
Reviewed-by: Ralph Boehme 

commit 6dcbea9e0fb09f2d420b2424081bb20d459277fb
Author: Volker Lendecke 
Date:   Thu Jan 12 12:11:49 2023 +0100

build: Don't compile source3/lib/util_sd.c four times

Signed-off-by: Volker Lendecke 
Reviewed-by: Ralph Boehme 

---

Summary of changes:
 source3/lib/util_sd.c | 45 +--
 source3/torture/wscript_build |  2 +-
 source3/utils/net_vfs.c   |  4 +++-
 source3/utils/wscript_build   |  8 +---
 source3/wscript_build |  3 +++
 5 files changed, 25 insertions(+), 37 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/lib/util_sd.c b/source3/lib/util_sd.c
index a4288a46f3d..23f37b7e734 100644
--- a/source3/lib/util_sd.c
+++ b/source3/lib/util_sd.c
@@ -240,53 +240,34 @@ bool StringToSid(struct cli_state *cli, struct dom_sid 
*sid, const char *str)
 static void print_ace_flags(FILE *f, uint8_t flags)
 {
char *str = talloc_strdup(NULL, "");
-
-   if (!str) {
-   goto out;
-   }
+   size_t len;
 
if (flags & SEC_ACE_FLAG_OBJECT_INHERIT) {
-   str = talloc_asprintf(str, "%s%s",
-   str, "OI|");
-   if (!str) {
-   goto out;
-   }
+   talloc_asprintf_addbuf(, "OI|");
}
if (flags & SEC_ACE_FLAG_CONTAINER_INHERIT) {
-   str = talloc_asprintf(str, "%s%s",
-   str, "CI|");
-   if (!str) {
-   goto out;
-   }
+   talloc_asprintf_addbuf(, "CI|");
}
if (flags & SEC_ACE_FLAG_NO_PROPAGATE_INHERIT) {
-   str = talloc_asprintf(str, "%s%s",
-   str, "NP|");
-   if (!str) {
-   goto out;
-   }
+   talloc_asprintf_addbuf(, "NP|");
}
if (flags & SEC_ACE_FLAG_INHERIT_ONLY) {
-   str = talloc_asprintf(str, "%s%s",
-   str, "IO|");
-   if (!str) {
-   goto out;
-   }
+   talloc_asprintf_addbuf(, "IO|");
}
if (flags & SEC_ACE_FLAG_INHERITED_ACE) {
-   str = talloc_asprintf(str, "%s%s",
-   str, "I|");
-   if (!str) {
-   goto out;
-   }
+   talloc_asprintf_addbuf(, "I|");
}
+   if (str == NULL) {
+   goto out;
+   }
+
/* Ignore define SEC_ACE_FLAG_SUCCESSFUL_ACCESS ( 0x40 )
   and SEC_ACE_FLAG_FAILED_ACCESS ( 0x80 ) as they're
   audit ace flags. */
 
-   if (str[strlen(str)-1] == '|') {
-   str[strlen(str)-1] = '\0';
-   fprintf(f, "/%s/", str);
+   len = strlen(str);
+   if (len > 0) {
+   fprintf(f, "/%.*s/", (int)len-1, str);
} else {
fprintf(f, "/0x%x/", flags);
}
diff --git a/source3/torture/wscript_build b/source3/torture/wscript_build
index e941829ab5f..18106aaf59a 100644
--- a/source3/torture/wscript_build
+++ b/source3/torture/wscript_build
@@ -58,7 +58,6 @@ bld.SAMBA3_BINARY('smbtorture' + bld.env.suffix3,
 test_idmap_cache.c
 test_hidenewfiles.c
 test_readdir_timestamp.c
-../lib/util_sd.c
   

[SCM] Samba Shared Repository - branch master updated

2023-01-12 Thread Volker Lendecke
The branch, master has been updated
   via  98d84192a03 s3:utils:mdsearch go to cmdline_messaging_context_free
  from  de5d31f452b s3:smbstatus: go to cmdline_messaging_context_free

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -
commit 98d84192a03a4f1135eaf1590fb62b16d8bc49c8
Author: Jones Syue 
Date:   Thu Jan 12 15:47:20 2023 +0800

s3:utils:mdsearch go to cmdline_messaging_context_free

mdsearch utility would exit earlier with failure in several cases like:
a. samba server is not running yet,
[~] # mdsearch -Uuser%password1 ${server} Public '*=="Samba"'
main: Cannot connect to server: NT_STATUS_CONNECTION_REFUSED

b. spotlight backend service is not ready yet,
[~] # mdsearch -Uuser%password1 ${server} Public '*=="Samba"'
Failed to connect mdssvc

c. mdsearch utility paramters is not as expecred,
[~] # mdsearch -Uuser%password1 ${server} share_not_exist '*=="Samba"'
mdscli_search failed

And in the mean while once mdsearch utility exit earlier with failure,
the lock files are left behind in the directory 'msg.sock' and 'msg.lock'.
If a script to run mdsearch utility in a loop,
this might result in used space slowly growing-up on underlying filesystem.

Supposed to add a new label 'fail_free_messaging',
make it go through the cmdline_messaging_context_free() which deletes the
lock files in the directory msg.sock and msg.lock before mdsearch utility
is exiting with failure.

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

Signed-off-by: Jones Syue 
Reviewed-by: Ralph Boehme 
Reviewed-by: Volker Lendecke 

Autobuild-User(master): Volker Lendecke 
Autobuild-Date(master): Thu Jan 12 11:40:19 UTC 2023 on sn-devel-184

---

Summary of changes:
 source3/utils/mdsearch.c | 20 +++-
 1 file changed, 11 insertions(+), 9 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/utils/mdsearch.c b/source3/utils/mdsearch.c
index ab48e366a0a..eddb83874cb 100644
--- a/source3/utils/mdsearch.c
+++ b/source3/utils/mdsearch.c
@@ -144,12 +144,12 @@ int main(int argc, char **argv)
   flags);
if (!NT_STATUS_IS_OK(status)) {
DBG_ERR("Cannot connect to server: %s\n", nt_errstr(status));
-   goto fail;
+   goto fail_free_messaging;
}
 
status = cli_rpc_pipe_open_noauth(cli, _table_mdssvc, );
if (!NT_STATUS_IS_OK(status)) {
-   goto fail;
+   goto fail_free_messaging;
}
 
status = mdscli_connect(frame,
@@ -159,7 +159,7 @@ int main(int argc, char **argv)
_ctx);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to connect mdssvc\n");
-   goto fail;
+   goto fail_free_messaging;
}
 
if (opt_path == NULL) {
@@ -168,7 +168,7 @@ int main(int argc, char **argv)
basepath = talloc_strdup(frame, opt_path);
}
if (basepath == NULL) {
-   goto fail;
+   goto fail_free_messaging;
}
 
status = mdscli_search(frame,
@@ -179,7 +179,7 @@ int main(int argc, char **argv)
   );
if (!NT_STATUS_IS_OK(status)) {
printf("mdscli_search failed\n");
-   goto fail;
+   goto fail_free_messaging;
}
 
if (!opt_live) {
@@ -199,7 +199,7 @@ int main(int argc, char **argv)
}
if (!NT_STATUS_IS_OK(status)) {
printf("mdscli_get_results failed\n");
-   goto fail;
+   goto fail_free_messaging;
}
 
ncnids = talloc_array_length(cnids);
@@ -217,7 +217,7 @@ int main(int argc, char **argv)
if (!NT_STATUS_IS_OK(status)) {
printf("Get path for CNID 0x%"PRIx64" failed\n",
   cnids[i]);
-   goto fail;
+   goto fail_free_messaging;
}
printf("%s\n", path);
TALLOC_FREE(path);
@@ -227,13 +227,13 @@ int main(int argc, char **argv)
status = mdscli_close_search();
if (!NT_STATUS_IS_OK(status)) {
printf("mdscli_close_search failed\n");
-   goto fail;
+   goto fail_free_messaging;
}
 
status = mdscli_disconnect(mdscli_ctx);
if (!NT_STATUS_IS_OK(status)) {
printf("mdscli_disconnect failed\n");
-   goto fail;
+   goto fail_free_messaging;
}
 
cmdline_messaging_context_free();
@@ -241,6 +241,8