root/source3/modules/vfs_fake_perms.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. fake_perms_stat
  2. fake_perms_fstat
  3. vfs_fake_perms_init

   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 3 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, see <http://www.gnu.org/licenses/>.
  22  */
  23 
  24 #include "includes.h"
  25 
  26 #undef DBGC_CLASS
  27 #define DBGC_CLASS DBGC_VFS
  28 
  29 static int fake_perms_stat(vfs_handle_struct *handle, const char *fname, SMB_STRUCT_STAT *sbuf)
     /* [<][>][^][v][top][bottom][index][help] */
  30 {
  31         int ret = -1;
  32 
  33         ret = SMB_VFS_NEXT_STAT(handle, fname, sbuf);
  34         if (ret == 0) {
  35                 if (S_ISDIR(sbuf->st_mode)) {
  36                         sbuf->st_mode = S_IFDIR | S_IRWXU;
  37                 } else {
  38                         sbuf->st_mode = S_IRWXU;
  39                 }
  40                 sbuf->st_uid = handle->conn->server_info->utok.uid;
  41                 sbuf->st_gid = handle->conn->server_info->utok.gid;
  42         }
  43 
  44         return ret;
  45 }
  46 
  47 static int fake_perms_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)
     /* [<][>][^][v][top][bottom][index][help] */
  48 {
  49         int ret = -1;
  50 
  51         ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
  52         if (ret == 0) {
  53                 if (S_ISDIR(sbuf->st_mode)) {
  54                         sbuf->st_mode = S_IFDIR | S_IRWXU;
  55                 } else {
  56                         sbuf->st_mode = S_IRWXU;
  57                 }
  58                 sbuf->st_uid = handle->conn->server_info->utok.uid;
  59                 sbuf->st_gid = handle->conn->server_info->utok.gid;
  60         }
  61         return ret;
  62 }
  63 
  64 /* VFS operations structure */
  65 
  66 static vfs_op_tuple fake_perms_ops[] = {        
  67         {SMB_VFS_OP(fake_perms_stat),   SMB_VFS_OP_STAT,        SMB_VFS_LAYER_TRANSPARENT},
  68         {SMB_VFS_OP(fake_perms_fstat),  SMB_VFS_OP_FSTAT,       SMB_VFS_LAYER_TRANSPARENT},
  69 
  70         {SMB_VFS_OP(NULL),              SMB_VFS_OP_NOOP,        SMB_VFS_LAYER_NOOP}
  71 };
  72 
  73 NTSTATUS vfs_fake_perms_init(void);
  74 NTSTATUS vfs_fake_perms_init(void)
     /* [<][>][^][v][top][bottom][index][help] */
  75 {
  76         return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "fake_perms", fake_perms_ops);
  77 }

/* [<][>][^][v][top][bottom][index][help] */