X-Git-Url: http://git.samba.org/?a=blobdiff_plain;f=source3%2Fmodules%2Fvfs_readonly.c;h=c19f5941beec9793f090d9fd7175f33892003c26;hb=HEAD;hp=ee9e40c2fcaa7b51a6caab0af6161750d6eba993;hpb=1579089d91aeb43802b558bf4c41f4db5360618c;p=samba.git diff --git a/source3/modules/vfs_readonly.c b/source3/modules/vfs_readonly.c index ee9e40c2fca..cde8ef973ca 100644 --- a/source3/modules/vfs_readonly.c +++ b/source3/modules/vfs_readonly.c @@ -6,7 +6,7 @@ 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 2 of the License, or + 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, @@ -15,13 +15,13 @@ 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, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with this program. If not, see . This work was sponsored by Optifacio Software Services, Inc. */ #include "includes.h" +#include "smbd/smbd.h" #include "getdate.h" /* @@ -55,7 +55,6 @@ #define MODULE_NAME "readonly" static int readonly_connect(vfs_handle_struct *handle, - connection_struct *conn, const char *service, const char *user) { @@ -64,35 +63,51 @@ static int readonly_connect(vfs_handle_struct *handle, const char **period = lp_parm_string_list(SNUM(handle->conn), (handle->param ? handle->param : MODULE_NAME), "period", period_def); + int ret = SMB_VFS_NEXT_CONNECT(handle, service, user); + + if (ret < 0) { + return ret; + } if (period && period[0] && period[1]) { + int i; time_t current_time = time(NULL); time_t begin_period = get_date(period[0], ¤t_time); time_t end_period = get_date(period[1], ¤t_time); if ((current_time >= begin_period) && (current_time <= end_period)) { - conn->read_only = True; + connection_struct *conn = handle->conn; + + handle->conn->read_only = True; + + /* Wipe out the VUID cache. */ + for (i=0; i< VUID_CACHE_SIZE; i++) { + struct vuid_cache_entry *ent = &conn->vuid_cache->array[i]; + ent->vuid = UID_FIELD_INVALID; + TALLOC_FREE(ent->session_info); + ent->read_only = false; + ent->share_access = 0; + } + conn->vuid_cache->next_entry = 0; } - return SMB_VFS_NEXT_CONNECT(handle, conn, service, user); + return 0; } else { - return 1; + return 0; } } -/* VFS operations structure */ - -static vfs_op_tuple readonly_op_tuples[] = { - /* Disk operations */ - {SMB_VFS_OP(readonly_connect), SMB_VFS_OP_CONNECT, SMB_VFS_LAYER_TRANSPARENT}, - {SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP} +static struct vfs_fn_pointers vfs_readonly_fns = { + .connect_fn = readonly_connect }; -NTSTATUS vfs_readonly_init(void) +NTSTATUS vfs_readonly_init(TALLOC_CTX *); +NTSTATUS vfs_readonly_init(TALLOC_CTX *ctx) { - return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, MODULE_NAME, readonly_op_tuples); + return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, MODULE_NAME, + &vfs_readonly_fns); }