diff options
author | Andreas Schneider <asn@samba.org> | 2019-06-18 17:09:29 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2019-07-03 12:37:11 +0000 |
commit | 9d5044fe97b16158260c504979a1fc808fa901d4 (patch) | |
tree | b898308aaf732b9c5defe1c16411fd846ba1d2df /source3/modules | |
parent | 10f828629bb81a651b9e8aab002a84c053f37387 (diff) | |
download | samba-9d5044fe97b16158260c504979a1fc808fa901d4.tar.gz |
s3:modules: Use hash_inode() in vfs_streams_xattr
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
Diffstat (limited to 'source3/modules')
-rw-r--r-- | source3/modules/vfs_streams_xattr.c | 65 | ||||
-rw-r--r-- | source3/modules/wscript_build | 2 |
2 files changed, 5 insertions, 62 deletions
diff --git a/source3/modules/vfs_streams_xattr.c b/source3/modules/vfs_streams_xattr.c index 4050d9319fe..3e840d9535e 100644 --- a/source3/modules/vfs_streams_xattr.c +++ b/source3/modules/vfs_streams_xattr.c @@ -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 = diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build index 58ca11dea61..5e0047da917 100644 --- a/source3/modules/wscript_build +++ b/source3/modules/wscript_build @@ -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')) |