s4-torture: verify #8373 and add ndr nbt tests for LOGON_PRIMARY_QUERY nbt_netlogon_r...
[Samba/wip.git] / source3 / modules / vfs_fake_perms.c
blob4cda7ea1601dbb9d63266ff6522d62db4a4cc3d6
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.
6 * Copyright (C) Tim Potter, 1999-2000
7 * Copyright (C) Alexander Bokovoy, 2002
8 * Copyright (C) Andrew Bartlett, 2002
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.
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.
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/>.
24 #include "includes.h"
25 #include "smbd/smbd.h"
26 #include "system/filesys.h"
27 #include "auth.h"
29 #undef DBGC_CLASS
30 #define DBGC_CLASS DBGC_VFS
32 static int fake_perms_stat(vfs_handle_struct *handle,
33 struct smb_filename *smb_fname)
35 int ret = -1;
37 ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
38 if (ret == 0) {
39 if (S_ISDIR(smb_fname->st.st_ex_mode)) {
40 smb_fname->st.st_ex_mode = S_IFDIR | S_IRWXU;
41 } else {
42 smb_fname->st.st_ex_mode = S_IRWXU;
44 smb_fname->st.st_ex_uid = handle->conn->session_info->unix_token->uid;
45 smb_fname->st.st_ex_gid = handle->conn->session_info->unix_token->gid;
48 return ret;
51 static int fake_perms_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_STRUCT_STAT *sbuf)
53 int ret = -1;
55 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
56 if (ret == 0) {
57 if (S_ISDIR(sbuf->st_ex_mode)) {
58 sbuf->st_ex_mode = S_IFDIR | S_IRWXU;
59 } else {
60 sbuf->st_ex_mode = S_IRWXU;
62 sbuf->st_ex_uid = handle->conn->session_info->unix_token->uid;
63 sbuf->st_ex_gid = handle->conn->session_info->unix_token->gid;
65 return ret;
68 static struct vfs_fn_pointers vfs_fake_perms_fns = {
69 .stat_fn = fake_perms_stat,
70 .fstat_fn = fake_perms_fstat
73 NTSTATUS vfs_fake_perms_init(void);
74 NTSTATUS vfs_fake_perms_init(void)
76 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "fake_perms",
77 &vfs_fake_perms_fns);