s3:modules: Use hash_inode() in vfs_streams_xattr
authorAndreas Schneider <asn@samba.org>
Tue, 18 Jun 2019 15:09:29 +0000 (17:09 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 3 Jul 2019 12:37:11 +0000 (12:37 +0000)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Jul  3 12:37:12 UTC 2019 on sn-devel-184

source3/modules/vfs_streams_xattr.c
source3/modules/wscript_build

index 4050d9319fe7ae9f53ad989b14b0fd6548717d2b..3e840d9535ee7351efa36ffa37a7b7c0351502c7 100644 (file)
@@ -26,9 +26,7 @@
 #include "system/filesys.h"
 #include "lib/util/tevent_unix.h"
 #include "librpc/gen_ndr/ioctl.h"
-
-#include <gnutls/gnutls.h>
-#include <gnutls/crypto.h>
+#include "hash_inode.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
@@ -47,61 +45,6 @@ struct stream_io {
        vfs_handle_struct *handle;
 };
 
-static SMB_INO_T stream_inode(const SMB_STRUCT_STAT *sbuf, const char *sname)
-{
-       unsigned char hash[16];
-       gnutls_hash_hd_t hash_hnd = NULL;
-       SMB_INO_T result = 0;
-       char *upper_sname;
-       int rc;
-
-       DEBUG(10, ("stream_inode called for %lu/%lu [%s]\n",
-                  (unsigned long)sbuf->st_ex_dev,
-                  (unsigned long)sbuf->st_ex_ino, sname));
-
-       upper_sname = talloc_strdup_upper(talloc_tos(), sname);
-       SMB_ASSERT(upper_sname != NULL);
-
-       rc = gnutls_hash_init(&hash_hnd, GNUTLS_DIG_MD5);
-       if (rc < 0) {
-               goto out;
-       }
-
-       rc = gnutls_hash(hash_hnd, &(sbuf->st_ex_dev), sizeof(sbuf->st_ex_dev));
-       if (rc < 0) {
-               gnutls_hash_deinit(hash_hnd, NULL);
-               goto out;
-       }
-       rc = gnutls_hash(hash_hnd,
-                        &(sbuf->st_ex_ino),
-                        sizeof(sbuf->st_ex_ino));
-       if (rc < 0) {
-               gnutls_hash_deinit(hash_hnd, NULL);
-               goto out;
-       }
-       rc = gnutls_hash(hash_hnd,
-                        upper_sname,
-                        talloc_get_size(upper_sname) - 1);
-       if (rc < 0) {
-               gnutls_hash_deinit(hash_hnd, NULL);
-               goto out;
-       }
-
-       gnutls_hash_deinit(hash_hnd, hash);
-
-
-        /* Hopefully all the variation is in the lower 4 (or 8) bytes! */
-       memcpy(&result, hash, sizeof(result));
-       ZERO_ARRAY(hash);
-
-       DEBUG(10, ("stream_inode returns %lu\n", (unsigned long)result));
-
-out:
-       TALLOC_FREE(upper_sname);
-
-       return result;
-}
-
 static ssize_t get_xattr_size(connection_struct *conn,
                                const struct smb_filename *smb_fname,
                                const char *xattr_name)
@@ -304,7 +247,7 @@ static int streams_xattr_fstat(vfs_handle_struct *handle, files_struct *fsp,
 
        DEBUG(10, ("sbuf->st_ex_size = %d\n", (int)sbuf->st_ex_size));
 
-       sbuf->st_ex_ino = stream_inode(sbuf, io->xattr_name);
+       sbuf->st_ex_ino = hash_inode(sbuf, io->xattr_name);
        sbuf->st_ex_mode &= ~S_IFMT;
        sbuf->st_ex_mode &= ~S_IFDIR;
         sbuf->st_ex_mode |= S_IFREG;
@@ -359,7 +302,7 @@ static int streams_xattr_stat(vfs_handle_struct *handle,
                goto fail;
        }
 
-       smb_fname->st.st_ex_ino = stream_inode(&smb_fname->st, xattr_name);
+       smb_fname->st.st_ex_ino = hash_inode(&smb_fname->st, xattr_name);
        smb_fname->st.st_ex_mode &= ~S_IFMT;
        smb_fname->st.st_ex_mode &= ~S_IFDIR;
         smb_fname->st.st_ex_mode |= S_IFREG;
@@ -412,7 +355,7 @@ static int streams_xattr_lstat(vfs_handle_struct *handle,
                goto fail;
        }
 
-       smb_fname->st.st_ex_ino = stream_inode(&smb_fname->st, xattr_name);
+       smb_fname->st.st_ex_ino = hash_inode(&smb_fname->st, xattr_name);
        smb_fname->st.st_ex_mode &= ~S_IFMT;
         smb_fname->st.st_ex_mode |= S_IFREG;
         smb_fname->st.st_ex_blocks =
index 58ca11dea61a94031dd4b1ac3feeb7d0a9efbfbd..5e0047da9170f0a7cb2ee78f740a990e5b5cdc60 100644 (file)
@@ -315,7 +315,7 @@ bld.SAMBA3_MODULE('vfs_catia',
 bld.SAMBA3_MODULE('vfs_streams_xattr',
                  subsystem='vfs',
                  source='vfs_streams_xattr.c',
-                 deps='samba-util',
+                 deps='samba-util HASH_INODE',
                  init_function='',
                  internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_streams_xattr'),
                  enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_streams_xattr'))