samba-fu resurrected for 3.0.9 - any interest?
Jurriaan
thunder7 at xs4all.nl
Wed Dec 8 20:15:19 GMT 2004
At work, I have a proprietary application (without source) that can,
under some circumstances, only save files, not print them.
I want to print those files. Since the clients are windows clients, and
the server runs unix, we already use samba.
To print a file after the program has saved it, there are two
possibilities:
- run a script on the unix server that monitors a certain directory, and
prints files if they arrive
- resurrect the samba-fu module that can take action when a client
closes a file
The first is not as simple as it seems, taking into account large files
that take time to get written, multiple clients, printing as fast as
possible since the users won't accept a print script that takes 5
minutes to decide if the file is really complete on the server etc etc.
In short, I've adapted the samba-fu module to samba-3.0.9.
This module, from before 2.2, allows users to define scripts to run when
certain actions are taken.
I hope to get this accepted in the official distribution, since that
means I can point the documentation at work at the official docs :-)
Also, sometimes people on the internet ask about this, so there is
interest in this module.
Attached is the .diff against samba-3.0.9.
Please send any constructive comments you may have, I never looked as
samba's internals before today and I think it shows. For example, it
seems overdone to get the parameters each time an action is taken. But
the default call to get parameters does want a connection, and
vfs_audit.c works in the same way - so I suppose this is meant to be.
Also, the patch may change more files than strictly necessary, for
example configure vs. configure.in.
Kind regards,
Jurriaan
diff -U 3 -Br -N samba-3.0.9/source/Makefile.in samba-3.0.9-jk/source/Makefile.in
--- samba-3.0.9/source/Makefile.in 2004-11-16 04:03:12.000000000 +0100
+++ samba-3.0.9-jk/source/Makefile.in 2004-12-08 16:21:39.000000000 +0100
@@ -333,6 +333,7 @@
NOTIFY_OBJ = smbd/notify.o smbd/notify_hash.o smbd/notify_kernel.o
+VFS_SAMBAFU_OBJ = modules/vfs_sambafu.o
VFS_AUDIT_OBJ = modules/vfs_audit.o
VFS_EXTD_AUDIT_OBJ = modules/vfs_extd_audit.o
VFS_FULL_AUDIT_OBJ = modules/vfs_full_audit.o
@@ -1171,6 +1172,11 @@
@$(SHLD) $(LDSHFLAGS) -o $@ $(XML_OBJ:.o=. at PICSUFFIX@) @XML_LIBS@ \
@SONAMEFLAG@`basename $@`
+bin/sambafu. at SHLIBEXT@: $(VFS_SAMBAFU_OBJ:.o=. at PICSUFFIX@)
+ @echo "Building plugin $@"
+ @$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_SAMBAFU_OBJ:.o=. at PICSUFFIX@) \
+ @SONAMEFLAG@`basename $@`
+
bin/audit. at SHLIBEXT@: $(VFS_AUDIT_OBJ:.o=. at PICSUFFIX@)
@echo "Building plugin $@"
@$(SHLD) $(LDSHFLAGS) -o $@ $(VFS_AUDIT_OBJ:.o=. at PICSUFFIX@) \
diff -U 3 -Br -N samba-3.0.9/source/configure samba-3.0.9-jk/source/configure
--- samba-3.0.9/source/configure 2004-11-16 04:32:30.000000000 +0100
+++ samba-3.0.9-jk/source/configure 2004-12-08 16:21:39.000000000 +0100
@@ -3757,7 +3757,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"
-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_sambafu 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"
if test "x$developer" = xyes; then
default_static_modules="$default_static_modules rpc_echo"
@@ -39704,6 +39704,42 @@
echo "${ECHO_T}not" >&6
fi
+ echo "$as_me:$LINENO: checking how to build vfs_sambafu" >&5
+echo $ECHO_N "checking how to build vfs_sambafu... $ECHO_C" >&6
+ if test "$MODULE_vfs_sambafu"; then
+ DEST=$MODULE_vfs_sambafu
+ elif test "$MODULE_vfs" -a "$MODULE_DEFAULT_vfs_sambafu"; then
+ DEST=$MODULE_vfs
+ else
+ DEST=$MODULE_DEFAULT_vfs_sambafu
+ fi
+
+ if test x"$DEST" = xSHARED; then
+
+cat >>confdefs.h <<\_ACEOF
+#define vfs_sambafu_init init_module
+_ACEOF
+
+ VFS_MODULES="$VFS_MODULES "bin/sambafu.$SHLIBEXT""
+ echo "$as_me:$LINENO: result: shared" >&5
+echo "${ECHO_T}shared" >&6
+
+ string_shared_modules="$string_shared_modules vfs_sambafu"
+ elif test x"$DEST" = xSTATIC; then
+ init_static_modules_vfs="$init_static_modules_vfs vfs_sambafu_init();"
+ string_static_modules="$string_static_modules vfs_sambafu"
+ VFS_STATIC="$VFS_STATIC \$(VFS_SAMBAFU_OBJ)"
+
+
+
+ echo "$as_me:$LINENO: result: static" >&5
+echo "${ECHO_T}static" >&6
+ else
+ string_ignored_modules="$string_ignored_modules vfs_sambafu"
+ echo "$as_me:$LINENO: result: not" >&5
+echo "${ECHO_T}not" >&6
+ fi
+
echo "$as_me:$LINENO: checking how to build vfs_audit" >&5
echo $ECHO_N "checking how to build vfs_audit... $ECHO_C" >&6
diff -U 3 -Br -N samba-3.0.9/source/configure.in samba-3.0.9-jk/source/configure.in
--- samba-3.0.9/source/configure.in 2004-11-16 04:03:30.000000000 +0100
+++ samba-3.0.9-jk/source/configure.in 2004-12-08 16:21:39.000000000 +0100
@@ -383,7 +383,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_sambafu 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"
if test "x$developer" = xyes; then
default_static_modules="$default_static_modules rpc_echo"
@@ -4520,6 +4520,7 @@
SMB_SUBSYSTEM(AUTH,auth/auth.o)
SMB_MODULE(vfs_recycle, \$(VFS_RECYCLE_OBJ), "bin/recycle.$SHLIBEXT", VFS)
+SMB_MODULE(vfs_sambafu, \$(VFS_SAMBAFU_OBJ), "bin/sambafu.$SHLIBEXT", VFS)
SMB_MODULE(vfs_audit, \$(VFS_AUDIT_OBJ), "bin/audit.$SHLIBEXT", VFS)
SMB_MODULE(vfs_extd_audit, \$(VFS_EXTD_AUDIT_OBJ), "bin/extd_audit.$SHLIBEXT", VFS)
SMB_MODULE(vfs_full_audit, \$(VFS_FULL_AUDIT_OBJ), "bin/full_audit.$SHLIBEXT", VFS)
diff -U 3 -Br -N samba-3.0.9/source/include/config.h samba-3.0.9-jk/source/include/config.h
--- samba-3.0.9/source/include/config.h 2004-12-08 20:38:27.000000000 +0100
+++ samba-3.0.9-jk/source/include/config.h 2004-12-08 16:22:34.000000000 +0100
@@ -2014,6 +2014,9 @@
/* Whether to build vfs_afsacl as shared module */
/* #undef vfs_afsacl_init */
+/* Whether to build vfs_sambafu as shared module */
+#define vfs_sambafu_init init_module
+
/* Whether to build vfs_audit as shared module */
#define vfs_audit_init init_module
diff -U 3 -Br -N samba-3.0.9/source/include/config.h.in samba-3.0.9-jk/source/include/config.h.in
--- samba-3.0.9/source/include/config.h.in 2004-11-16 04:32:28.000000000 +0100
+++ samba-3.0.9-jk/source/include/config.h.in 2004-12-08 16:21:39.000000000 +0100
@@ -2013,6 +2013,9 @@
/* Whether to build vfs_afsacl as shared module */
#undef vfs_afsacl_init
+/* Whether to build vfs_sambafu as shared module */
+#undef vfs_sambafu_init
+
/* Whether to build vfs_audit as shared module */
#undef vfs_audit_init
diff -U 3 -Br -N samba-3.0.9/source/modules/vfs_sambafu.c samba-3.0.9-jk/source/modules/vfs_sambafu.c
--- samba-3.0.9/source/modules/vfs_sambafu.c 1970-01-01 01:00:00.000000000 +0100
+++ samba-3.0.9-jk/source/modules/vfs_sambafu.c 2004-12-08 20:50:04.000000000 +0100
@@ -0,0 +1,556 @@
+/*
+ Version 2.0.
+ Samba scripting module.
+
+ Copyright (C) Tim Potter 1999
+ Adapted to samba-3.0.9 (C) Jurriaan Kalkman 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., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+
+ This modules executes scripts after executing an action.
+ Such an action may be:
+
+ connect connecting to the service
+ disconnect disconnecting from the service
+ opendir opening a directory
+ mkdir creating a directory
+ rmdir removing a directory
+ closedir closing a directory
+ open opening a file
+ close closing a file
+ rename renaming a file
+ unlink unlinking a file
+
+ scripts are mentioned in the smb.conf file like this:
+
+ vfs objects = sambafu
+ sambafu:opendir = /usr/local/bin/test.sh "opendir" %s %u %d %m %p
+ sambafu:closedir = /usr/local/bin/test.sh "closedir" %s %u %d %m %p
+ sambafu:open = /usr/local/bin/test.sh "open" %s %u %d %m %p
+ sambafu:close = /usr/local/bin/test.sh "close" %s %u %d %m %p
+
+ except the regular samba substitutions, the following are sambafu extras:
+ %_fu_f file name (actions working on files)
+ %_fu_d directory name (actions working on directories)
+ %_fu_o old file name (rename action)
+ %_fu_n new file name (rename action)
+
+ Remember to quote these variables if you want spaces in the name to work
+ in your script!
+
+ Don't use this module if you need absolute speed - executing scripts means
+ loading a shell, reading the script, executing the script and these things
+ take time.
+*/
+
+#include <stdio.h>
+#include <sys/stat.h>
+#ifdef HAVE_UTIME_H
+#include <utime.h>
+#endif
+#ifdef HAVE_DIRENT_H
+#include <dirent.h>
+#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#include <errno.h>
+#include <string.h>
+
+#include "includes.h"
+
+int fu_connect(vfs_handle_struct *handle, connection_struct *conn, const char *svc, const char *user);
+void fu_disconnect(vfs_handle_struct *handle, connection_struct *conn);
+
+DIR *fu_opendir(vfs_handle_struct *handle, connection_struct *conn, const char *fname);
+int fu_mkdir(vfs_handle_struct *handle, connection_struct *conn, const char *path, mode_t mode);
+int fu_rmdir(vfs_handle_struct *handle, connection_struct *conn, const char *path);
+int fu_closedir(vfs_handle_struct *handle, connection_struct *conn, DIR *dirp);
+
+int fu_open(vfs_handle_struct *handle, connection_struct *conn, const char *fname, int flags, mode_t mode);
+int fu_close(vfs_handle_struct *handle, files_struct *fso, int fd);
+int fu_rename(vfs_handle_struct *handle, connection_struct *conn, const char *old, const char *new);
+int fu_unlink(vfs_handle_struct *handle, connection_struct *conn, const char *path);
+
+struct sambafu_ops {
+ char *connect_script;
+ char *disconnect_script;
+ char *opendir_script;
+ char *readdir_script;
+ char *mkdir_script;
+ char *rmdir_script;
+ char *closedir_script;
+ char *open_script;
+ char *close_script;
+ char *rename_script;
+ char *unlink_script;
+};
+
+static vfs_op_tuple sambafu_op_tuples[] = {
+ /* transparant layers, since we don't provide the actual actions,
+ * we only execute a script after the action is done
+ */
+
+ /* Disk Operations */
+ {SMB_VFS_OP(fu_connect), SMB_VFS_OP_CONNECT, SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(fu_disconnect), SMB_VFS_OP_DISCONNECT, SMB_VFS_LAYER_TRANSPARENT},
+ /* Directory Operations */
+ {SMB_VFS_OP(fu_opendir), SMB_VFS_OP_OPENDIR, SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(fu_closedir), SMB_VFS_OP_CLOSEDIR, SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(fu_mkdir), SMB_VFS_OP_MKDIR, SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(fu_rmdir), SMB_VFS_OP_RMDIR, SMB_VFS_LAYER_TRANSPARENT},
+ /* File Operations */
+ {SMB_VFS_OP(fu_open), SMB_VFS_OP_OPEN, SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(fu_close), SMB_VFS_OP_CLOSE, SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(fu_rename), SMB_VFS_OP_RENAME, SMB_VFS_LAYER_TRANSPARENT},
+ {SMB_VFS_OP(fu_unlink), SMB_VFS_OP_UNLINK, SMB_VFS_LAYER_TRANSPARENT},
+ /* Finish */
+ {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP}
+};
+
+static char *fu_option_connect(connection_struct *conn)
+{
+ static pstring o_connect;
+ pstrcpy(o_connect, lp_parm_const_string(SNUM(conn), "sambafu",
+ "connect", NULL));
+ standard_sub_snum(SNUM(conn), o_connect, sizeof(o_connect)-1);
+ return o_connect;
+}
+
+static char *fu_option_disconnect(connection_struct *conn)
+{
+ static pstring o_disconnect;
+ pstrcpy(o_disconnect, lp_parm_const_string(SNUM(conn), "sambafu",
+ "disconnect", NULL));
+ standard_sub_snum(SNUM(conn), o_disconnect, sizeof(o_disconnect)-1);
+ return o_disconnect;
+}
+
+static char *fu_option_opendir(connection_struct *conn)
+{
+ static pstring o_opendir;
+ pstrcpy(o_opendir, lp_parm_const_string(SNUM(conn), "sambafu",
+ "opendir", NULL));
+ standard_sub_snum(SNUM(conn), o_opendir, sizeof(o_opendir)-1);
+ return o_opendir;
+}
+
+static char *fu_option_closedir(connection_struct *conn)
+{
+ static pstring o_closedir;
+ pstrcpy(o_closedir, lp_parm_const_string(SNUM(conn), "sambafu",
+ "o_closedir", NULL));
+ standard_sub_snum(SNUM(conn), o_closedir, sizeof(o_closedir)-1);
+ return o_closedir;
+}
+
+static char *fu_option_mkdir(connection_struct *conn)
+{
+ static pstring o_mkdir;
+ pstrcpy(o_mkdir, lp_parm_const_string(SNUM(conn), "sambafu",
+ "mkdir", NULL));
+ standard_sub_snum(SNUM(conn), o_mkdir, sizeof(o_mkdir)-1);
+ return o_mkdir;
+}
+
+static char *fu_option_rmdir(connection_struct *conn)
+{
+ static pstring o_rmdir;
+ pstrcpy(o_rmdir, lp_parm_const_string(SNUM(conn), "sambafu",
+ "rmdir", NULL));
+ standard_sub_snum(SNUM(conn), o_rmdir, sizeof(o_rmdir)-1);
+ return o_rmdir;
+}
+
+static char *fu_option_open(connection_struct *conn)
+{
+ static pstring o_open;
+ pstrcpy(o_open, lp_parm_const_string(SNUM(conn), "sambafu",
+ "open", NULL));
+ standard_sub_snum(SNUM(conn), o_open, sizeof(o_open)-1);
+ return o_open;
+}
+
+static char *fu_option_close(connection_struct *conn)
+{
+ static pstring o_close;
+ pstrcpy(o_close, lp_parm_const_string(SNUM(conn), "sambafu",
+ "close", NULL));
+ standard_sub_snum(SNUM(conn), o_close, sizeof(o_close)-1);
+ return o_close;
+}
+
+static char *fu_option_rename(connection_struct *conn)
+{
+ static pstring o_rename;
+ pstrcpy(o_rename, lp_parm_const_string(SNUM(conn), "sambafu",
+ "rename", NULL));
+ standard_sub_snum(SNUM(conn), o_rename, sizeof(o_rename)-1);
+ return o_rename;
+}
+
+static char *fu_option_unlink(connection_struct *conn)
+{
+ static pstring o_unlink;
+ pstrcpy(o_unlink, lp_parm_const_string(SNUM(conn), "sambafu",
+ "unlink", NULL));
+ standard_sub_snum(SNUM(conn), o_unlink, sizeof(o_unlink)-1);
+ return o_unlink;
+}
+
+/* Standard string substitutions */
+
+static void fu_string_sub(pstring s, connection_struct *conn)
+{
+ pstring_sub(s, "%s", lp_servicename(SNUM(conn)));
+ pstring_sub(s, "%u", lp_username(SNUM(conn)));
+}
+
+/*
+ * Simple fd to filename caching
+ */
+
+struct fu_fdcache {
+ int fd;
+ pstring filename;
+ struct fu_fdcache *prev, *next;
+};
+
+static struct fu_fdcache *ffc = NULL;
+
+static void fu_add_fdcache(int fd, const char *filename)
+{
+ struct fu_fdcache *entry = (struct fu_fdcache *)malloc(sizeof(*entry));
+
+ if (entry != NULL) {
+ entry->fd = fd;
+ pstrcpy(entry->filename, filename);
+ DLIST_ADD(ffc, entry);
+ }
+}
+
+static char *fu_lookup_fdcache(int fd)
+{
+ struct fu_fdcache *entry;
+
+ for (entry = ffc; entry != NULL; entry = entry->next) {
+ if (entry->fd == fd) return entry->filename;
+ }
+
+ return NULL;
+}
+
+static void fu_del_fdcache(int fd)
+{
+ struct fu_fdcache *entry;
+
+ for (entry = ffc; entry != NULL; entry = entry->next) {
+ if (entry->fd == fd) break;
+ }
+
+ DLIST_REMOVE(ffc, entry);
+ free(entry);
+}
+
+/*
+ * Simple DIR* to directory name caching
+ */
+
+struct fu_dircache {
+ DIR *dir;
+ pstring dirname;
+ struct fu_dircache *prev, *next;
+};
+
+static struct fu_dircache *fdc = NULL;
+
+static void fu_add_dircache(DIR *dir, const char *dirname)
+{
+ struct fu_dircache *entry = (struct fu_dircache *)malloc(sizeof(*entry));
+
+ if ((entry != NULL) && (dir != NULL)) {
+ entry->dir = dir;
+ pstrcpy(entry->dirname, dirname);
+ DLIST_ADD(fdc, entry);
+ }
+}
+
+static char *fu_lookup_dircache(DIR *dir)
+{
+ struct fu_dircache *entry;
+
+ for (entry = fdc; entry != NULL; entry = entry->next) {
+ if (entry->dir == dir) return entry->dirname;
+ }
+
+ return NULL;
+}
+
+static void fu_del_dircache(DIR *dir)
+{
+ if (dir != NULL) {
+ struct fu_dircache *entry;
+
+ for (entry = fdc; entry != NULL; entry = entry->next) {
+ if (entry->dir == dir) break;
+ }
+
+ DLIST_REMOVE(fdc, entry);
+ free(entry);
+ }
+}
+
+int fu_connect(vfs_handle_struct *handle, connection_struct *conn,
+ const char *svc, const char *user)
+{
+ pstring cmd;
+ int result = SMB_VFS_NEXT_CONNECT(handle, conn, svc, user);
+
+ pstrcpy(cmd, fu_option_connect(conn));
+
+ if ((result == 0) && (cmd != NULL)) {
+ int ret;
+
+ fu_string_sub(cmd, conn);
+
+ ret = smbrun(cmd, NULL);
+
+ DEBUG(3, ("sambafu: connect script returned %d\n", ret));
+ }
+
+ return result;
+}
+
+void fu_disconnect(vfs_handle_struct *handle, connection_struct *conn)
+{
+ pstring cmd;
+ SMB_VFS_NEXT_DISCONNECT(handle, conn);
+
+ pstrcpy(cmd, fu_option_disconnect(conn));
+
+ if (cmd != NULL) {
+ int ret;
+
+ fu_string_sub(cmd, conn);
+
+ ret = smbrun(cmd, NULL);
+
+ DEBUG(3, ("sambafu: disconnect script returned %d\n", ret));
+ }
+}
+
+DIR *fu_opendir(vfs_handle_struct *handle, connection_struct *conn,
+ const char *fname)
+{
+ pstring cmd;
+ DIR *result = SMB_VFS_NEXT_OPENDIR(handle, conn, fname);
+
+ pstrcpy(cmd, fu_option_opendir(conn));
+
+ if ((result != NULL) && (cmd != NULL)) {
+ int ret;
+
+ pstring_sub(cmd, "%_fu_d", fname);
+ fu_string_sub(cmd, conn);
+
+ ret = smbrun(cmd, NULL);
+
+ DEBUG(3, ("sambafu: opendir script returned %d\n", ret));
+ }
+ if (result != NULL) {
+ fu_add_dircache(result, fname);
+ }
+
+ return result;
+}
+
+int fu_closedir(vfs_handle_struct *handle, connection_struct *conn,
+ DIR *dirp)
+{
+ pstring cmd;
+ int result = SMB_VFS_NEXT_CLOSEDIR(handle, conn, dirp);
+
+ pstrcpy(cmd, fu_option_closedir(conn));
+
+ if ((result == 0) && (cmd != NULL)) {
+ int ret;
+
+ pstring_sub(cmd, "%_fu_d", fu_lookup_dircache(dirp));
+ fu_string_sub(cmd, conn);
+
+ ret = smbrun(cmd, NULL);
+
+ DEBUG(3, ("sambafu: closedir script returned %d\n", ret));
+ }
+
+ /* Remove directory pointer from cache */
+
+ if (result == 0) {
+ fu_del_dircache(dirp);
+ }
+
+ return result;
+}
+
+int fu_mkdir(vfs_handle_struct *handle, connection_struct *conn,
+ const char *path, mode_t mode)
+{
+ pstring cmd;
+ int result = SMB_VFS_NEXT_MKDIR(handle, conn, path, mode);
+
+ pstrcpy(cmd, fu_option_mkdir(conn));
+
+ if ((result == 0) && (cmd != NULL)) {
+ int ret;
+
+ pstring_sub(cmd, "%_fu_d", path);
+ fu_string_sub(cmd, conn);
+
+ ret = smbrun(cmd, NULL);
+
+ DEBUG(3, ("sambafu: mkdir script returned %d\n", ret));
+ }
+
+ return result;
+}
+
+int fu_rmdir(vfs_handle_struct *handle, connection_struct *conn,
+ const char *path)
+{
+ pstring cmd;
+ int result = SMB_VFS_NEXT_RMDIR(handle, conn, path);
+
+ pstrcpy(cmd, fu_option_rmdir(conn));
+
+ if ((result == 0) && (cmd != NULL)) {
+ int ret;
+
+ pstring_sub(cmd, "%_fu_d", path);
+ fu_string_sub(cmd, conn);
+
+ ret = smbrun(cmd, NULL);
+
+ DEBUG(3, ("sambafu: mkdir script returned %d\n", ret));
+ }
+
+ return result;
+}
+
+int fu_open(vfs_handle_struct *handle, connection_struct *conn,
+ const char *fname, int flags, mode_t mode)
+{
+ pstring cmd;
+ int result = SMB_VFS_NEXT_OPEN(handle, conn, fname, flags, mode);
+
+ pstrcpy(cmd, fu_option_open(conn));
+
+ if ((result != -1) && (cmd != NULL)) {
+ int ret;
+
+ pstring_sub(cmd, "%_fu_f", fname);
+ fu_string_sub(cmd, conn);
+
+ ret = smbrun(cmd, NULL);
+
+ DEBUG(3, ("sambafu: open script returned %d\n", ret));
+ }
+
+ /* Add to fd->filename cache */
+
+ if (result != -1) {
+ fu_add_fdcache(result, fname);
+ }
+
+ return result;
+}
+
+int fu_close(vfs_handle_struct *handle, files_struct *fsp, int fd)
+{
+ pstring cmd;
+ int result = SMB_VFS_NEXT_CLOSE(handle, fsp, fd);
+
+ pstrcpy(cmd, fu_option_close(handle->conn));
+
+ if ((result != -1) && (cmd != NULL)) {
+ int ret;
+
+ pstring_sub(cmd, "%_fu_f", fu_lookup_fdcache(fd));
+ fu_string_sub(cmd, handle->conn);
+
+ ret = smbrun(cmd, NULL);
+
+ DEBUG(3, ("sambafu: close script returned %d\n", ret));
+ }
+
+ /* Remove from fd->filename cache */
+
+ if (result != -1) {
+ fu_del_fdcache(fd);
+ }
+
+ return result;
+}
+
+int fu_rename(vfs_handle_struct *handle, connection_struct *conn,
+ const char *old, const char *new)
+{
+ pstring cmd;
+ int result = SMB_VFS_NEXT_RENAME(handle, conn, old, new);
+
+ pstrcpy(cmd, fu_option_rename(conn));
+
+ if ((result == 0) && (cmd != NULL)) {
+ int ret;
+
+ pstring_sub(cmd, "%_fu_o", old);
+ pstring_sub(cmd, "%_fu_n", new);
+ fu_string_sub(cmd, conn);
+
+ ret = smbrun(cmd, NULL);
+
+ DEBUG(3, ("sambafu: rename script returned %d\n", ret));
+ }
+
+ return result;
+}
+
+int fu_unlink(vfs_handle_struct *handle, connection_struct *conn,
+ const char *path)
+{
+ pstring cmd;
+ int result = SMB_VFS_NEXT_UNLINK(handle, conn, path);
+
+ pstrcpy(cmd, fu_option_rename(conn));
+
+ if (cmd != NULL) {
+ int ret;
+
+ pstring_sub(cmd, "%_fu_f", path);
+ fu_string_sub(cmd, conn);
+
+ ret = smbrun(cmd, NULL);
+
+ DEBUG(3, ("sambafu: unlink script returned %d\n", ret));
+ }
+
+ return result;
+}
+
+NTSTATUS vfs_sambafu_init(void)
+{
+ return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "sambafu", sambafu_op_tuples);
+}
+
diff -U 3 -Br -N samba-3.0.9/source/utils/ntlm_auth_proto.h samba-3.0.9-jk/source/utils/ntlm_auth_proto.h
--- samba-3.0.9/source/utils/ntlm_auth_proto.h 1970-01-01 01:00:00.000000000 +0100
+++ samba-3.0.9-jk/source/utils/ntlm_auth_proto.h 2004-12-08 16:22:41.000000000 +0100
@@ -0,0 +1,28 @@
+#ifndef _NTLM_AUTH_PROTO_H_
+#define _NTLM_AUTH_PROTO_H_
+
+/* This file is automatically generated with "make proto". DO NOT EDIT */
+
+
+/* The following definitions come from utils/ntlm_auth.c */
+
+const char *get_winbind_domain(void);
+const char *get_winbind_netbios_name(void);
+DATA_BLOB get_challenge(void) ;
+NTSTATUS contact_winbind_auth_crap(const char *username,
+ const char *domain,
+ const char *workstation,
+ const DATA_BLOB *challenge,
+ const DATA_BLOB *lm_response,
+ const DATA_BLOB *nt_response,
+ uint32 flags,
+ uint8 lm_key[8],
+ uint8 user_session_key[16],
+ char **error_string,
+ char **unix_name) ;
+
+/* The following definitions come from utils/ntlm_auth_diagnostics.c */
+
+BOOL diagnose_ntlm_auth(void);
+
+#endif /* _NTLM_AUTH_PROTO_H_ */
--
"What is possible for many may seem like magic when only a few contemplate
the same amount of work."
Eldest Uncle, Kate Elliot - Child of Flame
Debian (Unstable) GNU/Linux 2.6.10-rc3 2x6078 bogomips load 0.04
More information about the samba-technical
mailing list