From 2b15e8a33efeb14d2132a32396537d144d2f0a2c Mon Sep 17 00:00:00 2001 From: Tim Potter Date: Wed, 17 May 2000 02:48:04 +0000 Subject: Updated VFS examples to use ftruncate() and lock() functions. (This used to be commit def0da145aa8b804b75b0f35bdd4a809a2a806fc) --- examples/VFS/audit.c | 163 ++++++++++++++++++++++++++------------------------- 1 file changed, 82 insertions(+), 81 deletions(-) (limited to 'examples/VFS/audit.c') diff --git a/examples/VFS/audit.c b/examples/VFS/audit.c index 8f0aaac4be..036438e90e 100644 --- a/examples/VFS/audit.c +++ b/examples/VFS/audit.c @@ -1,5 +1,5 @@ /* - * Auditing VFS module for samba. Log select file operations to syslog + * Auditing VFS module for samba. Log selected file operations to syslog * facility. * * Copyright (C) Tim Potter, 1999-2000 @@ -17,8 +17,6 @@ * 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. - * - * $Id: audit.c,v 1.2 2000/02/04 05:08:16 tpot Exp $ */ #include "config.h" @@ -65,35 +63,37 @@ extern struct vfs_ops default_vfs_ops; /* For passthrough operation */ struct vfs_ops audit_ops = { - /* Disk operations */ - - audit_connect, - audit_disconnect, - NULL, /* disk free */ - - /* Directory operations */ - - audit_opendir, - NULL, /* readdir */ - audit_mkdir, - audit_rmdir, - NULL, /* closedir */ - - /* File operations */ - - audit_open, - audit_close, - NULL, /* read */ - NULL, /* write */ - NULL, /* lseek */ - audit_rename, - NULL, /* fsync */ - NULL, /* stat */ - NULL, /* fstat */ - NULL, /* lstat */ - audit_unlink, - NULL, /* chmod */ - NULL /* utime */ + /* Disk operations */ + + audit_connect, + audit_disconnect, + NULL, /* disk free */ + + /* Directory operations */ + + audit_opendir, + NULL, /* readdir */ + audit_mkdir, + audit_rmdir, + NULL, /* closedir */ + + /* File operations */ + + audit_open, + audit_close, + NULL, /* read */ + NULL, /* write */ + NULL, /* lseek */ + audit_rename, + NULL, /* fsync */ + NULL, /* stat */ + NULL, /* fstat */ + NULL, /* lstat */ + audit_unlink, + NULL, /* chmod */ + NULL, /* utime */ + NULL, /* ftruncate */ + NULL /* lock */ }; /* VFS initialisation function. Return initialised vfs_ops structure @@ -101,8 +101,8 @@ struct vfs_ops audit_ops = { struct vfs_ops *vfs_init(void) { - openlog("smbd_audit", LOG_PID, SYSLOG_FACILITY); - return(&audit_ops); + openlog("smbd_audit", LOG_PID, SYSLOG_FACILITY); + return(&audit_ops); } /* Implementation of vfs_ops. Pass everything on to the default @@ -110,98 +110,99 @@ struct vfs_ops *vfs_init(void) int audit_connect(struct vfs_connection_struct *conn, char *svc, char *user) { - syslog(SYSLOG_PRIORITY, "connect to service %s by user %s\n", svc, user); + syslog(SYSLOG_PRIORITY, "connect to service %s by user %s\n", + svc, user); - return default_vfs_ops.connect(conn, svc, user); + return default_vfs_ops.connect(conn, svc, user); } void audit_disconnect(void) { - syslog(SYSLOG_PRIORITY, "disconnected\n"); - default_vfs_ops.disconnect(); + syslog(SYSLOG_PRIORITY, "disconnected\n"); + default_vfs_ops.disconnect(); } DIR *audit_opendir(char *fname) { - DIR *result = default_vfs_ops.opendir(fname); + DIR *result = default_vfs_ops.opendir(fname); - syslog(SYSLOG_PRIORITY, "opendir %s %s%s\n", - fname, - (result == NULL) ? "failed: " : "", - (result == NULL) ? strerror(errno) : ""); + syslog(SYSLOG_PRIORITY, "opendir %s %s%s\n", + fname, + (result == NULL) ? "failed: " : "", + (result == NULL) ? strerror(errno) : ""); - return result; + return result; } int audit_mkdir(char *path, mode_t mode) { - int result = default_vfs_ops.mkdir(path, mode); + int result = default_vfs_ops.mkdir(path, mode); - syslog(SYSLOG_PRIORITY, "mkdir %s %s%s\n", - path, - (result < 0) ? "failed: " : "", - (result < 0) ? strerror(errno) : ""); + syslog(SYSLOG_PRIORITY, "mkdir %s %s%s\n", + path, + (result < 0) ? "failed: " : "", + (result < 0) ? strerror(errno) : ""); - return result; + return result; } int audit_rmdir(char *path) { - int result = default_vfs_ops.rmdir(path); + int result = default_vfs_ops.rmdir(path); - syslog(SYSLOG_PRIORITY, "rmdir %s %s%s\n", - path, - (result < 0) ? "failed: " : "", - (result < 0) ? strerror(errno) : ""); + syslog(SYSLOG_PRIORITY, "rmdir %s %s%s\n", + path, + (result < 0) ? "failed: " : "", + (result < 0) ? strerror(errno) : ""); - return result; + return result; } int audit_open(char *fname, int flags, mode_t mode) { - int result = default_vfs_ops.open(fname, flags, mode); + int result = default_vfs_ops.open(fname, flags, mode); - syslog(SYSLOG_PRIORITY, "open %s (fd %d) %s%s%s\n", - fname, result, - ((flags & O_WRONLY) || (flags & O_RDWR)) ? "for writing " : "", - (result < 0) ? "failed: " : "", - (result < 0) ? strerror(errno) : ""); + syslog(SYSLOG_PRIORITY, "open %s (fd %d) %s%s%s\n", + fname, result, + ((flags & O_WRONLY) || (flags & O_RDWR)) ? "for writing " : "", + (result < 0) ? "failed: " : "", + (result < 0) ? strerror(errno) : ""); - return result; + return result; } int audit_close(int fd) { - int result = default_vfs_ops.close(fd); + int result = default_vfs_ops.close(fd); - syslog(SYSLOG_PRIORITY, "close fd %d %s%s\n", - fd, - (result < 0) ? "failed: " : "", - (result < 0) ? strerror(errno) : ""); + syslog(SYSLOG_PRIORITY, "close fd %d %s%s\n", + fd, + (result < 0) ? "failed: " : "", + (result < 0) ? strerror(errno) : ""); - return result; + return result; } int audit_rename(char *old, char *new) { - int result = default_vfs_ops.rename(old, new); + int result = default_vfs_ops.rename(old, new); - syslog(SYSLOG_PRIORITY, "rename %s -> %s %s%s\n", - old, new, - (result < 0) ? "failed: " : "", - (result < 0) ? strerror(errno) : ""); + syslog(SYSLOG_PRIORITY, "rename %s -> %s %s%s\n", + old, new, + (result < 0) ? "failed: " : "", + (result < 0) ? strerror(errno) : ""); - return result; + return result; } int audit_unlink(char *path) { - int result = default_vfs_ops.unlink(path); + int result = default_vfs_ops.unlink(path); - syslog(SYSLOG_PRIORITY, "unlink %s %s%s\n", - path, - (result < 0) ? "failed: " : "", - (result < 0) ? strerror(errno) : ""); + syslog(SYSLOG_PRIORITY, "unlink %s %s%s\n", + path, + (result < 0) ? "failed: " : "", + (result < 0) ? strerror(errno) : ""); - return result; + return result; } -- cgit