libsmb: Fix the smbclient readlink command
authorVolker Lendecke <vl@samba.org>
Thu, 29 Sep 2022 13:41:30 +0000 (15:41 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 3 Oct 2022 20:03:32 +0000 (20:03 +0000)
We use cli_smb2_qpathinfo_basic() for cli_resolve_path() before
calling cli_readlink(). This fails as it never tries with
FILE_OPEN_REPARSE_POINT, so we never get to the point where we
actually can issue the FSCTL_GET_REPARSE_POINT.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/cli_smb2_fnum.c

index f64bbef961da389761dff558b34649a70df1b3b1..c7d5ac70dcd536e6f4d5ac62445adddc9e874bb5 100644 (file)
@@ -1614,6 +1614,24 @@ NTSTATUS cli_smb2_qpathinfo_basic(struct cli_state *cli,
                        NULL);
        }
 
+       if (NT_STATUS_EQUAL(status, NT_STATUS_STOPPED_ON_SYMLINK)) {
+               /* Maybe a reparse point ? */
+               status = cli_smb2_create_fnum(cli,
+                       name,
+                       0,                      /* create_flags */
+                       SMB2_IMPERSONATION_IMPERSONATION,
+                       FILE_READ_ATTRIBUTES,           /* desired_access */
+                       0, /* file attributes */
+                       FILE_SHARE_READ|FILE_SHARE_WRITE|FILE_SHARE_DELETE, /* share_access */
+                       FILE_OPEN,              /* create_disposition */
+                       FILE_OPEN_REPARSE_POINT, /* create_options */
+                       NULL,
+                       &fnum,
+                       &cr,
+                       NULL,
+                       NULL);
+       }
+
        if (!NT_STATUS_IS_OK(status)) {
                return status;
        }