]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Remove reparse_symlink.c
authorVolker Lendecke <vl@samba.org>
Thu, 21 Sep 2023 14:40:43 +0000 (07:40 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 25 Sep 2023 17:09:37 +0000 (17:09 +0000)
Makes reparse_buffer_marshall static to reparse.c

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
libcli/smb/py_reparse_symlink.c
libcli/smb/reparse.c
libcli/smb/reparse_symlink.c [deleted file]
libcli/smb/reparse_symlink.h [deleted file]
libcli/smb/wscript
source3/libsmb/clisymlink.c
source3/libsmb/pylibsmb.c

index 52fcc487f40928c85582da3cca9a46eb86e252ff..93e5cf8f0493716ce07bea7a54182bed562ef676 100644 (file)
@@ -22,7 +22,7 @@
 #include "python/py3compat.h"
 #include "libcli/util/pyerrors.h"
 #include "reparse.h"
-#include "reparse_symlink.h"
+#include "lib/util/iov_buf.h"
 #include "smb_constants.h"
 
 static PyObject *py_reparse_put(PyObject *module, PyObject *args)
index 77ef7fb715b5b662f3a334da4c85c13a35197083..1a6feff17e1373bf03e679ebbcab2cf67110be14 100644 (file)
@@ -17,7 +17,7 @@
 
 #include "replace.h"
 #include "libcli/smb/reparse.h"
-#include "libcli/smb/reparse_symlink.h"
+#include "lib/util/iov_buf.h"
 #include "libcli/smb/smb_constants.h"
 #include "libcli/util/error.h"
 #include "lib/util/debug.h"
@@ -349,6 +349,38 @@ char *reparse_data_buffer_str(TALLOC_CTX *mem_ctx,
        return s;
 }
 
+static ssize_t reparse_buffer_marshall(uint32_t reparse_tag,
+                                      uint16_t reserved,
+                                      const struct iovec *iov,
+                                      int iovlen,
+                                      uint8_t *buf,
+                                      size_t buflen)
+{
+       ssize_t reparse_data_length = iov_buflen(iov, iovlen);
+       size_t needed;
+
+       if (reparse_data_length == -1) {
+               return -1;
+       }
+       if (reparse_data_length > UINT16_MAX) {
+               return -1;
+       }
+
+       needed = reparse_data_length + 8;
+       if (needed < reparse_data_length) {
+               return -1;
+       }
+
+       if (buflen >= needed) {
+               PUSH_LE_U32(buf, 0, reparse_tag);
+               PUSH_LE_U16(buf, 4, reparse_data_length);
+               PUSH_LE_U16(buf, 6, reserved);
+               iov_buf(iov, iovlen, buf + 8, buflen - 8);
+       }
+
+       return needed;
+}
+
 static ssize_t
 reparse_data_buffer_marshall_syml(const struct symlink_reparse_struct *src,
                                  uint8_t *buf,
diff --git a/libcli/smb/reparse_symlink.c b/libcli/smb/reparse_symlink.c
deleted file mode 100644 (file)
index b99cca2..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- *
- * Implementation of
- * http://msdn.microsoft.com/en-us/library/cc232006%28v=PROT.13%29.aspx
- *
- * Copyright (C) Volker Lendecke 2011
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "replace.h"
-#include "reparse_symlink.h"
-#include "lib/util/charset/charset.h"
-#include "lib/util/bytearray.h"
-#include "libcli/smb/smb_constants.h"
-#include "libcli/smb/smb_util.h"
-#include "lib/util/debug.h"
-
-ssize_t reparse_buffer_marshall(
-       uint32_t reparse_tag,
-       uint16_t reserved,
-       const struct iovec *iov,
-       int iovlen,
-       uint8_t *buf,
-       size_t buflen)
-{
-       ssize_t reparse_data_length = iov_buflen(iov, iovlen);
-       size_t needed;
-
-       if (reparse_data_length == -1) {
-               return -1;
-       }
-       if (reparse_data_length > UINT16_MAX) {
-               return -1;
-       }
-
-       needed = reparse_data_length + 8;
-       if (needed < reparse_data_length) {
-               return -1;
-       }
-
-       if (buflen >= needed) {
-               PUSH_LE_U32(buf, 0, reparse_tag);
-               PUSH_LE_U16(buf, 4, reparse_data_length);
-               PUSH_LE_U16(buf, 6, reserved);
-               iov_buf(iov, iovlen, buf+8, buflen-8);
-       }
-
-       return needed;
-}
-
-bool symlink_reparse_buffer_marshall(
-       const char *substitute,
-       const char *printname,
-       uint16_t unparsed_path_length,
-       uint32_t flags,
-       TALLOC_CTX *mem_ctx,
-       uint8_t **pdst,
-       size_t *pdstlen)
-{
-       uint8_t sbuf[12];
-       struct iovec iov[3];
-       uint8_t *dst = NULL;
-       ssize_t dst_len;
-       uint8_t *subst_utf16 = NULL;
-       uint8_t *print_utf16 = NULL;
-       size_t subst_len = 0;
-       size_t print_len = 0;
-       bool ret = false;
-       bool ok;
-
-       if (substitute == NULL) {
-               return false;
-       }
-       if (printname == NULL) {
-               printname = substitute;
-       }
-
-       iov[0] = (struct iovec) { .iov_base = sbuf, .iov_len = sizeof(sbuf), };
-
-       ok = convert_string_talloc(
-               mem_ctx,
-               CH_UNIX,
-               CH_UTF16,
-               substitute,
-               strlen(substitute),
-               &subst_utf16,
-               &subst_len);
-       if (!ok) {
-               goto fail;
-       }
-       if (subst_len > UINT16_MAX) {
-               goto fail;
-       }
-       iov[1] = (struct iovec) {
-               .iov_base = subst_utf16, .iov_len = subst_len,
-       };
-
-       ok = convert_string_talloc(
-               mem_ctx,
-               CH_UNIX,
-               CH_UTF16,
-               printname,
-               strlen(printname),
-               &print_utf16,
-               &print_len);
-       if (!ok) {
-               goto fail;
-       }
-       if (print_len > UINT16_MAX) {
-               goto fail;
-       }
-       iov[2] = (struct iovec) {
-               .iov_base = print_utf16, .iov_len = print_len,
-       };
-
-       PUSH_LE_U16(sbuf, 0, 0);         /* SubstituteNameOffset */
-       PUSH_LE_U16(sbuf, 2, subst_len); /* SubstituteNameLength */
-       PUSH_LE_U16(sbuf, 4, subst_len); /* PrintNameOffset */
-       PUSH_LE_U16(sbuf, 6, print_len); /* PrintNameLength */
-       PUSH_LE_U32(sbuf, 8, flags);     /* Flags */
-
-       dst_len = reparse_buffer_marshall(
-               IO_REPARSE_TAG_SYMLINK,
-               unparsed_path_length,
-               iov,
-               ARRAY_SIZE(iov),
-               NULL,
-               0);
-       if (dst_len == -1) {
-               goto fail;
-       }
-
-       dst = talloc_array(mem_ctx, uint8_t, dst_len);
-       if (dst == NULL) {
-               goto fail;
-       }
-
-       reparse_buffer_marshall(
-               IO_REPARSE_TAG_SYMLINK,
-               unparsed_path_length,
-               iov,
-               ARRAY_SIZE(iov),
-               dst,
-               dst_len);
-
-       *pdst = dst;
-       *pdstlen = dst_len;
-       ret = true;
-
-fail:
-       TALLOC_FREE(subst_utf16);
-       TALLOC_FREE(print_utf16);
-       return ret;
-}
diff --git a/libcli/smb/reparse_symlink.h b/libcli/smb/reparse_symlink.h
deleted file mode 100644 (file)
index 322bf73..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Unix SMB/CIFS implementation.
- *
- * Implementation of
- * http://msdn.microsoft.com/en-us/library/cc232006%28v=PROT.13%29.aspx
- *
- * Copyright (C) Volker Lendecke 2011
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __REPARSE_SYMLINK_H__
-#define __REPARSE_SYMLINK_H__
-
-#include "replace.h"
-#include <talloc.h>
-#include "lib/util/iov_buf.h"
-
-ssize_t reparse_buffer_marshall(
-       uint32_t reparse_tag,
-       uint16_t reserved,
-       const struct iovec *iov,
-       int iovlen,
-       uint8_t *buf,
-       size_t buflen);
-
-bool symlink_reparse_buffer_marshall(
-       const char *substitute,
-       const char *printname,
-       uint16_t unparsed_path_length,
-       uint32_t flags,
-       TALLOC_CTX *mem_ctx,
-       uint8_t **pdst,
-       size_t *pdstlen);
-
-#endif
index 3c7848716f3876bd03a2027dbdc41c50ebbcaabd..45d8cdb8bb5a05f5243e96ae88e94a0d843f4732 100644 (file)
@@ -45,7 +45,6 @@ def build(bld):
            smb2cli_echo.c
            smb2_posix.c
            tstream_smbXcli_np.c
-           reparse_symlink.c
            reparse.c
     ''',
     deps='''
index d13332b11bdf6cd4afaf357efa3f541fe2216c3c..81d8646afccdac412c066a431432ecf25e4ffea4 100644 (file)
@@ -28,7 +28,6 @@
 #include "libcli/security/security.h"
 #include "../libcli/smb/smbXcli_base.h"
 #include "libcli/smb/reparse.h"
-#include "libcli/smb/reparse_symlink.h"
 
 struct cli_create_reparse_point_state {
        struct tevent_context *ev;
index faef47de49d572196121319e728ff8cb4b600ce7..deda81d16b4ef980747dedbad884847f4c66895d 100644 (file)
@@ -52,7 +52,6 @@ c = libsmb.Conn("127.0.0.1",
 #include "libcli/smb/smbXcli_base.h"
 #include "libcli/smb/smb2_negotiate_context.h"
 #include "libcli/smb/reparse.h"
-#include "libcli/smb/reparse_symlink.h"
 #include "libsmb/libsmb.h"
 #include "libcli/security/security.h"
 #include "system/select.h"