From 5ec660160e414c18a6ea0e61ef9e7c970dc3d7a1 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Thu, 6 Jul 2023 17:53:35 +0200 Subject: [PATCH] smbclient3: Get all reparse data for allinfo If we hit a reparse point in point, it might be something but a symlink. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison Autobuild-User(master): Stefan Metzmacher Autobuild-Date(master): Thu Aug 10 14:36:40 UTC 2023 on atb-devel-224 --- source3/client/client.c | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/source3/client/client.c b/source3/client/client.c index 0948e6a07fd..19ff37248c3 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -41,6 +41,7 @@ #include "lib/util/time_basic.h" #include "lib/util/string_wrappers.h" #include "lib/cmdline/cmdline.h" +#include "libcli/smb/reparse.h" #ifndef REGISTER #define REGISTER 0 @@ -1707,20 +1708,38 @@ static int do_allinfo(const char *name) } if (attr & FILE_ATTRIBUTE_REPARSE_POINT) { - char *subst, *print; - uint32_t flags; + struct reparse_data_buffer *rep = NULL; + uint8_t *data = NULL; + uint32_t datalen; + char *s = NULL; + + rep = talloc_zero(talloc_tos(), struct reparse_data_buffer); + if (rep == NULL) { + d_printf("talloc_zero() failed\n"); + return false; + } - status = cli_readlink(cli, name, talloc_tos(), &subst, &print, - &flags); + status = cli_get_reparse_data(cli, name, rep, &data, &datalen); if (!NT_STATUS_IS_OK(status)) { - d_fprintf(stderr, "cli_readlink returned %s\n", + d_fprintf(stderr, + "cli_get_reparse_data() failed: %s\n", nt_errstr(status)); - } else { - d_printf("symlink: subst=[%s], print=[%s], flags=%x\n", - subst, print, flags); - TALLOC_FREE(subst); - TALLOC_FREE(print); + TALLOC_FREE(rep); + return false; + } + + status = reparse_data_buffer_parse(rep, rep, data, datalen); + if (!NT_STATUS_IS_OK(status)) { + d_fprintf(stderr, + "reparse_data_buffer_parse() failed: %s\n", + nt_errstr(status)); + TALLOC_FREE(rep); + return false; } + + s = reparse_data_buffer_str(rep, rep); + d_printf("%s", s); + TALLOC_FREE(rep); } status = cli_ntcreate(cli, name, 0, -- 2.47.3