/*
* Fake full Perms VFS module. Implements passthrough operation of all
* VFS calls to disk functions, except for file permissions, which are
* set to mode 0777. This addresses a changed behaviour of the explorer
* on windows >= 7. When an ACL is set on a filesystem entry allowing
* access, but the ACL is not visible to the Samba service (e.g. because
* it's an NFSv3 mount and Sun's NFSv3-ACL extension is not available
* e.g. on a Netapp as fileserver), Samba reports to the client, that
* access is not possible, though it actually would work. Then explorer
* reports to the user, that he may not access the filesystem entry,
* though this is not true. This module fakes full access, so access
* finally fails when attempting it and not when evaluating permission
* attributes.
*
* 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 .
*/
#include
#include
#ifdef SAMBA_VERSION_MAJOR
#if SAMBA_VERSION_MAJOR >= 4
#define __SAMBA_FOUR_OR_HIGHER
#endif
#endif
#ifdef __SAMBA_FOUR_OR_HIGHER
#include
#include
#include
#endif
#undef DBGC_CLASS
#define DBGC_CLASS DBGC_VFS
#ifndef vfs_fake_full_access_init
#define vfs_fake_full_access_init init_samba_module
#endif
static int fake_full_access_stat(vfs_handle_struct *handle,
struct smb_filename *smb_fname)
{
int ret = -1;
ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
if (ret == 0) {
smb_fname->st.st_ex_mode |= (S_IRWXU | S_IRWXG | S_IRWXO) ;
}
return ret;
}
static int fake_full_access_fstat(vfs_handle_struct *handle,
files_struct *fsp, SMB_STRUCT_STAT *sbuf)
{
int ret = -1;
ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
if (ret == 0) {
sbuf->st_ex_mode |= (S_IRWXU | S_IRWXG | S_IRWXO) ;
}
return ret;
}
static int fake_full_access_lstat(vfs_handle_struct *handle,
struct smb_filename *smb_fname)
{
int ret = -1;
ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
if (ret == 0) {
smb_fname->st.st_ex_mode |= (S_IRWXU | S_IRWXG | S_IRWXO) ;
}
return ret;
}
static struct vfs_fn_pointers vfs_fake_full_access_fns = {
#ifdef __SAMBA_FOUR_OR_HIGHER
.stat_fn = fake_full_access_stat,
.fstat_fn = fake_full_access_fstat,
.lstat_fn = fake_full_access_lstat
#else
.stat = fake_full_access_stat,
.fstat = fake_full_access_fstat,
.lstat = fake_full_access_lstat
#endif
};
NTSTATUS vfs_fake_full_access_init(void);
NTSTATUS vfs_fake_full_access_init(void)
{
return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "fake_full_access",
&vfs_fake_full_access_fns);
}