Modified skel.c file
Ries van twisk
rvt at dds.nl
Sun Mar 3 05:13:03 GMT 2002
Hi Andrew,
here is the complete patch to get a working VFS system.
I tested both skel.so and audit.so.
The block.so example loads succesfully but I didn't really test it out
since I have not clue what it really does....
This patch also includes the patches found on www.openantivirus.org in
the samba-vscan project created by Rainer Link.
Ries
Andrew Bartlett wrote:
>
> Ries van twisk wrote:
> >
> > Hi,
> >
> > I modified the skeleton example so it works with samba 2.2.3 again.
>
> Can you resend as a context diff?
>
> --
> Andrew Bartlett abartlet at pcug.org.au
> Manager, Authentication Subsystems, Samba Team abartlet at samba.org
> Student Network Administrator, Hawker College abartlet at hawkerc.net
> http://samba.org http://build.samba.org http://hawkerc.net
-------------- next part --------------
diff -cr samba-2.2.3a.orig/examples/VFS/audit.c samba-2.2.3a/examples/VFS/audit.c
*** samba-2.2.3a.orig/examples/VFS/audit.c Sat Oct 13 23:08:56 2001
--- samba-2.2.3a/examples/VFS/audit.c Sun Mar 3 13:52:54 2002
***************
*** 3,8 ****
--- 3,9 ----
* facility.
*
* Copyright (C) Tim Potter, 1999-2000
+ * Modified to work with 2.2.3a by Ries van Twisk, march 2002
*
* 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
***************
*** 19,39 ****
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
- #include "config.h"
- #include <stdio.h>
- #include <sys/stat.h>
- #ifdef HAVE_UTIME_H
- #include <utime.h>
- #endif
- #ifdef HAVE_DIRENT_H
- #include <dirent.h>
- #endif
- #include <syslog.h>
- #ifdef HAVE_FCNTL_H
- #include <fcntl.h>
- #endif
- #include <errno.h>
- #include <string.h>
#include <includes.h>
#include <vfs.h>
--- 20,25 ----
***************
*** 59,67 ****
int audit_chmod(struct connection_struct *conn, char *path, mode_t mode);
/* VFS operations */
!
! extern struct vfs_ops default_vfs_ops; /* For passthrough operation */
!
struct vfs_ops audit_ops = {
/* Disk operations */
--- 45,51 ----
int audit_chmod(struct connection_struct *conn, char *path, mode_t mode);
/* VFS operations */
! extern struct vfs_ops default_vfs_ops;
struct vfs_ops audit_ops = {
/* Disk operations */
***************
*** 92,117 ****
NULL, /* lstat */
audit_unlink,
audit_chmod,
! NULL, /* chown */
NULL, /* chdir */
NULL, /* getwd */
NULL, /* utime */
NULL, /* ftruncate */
NULL, /* lock */
NULL, /* fget_nt_acl */
NULL, /* get_nt_acl */
NULL, /* fset_nt_acl */
! NULL /* set_nt_acl */
};
/* VFS initialisation function. Return initialised vfs_ops structure
back to SAMBA. */
! BOOL vfs_init(connection_struct *conn)
{
! openlog("smbd_audit", LOG_PID, SYSLOG_FACILITY);
! syslog(SYSLOG_PRIORITY, "VFS_INIT: vfs_ops loaded\n");
! return True;
}
/* Implementation of vfs_ops. Pass everything on to the default
--- 76,112 ----
NULL, /* lstat */
audit_unlink,
audit_chmod,
! NULL, /* fchmod */
! NULL, /* chown */
! NULL, /* fchown */
NULL, /* chdir */
NULL, /* getwd */
NULL, /* utime */
NULL, /* ftruncate */
NULL, /* lock */
+ NULL, /* symlink */
+ NULL, /* readlink */
+ NULL, /* link */
+ NULL, /* mknod */
+ NULL, /* realpath */
NULL, /* fget_nt_acl */
NULL, /* get_nt_acl */
NULL, /* fset_nt_acl */
! NULL, /* set_nt_acl */
! NULL, /* chmod_acl */
! NULL /* fchmod_acl */
};
/* VFS initialisation function. Return initialised vfs_ops structure
back to SAMBA. */
! struct vfs_ops *vfs_init(int* Version, struct vfs_ops *ops)
{
! *Version = SMB_VFS_INTERFACE_VERSION;
! openlog("smbd_audit", LOG_PID, SYSLOG_FACILITY);
! syslog(SYSLOG_PRIORITY, "VFS_INIT: vfs_ops loaded\n");
! DEBUG(1, ("Loaded audit module!\n"));
! return(&audit_ops);
}
/* Implementation of vfs_ops. Pass everything on to the default
diff -cr samba-2.2.3a.orig/examples/VFS/block/Makefile samba-2.2.3a/examples/VFS/block/Makefile
*** samba-2.2.3a.orig/examples/VFS/block/Makefile Fri Jul 6 03:21:45 2001
--- samba-2.2.3a/examples/VFS/block/Makefile Sun Mar 3 13:19:59 2002
***************
*** 1,37 ****
#
! # Makefile for samba-vfs examples
! #
#
# Variables
CC = gcc
LIBTOOL = libtool
! SAMBA_SRC = /usr/local/src/samba/samba-2.2.0-ron/source
! SAMBA_INCL = ${SAMBA_SRC}/include
! UBIQX_SRC = ${SAMBA_SRC}/ubiqx
! SMBWR_SRC = ${SAMBA_SRC}/smbwrapper
! CFLAGS = -I$(SAMBA_SRC) -I$(SAMBA_INCL) -I$(UBIQX_SRC) -I$(SMBWR_SRC) -Wall -g -D_LARGEFILE63_SOURCE -D_GNU_SOURCE -fno-builtin
!
!
VFS_OBJS = block.so
! # Default target
! default: $(VFS_OBJS)
!
! # Pattern rules
! %.so: %.lo
! $(LIBTOOL) $(CC) -shared -o $@ $< $(LDFLAGS)
! %.lo: %.c
! $(LIBTOOL) $(CC) $(CPPFLAGS) $(CFLAGS) -c $<
# Misc targets
-
clean:
rm -rf .libs
! rm -f core *~ *% *.bak \
! $(VFS_OBJS) $(VFS_OBJS:.so=.o) $(VFS_OBJS:.so=.lo)
--- 1,40 ----
#
! # Makefile for block access
#
# Variables
+ #USE_DEBUG=1
+
CC = gcc
LIBTOOL = libtool
! SAMBA_SRC = ../../../source
! SAMBA_INCL = ../../../source/include
! UBIQX_SRC = ../../../source/ubiqx
! SMBWR_SRC = ../../../source/smbwrapper
VFS_OBJS = block.so
! ifdef USE_DEBUG
! CFLAGS = -I$(SAMBA_SRC) -I$(SAMBA_INCL) -I$(UBIQX_SRC) -I$(SMBWR_SRC) -Wall -g
! else
! CFLAGS = -I$(SAMBA_SRC) -I$(SAMBA_INCL) -I$(UBIQX_SRC) -I$(SMBWR_SRC) -Wall
! endif
! LIBS =
! OBJS = block.o
! SOURCES = block.c
! # Default target
! all: $(VFS_OBJS)
! block.so: ${SOURCES}
! $(LIBTOOL) $(CC) ${CFLAGS} -c block.c
! $(LIBTOOL) $(CC) ${CFLAGS} -shared $(LDFLAGS) ${LIBS} ${OBJS} -o block.so
! rm -f *.lo
# Misc targets
clean:
rm -rf .libs
! rm -f core *~ *% *.bak *.so *.lo *.o
!
\ No newline at end of file
diff -cr samba-2.2.3a.orig/examples/VFS/block/block.c samba-2.2.3a/examples/VFS/block/block.c
*** samba-2.2.3a.orig/examples/VFS/block/block.c Fri Jul 6 03:21:45 2001
--- samba-2.2.3a/examples/VFS/block/block.c Sun Mar 3 13:20:55 2002
***************
*** 3,8 ****
--- 3,9 ----
* Block access from links to dev mount points specified in PARAMCONF file
*
* Copyright (C) Ronald Kuetemeier, 2001
+ * Modified to work with 2.2.3a by Ries van Twisk, March 2002
*
* 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
***************
*** 19,52 ****
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
- #include "config.h"
- #include <stdio.h>
- #include <sys/stat.h>
- #include <sys/types.h>
- #include <string.h>
- #include <stdlib.h>
- #include <fcntl.h>
- #include <unistd.h>
- #include <errno.h>
-
-
- #ifdef HAVE_UTIME_H
- #include <utime.h>
- #endif
- #ifdef HAVE_DIRENT_H
- #include <dirent.h>
- #endif
- #include <syslog.h>
- #ifdef HAVE_FCNTL_H
- #include <fcntl.h>
- #endif
-
-
#include <includes.h>
#include <vfs.h>
-
-
DIR *block_opendir(struct connection_struct *conn, char *fname);
int block_connect(struct connection_struct *conn, char *service, char *user);
void block_disconnect(struct connection_struct *conn);
--- 20,28 ----
***************
*** 69,106 ****
block_opendir,
NULL, /* readdir */
! NULL,
! NULL,
NULL, /* closedir */
/* File operations */
! NULL,
! NULL,
NULL, /* read */
NULL, /* write */
NULL, /* lseek */
! NULL,
NULL, /* fsync */
NULL, /* stat */
NULL, /* fstat */
NULL, /* lstat */
! NULL,
! NULL,
! NULL,
! NULL, /* chown */
! NULL,
NULL, /* chdir */
NULL, /* getwd */
NULL, /* utime */
NULL, /* ftruncate */
NULL, /* lock */
NULL, /* fget_nt_acl */
NULL, /* get_nt_acl */
NULL, /* fset_nt_acl */
! NULL, /* set_nt_acl */
! NULL,
! NULL
};
--- 45,87 ----
block_opendir,
NULL, /* readdir */
! NULL, /* mkdir */
! NULL, /* rmdir */
NULL, /* closedir */
/* File operations */
! NULL, /* open */
! NULL, /* close */
NULL, /* read */
NULL, /* write */
NULL, /* lseek */
! NULL, /* rename */
NULL, /* fsync */
NULL, /* stat */
NULL, /* fstat */
NULL, /* lstat */
! NULL, /* unlink */
! NULL, /* chmod */
! NULL, /* fchmod */
! NULL, /* chown */
! NULL, /* fchown */
NULL, /* chdir */
NULL, /* getwd */
NULL, /* utime */
NULL, /* ftruncate */
NULL, /* lock */
+ NULL, /* symlink */
+ NULL, /* readlink */
+ NULL, /* link */
+ NULL, /* mknod */
+ NULL, /* realpath */
NULL, /* fget_nt_acl */
NULL, /* get_nt_acl */
NULL, /* fset_nt_acl */
! NULL, /* set_nt_acl */
! NULL, /* chmod_acl */
! NULL /* fchmod_acl */
};
***************
*** 297,310 ****
/* VFS initialisation function. Return initialised vfs_ops structure
back to SAMBA. */
! struct vfs_ops *vfs_init(int *vfs_version)
{
! *vfs_version = SMB_VFS_INTERFACE_VERSION;
!
! return(&execute_vfs_ops);
}
-
/*
* VFS connect and param file loading
*/
--- 278,290 ----
/* VFS initialisation function. Return initialised vfs_ops structure
back to SAMBA. */
! struct vfs_ops *vfs_init(int* Version, struct vfs_ops *ops)
{
! *Version = SMB_VFS_INTERFACE_VERSION;
! DEBUG(1, ("Loading block access module!\n"));
! return(&execute_vfs_ops);
}
/*
* VFS connect and param file loading
*/
***************
*** 457,546 ****
return FALSE;
}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
--- 437,439 ----
Only in samba-2.2.3a/examples/VFS/block: makefile.org
diff -cr samba-2.2.3a.orig/examples/VFS/skel.c samba-2.2.3a/examples/VFS/skel.c
*** samba-2.2.3a.orig/examples/VFS/skel.c Sat Oct 13 23:08:56 2001
--- samba-2.2.3a/examples/VFS/skel.c Sun Mar 3 13:16:09 2002
***************
*** 3,8 ****
--- 3,9 ----
* calls to disk functions.
*
* Copyright (C) Tim Potter, 1999-2000
+ * Modified to work with 2.2.3a by Ries van Twisk, March 2002
*
* 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
***************
*** 19,56 ****
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
- #include "config.h"
-
- #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>
#include <vfs.h>
! extern struct vfs_ops default_vfs_ops; /* For passthrough operation */
struct vfs_ops skel_ops;
-
-
/* VFS initialisation - return vfs_ops function pointer structure */
!
! BOOL vfs_init(connection_struct *conn)
{
! DEBUG(3, ("Initialising default vfs hooks\n"));
!
! memcpy(&conn->vfs_ops, &skel_ops, sizeof(struct vfs_ops));
! return True;
}
int skel_connect(struct connection_struct *conn, char *service, char *user)
--- 20,37 ----
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <includes.h>
#include <vfs.h>
! extern struct vfs_ops default_vfs_ops;
struct vfs_ops skel_ops;
/* VFS initialisation - return vfs_ops function pointer structure */
! struct vfs_ops *vfs_init(int* Version, struct vfs_ops *ops)
{
! *Version = SMB_VFS_INTERFACE_VERSION;
! DEBUG(1, ("Loading skeleton module!\n"));
! return(&skel_ops);
}
int skel_connect(struct connection_struct *conn, char *service, char *user)
***************
*** 106,117 ****
return default_vfs_ops.close(fsp, fd);
}
! ssize_t skel_read(struct files_struct *fsp, int fd, char *data, size_t n)
{
return default_vfs_ops.read(fsp, fd, data, n);
}
! ssize_t skel_write(struct files_struct *fsp, int fd, char *data, size_t n)
{
return default_vfs_ops.write(fsp, fd, data, n);
}
--- 87,98 ----
return default_vfs_ops.close(fsp, fd);
}
! ssize_t skel_read(struct files_struct *fsp, int fd, void *data, size_t n)
{
return default_vfs_ops.read(fsp, fd, data, n);
}
! ssize_t skel_write(struct files_struct *fsp, int fd, const void *data, size_t n)
{
return default_vfs_ops.write(fsp, fd, data, n);
}
***************
*** 226,241 ****
return default_vfs_ops.set_nt_acl(fsp, name, security_info_sent, psd);
}
! BOOL skel_chmod_acl(struct connection_struct *conn, char *name, mode_t mode)
{
return default_vfs_ops.chmod_acl(conn, name, mode);
}
! BOOL skel_fchmod_acl(struct files_struct *fsp, int fd, mode_t mode)
{
return default_vfs_ops.fchmod_acl(fsp, fd, mode);
}
/* VFS operations structure */
--- 207,238 ----
return default_vfs_ops.set_nt_acl(fsp, name, security_info_sent, psd);
}
! int skel_chmod_acl(struct connection_struct *conn, char *name, mode_t mode)
{
return default_vfs_ops.chmod_acl(conn, name, mode);
}
! int skel_fchmod_acl(struct files_struct *fsp, int fd, mode_t mode)
{
return default_vfs_ops.fchmod_acl(fsp, fd, mode);
}
+ int skel_link(struct connection_struct *conn, const char *oldpath, const char *newpath)
+ {
+ return default_vfs_ops.link(conn,oldpath, newpath);
+ }
+
+ int skel_mknod(struct connection_struct *conn, const char *path, mode_t mode, SMB_DEV_T dev)
+ {
+ return default_vfs_ops.mknod(conn, path, mode, dev);
+ }
+
+ char * skel_realpath(struct connection_struct *conn, const char *path, char *resolved_path)
+ {
+ return default_vfs_ops.realpath(conn, path, resolved_path);
+ }
+
+
/* VFS operations structure */
***************
*** 279,284 ****
--- 276,284 ----
skel_lock,
skel_symlink,
skel_readlink,
+ skel_link,
+ skel_mknod,
+ skel_realpath,
/* NT File ACL operations */
***************
*** 290,292 ****
--- 290,293 ----
skel_chmod_acl,
skel_fchmod_acl
};
+
Only in samba-2.2.3a/source: Makefile
diff -cr samba-2.2.3a.orig/source/Makefile.in samba-2.2.3a/source/Makefile.in
*** samba-2.2.3a.orig/source/Makefile.in Sun Feb 3 01:46:05 2002
--- samba-2.2.3a/source/Makefile.in Sun Mar 3 12:59:39 2002
***************
*** 487,493 ****
bin/smbd: $(SMBD_OBJ) bin/.dummy
@echo Linking $@
! @$(CC) $(FLAGS) -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LIBS)
bin/nmbd: $(NMBD_OBJ) bin/.dummy
@echo Linking $@
--- 487,493 ----
bin/smbd: $(SMBD_OBJ) bin/.dummy
@echo Linking $@
! @$(CC) $(FLAGS) -rdynamic -o $@ $(SMBD_OBJ) $(LDFLAGS) $(LIBS)
bin/nmbd: $(NMBD_OBJ) bin/.dummy
@echo Linking $@
Only in samba-2.2.3a/source/bin: .dummy
Only in samba-2.2.3a/source/bin: make_printerdef
Only in samba-2.2.3a/source/bin: make_smbcodepage
Only in samba-2.2.3a/source/bin: make_unicodemap
Only in samba-2.2.3a/source/bin: nmbd
Only in samba-2.2.3a/source/bin: nmblookup
Only in samba-2.2.3a/source/bin: rpcclient
Only in samba-2.2.3a/source/bin: smbcacls
Only in samba-2.2.3a/source/bin: smbclient
Only in samba-2.2.3a/source/bin: smbcontrol
Only in samba-2.2.3a/source/bin: smbd
Only in samba-2.2.3a/source/bin: smbpasswd
Only in samba-2.2.3a/source/bin: smbspool
Only in samba-2.2.3a/source/bin: smbstatus
Only in samba-2.2.3a/source/bin: swat
Only in samba-2.2.3a/source/bin: testparm
Only in samba-2.2.3a/source/bin: testprns
Only in samba-2.2.3a/source: config.cache
Only in samba-2.2.3a/source: config.log
Only in samba-2.2.3a/source: config.status
Only in samba-2.2.3a/source/include: config.h
diff -cr samba-2.2.3a.orig/source/include/proto.h samba-2.2.3a/source/include/proto.h
*** samba-2.2.3a.orig/source/include/proto.h Sun Feb 3 01:46:40 2002
--- samba-2.2.3a/source/include/proto.h Sun Mar 3 12:59:39 2002
***************
*** 4543,4549 ****
/*The following definitions come from smbd/vfs.c */
! BOOL vfs_init(connection_struct *conn);
BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT *st);
int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode);
char *vfs_getwd(connection_struct *conn, char *unix_path);
--- 4543,4549 ----
/*The following definitions come from smbd/vfs.c */
! BOOL smbd_vfs_init(connection_struct *conn);
BOOL vfs_directory_exist(connection_struct *conn, char *dname, SMB_STRUCT_STAT *st);
int vfs_mkdir(connection_struct *conn, char *fname, mode_t mode);
char *vfs_getwd(connection_struct *conn, char *unix_path);
Only in samba-2.2.3a/source/include: stamp-h
diff -cr samba-2.2.3a.orig/source/msdfs/msdfs.c samba-2.2.3a/source/msdfs/msdfs.c
*** samba-2.2.3a.orig/source/msdfs/msdfs.c Sun Feb 3 01:46:44 2002
--- samba-2.2.3a/source/msdfs/msdfs.c Sun Mar 3 12:59:39 2002
***************
*** 88,94 ****
conn->service = snum;
conn->connectpath = lp_pathname(snum);
! if (!vfs_init(conn)) {
DEBUG(0,("create_conn_struct: vfs init failed.\n"));
return False;
}
--- 88,94 ----
conn->service = snum;
conn->connectpath = lp_pathname(snum);
! if (!smbd_vfs_init(conn)) {
DEBUG(0,("create_conn_struct: vfs init failed.\n"));
return False;
}
diff -cr samba-2.2.3a.orig/source/smbd/service.c samba-2.2.3a/source/smbd/service.c
*** samba-2.2.3a.orig/source/smbd/service.c Sun Feb 3 01:46:56 2002
--- samba-2.2.3a/source/smbd/service.c Sun Mar 3 12:59:39 2002
***************
*** 537,543 ****
}
/* Initialise VFS function pointers */
! if (!vfs_init(conn)) {
DEBUG(0, ("vfs_init failed for service %s\n", lp_servicename(SNUM(conn))));
yield_connection(conn, lp_servicename(SNUM(conn)));
conn_free(conn);
--- 537,543 ----
}
/* Initialise VFS function pointers */
! if (!smbd_vfs_init(conn)) {
DEBUG(0, ("vfs_init failed for service %s\n", lp_servicename(SNUM(conn))));
yield_connection(conn, lp_servicename(SNUM(conn)));
conn_free(conn);
diff -cr samba-2.2.3a.orig/source/smbd/vfs.c samba-2.2.3a/source/smbd/vfs.c
*** samba-2.2.3a.orig/source/smbd/vfs.c Sun Feb 3 01:46:57 2002
--- samba-2.2.3a/source/smbd/vfs.c Sun Mar 3 12:59:39 2002
***************
*** 273,279 ****
Generic VFS init.
******************************************************************/
! BOOL vfs_init(connection_struct *conn)
{
if (*lp_vfsobj(SNUM(conn))) {
#ifdef HAVE_LIBDL
--- 273,279 ----
Generic VFS init.
******************************************************************/
! BOOL smbd_vfs_init(connection_struct *conn)
{
if (*lp_vfsobj(SNUM(conn))) {
#ifdef HAVE_LIBDL
***************
*** 281,293 ****
/* Loadable object file */
if (!vfs_init_custom(conn)) {
! DEBUG(0, ("vfs_init: vfs_init_custom failed\n"));
return False;
}
return True;
#else
! DEBUG(0, ("vfs_init: No libdl present - cannot use VFS objects\n"));
return False;
#endif
}
--- 281,293 ----
/* Loadable object file */
if (!vfs_init_custom(conn)) {
! DEBUG(0, ("smbd_vfs_init: vfs_init_custom failed\n"));
return False;
}
return True;
#else
! DEBUG(0, ("smbd_vfs_init: No libdl present - cannot use VFS objects\n"));
return False;
#endif
}
More information about the samba-technical
mailing list