The Samba-Bugzilla – Attachment 527 Details for
Bug 1397
Created vfs_hex module patch to support HEX encoding
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
HEX encoding support
samba-3.0.5pre1.hex.patch (text/plain), 24.25 KB, created by
TAKEDA yasuma (mail address dead)
on 2004-05-27 15:05:43 UTC
(
hide
)
Description:
HEX encoding support
Filename:
MIME Type:
Creator:
TAKEDA yasuma (mail address dead)
Created:
2004-05-27 15:05:43 UTC
Size:
24.25 KB
patch
obsolete
>diff -uNr samba-3.0.5pre1.org/source/Makefile.in samba-3.0.5pre1/source/Makefile.in >--- samba-3.0.5pre1.org/source/Makefile.in 2004-05-25 23:09:30.000000000 +0900 >+++ samba-3.0.5pre1/source/Makefile.in 2004-05-28 19:01:04.000000000 +0900 >@@ -346,6 +346,7 @@ > VFS_EXPAND_MSDFS_OBJ = modules/vfs_expand_msdfs.o > VFS_SHADOW_COPY_OBJ = modules/vfs_shadow_copy.o > VFS_AFSACL_OBJ = modules/vfs_afsacl.o >+VFS_HEX_OBJ = modules/vfs_hex.o > > PLAINTEXT_AUTH_OBJ = auth/pampass.o auth/pass_check.o > >@@ -1213,6 +1214,11 @@ > @$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_CAP_OBJ:.o=.@PICSUFFIX@) \ > @SONAMEFLAG@`basename $@` > >+bin/hex.@SHLIBEXT@: $(VFS_HEX_OBJ:.o=.@PICSUFFIX@) >+ @echo "Building plugin $@" >+ @$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_HEX_OBJ:.o=.@PICSUFFIX@) \ >+ @SONAMEFLAG@`basename $@` >+ > bin/expand_msdfs.@SHLIBEXT@: $(VFS_EXPAND_MSDFS_OBJ:.o=.@PICSUFFIX@) > @echo "Building plugin $@" > @$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_EXPAND_MSDFS_OBJ:.o=.@PICSUFFIX@) \ >diff -uNr samba-3.0.5pre1.org/source/configure.in samba-3.0.5pre1/source/configure.in >--- samba-3.0.5pre1.org/source/configure.in 2004-05-25 23:09:34.000000000 +0900 >+++ samba-3.0.5pre1/source/configure.in 2004-05-28 19:09:49.000000000 +0900 >@@ -363,7 +363,7 @@ > default_static_modules="pdb_smbpasswd pdb_tdbsam rpc_lsa rpc_samr rpc_reg rpc_lsa_ds rpc_wks rpc_net rpc_dfs rpc_srv rpc_spoolss auth_rhosts auth_sam auth_unix auth_winbind auth_server auth_domain auth_builtin" > > dnl These are preferably build shared, and static if dlopen() is not available >-default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437" >+default_shared_modules="vfs_recycle vfs_audit vfs_extd_audit vfs_full_audit vfs_netatalk vfs_fake_perms vfs_default_quota vfs_readonly vfs_cap vfs_hex vfs_expand_msdfs vfs_shadow_copy charset_CP850 charset_CP437" > > if test "x$developer" = xyes; then > default_static_modules="$default_static_modules rpc_echo" >@@ -4373,6 +4373,7 @@ > SMB_MODULE(vfs_expand_msdfs, \$(VFS_EXPAND_MSDFS_OBJ), "bin/expand_msdfs.$SHLIBEXT", VFS) > SMB_MODULE(vfs_shadow_copy, \$(VFS_SHADOW_COPY_OBJ), "bin/shadow_copy.$SHLIBEXT", VFS) > SMB_MODULE(vfs_afsacl, \$(VFS_AFSACL_OBJ), "bin/afsacl.$SHLIBEXT", VFS) >+SMB_MODULE(vfs_hex, \$(VFS_HEX_OBJ), "bin/hex.$SHLIBEXT", VFS) > SMB_SUBSYSTEM(VFS,smbd/vfs.o) > > AC_DEFINE_UNQUOTED(STRING_STATIC_MODULES, "$string_static_modules", [String list of builtin modules]) >diff -uNr samba-3.0.5pre1.org/source/modules/vfs_hex.c samba-3.0.5pre1/source/modules/vfs_hex.c >--- samba-3.0.5pre1.org/source/modules/vfs_hex.c 1970-01-01 09:00:00.000000000 +0900 >+++ samba-3.0.5pre1/source/modules/vfs_hex.c 2004-05-28 19:00:22.000000000 +0900 >@@ -0,0 +1,624 @@ >+/* >+ >+ HEX VFS module for Samba 3.x Version 0.1 >+ Original Code from CAP VFS module >+ >+ * Copyright (C) Tim Potter, 1999-2000 >+ * Copyright (C) Alexander Bokovoy, 2002-2003 >+ * Copyright (C) Stefan (metze) Metzmacher, 2003 >+ * Copyright (C) TAKAHASHI Motonobu (monyo), 2003 >+ * Copyright (C) TAKEDA Yasuma <yasuma@miraclelinux.com>, 2004 >+ >+ 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 2 >+ 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, write to the Free Software >+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. >+ >+*/ >+ >+#include "includes.h" >+ >+/* >+ * If you want to use this module, set the following setting to smb.conf. >+ * [share] >+ * path = /xxxx/xxxx >+ * vfs object = hex >+ * ... >+ */ >+ >+static char *cp932_hex_encode(char *to, const char *from); >+static char *cp932_hex_decode(char *to, const char *from); >+ >+struct unix_to_hex_fn >+{ >+ const char *name; /* unix charset name */ >+ char *(*hex_encode_fn)(char *, const char *); >+ char *(*hex_decode_fn)(char *, const char *); >+}; >+ >+static struct unix_to_hex_fn *hex_fn; >+static struct unix_to_hex_fn *select_charset(void); >+ >+/* >+ * This modules depends on unix charset. >+ * If you want to use this module, you must set a appropriate encoding. >+ * You can set following encodings. >+ */ >+ >+static struct unix_to_hex_fn hex_encode_fn[] = { >+ {"CP932", cp932_hex_encode, cp932_hex_decode}, >+ {NULL,NULL,NULL} >+}; >+ >+static char *hexencode(char *to, const char *from) >+{ >+ if (hex_fn){ >+ return hex_fn->hex_encode_fn(to, from); >+ } >+ return pstrcpy(to, from); >+} >+ >+static char *hexdecode(char *to, const char *from) >+{ >+ if (hex_fn){ >+ return hex_fn->hex_decode_fn(to, from); >+ } >+ return pstrcpy(to, from); >+} >+ >+/* vfs operation function */ >+ >+static SMB_BIG_UINT hex_disk_free(vfs_handle_struct *handle, connection_struct *conn, const char *path, >+ BOOL small_query, SMB_BIG_UINT *bsize, >+ SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) >+{ >+ pstring hexpath; >+ DEBUG(5,("hex: hex_disk_free\n")); >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_DISK_FREE(handle, conn, hexpath, small_query, bsize, dfree, dsize); >+} >+ >+static DIR *hex_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname) >+{ >+ pstring hexname; >+ hexencode(hexname, fname); >+ DEBUG(5,("hex: hex_opendir %s[%s]\n", fname, hexname)); >+ return SMB_VFS_NEXT_OPENDIR(handle, conn, hexname); >+} >+ >+static struct dirent *hex_readdir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp) >+{ >+ struct dirent *result; >+ >+ result = SMB_VFS_NEXT_READDIR(handle, conn, dirp); >+ if (result) { >+ DEBUG(5,("hex: hex_readdir: %s\n", result->d_name)); >+ hexdecode(result->d_name, result->d_name); >+ } >+ return result; >+} >+ >+static int hex_mkdir(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_MKDIR(handle, conn, hexpath, mode); >+} >+ >+static int hex_rmdir(vfs_handle_struct *handle, connection_struct *conn, const char *path) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_RMDIR(handle, conn, hexpath); >+} >+ >+static int hex_open(vfs_handle_struct *handle, connection_struct *conn, const char *fname, int flags, mode_t mode) >+{ >+ pstring hexname; >+ DEBUG(5,("hex: hex_open for %s\n", fname)); >+ hexencode(hexname, fname); >+ return SMB_VFS_NEXT_OPEN(handle, conn, hexname, flags, mode); >+} >+ >+static int hex_rename(vfs_handle_struct *handle, connection_struct *conn, const char *old, const char *new) >+{ >+ pstring hexold, hexnew; >+ hexencode(hexold, old); >+ hexencode(hexnew, new); >+ >+ return SMB_VFS_NEXT_RENAME(handle, conn, hexold, hexnew); >+} >+ >+static int hex_stat(vfs_handle_struct *handle, connection_struct *conn, const char *fname, SMB_STRUCT_STAT *sbuf) >+{ >+ pstring hexname; >+ hexencode(hexname, fname); >+ return SMB_VFS_NEXT_STAT(handle, conn, hexname, sbuf); >+} >+ >+static int hex_lstat(vfs_handle_struct *handle, connection_struct *conn, const char *path, SMB_STRUCT_STAT *sbuf) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_LSTAT(handle, conn, hexpath, sbuf); >+} >+ >+static int hex_unlink(vfs_handle_struct *handle, connection_struct *conn, const char *path) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_UNLINK(handle, conn, hexpath); >+} >+ >+static int hex_chmod(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_CHMOD(handle, conn, hexpath, mode); >+} >+ >+static int hex_chown(vfs_handle_struct *handle, connection_struct *conn, const char *path, uid_t uid, gid_t gid) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_CHOWN(handle, conn, hexpath, uid, gid); >+} >+ >+static int hex_chdir(vfs_handle_struct *handle, connection_struct *conn, const char *path) >+{ >+ pstring hexpath; >+ DEBUG(5,("hex: hex_chdir for %s\n", path)); >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_CHDIR(handle, conn, hexpath); >+} >+ >+static char *hex_getwd(vfs_handle_struct *handle, connection_struct *conn, char *path) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_GETWD(handle, conn, hexpath); >+} >+ >+ >+static int hex_utime(vfs_handle_struct *handle, connection_struct *conn, const char *path, struct utimbuf *times) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_UTIME(handle, conn, hexpath, times); >+} >+ >+ >+static BOOL hex_symlink(vfs_handle_struct *handle, connection_struct *conn, const char *oldpath, const char *newpath) >+{ >+ pstring hexoldpath, hexnewpath; >+ hexencode(hexoldpath, oldpath); >+ hexencode(hexnewpath, newpath); >+ return SMB_VFS_NEXT_SYMLINK(handle, conn, hexoldpath, hexnewpath); >+} >+ >+static BOOL hex_readlink(vfs_handle_struct *handle, connection_struct *conn, const char *path, char *buf, size_t bufsiz) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_READLINK(handle, conn, hexpath, buf, bufsiz); >+} >+ >+static int hex_link(vfs_handle_struct *handle, connection_struct *conn, const char *oldpath, const char *newpath) >+{ >+ pstring hexoldpath, hexnewpath; >+ hexencode(hexoldpath, oldpath); >+ hexencode(hexnewpath, newpath); >+ return SMB_VFS_NEXT_LINK(handle, conn, hexoldpath, hexnewpath); >+} >+ >+static int hex_mknod(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode, SMB_DEV_T dev) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_MKNOD(handle, conn, hexpath, mode, dev); >+} >+ >+static char *hex_realpath(vfs_handle_struct *handle, connection_struct *conn, const char *path, char *resolved_path) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_REALPATH(handle, conn, path, resolved_path); >+} >+ >+static BOOL hex_get_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info, struct security_descriptor_info **ppdesc) >+{ >+ pstring hexname; >+ hexencode(hexname, name); >+ return SMB_VFS_NEXT_GET_NT_ACL(handle, fsp, hexname, security_info, ppdesc); >+} >+ >+static BOOL hex_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp, const char *name, uint32 security_info_sent, struct security_descriptor_info *psd) >+{ >+ pstring hexname; >+ hexencode(hexname, name); >+ return SMB_VFS_NEXT_SET_NT_ACL(handle, fsp, hexname, security_info_sent, psd); >+} >+ >+static int hex_chmod_acl(vfs_handle_struct *handle, connection_struct *conn, const char *name, mode_t mode) >+{ >+ pstring hexname; >+ hexencode(hexname, name); >+ >+ /* If the underlying VFS doesn't have ACL support... */ >+ if (!handle->vfs_next.ops.chmod_acl) { >+ errno = ENOSYS; >+ return -1; >+ } >+ return SMB_VFS_NEXT_CHMOD_ACL(handle, conn, hexname, mode); >+} >+ >+static SMB_ACL_T hex_sys_acl_get_file(vfs_handle_struct *handle, connection_struct *conn, const char *path_p, SMB_ACL_TYPE_T type) >+{ >+ pstring hexpath_p; >+ hexencode(hexpath_p, path_p); >+ return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, conn, hexpath_p, type); >+} >+ >+static int hex_sys_acl_set_file(vfs_handle_struct *handle, connection_struct *conn, const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl) >+{ >+ pstring hexname; >+ hexencode(hexname, name); >+ return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, conn, hexname, acltype, theacl); >+} >+ >+static int hex_sys_acl_delete_def_file(vfs_handle_struct *handle, connection_struct *conn, const char *path) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, conn, hexpath); >+} >+ >+static ssize_t hex_getxattr(vfs_handle_struct *handle, struct connection_struct *conn,const char *path, const char *name, void *value, size_t size) >+{ >+ pstring hexpath, hexname; >+ hexencode(hexpath, path); >+ hexencode(hexname, name); >+ return SMB_VFS_NEXT_GETXATTR(handle, conn, hexpath, hexname, value, size); >+} >+ >+static ssize_t hex_lgetxattr(vfs_handle_struct *handle, struct connection_struct *conn,const char *path, const char *name, void *value, size_t >+size) >+{ >+ pstring hexpath, hexname; >+ hexencode(hexpath, path); >+ hexencode(hexname, name); >+ return SMB_VFS_NEXT_LGETXATTR(handle, conn, hexpath, hexname, value, size); >+} >+ >+static ssize_t hex_fgetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, void *value, size_t size) >+{ >+ pstring hexname; >+ hexencode(hexname, name); >+ return SMB_VFS_NEXT_FGETXATTR(handle, fsp, fd, hexname, value, size); >+} >+ >+static ssize_t hex_listxattr(vfs_handle_struct *handle, struct connection_struct *conn,const char *path, char *list, size_t size) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_LISTXATTR(handle, conn, hexpath, list, size); >+} >+ >+static ssize_t hex_llistxattr(vfs_handle_struct *handle, struct connection_struct *conn,const char *path, char *list, size_t size) >+{ >+ pstring hexpath; >+ hexencode(hexpath, path); >+ return SMB_VFS_NEXT_LLISTXATTR(handle, conn, hexpath, list, size); >+} >+ >+static int hex_removexattr(vfs_handle_struct *handle, struct connection_struct *conn,const char *path, const char *name) >+{ >+ pstring hexpath, hexname; >+ hexencode(hexpath, path); >+ hexencode(hexname, name); >+ return SMB_VFS_NEXT_REMOVEXATTR(handle, conn, hexpath, hexname); >+} >+ >+static int hex_lremovexattr(vfs_handle_struct *handle, struct connection_struct *conn,const char *path, const char *name) >+{ >+ pstring hexpath, hexname; >+ hexencode(hexpath, path); >+ hexencode(hexname, name); >+ return SMB_VFS_NEXT_LREMOVEXATTR(handle, conn, hexpath, hexname); >+} >+ >+static int hex_fremovexattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name) >+{ >+ pstring hexname; >+ hexencode(hexname, name); >+ return SMB_VFS_NEXT_FREMOVEXATTR(handle, fsp, fd, hexname); >+} >+ >+static int hex_setxattr(vfs_handle_struct *handle, struct connection_struct *conn,const char *path, const char *name, const void *value, size_t size, int flags) >+{ >+ pstring hexpath, hexname; >+ hexencode(hexpath, path); >+ hexencode(hexname, name); >+ return SMB_VFS_NEXT_SETXATTR(handle, conn, hexpath, hexname, value, size, flags); >+} >+ >+static int hex_lsetxattr(vfs_handle_struct *handle, struct connection_struct *conn,const char *path, const char *name, const void *value, size_t size, int flags) >+{ >+ pstring hexpath, hexname; >+ hexencode(hexpath, path); >+ hexencode(hexname, name); >+ return SMB_VFS_NEXT_LSETXATTR(handle, conn, hexpath, hexname, value, size, flags); >+} >+ >+static int hex_fsetxattr(vfs_handle_struct *handle, struct files_struct *fsp,int fd, const char *name, const void *value, size_t size, int flags) >+{ >+ pstring hexname; >+ hexencode(hexname, name); >+ return SMB_VFS_NEXT_FSETXATTR(handle, fsp, fd, hexname, value, size, flags); >+} >+ >+ >+ >+/* VFS operations structure */ >+ >+static vfs_op_tuple hex_op_tuples[] = { >+ >+ /* Disk operations */ >+ >+ {SMB_VFS_OP(hex_disk_free), SMB_VFS_OP_DISK_FREE, SMB_VFS_LAYER_TRANSPARENT}, >+ >+ /* Directory operations */ >+ >+ {SMB_VFS_OP(hex_opendir), SMB_VFS_OP_OPENDIR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_readdir), SMB_VFS_OP_READDIR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_mkdir), SMB_VFS_OP_MKDIR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_rmdir), SMB_VFS_OP_RMDIR, SMB_VFS_LAYER_TRANSPARENT}, >+ >+ /* File operations */ >+ >+ {SMB_VFS_OP(hex_open), SMB_VFS_OP_OPEN, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_rename), SMB_VFS_OP_RENAME, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_stat), SMB_VFS_OP_STAT, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_lstat), SMB_VFS_OP_LSTAT, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_unlink), SMB_VFS_OP_UNLINK, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_chmod), SMB_VFS_OP_CHMOD, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_chown), SMB_VFS_OP_CHOWN, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_chdir), SMB_VFS_OP_CHDIR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_getwd), SMB_VFS_OP_GETWD, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_utime), SMB_VFS_OP_UTIME, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_symlink), SMB_VFS_OP_SYMLINK, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_readlink), SMB_VFS_OP_READLINK, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_link), SMB_VFS_OP_LINK, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_mknod), SMB_VFS_OP_MKNOD, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_realpath), SMB_VFS_OP_REALPATH, SMB_VFS_LAYER_TRANSPARENT}, >+ >+ /* NT ACL operations. */ >+ >+ {SMB_VFS_OP(hex_get_nt_acl), SMB_VFS_OP_GET_NT_ACL, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_set_nt_acl), SMB_VFS_OP_SET_NT_ACL, SMB_VFS_LAYER_TRANSPARENT}, >+ >+ /* POSIX ACL operations. */ >+ >+ {SMB_VFS_OP(hex_chmod_acl), SMB_VFS_OP_CHMOD_ACL, SMB_VFS_LAYER_TRANSPARENT}, >+ >+ {SMB_VFS_OP(hex_sys_acl_get_file), SMB_VFS_OP_SYS_ACL_GET_FILE, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_sys_acl_set_file), SMB_VFS_OP_SYS_ACL_SET_FILE, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_sys_acl_delete_def_file), SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, SMB_VFS_LAYER_TRANSPARENT}, >+ >+ /* EA operations. */ >+ {SMB_VFS_OP(hex_getxattr), SMB_VFS_OP_GETXATTR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_lgetxattr), SMB_VFS_OP_LGETXATTR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_fgetxattr), SMB_VFS_OP_FGETXATTR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_listxattr), SMB_VFS_OP_LISTXATTR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_llistxattr), SMB_VFS_OP_LLISTXATTR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_removexattr), SMB_VFS_OP_REMOVEXATTR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_lremovexattr), SMB_VFS_OP_LREMOVEXATTR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_fremovexattr), SMB_VFS_OP_FREMOVEXATTR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_setxattr), SMB_VFS_OP_SETXATTR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_lsetxattr), SMB_VFS_OP_LSETXATTR, SMB_VFS_LAYER_TRANSPARENT}, >+ {SMB_VFS_OP(hex_fsetxattr), SMB_VFS_OP_FSETXATTR, SMB_VFS_LAYER_TRANSPARENT}, >+ >+ /* last operation */ >+ {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} >+}; >+ >+static struct unix_to_hex_fn *select_charset(void) >+{ >+ struct unix_to_hex_fn *fn_pnt; >+ >+ for (fn_pnt=hex_encode_fn; fn_pnt->name; fn_pnt++) >+ { >+ DEBUG(5, ("hex: select unix_charset %s : %s\n", fn_pnt->name, lp_unix_charset())); >+ if (!StrCaseCmp(fn_pnt->name, lp_unix_charset())){ >+ return fn_pnt; >+ } >+ } >+ DEBUG(1, ("hex: can't convert from %s to hex", lp_unix_charset())); >+ return NULL; >+} >+ >+ >+NTSTATUS vfs_hex_init(void) >+{ >+ hex_fn = NULL; >+ >+ hex_fn = select_charset(); >+ >+ return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "hex", hex_op_tuples); >+} >+ >+/* For HEX functions */ >+#define hex_tag ':' >+#define hex2bin(c) hex2bin_table[(unsigned char)(c)] >+#define bin2hex(c) bin2hex_table[(unsigned char)(c)] >+ >+static unsigned char hex2bin_table[256] = { >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */ >+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 0, 0, 0, 0, 0, /* 0x30 */ >+ 0000, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0000, /* 0x40 */ >+ 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 */ >+ 0000, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0000, /* 0x60 */ >+ 0000, 0000, 0000, 0000, 0000, 0000, 0000, 0000, >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x80 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x90 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xe0 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 /* 0xf0 */ >+}; >+ >+static unsigned char bin2hex_table[256] = "0123456789abcdef"; >+ >+/* >+ * Following code is available only CP932 >+ */ >+ >+/* CP932 first byte is 0x81-0x9F or 0xE0-0xFC */ >+static unsigned char cp932_1st_table[256] = { >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x40 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x50 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x60 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x70 */ >+ 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x90 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xa0 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xb0 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xc0 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0xd0 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xe0 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 /* 0xf0 */ >+}; >+ >+/* CP932 second byte is 0x40-0x7E or 0x80-0xFC */ >+static unsigned char cp932_2nd_table[256] = { >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x20 */ >+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 0x30 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x50 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x60 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, /* 0x70 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x80 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0x90 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xa0 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xb0 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xc0 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xd0 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* 0xe0 */ >+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0 /* 0xf0 */ >+}; >+ >+ >+#define is_cp932_jisx0201RH(s) ((unsigned char)*s >= 0xa1 \ >+ && (unsigned char)*s <= 0xdf) >+ >+static BOOL is_cp932_str(const unsigned char *s) >+{ >+ if ((s[0] && (unsigned int) cp932_1st_table[s[0]]) && (s[1] && (unsigned int) cp932_2nd_table[s[1]])) >+ { >+ return True; >+ } >+ return False; >+} >+ >+static BOOL is_cp932_hex(const char *s) >+{ >+ if (s[0] == hex_tag){ >+ if ((s[1] && strchr(bin2hex_table, s[1])) && >+ (s[2] && strchr(bin2hex_table, s[2]))) >+ return True; >+ } >+ return False; >+} >+ >+/******************************************************************* >+ original code -> ":xx" - CP932 to HEX format >+********************************************************************/ >+static char *cp932_hex_encode(char *to, const char *from) >+{ >+ pstring cvtbuf; >+ char *out; >+ >+ DEBUG(10, ("hex: encode %s\n", from)); >+ >+ if (to == from){ >+ from = pstrcpy((char *)cvtbuf, from); >+ } >+ >+ for (out = to; *from && (out - to < sizeof(pstring)-7);){ >+ /* notice buffer shortage error */ >+ if (is_cp932_jisx0201RH(from)){ >+ /* JISX0201 1byte kana */ >+ *out++ = hex_tag; >+ *out++ = bin2hex (((*from)>>4)&0x0f); >+ *out++ = bin2hex ((*from)&0x0f); >+ from++; >+ }else if(is_cp932_str(from)){ >+ /* JISX0208 2byte kana and user defined char */ >+ *out++ = hex_tag; >+ *out++ = bin2hex (((*from)>>4)&0x0f); >+ *out++ = bin2hex ((*from)&0x0f); >+ from++; >+ *out++ = hex_tag; >+ *out++ = bin2hex (((*from)>>4)&0x0f); >+ *out++ = bin2hex ((*from)&0x0f); >+ from++; >+ }else{ >+ /* ASCII character */ >+ *out++ = *from++; >+ } >+ } >+ *out = '\0'; >+ return to; >+} >+ >+ >+/******************************************************************* >+ HEX -> original code HEX to CP932 >+********************************************************************/ >+static char *cp932_hex_decode(char *to, const char *from) >+{ >+ pstring cvtbuf; >+ char *out; >+ >+ DEBUG(10, ("hex: decode %s\n", from)); >+ >+ if (to == from){ >+ from = pstrcpy ((char *) cvtbuf, from); >+ } >+ >+ for (out = to; *from && (out - to < sizeof(pstring)-3);) { >+ if (is_cp932_hex(from)){ >+ /* converted HEX code */ >+ *out++ = (hex2bin(from[1]) << 4) | (hex2bin(from[2])); >+ from += 3; >+ } else { >+ /* non converted HEX code */ >+ *out++ = *from++; >+ } >+ } >+ *out = '\0'; >+ DEBUG(10, ("hex: decoded %s\n", to)); >+ return to; >+} >+
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 1397
: 527