From: pete scott Date: Wed, 27 Feb 2013 15:51:44 +0000 (-0700) Subject: Windows: IOCTL_AFS_SET_REPARSE_POLICY X-Git-Tag: upstream/1.8.0_pre1^2~1184 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=1ff59729dce57dbcf02e593310e7065d92d73bb7;p=packages%2Fo%2Fopenafs.git Windows: IOCTL_AFS_SET_REPARSE_POLICY IOCTL_AFS_SET_REPARSE_POLICY is a new ioctl that can be executed by anyone to alter the behavior of AFS Symlink-to-File reparse point processing. Policy can be set for a global default or for the active authentication group. If the AFS_REPARSE_POINT_TO_FILE_AS_FILE policy is active, afs symlinks will not be reported as reparse points if the symlink target is known to be a file. This patchset implements the ioctl but not the "reparse point to file as file" functionality. Per authgroup policy setting is not permitted by the ioctl but is not supported at this time. This patchset was modified by Jeffrey Altman. Change-Id: I6fd8b3c7f94dd97e15d6b82642f43cb2d8193563 Reviewed-on: http://gerrit.openafs.org/9341 Tested-by: BuildBot Tested-by: Jeffrey Altman Reviewed-by: Jeffrey Altman --- diff --git a/src/WINNT/afsrdr/common/AFSRedirCommonDefines.h b/src/WINNT/afsrdr/common/AFSRedirCommonDefines.h index 6e5ea4091..816331deb 100644 --- a/src/WINNT/afsrdr/common/AFSRedirCommonDefines.h +++ b/src/WINNT/afsrdr/common/AFSRedirCommonDefines.h @@ -1,6 +1,6 @@ /* - * Copyright (c) 2008-2011 Kernel Drivers, LLC. - * Copyright (c) 2009-2011 Your File System, Inc. + * Copyright (c) 2008-2013 Kernel Drivers, LLC. + * Copyright (c) 2009-2013 Your File System, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -10,15 +10,12 @@ * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright - * notice, - * this list of conditions and the following disclaimer in the - * documentation - * and/or other materials provided with the distribution. + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - Neither the name of Kernel Drivers, LLC nor the names of its - * contributors may be - * used to endorse or promote products derived from this software without - * specific prior written permission from Kernel Drivers, LLC - * and Your File System, Inc. + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission from + * Kernel Drivers, LLC and Your File System, Inc. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED @@ -184,6 +181,13 @@ #define AFS_VOLUME_INSERTED_HASH_TREE 0x00000004 #define AFS_VOLUME_ACTIVE_GLOBAL_ROOT 0x00000008 +// +// Authentication Group Flags +// + +#define AFS_AUTHGROUP_REPARSE_POLICY_SET 0x00000001 +#define AFS_AUTHGROUP_REPARSE_POINT_TO_FILE_AS_FILE 0x00000002 + // // Need this to handle the break point definition // diff --git a/src/WINNT/afsrdr/common/AFSRedirCommonStructs.h b/src/WINNT/afsrdr/common/AFSRedirCommonStructs.h index 5da3ce9ae..bddd44799 100644 --- a/src/WINNT/afsrdr/common/AFSRedirCommonStructs.h +++ b/src/WINNT/afsrdr/common/AFSRedirCommonStructs.h @@ -680,6 +680,12 @@ typedef struct _AFS_DEVICE_EXTENSION struct _AFSFSD_PROVIDER_CONNECTION_CB *ProviderEnumerationList; + // + // Reparse point policy + // + + ULONG ReparsePointPolicy; + } RDR; struct diff --git a/src/WINNT/afsrdr/common/AFSUserDefines.h b/src/WINNT/afsrdr/common/AFSUserDefines.h index 324cb8d58..421fe2c8a 100644 --- a/src/WINNT/afsrdr/common/AFSUserDefines.h +++ b/src/WINNT/afsrdr/common/AFSUserDefines.h @@ -326,4 +326,27 @@ #define AFS_FILE_ACCESS_EXCLUSIVE 0x00000001 #define AFS_FILE_ACCESS_SHARED 0x00000002 +// +// Reparse Point processing policy +// + +#define AFS_REPARSE_POINT_POLICY_RESET 0x00000000 // This will reset the policy to default + // behavior which is to process the + // "open as reparse point" flag during + // Create per normal operation. + +#define AFS_REPARSE_POINT_TO_FILE_AS_FILE 0x00000001 // If indicated then ignore any attempt to + // "open as reparse point" when the target is + // a file. + +#define AFS_REPARSE_POINT_VALID_POLICY_FLAGS 0x00000001 + +// +// Reparse Point policy scope +// + +#define AFS_REPARSE_POINT_POLICY_GLOBAL 0x00000000 + +#define AFS_REPARSE_POINT_POLICY_AUTHGROUP 0x00000001 + #endif /* _AFS_USER_DEFINE_H */ diff --git a/src/WINNT/afsrdr/common/AFSUserIoctl.h b/src/WINNT/afsrdr/common/AFSUserIoctl.h index 35998994f..f788dadfa 100644 --- a/src/WINNT/afsrdr/common/AFSUserIoctl.h +++ b/src/WINNT/afsrdr/common/AFSUserIoctl.h @@ -94,4 +94,6 @@ #define IOCTL_AFS_CONFIG_LIBRARY_TRACE CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x101B, METHOD_BUFFERED, FILE_ANY_ACCESS) +#define IOCTL_AFS_SET_REPARSE_POLICY CTL_CODE( FILE_DEVICE_DISK_FILE_SYSTEM, 0x101C, METHOD_BUFFERED, FILE_ANY_ACCESS) + #endif /* _AFS_USER_IOCTL_H */ \ No newline at end of file diff --git a/src/WINNT/afsrdr/common/AFSUserStructs.h b/src/WINNT/afsrdr/common/AFSUserStructs.h index 502e9bcd4..aa7586d35 100644 --- a/src/WINNT/afsrdr/common/AFSUserStructs.h +++ b/src/WINNT/afsrdr/common/AFSUserStructs.h @@ -1311,5 +1311,14 @@ typedef struct _AFS_FILE_IO_RESULT_CB } AFSFileIOResultCB; +typedef struct _AFS_SET_REPARSE_POINT_POLICY +{ + + ULONG Policy; + + ULONG Scope; + +} AFSSetReparsePointPolicyCB; + #endif /* _AFS_USER_STRUCT_H */ diff --git a/src/WINNT/afsrdr/kernel/fs/AFSCommSupport.cpp b/src/WINNT/afsrdr/kernel/fs/AFSCommSupport.cpp index c67cabe2e..0385d973e 100644 --- a/src/WINNT/afsrdr/kernel/fs/AFSCommSupport.cpp +++ b/src/WINNT/afsrdr/kernel/fs/AFSCommSupport.cpp @@ -529,6 +529,14 @@ AFSCheckIoctlPermissions( IN ULONG ControlCode) } return STATUS_SUCCESS; + case IOCTL_AFS_SET_REPARSE_POLICY: + + // + // Anyone can call this + // + + return STATUS_SUCCESS; + default: // @@ -905,6 +913,23 @@ AFSProcessControlRequest( IN PIRP Irp) break; } + case IOCTL_AFS_SET_REPARSE_POLICY: + { + + AFSSetReparsePointPolicyCB *pPolicy = (AFSSetReparsePointPolicyCB *)Irp->AssociatedIrp.SystemBuffer; + + if( pPolicy == NULL || + pIrpSp->Parameters.DeviceIoControl.InputBufferLength < sizeof( AFSSetReparsePointPolicyCB)) + { + ntStatus = STATUS_INVALID_PARAMETER; + break; + } + + ntStatus = AFSSetReparsePointPolicy( pPolicy); + + break; + } + default: { diff --git a/src/WINNT/afsrdr/kernel/fs/AFSGeneric.cpp b/src/WINNT/afsrdr/kernel/fs/AFSGeneric.cpp index 4d42de3df..9bfe51308 100644 --- a/src/WINNT/afsrdr/kernel/fs/AFSGeneric.cpp +++ b/src/WINNT/afsrdr/kernel/fs/AFSGeneric.cpp @@ -1,6 +1,6 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC. - * Copyright (c) 2009, 2010, 2011 Your File System, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Kernel Drivers, LLC. + * Copyright (c) 2009, 2010, 2011, 2012, 2013 Your File System, Inc. * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -10,10 +10,8 @@ * - Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * - Redistributions in binary form must reproduce the above copyright - * notice, - * this list of conditions and the following disclaimer in the - * documentation - * and/or other materials provided with the distribution. + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. * - Neither the names of Kernel Drivers, LLC and Your File System, Inc. * nor the names of their contributors may be used to endorse or promote * products derived from this software without specific prior written @@ -2234,4 +2232,31 @@ try_exit: return ntStatus; } +NTSTATUS +AFSSetReparsePointPolicy( IN AFSSetReparsePointPolicyCB *PolicyCB) +{ + + NTSTATUS ntStatus = STATUS_SUCCESS; + AFSDeviceExt* pDeviceExt = (AFSDeviceExt *)AFSRDRDeviceObject->DeviceExtension; + ULONG ulPolicy = 0; + + __Enter + { + + ulPolicy = (PolicyCB->Policy & AFS_REPARSE_POINT_VALID_POLICY_FLAGS); + + if ( PolicyCB->Scope == AFS_REPARSE_POINT_POLICY_GLOBAL) + { + + pDeviceExt->Specific.RDR.ReparsePointPolicy = ulPolicy; + } + else if ( PolicyCB->Scope == AFS_REPARSE_POINT_POLICY_AUTHGROUP) + { + + ntStatus = STATUS_NOT_SUPPORTED; + } + } + + return ntStatus; +} diff --git a/src/WINNT/afsrdr/kernel/fs/Include/AFSCommon.h b/src/WINNT/afsrdr/kernel/fs/Include/AFSCommon.h index 432fd2cad..5b74a210d 100644 --- a/src/WINNT/afsrdr/kernel/fs/Include/AFSCommon.h +++ b/src/WINNT/afsrdr/kernel/fs/Include/AFSCommon.h @@ -516,6 +516,9 @@ AFSCheckThreadDacl( OUT GUID *AuthGroup); NTSTATUS AFSProcessSetProcessDacl( IN AFSProcessCB *ProcessCB); +NTSTATUS +AFSSetReparsePointPolicy( IN AFSSetReparsePointPolicyCB *Policy); + // // Prototypes in AFSFastIoSupprt.cpp //