The Samba-Bugzilla – Attachment 4887 Details for
Bug 6819
fsp->fsp_name
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
the source file of the vfs module
dnacopy.c (text/x-csrc), 8.77 KB, created by
Daniel De Baerdemaeker
on 2009-10-26 05:27:14 UTC
(
hide
)
Description:
the source file of the vfs module
Filename:
MIME Type:
Creator:
Daniel De Baerdemaeker
Created:
2009-10-26 05:27:14 UTC
Size:
8.77 KB
patch
obsolete
>/* > * Skeleton VFS module. Implements passthrough operation of all VFS > * calls to disk functions. > * > * Copyright (C) Tim Potter, 1999-2000 > * Copyright (C) Alexander Bokovoy, 2002 > * Copyright (C) Stefan (metze) Metzmacher, 2003 > * > * 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 3 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, see <http://www.gnu.org/licenses/>. > */ > > >#include "includes.h" >#include <string.h> >#undef DBGC_CLASS >#define DBGC_CLASS DBGC_VFS > >/* PLEASE,PLEASE READ THE VFS MODULES CHAPTER OF THE > SAMBA DEVELOPERS GUIDE!!!!!! > */ > >/* If you take this file as template for your module > * please make sure that you remove all functions you didn't > * want to implement!! > * > * This passthrough operations are useless in reall vfs modules! > * > * --metze > */ > > >static int audit_connect(vfs_handle_struct *handle, const char *svc, const char *user); >static void audit_disconnect(vfs_handle_struct *handle); >struct file_mod_info >{ > bool write; /* open for write */ > char* fn; /* filename */ >}; > >static size_t av_strlcpy(char *dst, const char *src, size_t size) >{ > size_t len = 0; > size++; > while (++len < size && *src) > *dst++ = *src++; > if (len <= size) > *dst = 0; > return len - 1; >} > >void av_pathtofile(char *dst, const char *src) >{ > > size_t len = strlen(src); > av_strlcpy(dst,src,len); > > len--; > while (--len > 0 && *src) { > > if (dst[len] == '/') { > dst[len] = 0; > break; > } > } >} > >static void free_privates(void **datap) >{ > struct file_mod_info *data = (struct file_mod_info *)*datap; > > SAFE_FREE(data->fn); > SAFE_FREE(data); > > *datap = NULL; > > return; >} > > > >static int audit_syslog_facility(vfs_handle_struct *handle) >{ > static const struct enum_list enum_log_facilities[] = { > { LOG_USER, "USER" }, > { LOG_LOCAL0, "LOCAL0" }, > { LOG_LOCAL1, "LOCAL1" }, > { LOG_LOCAL2, "LOCAL2" }, > { LOG_LOCAL3, "LOCAL3" }, > { LOG_LOCAL4, "LOCAL4" }, > { LOG_LOCAL5, "LOCAL5" }, > { LOG_LOCAL6, "LOCAL6" }, > { LOG_LOCAL7, "LOCAL7" } > }; > > int facility; > > facility = lp_parm_enum(SNUM(handle->conn), "audit", "facility", enum_log_facilities, LOG_USER); > > return facility; >} > >static int audit_syslog_priority(vfs_handle_struct *handle) >{ > static const struct enum_list enum_log_priorities[] = { > { LOG_EMERG, "EMERG" }, > { LOG_ALERT, "ALERT" }, > { LOG_CRIT, "CRIT" }, > { LOG_ERR, "ERR" }, > { LOG_WARNING, "WARNING" }, > { LOG_NOTICE, "NOTICE" }, > { LOG_INFO, "INFO" }, > { LOG_DEBUG, "DEBUG" } > }; > > int priority; > > priority = lp_parm_enum(SNUM(handle->conn), "audit", "priority", > enum_log_priorities, LOG_NOTICE); > if (priority == -1) { > priority = LOG_WARNING; > } > > return priority; >} > >/* Implementation of vfs_oint ps. Pass everything on to the default > operation but log event first. */ > >static int audit_connect(vfs_handle_struct *handle, const char *svc, const char *user) >{ > int result; > > openlog("smbd_audit", LOG_PID, audit_syslog_facility(handle)); > > syslog(audit_syslog_priority(handle), "connect to service %s by user %s\n", > svc, user); > > result = SMB_VFS_NEXT_CONNECT(handle, svc, user); > > return result; >} > >static void audit_disconnect(vfs_handle_struct *handle) >{ > syslog(audit_syslog_priority(handle), "disconnected\n"); > SMB_VFS_NEXT_DISCONNECT(handle); > > return; >} > >static int skel_mkdir(vfs_handle_struct *handle, const char *path, mode_t mode) >{ > return SMB_VFS_NEXT_MKDIR(handle, path, mode); > pid_t pid; > switch(pid=fork()){ > case -1: syslog(audit_syslog_priority(handle), "unablet to fork"); > case 0 : execl(handle->param, handle->param,"mkdir", path,(char *) 0); > default: ; > } >} > >static int skel_open(vfs_handle_struct *handle, const char *fname, files_struct *fsp, int flags, mode_t mode) >{ > int rc; > bool schrijf; > > if ((flags & O_WRONLY) || (flags & O_RDWR)) { > > char * fn = (char *)malloc(strlen(fname)+1); > av_strlcpy(fn , fname, strlen(fname)); > struct file_mod_info * c; > syslog(audit_syslog_priority(handle), "before adding extra info to open %d %s\n", > true,fname); > > c = VFS_ADD_FSP_EXTENSION(handle, fsp, struct file_mod_info,NULL); > if (c) { > c->write = true; > c->fn = fn; > } > syslog(audit_syslog_priority(handle), "adding extra info to open %d %s\n", > c->write,c->fn); > > > } > rc = SMB_VFS_NEXT_OPEN(handle, fname, fsp, flags, mode); > > syslog(audit_syslog_priority(handle), "open %s (fd %d) %s%s%s\n", > fname, rc, > ((flags & O_WRONLY) || (flags & O_RDWR)) ? "for writing " : "", > (rc < 0) ? "failed: " : "", > (rc < 0) ? strerror(errno) : ""); > > return rc; >} > > >static int skel_close(vfs_handle_struct *handle, files_struct *fsp) >{ > int result; > char pathtofile[200]; > struct file_mod_info * c; > > > syslog(audit_syslog_priority(handle), "closing fd %d -- origpath : %s -- connectpath : %s -- dirpath : %s -- param : %s -- : fsp->fsp_name : %s \n", > fsp->fh->fd,fsp->conn->origpath,fsp->conn->connectpath,fsp->conn->dirpath,handle->param,fsp->fsp_name); > > result = SMB_VFS_NEXT_CLOSE(handle, fsp); > if ((c = VFS_FETCH_FSP_EXTENSION(handle, fsp)) != NULL) { > syslog(audit_syslog_priority(handle), "getting extra after close %d %s\n", > c->write,c->fn); > av_pathtofile(pathtofile, c->fn); > pid_t pid; > switch(pid=fork()){ > case -1: syslog(audit_syslog_priority(handle), "unablet to fork"); > case 0 : execl(handle->param, handle->param,"save", fsp->conn->origpath, c->fn,pathtofile,(char *) 0); > default: ; > } > > > > SAFE_FREE(c->fn); > > } > > syslog(audit_syslog_priority(handle), "closed fd %d %s%s \n", > fsp->fh->fd, > (result < 0) ? "failed: " : "", > (result < 0) ? strerror(errno) : ""); > > return result; >} > > >static ssize_t skel_read(vfs_handle_struct *handle, files_struct *fsp, void *data, size_t n) >{ > int rc; > > rc = SMB_VFS_NEXT_READ(handle, fsp, data, n); > syslog(audit_syslog_priority(handle), "read %d -- %s with modified : %d %s%s\n", fsp->fh->fd, fsp->fsp_name, fsp->modified, > (rc != 0) ? "failed: " : "", > (rc != 0) ? strerror(errno) : ""); > > return rc; >} > > >static ssize_t skel_write(vfs_handle_struct *handle, files_struct *fsp, const void *data, size_t n) >{ > int rc; > rc = SMB_VFS_NEXT_WRITE(handle, fsp, data, n); > syslog(audit_syslog_priority(handle), "write %d -- %s with modified : %d %s%s\n", fsp->fh->fd, fsp->fsp_name, fsp->modified, > (rc != 0) ? "failed: " : "", > (rc != 0) ? strerror(errno) : ""); > return rc; >} > > > > >static int skel_rename(vfs_handle_struct *handle, const char *oldname, const char *newname) >{ > int rc; > char pathtofile[200]; > rc = SMB_VFS_NEXT_RENAME(handle, oldname, newname); > syslog(audit_syslog_priority(handle), "rename %s -- to -- %s %d %s %s\n", oldname, newname,rc, > (rc != 0) ? "failed: " : "", > (rc != 0) ? strerror(errno) : ""); > pid_t pid; > av_pathtofile(pathtofile, newname); > switch(pid=fork()){ > case -1: syslog(audit_syslog_priority(handle), "unablet to fork");break; > case 0 : > syslog(audit_syslog_priority(handle), "before execl rename"); > execl(handle->param, handle->param,"rename", oldname, newname,handle->conn->origpath,pathtofile,(char *) 0); > syslog(audit_syslog_priority(handle), "after execl rename") ; > break; > default: ; > > } > > > > return rc; >} > > > >/* VFS operations structure */ > >static vfs_op_tuple skel_op_tuples[] = { > > {SMB_VFS_OP(skel_mkdir), SMB_VFS_OP_MKDIR, SMB_VFS_LAYER_TRANSPARENT}, > > /* File operations */ > > {SMB_VFS_OP(skel_open), SMB_VFS_OP_OPEN, SMB_VFS_LAYER_TRANSPARENT}, > {SMB_VFS_OP(skel_close), SMB_VFS_OP_CLOSE, SMB_VFS_LAYER_TRANSPARENT}, > {SMB_VFS_OP(skel_read), SMB_VFS_OP_READ, SMB_VFS_LAYER_TRANSPARENT}, > {SMB_VFS_OP(skel_write), SMB_VFS_OP_WRITE, SMB_VFS_LAYER_TRANSPARENT}, > {SMB_VFS_OP(skel_rename), SMB_VFS_OP_RENAME, SMB_VFS_LAYER_TRANSPARENT}, > > {NULL, SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} >}; > >NTSTATUS init_samba_module(void) >{ > return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "dnacopy", skel_op_tuples); >}
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 6819
:
4886
| 4887