diff options
author | Jeremy Allison <jra@samba.org> | 2000-11-06 20:01:03 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2000-11-06 20:01:03 +0000 |
commit | 5ba7235f0f3bd5ec08e3798795af0c56b1f0e5f5 (patch) | |
tree | 0c6491b3dd6444831c9a444a12843f1b747af5fa /examples/VFS | |
parent | f68bbb4b665376b75a04af349a475928a3721d73 (diff) | |
download | samba-5ba7235f0f3bd5ec08e3798795af0c56b1f0e5f5.tar.gz samba-5ba7235f0f3bd5ec08e3798795af0c56b1f0e5f5.tar.bz2 samba-5ba7235f0f3bd5ec08e3798795af0c56b1f0e5f5.zip |
Fixes for sample VFS audit code from "Brad Sahr" <bsahr@macromedia.com>.
Jeremy.
(This used to be commit 5d6dec3a94f496651a5f0643ab228c975911e6cd)
Diffstat (limited to 'examples/VFS')
-rw-r--r-- | examples/VFS/Makefile | 9 | ||||
-rw-r--r-- | examples/VFS/audit.c | 81 | ||||
-rw-r--r-- | examples/VFS/skel.c | 212 |
3 files changed, 196 insertions, 106 deletions
diff --git a/examples/VFS/Makefile b/examples/VFS/Makefile index bb0c307fe9..581e1a06fb 100644 --- a/examples/VFS/Makefile +++ b/examples/VFS/Makefile @@ -1,7 +1,7 @@ # # Makefile for samba-vfs examples # -# $Id: Makefile,v 1.3 2000/04/05 22:41:42 tpot Exp $ +# $Id: Makefile,v 1.4 2000/11/06 20:01:03 jra Exp $ # # Variables @@ -9,8 +9,11 @@ CC = gcc LIBTOOL = libtool -SAMBA_SRC = ../../source/include -CFLAGS = -I$(SAMBA_SRC) +SAMBA_SRC = ../../source +SAMBA_INCL = ../../source/include +UBIQX_SRC = ../../source/ubiqx +SMBWR_SRC = ../../source/smbwrapper +CFLAGS = -I$(SAMBA_SRC) -I$(SAMBA_INCL) -I$(UBIQX_SRC) -I$(SMBWR_SRC) -Wall -g VFS_OBJS = audit.so skel.so # Default target diff --git a/examples/VFS/audit.c b/examples/VFS/audit.c index 036438e90e..dc57b64940 100644 --- a/examples/VFS/audit.c +++ b/examples/VFS/audit.c @@ -34,6 +34,7 @@ #endif #include <errno.h> #include <string.h> +#include <includes.h> #include <vfs.h> #ifndef SYSLOG_FACILITY @@ -46,16 +47,16 @@ /* Function prototypes */ -int audit_connect(struct vfs_connection_struct *conn, char *svc, char *user); -void audit_disconnect(void); -DIR *audit_opendir(char *fname); -int audit_mkdir(char *path, mode_t mode); -int audit_rmdir(char *path); -int audit_open(char *fname, int flags, mode_t mode); -int audit_close(int fd); -int audit_rename(char *old, char *new); -int audit_unlink(char *path); -int audit_chmod(char *path, mode_t mode); +int audit_connect(struct connection_struct *conn, char *svc, char *user); +void audit_disconnect(struct connection_struct *conn); +DIR *audit_opendir(struct connection_struct *conn, char *fname); +int audit_mkdir(struct connection_struct *conn, char *path, mode_t mode); +int audit_rmdir(struct connection_struct *conn, char *path); +int audit_open(struct connection_struct *conn, char *fname, int flags, mode_t mode); +int audit_close(struct files_struct *fsp, int fd); +int audit_rename(struct connection_struct *conn, char *old, char *new); +int audit_unlink(struct connection_struct *conn, char *path); +int audit_chmod(struct connection_struct *conn, char *path, mode_t mode); /* VFS operations */ @@ -90,10 +91,17 @@ struct vfs_ops audit_ops = { NULL, /* fstat */ NULL, /* lstat */ audit_unlink, - NULL, /* chmod */ + audit_chmod, + NULL, /* chown */ + NULL, /* chdir */ + NULL, /* getwd */ NULL, /* utime */ NULL, /* ftruncate */ - NULL /* lock */ + 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 @@ -102,13 +110,15 @@ struct vfs_ops audit_ops = { struct vfs_ops *vfs_init(void) { openlog("smbd_audit", LOG_PID, SYSLOG_FACILITY); + syslog(SYSLOG_PRIORITY, "VFS_INIT: &audit_ops: 0x%8.8x\n", + &audit_ops); return(&audit_ops); } /* Implementation of vfs_ops. Pass everything on to the default operation but log event first. */ -int audit_connect(struct vfs_connection_struct *conn, char *svc, char *user) +int audit_connect(struct connection_struct *conn, char *svc, char *user) { syslog(SYSLOG_PRIORITY, "connect to service %s by user %s\n", svc, user); @@ -116,15 +126,15 @@ int audit_connect(struct vfs_connection_struct *conn, char *svc, char *user) return default_vfs_ops.connect(conn, svc, user); } -void audit_disconnect(void) +void audit_disconnect(struct connection_struct *conn) { syslog(SYSLOG_PRIORITY, "disconnected\n"); - default_vfs_ops.disconnect(); + default_vfs_ops.disconnect(conn); } -DIR *audit_opendir(char *fname) +DIR *audit_opendir(struct connection_struct *conn, char *fname) { - DIR *result = default_vfs_ops.opendir(fname); + DIR *result = default_vfs_ops.opendir(conn, fname); syslog(SYSLOG_PRIORITY, "opendir %s %s%s\n", fname, @@ -134,9 +144,9 @@ DIR *audit_opendir(char *fname) return result; } -int audit_mkdir(char *path, mode_t mode) +int audit_mkdir(struct connection_struct *conn, char *path, mode_t mode) { - int result = default_vfs_ops.mkdir(path, mode); + int result = default_vfs_ops.mkdir(conn, path, mode); syslog(SYSLOG_PRIORITY, "mkdir %s %s%s\n", path, @@ -146,9 +156,9 @@ int audit_mkdir(char *path, mode_t mode) return result; } -int audit_rmdir(char *path) +int audit_rmdir(struct connection_struct *conn, char *path) { - int result = default_vfs_ops.rmdir(path); + int result = default_vfs_ops.rmdir(conn, path); syslog(SYSLOG_PRIORITY, "rmdir %s %s%s\n", path, @@ -158,9 +168,9 @@ int audit_rmdir(char *path) return result; } -int audit_open(char *fname, int flags, mode_t mode) +int audit_open(struct connection_struct *conn, char *fname, int flags, mode_t mode) { - int result = default_vfs_ops.open(fname, flags, mode); + int result = default_vfs_ops.open(conn, fname, flags, mode); syslog(SYSLOG_PRIORITY, "open %s (fd %d) %s%s%s\n", fname, result, @@ -171,9 +181,9 @@ int audit_open(char *fname, int flags, mode_t mode) return result; } -int audit_close(int fd) +int audit_close(struct files_struct *fsp, int fd) { - int result = default_vfs_ops.close(fd); + int result = default_vfs_ops.close(fsp, fd); syslog(SYSLOG_PRIORITY, "close fd %d %s%s\n", fd, @@ -183,9 +193,9 @@ int audit_close(int fd) return result; } -int audit_rename(char *old, char *new) +int audit_rename(struct connection_struct *conn, char *old, char *new) { - int result = default_vfs_ops.rename(old, new); + int result = default_vfs_ops.rename(conn, old, new); syslog(SYSLOG_PRIORITY, "rename %s -> %s %s%s\n", old, new, @@ -195,9 +205,9 @@ int audit_rename(char *old, char *new) return result; } -int audit_unlink(char *path) +int audit_unlink(struct connection_struct *conn, char *path) { - int result = default_vfs_ops.unlink(path); + int result = default_vfs_ops.unlink(conn, path); syslog(SYSLOG_PRIORITY, "unlink %s %s%s\n", path, @@ -206,3 +216,16 @@ int audit_unlink(char *path) return result; } + +int audit_chmod(struct connection_struct *conn, char *path, mode_t mode) +{ + int result = default_vfs_ops.chmod(conn, path, mode); + + syslog(SYSLOG_PRIORITY, "chmod %s mode 0x%x %s%s\n", + path, mode, + (result < 0) ? "failed: " : "", + (result < 0) ? strerror(errno) : ""); + + return result; +} + diff --git a/examples/VFS/skel.c b/examples/VFS/skel.c index 90f16f952f..d1ec5b9180 100644 --- a/examples/VFS/skel.c +++ b/examples/VFS/skel.c @@ -35,36 +35,53 @@ #include <errno.h> #include <string.h> +#include <includes.h> #include <vfs.h> /* Function prototypes */ -int skel_connect(struct vfs_connection_struct *conn, char *svc, char *user); -void skel_disconnect(void); -SMB_BIG_UINT skel_disk_free(char *path, BOOL smallquery, SMB_BIG_UINT *bsize, - SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize); - -DIR *skel_opendir(char *fname); -struct dirent *skel_readdir(DIR *dirp); -int skel_mkdir(char *path, mode_t mode); -int skel_rmdir(char *path); -int skel_closedir(DIR *dir); - -int skel_open(char *fname, int flags, mode_t mode); -int skel_close(int fd); -ssize_t skel_read(int fd, char *data, size_t n); -ssize_t skel_write(int fd, char *data, size_t n); -SMB_OFF_T skel_lseek(int filedes, SMB_OFF_T offset, int whence); -int skel_rename(char *old, char *new); -int skel_fsync(int fd); -int skel_stat(char *fname, SMB_STRUCT_STAT *sbuf); -int skel_fstat(int fd, SMB_STRUCT_STAT *sbuf); -int skel_lstat(char *path, SMB_STRUCT_STAT *sbuf); -int skel_unlink(char *path); -int skel_chmod(char *path, mode_t mode); -int skel_utime(char *path, struct utimbuf *times); -int skel_ftruncate(int fd, SMB_OFF_T offset); -BOOL skel_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type); + /* Disk operations */ + + int skel_connect(struct connection_struct *conn, char *service, char *user); void skel_disconnect(struct connection_struct *conn); + SMB_BIG_UINT skel_disk_free(struct connection_struct *conn, char *path, BOOL small_query, SMB_BIG_UINT *bsize, + SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize); + + /* Directory operations */ + + DIR *skel_opendir(struct connection_struct *conn, char *fname); + struct dirent *skel_readdir(struct connection_struct *conn, DIR *dirp); + int skel_mkdir(struct connection_struct *conn, char *path, mode_t mode); + int skel_rmdir(struct connection_struct *conn, char *path); + int skel_closedir(struct connection_struct *conn, DIR *dir); + + /* File operations */ + + int skel_open(struct connection_struct *conn, char *fname, int flags, mode_t mode); + int skel_close(struct files_struct *fsp, int fd); + ssize_t skel_read(struct files_struct *fsp, int fd, char *data, size_t n); + ssize_t skel_write(struct files_struct *fsp, int fd, char *data, size_t n); + SMB_OFF_T skel_lseek(struct files_struct *fsp, int filedes, SMB_OFF_T offset, int whence); + int skel_rename(struct connection_struct *conn, char *old, char *new); + int skel_fsync(struct files_struct *fsp, int fd); + int skel_stat(struct connection_struct *conn, char *fname, SMB_STRUCT_STAT *sbuf); + int skel_fstat(struct files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf); + int skel_lstat(struct connection_struct *conn, char *path, SMB_STRUCT_STAT *sbuf); + int skel_unlink(struct connection_struct *conn, char *path); + int skel_chmod(struct connection_struct *conn, char *path, mode_t mode); + int skel_chown(struct connection_struct *conn, char *path, uid_t uid, gid_t gid); + int skel_chdir(struct connection_struct *conn, char *path); + char *skel_getwd(struct connection_struct *conn, char *buf); + int skel_utime(struct connection_struct *conn, char *path, struct utimbuf *times); + int skel_ftruncate(struct files_struct *fsp, int fd, SMB_OFF_T offset); + BOOL skel_lock(struct files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type); + + /* NT file access control list operations */ + + size_t skel_fget_nt_acl(struct files_struct *fsp, int fd, struct security_descriptor_info **ppdesc); + size_t skel_get_nt_acl(struct files_struct *fsp, char *name, struct security_descriptor_info **ppdesc); + BOOL skel_fset_nt_acl(struct files_struct *fsp, int fd, uint32 security_info_sent, struct security_descriptor_info *psd); + BOOL skel_set_nt_acl(struct files_struct *fsp, char *name, uint32 security_info_sent, struct security_descriptor_info *psd); + /* VFS operations structure */ @@ -98,9 +115,19 @@ struct vfs_ops skel_ops = { skel_lstat, skel_unlink, skel_chmod, + skel_chown, + skel_chdir, + skel_getwd, skel_utime, skel_ftruncate, - skel_lock + skel_lock, + + /* NT File ACL operations */ + + skel_fget_nt_acl, + skel_get_nt_acl, + skel_fset_nt_acl, + skel_set_nt_acl }; /* VFS initialisation - return vfs_ops function pointer structure */ @@ -114,119 +141,156 @@ struct vfs_ops *vfs_init(void) extern struct vfs_ops default_vfs_ops; /* For passthrough operation */ -int skel_connect(struct vfs_connection_struct *conn, char *svc, char *user) +int skel_connect(struct connection_struct *conn, char *service, char *user) { - return default_vfs_ops.connect(conn, svc, user); + return default_vfs_ops.connect(conn, service, user); } -void skel_disconnect(void) +void skel_disconnect(struct connection_struct *conn) { - default_vfs_ops.disconnect(); + default_vfs_ops.disconnect(conn); } -SMB_BIG_UINT skel_disk_free(char *path, BOOL small_query, SMB_BIG_UINT *bsize, - SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) +SMB_BIG_UINT skel_disk_free(struct connection_struct *conn, char *path, + BOOL small_query, SMB_BIG_UINT *bsize, + SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize) { - return default_vfs_ops.disk_free(path, small_query, bsize, + return default_vfs_ops.disk_free(conn, path, small_query, bsize, dfree, dsize); } -DIR *skel_opendir(char *fname) +DIR *skel_opendir(struct connection_struct *conn, char *fname) { - return default_vfs_ops.opendir(fname); + return default_vfs_ops.opendir(conn, fname); } -struct dirent *skel_readdir(DIR *dirp) +struct dirent *skel_readdir(struct connection_struct *conn, DIR *dirp) { - return default_vfs_ops.readdir(dirp); + return default_vfs_ops.readdir(conn, dirp); } -int skel_mkdir(char *path, mode_t mode) +int skel_mkdir(struct connection_struct *conn, char *path, mode_t mode) { - return default_vfs_ops.mkdir(path, mode); + return default_vfs_ops.mkdir(conn, path, mode); } -int skel_rmdir(char *path) +int skel_rmdir(struct connection_struct *conn, char *path) { - return default_vfs_ops.rmdir(path); + return default_vfs_ops.rmdir(conn, path); } -int skel_closedir(DIR *dir) +int skel_closedir(struct connection_struct *conn, DIR *dir) { - return default_vfs_ops.closedir(dir); + return default_vfs_ops.closedir(conn, dir); } -int skel_open(char *fname, int flags, mode_t mode) +int skel_open(struct connection_struct *conn, char *fname, int flags, mode_t mode) { - return default_vfs_ops.open(fname, flags, mode); + return default_vfs_ops.open(conn, fname, flags, mode); } -int skel_close(int fd) +int skel_close(struct files_struct *fsp, int fd) { - return default_vfs_ops.close(fd); + return default_vfs_ops.close(fsp, fd); } -ssize_t skel_read(int fd, char *data, size_t n) +ssize_t skel_read(struct files_struct *fsp, int fd, char *data, size_t n) { - return default_vfs_ops.read(fd, data, n); + return default_vfs_ops.read(fsp, fd, data, n); } -ssize_t skel_write(int fd, char *data, size_t n) +ssize_t skel_write(struct files_struct *fsp, int fd, char *data, size_t n) { - return default_vfs_ops.write(fd, data, n); + return default_vfs_ops.write(fsp, fd, data, n); } -SMB_OFF_T skel_lseek(int filedes, SMB_OFF_T offset, int whence) +SMB_OFF_T skel_lseek(struct files_struct *fsp, int filedes, SMB_OFF_T offset, int whence) { - return default_vfs_ops.lseek(filedes, offset, whence); + return default_vfs_ops.lseek(fsp, filedes, offset, whence); } -int skel_rename(char *old, char *new) +int skel_rename(struct connection_struct *conn, char *old, char *new) { - return default_vfs_ops.rename(old, new); + return default_vfs_ops.rename(conn, old, new); } -int skel_fsync(int fd) +int skel_fsync(struct files_struct *fsp, int fd) { - return default_vfs_ops.fsync(fd); + return default_vfs_ops.fsync(fsp, fd); } -int skel_stat(char *fname, SMB_STRUCT_STAT *sbuf) +int skel_stat(struct connection_struct *conn, char *fname, SMB_STRUCT_STAT *sbuf) { - return default_vfs_ops.stat(fname, sbuf); + return default_vfs_ops.stat(conn, fname, sbuf); } -int skel_fstat(int fd, SMB_STRUCT_STAT *sbuf) +int skel_fstat(struct files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf) { - return default_vfs_ops.fstat(fd, sbuf); + return default_vfs_ops.fstat(fsp, fd, sbuf); } -int skel_lstat(char *path, SMB_STRUCT_STAT *sbuf) +int skel_lstat(struct connection_struct *conn, char *path, SMB_STRUCT_STAT *sbuf) { - return default_vfs_ops.lstat(path, sbuf); + return default_vfs_ops.lstat(conn, path, sbuf); } -int skel_unlink(char *path) +int skel_unlink(struct connection_struct *conn, char *path) { - return default_vfs_ops.unlink(path); + return default_vfs_ops.unlink(conn, path); } -int skel_chmod(char *path, mode_t mode) +int skel_chmod(struct connection_struct *conn, char *path, mode_t mode) { - return default_vfs_ops.chmod(path, mode); + return default_vfs_ops.chmod(conn, path, mode); } -int skel_utime(char *path, struct utimbuf *times) +int skel_chown(struct connection_struct *conn, char *path, uid_t uid, gid_t gid) { - return default_vfs_ops.utime(path, times); + return default_vfs_ops.chown(conn, path, uid, gid); } -int skel_ftruncate(int fd, SMB_OFF_T offset) +int skel_chdir(struct connection_struct *conn, char *path) { - return default_vfs_ops.ftruncate(fd, offset); + return default_vfs_ops.chdir(conn, path); } -BOOL skel_lock(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) +char *skel_getwd(struct connection_struct *conn, char *buf) { - return default_vfs_ops.lock(fd, op, offset, count, type); + return default_vfs_ops.getwd(conn, buf); } + +int skel_utime(struct connection_struct *conn, char *path, struct utimbuf *times) +{ + return default_vfs_ops.utime(conn, path, times); +} + +int skel_ftruncate(struct files_struct *fsp, int fd, SMB_OFF_T offset) +{ + return default_vfs_ops.ftruncate(fsp, fd, offset); +} + +BOOL skel_lock(struct files_struct *fsp, int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type) +{ + return default_vfs_ops.lock(fsp, fd, op, offset, count, type); +} + +size_t skel_fget_nt_acl(struct files_struct *fsp, int fd, struct security_descriptor_info **ppdesc) +{ + return default_vfs_ops.fget_nt_acl(fsp, fd, ppdesc); +} + +size_t skel_get_nt_acl(struct files_struct *fsp, char *name, struct security_descriptor_info **ppdesc) +{ + return default_vfs_ops.get_nt_acl(fsp, name, ppdesc); +} + +BOOL skel_fset_nt_acl(struct files_struct *fsp, int fd, uint32 security_info_sent, struct security_descriptor_info *psd) +{ + return default_vfs_ops.fset_nt_acl(fsp, fd, security_info_sent, psd); +} + +BOOL skel_set_nt_acl(struct files_struct *fsp, char *name, uint32 security_info_sent, struct security_descriptor_info *psd) +{ + return default_vfs_ops.set_nt_acl(fsp, name, security_info_sent, psd); +} + |