1/* 2 * Fake Perms VFS module. Implements passthrough operation of all VFS 3 * calls to disk functions, except for file permissions, which are now 4 * mode 0700 for the current uid/gid. 5 * 6 * Copyright (C) Tim Potter, 1999-2000 7 * Copyright (C) Alexander Bokovoy, 2002 8 * Copyright (C) Andrew Bartlett, 2002 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 */ 24 25#include "includes.h" 26 27#undef DBGC_CLASS 28#define DBGC_CLASS DBGC_VFS 29 30static int fake_perms_stat(vfs_handle_struct *handle, connection_struct *conn, const char *fname, SMB_STRUCT_STAT *sbuf) 31{ 32 int ret = -1; 33 34 ret = SMB_VFS_NEXT_STAT(handle, conn, fname, sbuf); 35 if (ret == 0) { 36 extern struct current_user current_user; 37 38 if (S_ISDIR(sbuf->st_mode)) { 39 sbuf->st_mode = S_IFDIR | S_IRWXU; 40 } else { 41 sbuf->st_mode = S_IRWXU; 42 } 43 sbuf->st_uid = current_user.uid; 44 sbuf->st_gid = current_user.gid; 45 } 46 47 return ret; 48} 49 50static int fake_perms_fstat(vfs_handle_struct *handle, files_struct *fsp, int fd, SMB_STRUCT_STAT *sbuf) 51{ 52 int ret = -1; 53 54 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, fd, sbuf); 55 if (ret == 0) { 56 extern struct current_user current_user; 57 58 if (S_ISDIR(sbuf->st_mode)) { 59 sbuf->st_mode = S_IFDIR | S_IRWXU; 60 } else { 61 sbuf->st_mode = S_IRWXU; 62 } 63 sbuf->st_uid = current_user.uid; 64 sbuf->st_gid = current_user.gid; 65 } 66 return ret; 67} 68 69/* VFS operations structure */ 70 71static vfs_op_tuple fake_perms_ops[] = { 72 {SMB_VFS_OP(fake_perms_stat), SMB_VFS_OP_STAT, SMB_VFS_LAYER_TRANSPARENT}, 73 {SMB_VFS_OP(fake_perms_fstat), SMB_VFS_OP_FSTAT, SMB_VFS_LAYER_TRANSPARENT}, 74 75 {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} 76}; 77 78NTSTATUS vfs_fake_perms_init(void) 79{ 80 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "fake_perms", fake_perms_ops); 81} 82