Karsten Hopp 14f504
To: vim_dev@googlegroups.com
Karsten Hopp 14f504
Subject: Patch 7.3.1267
Karsten Hopp 14f504
Fcc: outbox
Karsten Hopp 14f504
From: Bram Moolenaar <Bram@moolenaar.net>
Karsten Hopp 14f504
Mime-Version: 1.0
Karsten Hopp 14f504
Content-Type: text/plain; charset=UTF-8
Karsten Hopp 14f504
Content-Transfer-Encoding: 8bit
Karsten Hopp 14f504
------------
Karsten Hopp 14f504
Karsten Hopp 14f504
Patch 7.3.1267
Karsten Hopp 14f504
Problem:    MS-Windows ACL support doesn't work well.
Karsten Hopp 14f504
Solution:   Implement more ACL support. (Ken Takata)
Karsten Hopp 14f504
Files:	    src/os_win32.c
Karsten Hopp 14f504
Karsten Hopp 14f504
Karsten Hopp 14f504
*** ../vim-7.3.1266/src/os_win32.c	2013-06-16 16:34:53.000000000 +0200
Karsten Hopp 14f504
--- src/os_win32.c	2013-06-29 15:33:52.000000000 +0200
Karsten Hopp 14f504
***************
Karsten Hopp 14f504
*** 481,500 ****
Karsten Hopp 14f504
  # ifndef PROTO
Karsten Hopp 14f504
  #  include <aclapi.h>
Karsten Hopp 14f504
  # endif
Karsten Hopp 14f504
  
Karsten Hopp 14f504
  /*
Karsten Hopp 14f504
   * These are needed to dynamically load the ADVAPI DLL, which is not
Karsten Hopp 14f504
   * implemented under Windows 95 (and causes VIM to crash)
Karsten Hopp 14f504
   */
Karsten Hopp 14f504
! typedef DWORD (WINAPI *PSNSECINFO) (LPTSTR, enum SE_OBJECT_TYPE,
Karsten Hopp 14f504
  	SECURITY_INFORMATION, PSID, PSID, PACL, PACL);
Karsten Hopp 14f504
  typedef DWORD (WINAPI *PGNSECINFO) (LPSTR, enum SE_OBJECT_TYPE,
Karsten Hopp 14f504
  	SECURITY_INFORMATION, PSID *, PSID *, PACL *, PACL *,
Karsten Hopp 14f504
  	PSECURITY_DESCRIPTOR *);
Karsten Hopp 14f504
  
Karsten Hopp 14f504
  static HANDLE advapi_lib = NULL;	/* Handle for ADVAPI library */
Karsten Hopp 14f504
  static PSNSECINFO pSetNamedSecurityInfo;
Karsten Hopp 14f504
  static PGNSECINFO pGetNamedSecurityInfo;
Karsten Hopp 14f504
  #endif
Karsten Hopp 14f504
  
Karsten Hopp 14f504
  typedef BOOL (WINAPI *PSETHANDLEINFORMATION)(HANDLE, DWORD, DWORD);
Karsten Hopp 14f504
--- 481,514 ----
Karsten Hopp 14f504
  # ifndef PROTO
Karsten Hopp 14f504
  #  include <aclapi.h>
Karsten Hopp 14f504
  # endif
Karsten Hopp 14f504
+ # ifndef PROTECTED_DACL_SECURITY_INFORMATION
Karsten Hopp 14f504
+ #  define PROTECTED_DACL_SECURITY_INFORMATION	0x80000000L
Karsten Hopp 14f504
+ # endif
Karsten Hopp 14f504
  
Karsten Hopp 14f504
  /*
Karsten Hopp 14f504
   * These are needed to dynamically load the ADVAPI DLL, which is not
Karsten Hopp 14f504
   * implemented under Windows 95 (and causes VIM to crash)
Karsten Hopp 14f504
   */
Karsten Hopp 14f504
! typedef DWORD (WINAPI *PSNSECINFO) (LPSTR, enum SE_OBJECT_TYPE,
Karsten Hopp 14f504
  	SECURITY_INFORMATION, PSID, PSID, PACL, PACL);
Karsten Hopp 14f504
  typedef DWORD (WINAPI *PGNSECINFO) (LPSTR, enum SE_OBJECT_TYPE,
Karsten Hopp 14f504
  	SECURITY_INFORMATION, PSID *, PSID *, PACL *, PACL *,
Karsten Hopp 14f504
  	PSECURITY_DESCRIPTOR *);
Karsten Hopp 14f504
+ # ifdef FEAT_MBYTE
Karsten Hopp 14f504
+ typedef DWORD (WINAPI *PSNSECINFOW) (LPWSTR, enum SE_OBJECT_TYPE,
Karsten Hopp 14f504
+ 	SECURITY_INFORMATION, PSID, PSID, PACL, PACL);
Karsten Hopp 14f504
+ typedef DWORD (WINAPI *PGNSECINFOW) (LPWSTR, enum SE_OBJECT_TYPE,
Karsten Hopp 14f504
+ 	SECURITY_INFORMATION, PSID *, PSID *, PACL *, PACL *,
Karsten Hopp 14f504
+ 	PSECURITY_DESCRIPTOR *);
Karsten Hopp 14f504
+ # endif
Karsten Hopp 14f504
  
Karsten Hopp 14f504
  static HANDLE advapi_lib = NULL;	/* Handle for ADVAPI library */
Karsten Hopp 14f504
  static PSNSECINFO pSetNamedSecurityInfo;
Karsten Hopp 14f504
  static PGNSECINFO pGetNamedSecurityInfo;
Karsten Hopp 14f504
+ # ifdef FEAT_MBYTE
Karsten Hopp 14f504
+ static PSNSECINFOW pSetNamedSecurityInfoW;
Karsten Hopp 14f504
+ static PGNSECINFOW pGetNamedSecurityInfoW;
Karsten Hopp 14f504
+ # endif
Karsten Hopp 14f504
  #endif
Karsten Hopp 14f504
  
Karsten Hopp 14f504
  typedef BOOL (WINAPI *PSETHANDLEINFORMATION)(HANDLE, DWORD, DWORD);
Karsten Hopp 14f504
***************
Karsten Hopp 14f504
*** 502,507 ****
Karsten Hopp 14f504
--- 516,557 ----
Karsten Hopp 14f504
  static BOOL allowPiping = FALSE;
Karsten Hopp 14f504
  static PSETHANDLEINFORMATION pSetHandleInformation;
Karsten Hopp 14f504
  
Karsten Hopp 14f504
+ #ifdef HAVE_ACL
Karsten Hopp 14f504
+ /*
Karsten Hopp 14f504
+  * Enables or disables the specified privilege.
Karsten Hopp 14f504
+  */
Karsten Hopp 14f504
+     static BOOL
Karsten Hopp 14f504
+ win32_enable_privilege(LPTSTR lpszPrivilege, BOOL bEnable)
Karsten Hopp 14f504
+ {
Karsten Hopp 14f504
+     BOOL             bResult;
Karsten Hopp 14f504
+     LUID             luid;
Karsten Hopp 14f504
+     HANDLE           hToken;
Karsten Hopp 14f504
+     TOKEN_PRIVILEGES tokenPrivileges;
Karsten Hopp 14f504
+ 
Karsten Hopp 14f504
+     if (!OpenProcessToken(GetCurrentProcess(),
Karsten Hopp 14f504
+ 		TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken))
Karsten Hopp 14f504
+ 	return FALSE;
Karsten Hopp 14f504
+ 
Karsten Hopp 14f504
+     if (!LookupPrivilegeValue(NULL, lpszPrivilege, &luid))
Karsten Hopp 14f504
+     {
Karsten Hopp 14f504
+ 	CloseHandle(hToken);
Karsten Hopp 14f504
+ 	return FALSE;
Karsten Hopp 14f504
+     }
Karsten Hopp 14f504
+ 
Karsten Hopp 14f504
+     tokenPrivileges.PrivilegeCount           = 1;
Karsten Hopp 14f504
+     tokenPrivileges.Privileges[0].Luid       = luid;
Karsten Hopp 14f504
+     tokenPrivileges.Privileges[0].Attributes = bEnable ?
Karsten Hopp 14f504
+ 						    SE_PRIVILEGE_ENABLED : 0;
Karsten Hopp 14f504
+ 
Karsten Hopp 14f504
+     bResult = AdjustTokenPrivileges(hToken, FALSE, &tokenPrivileges,
Karsten Hopp 14f504
+ 	    sizeof(TOKEN_PRIVILEGES), NULL, NULL);
Karsten Hopp 14f504
+ 
Karsten Hopp 14f504
+     CloseHandle(hToken);
Karsten Hopp 14f504
+ 
Karsten Hopp 14f504
+     return bResult && GetLastError() == ERROR_SUCCESS;
Karsten Hopp 14f504
+ }
Karsten Hopp 14f504
+ #endif
Karsten Hopp 14f504
+ 
Karsten Hopp 14f504
  /*
Karsten Hopp 14f504
   * Set g_PlatformId to VER_PLATFORM_WIN32_NT (NT) or
Karsten Hopp 14f504
   * VER_PLATFORM_WIN32_WINDOWS (Win95).
Karsten Hopp 14f504
***************
Karsten Hopp 14f504
*** 541,554 ****
Karsten Hopp 14f504
  						      "SetNamedSecurityInfoA");
Karsten Hopp 14f504
  		pGetNamedSecurityInfo = (PGNSECINFO)GetProcAddress(advapi_lib,
Karsten Hopp 14f504
  						      "GetNamedSecurityInfoA");
Karsten Hopp 14f504
  		if (pSetNamedSecurityInfo == NULL
Karsten Hopp 14f504
! 			|| pGetNamedSecurityInfo == NULL)
Karsten Hopp 14f504
  		{
Karsten Hopp 14f504
  		    /* If we can't get the function addresses, set advapi_lib
Karsten Hopp 14f504
  		     * to NULL so that we don't use them. */
Karsten Hopp 14f504
  		    FreeLibrary(advapi_lib);
Karsten Hopp 14f504
  		    advapi_lib = NULL;
Karsten Hopp 14f504
  		}
Karsten Hopp 14f504
  	    }
Karsten Hopp 14f504
  	}
Karsten Hopp 14f504
  #endif
Karsten Hopp 14f504
--- 591,617 ----
Karsten Hopp 14f504
  						      "SetNamedSecurityInfoA");
Karsten Hopp 14f504
  		pGetNamedSecurityInfo = (PGNSECINFO)GetProcAddress(advapi_lib,
Karsten Hopp 14f504
  						      "GetNamedSecurityInfoA");
Karsten Hopp 14f504
+ # ifdef FEAT_MBYTE
Karsten Hopp 14f504
+ 		pSetNamedSecurityInfoW = (PSNSECINFOW)GetProcAddress(advapi_lib,
Karsten Hopp 14f504
+ 						      "SetNamedSecurityInfoW");
Karsten Hopp 14f504
+ 		pGetNamedSecurityInfoW = (PGNSECINFOW)GetProcAddress(advapi_lib,
Karsten Hopp 14f504
+ 						      "GetNamedSecurityInfoW");
Karsten Hopp 14f504
+ # endif
Karsten Hopp 14f504
  		if (pSetNamedSecurityInfo == NULL
Karsten Hopp 14f504
! 			|| pGetNamedSecurityInfo == NULL
Karsten Hopp 14f504
! # ifdef FEAT_MBYTE
Karsten Hopp 14f504
! 			|| pSetNamedSecurityInfoW == NULL
Karsten Hopp 14f504
! 			|| pGetNamedSecurityInfoW == NULL
Karsten Hopp 14f504
! # endif
Karsten Hopp 14f504
! 			)
Karsten Hopp 14f504
  		{
Karsten Hopp 14f504
  		    /* If we can't get the function addresses, set advapi_lib
Karsten Hopp 14f504
  		     * to NULL so that we don't use them. */
Karsten Hopp 14f504
  		    FreeLibrary(advapi_lib);
Karsten Hopp 14f504
  		    advapi_lib = NULL;
Karsten Hopp 14f504
  		}
Karsten Hopp 14f504
+ 		/* Enable privilege for getting or setting SACLs. */
Karsten Hopp 14f504
+ 		win32_enable_privilege(SE_SECURITY_NAME, TRUE);
Karsten Hopp 14f504
  	    }
Karsten Hopp 14f504
  	}
Karsten Hopp 14f504
  #endif
Karsten Hopp 14f504
***************
Karsten Hopp 14f504
*** 3091,3096 ****
Karsten Hopp 14f504
--- 3154,3160 ----
Karsten Hopp 14f504
      return (vim_acl_T)NULL;
Karsten Hopp 14f504
  #else
Karsten Hopp 14f504
      struct my_acl   *p = NULL;
Karsten Hopp 14f504
+     DWORD   err;
Karsten Hopp 14f504
  
Karsten Hopp 14f504
      /* This only works on Windows NT and 2000. */
Karsten Hopp 14f504
      if (g_PlatformId == VER_PLATFORM_WIN32_NT && advapi_lib != NULL)
Karsten Hopp 14f504
***************
Karsten Hopp 14f504
*** 3098,3120 ****
Karsten Hopp 14f504
  	p = (struct my_acl *)alloc_clear((unsigned)sizeof(struct my_acl));
Karsten Hopp 14f504
  	if (p != NULL)
Karsten Hopp 14f504
  	{
Karsten Hopp 14f504
! 	    if (pGetNamedSecurityInfo(
Karsten Hopp 14f504
! 			(LPTSTR)fname,		// Abstract filename
Karsten Hopp 14f504
! 			SE_FILE_OBJECT,		// File Object
Karsten Hopp 14f504
! 			// Retrieve the entire security descriptor.
Karsten Hopp 14f504
! 			OWNER_SECURITY_INFORMATION |
Karsten Hopp 14f504
! 			GROUP_SECURITY_INFORMATION |
Karsten Hopp 14f504
! 			DACL_SECURITY_INFORMATION |
Karsten Hopp 14f504
! 			SACL_SECURITY_INFORMATION,
Karsten Hopp 14f504
! 			&p->pSidOwner,		// Ownership information.
Karsten Hopp 14f504
! 			&p->pSidGroup,		// Group membership.
Karsten Hopp 14f504
! 			&p->pDacl,		// Discretionary information.
Karsten Hopp 14f504
! 			&p->pSacl,		// For auditing purposes.
Karsten Hopp 14f504
! 			&p->pSecurityDescriptor
Karsten Hopp 14f504
! 				    ) != ERROR_SUCCESS)
Karsten Hopp 14f504
  	    {
Karsten Hopp 14f504
! 		mch_free_acl((vim_acl_T)p);
Karsten Hopp 14f504
! 		p = NULL;
Karsten Hopp 14f504
  	    }
Karsten Hopp 14f504
  	}
Karsten Hopp 14f504
      }
Karsten Hopp 14f504
--- 3162,3243 ----
Karsten Hopp 14f504
  	p = (struct my_acl *)alloc_clear((unsigned)sizeof(struct my_acl));
Karsten Hopp 14f504
  	if (p != NULL)
Karsten Hopp 14f504
  	{
Karsten Hopp 14f504
! # ifdef FEAT_MBYTE
Karsten Hopp 14f504
! 	    WCHAR	*wn = NULL;
Karsten Hopp 14f504
! 
Karsten Hopp 14f504
! 	    if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 14f504
! 		wn = enc_to_utf16(fname, NULL);
Karsten Hopp 14f504
! 	    if (wn != NULL)
Karsten Hopp 14f504
! 	    {
Karsten Hopp 14f504
! 		/* Try to retrieve the entire security descriptor. */
Karsten Hopp 14f504
! 		err = pGetNamedSecurityInfoW(
Karsten Hopp 14f504
! 			    wn,			// Abstract filename
Karsten Hopp 14f504
! 			    SE_FILE_OBJECT,	// File Object
Karsten Hopp 14f504
! 			    OWNER_SECURITY_INFORMATION |
Karsten Hopp 14f504
! 			    GROUP_SECURITY_INFORMATION |
Karsten Hopp 14f504
! 			    DACL_SECURITY_INFORMATION |
Karsten Hopp 14f504
! 			    SACL_SECURITY_INFORMATION,
Karsten Hopp 14f504
! 			    &p->pSidOwner,	// Ownership information.
Karsten Hopp 14f504
! 			    &p->pSidGroup,	// Group membership.
Karsten Hopp 14f504
! 			    &p->pDacl,		// Discretionary information.
Karsten Hopp 14f504
! 			    &p->pSacl,		// For auditing purposes.
Karsten Hopp 14f504
! 			    &p->pSecurityDescriptor);
Karsten Hopp 14f504
! 		if (err == ERROR_ACCESS_DENIED ||
Karsten Hopp 14f504
! 			err == ERROR_PRIVILEGE_NOT_HELD)
Karsten Hopp 14f504
! 		{
Karsten Hopp 14f504
! 		    /* Retrieve only DACL. */
Karsten Hopp 14f504
! 		    (void)pGetNamedSecurityInfoW(
Karsten Hopp 14f504
! 			    wn,
Karsten Hopp 14f504
! 			    SE_FILE_OBJECT,
Karsten Hopp 14f504
! 			    DACL_SECURITY_INFORMATION,
Karsten Hopp 14f504
! 			    NULL,
Karsten Hopp 14f504
! 			    NULL,
Karsten Hopp 14f504
! 			    &p->pDacl,
Karsten Hopp 14f504
! 			    NULL,
Karsten Hopp 14f504
! 			    &p->pSecurityDescriptor);
Karsten Hopp 14f504
! 		}
Karsten Hopp 14f504
! 		if (p->pSecurityDescriptor == NULL)
Karsten Hopp 14f504
! 		{
Karsten Hopp 14f504
! 		    mch_free_acl((vim_acl_T)p);
Karsten Hopp 14f504
! 		    p = NULL;
Karsten Hopp 14f504
! 		}
Karsten Hopp 14f504
! 		vim_free(wn);
Karsten Hopp 14f504
! 	    }
Karsten Hopp 14f504
! 	    else
Karsten Hopp 14f504
! # endif
Karsten Hopp 14f504
  	    {
Karsten Hopp 14f504
! 		/* Try to retrieve the entire security descriptor. */
Karsten Hopp 14f504
! 		err = pGetNamedSecurityInfo(
Karsten Hopp 14f504
! 			    (LPSTR)fname,	// Abstract filename
Karsten Hopp 14f504
! 			    SE_FILE_OBJECT,	// File Object
Karsten Hopp 14f504
! 			    OWNER_SECURITY_INFORMATION |
Karsten Hopp 14f504
! 			    GROUP_SECURITY_INFORMATION |
Karsten Hopp 14f504
! 			    DACL_SECURITY_INFORMATION |
Karsten Hopp 14f504
! 			    SACL_SECURITY_INFORMATION,
Karsten Hopp 14f504
! 			    &p->pSidOwner,	// Ownership information.
Karsten Hopp 14f504
! 			    &p->pSidGroup,	// Group membership.
Karsten Hopp 14f504
! 			    &p->pDacl,		// Discretionary information.
Karsten Hopp 14f504
! 			    &p->pSacl,		// For auditing purposes.
Karsten Hopp 14f504
! 			    &p->pSecurityDescriptor);
Karsten Hopp 14f504
! 		if (err == ERROR_ACCESS_DENIED ||
Karsten Hopp 14f504
! 			err == ERROR_PRIVILEGE_NOT_HELD)
Karsten Hopp 14f504
! 		{
Karsten Hopp 14f504
! 		    /* Retrieve only DACL. */
Karsten Hopp 14f504
! 		    (void)pGetNamedSecurityInfo(
Karsten Hopp 14f504
! 			    (LPSTR)fname,
Karsten Hopp 14f504
! 			    SE_FILE_OBJECT,
Karsten Hopp 14f504
! 			    DACL_SECURITY_INFORMATION,
Karsten Hopp 14f504
! 			    NULL,
Karsten Hopp 14f504
! 			    NULL,
Karsten Hopp 14f504
! 			    &p->pDacl,
Karsten Hopp 14f504
! 			    NULL,
Karsten Hopp 14f504
! 			    &p->pSecurityDescriptor);
Karsten Hopp 14f504
! 		}
Karsten Hopp 14f504
! 		if (p->pSecurityDescriptor == NULL)
Karsten Hopp 14f504
! 		{
Karsten Hopp 14f504
! 		    mch_free_acl((vim_acl_T)p);
Karsten Hopp 14f504
! 		    p = NULL;
Karsten Hopp 14f504
! 		}
Karsten Hopp 14f504
  	    }
Karsten Hopp 14f504
  	}
Karsten Hopp 14f504
      }
Karsten Hopp 14f504
***************
Karsten Hopp 14f504
*** 3123,3128 ****
Karsten Hopp 14f504
--- 3246,3274 ----
Karsten Hopp 14f504
  #endif
Karsten Hopp 14f504
  }
Karsten Hopp 14f504
  
Karsten Hopp 14f504
+ #ifdef HAVE_ACL
Karsten Hopp 14f504
+ /*
Karsten Hopp 14f504
+  * Check if "acl" contains inherited ACE.
Karsten Hopp 14f504
+  */
Karsten Hopp 14f504
+     static BOOL
Karsten Hopp 14f504
+ is_acl_inherited(PACL acl)
Karsten Hopp 14f504
+ {
Karsten Hopp 14f504
+     DWORD   i;
Karsten Hopp 14f504
+     ACL_SIZE_INFORMATION    acl_info;
Karsten Hopp 14f504
+     PACCESS_ALLOWED_ACE	    ace;
Karsten Hopp 14f504
+ 
Karsten Hopp 14f504
+     acl_info.AceCount = 0;
Karsten Hopp 14f504
+     GetAclInformation(acl, &acl_info, sizeof(acl_info), AclSizeInformation);
Karsten Hopp 14f504
+     for (i = 0; i < acl_info.AceCount; i++)
Karsten Hopp 14f504
+     {
Karsten Hopp 14f504
+ 	GetAce(acl, i, (LPVOID *)&ace;;
Karsten Hopp 14f504
+ 	if (ace->Header.AceFlags & INHERITED_ACE)
Karsten Hopp 14f504
+ 	    return TRUE;
Karsten Hopp 14f504
+     }
Karsten Hopp 14f504
+     return FALSE;
Karsten Hopp 14f504
+ }
Karsten Hopp 14f504
+ #endif
Karsten Hopp 14f504
+ 
Karsten Hopp 14f504
  /*
Karsten Hopp 14f504
   * Set the ACL of file "fname" to "acl" (unless it's NULL).
Karsten Hopp 14f504
   * Errors are ignored.
Karsten Hopp 14f504
***************
Karsten Hopp 14f504
*** 3133,3153 ****
Karsten Hopp 14f504
  {
Karsten Hopp 14f504
  #ifdef HAVE_ACL
Karsten Hopp 14f504
      struct my_acl   *p = (struct my_acl *)acl;
Karsten Hopp 14f504
  
Karsten Hopp 14f504
      if (p != NULL && advapi_lib != NULL)
Karsten Hopp 14f504
! 	(void)pSetNamedSecurityInfo(
Karsten Hopp 14f504
! 		    (LPTSTR)fname,		// Abstract filename
Karsten Hopp 14f504
! 		    SE_FILE_OBJECT,		// File Object
Karsten Hopp 14f504
! 		    // Retrieve the entire security descriptor.
Karsten Hopp 14f504
! 		    OWNER_SECURITY_INFORMATION |
Karsten Hopp 14f504
! 			GROUP_SECURITY_INFORMATION |
Karsten Hopp 14f504
! 			DACL_SECURITY_INFORMATION |
Karsten Hopp 14f504
! 			SACL_SECURITY_INFORMATION,
Karsten Hopp 14f504
! 		    p->pSidOwner,		// Ownership information.
Karsten Hopp 14f504
! 		    p->pSidGroup,		// Group membership.
Karsten Hopp 14f504
! 		    p->pDacl,			// Discretionary information.
Karsten Hopp 14f504
! 		    p->pSacl			// For auditing purposes.
Karsten Hopp 14f504
! 		    );
Karsten Hopp 14f504
  #endif
Karsten Hopp 14f504
  }
Karsten Hopp 14f504
  
Karsten Hopp 14f504
--- 3279,3339 ----
Karsten Hopp 14f504
  {
Karsten Hopp 14f504
  #ifdef HAVE_ACL
Karsten Hopp 14f504
      struct my_acl   *p = (struct my_acl *)acl;
Karsten Hopp 14f504
+     SECURITY_INFORMATION    sec_info = 0;
Karsten Hopp 14f504
  
Karsten Hopp 14f504
      if (p != NULL && advapi_lib != NULL)
Karsten Hopp 14f504
!     {
Karsten Hopp 14f504
! # ifdef FEAT_MBYTE
Karsten Hopp 14f504
! 	WCHAR	*wn = NULL;
Karsten Hopp 14f504
! # endif
Karsten Hopp 14f504
! 
Karsten Hopp 14f504
! 	/* Set security flags */
Karsten Hopp 14f504
! 	if (p->pSidOwner)
Karsten Hopp 14f504
! 	    sec_info |= OWNER_SECURITY_INFORMATION;
Karsten Hopp 14f504
! 	if (p->pSidGroup)
Karsten Hopp 14f504
! 	    sec_info |= GROUP_SECURITY_INFORMATION;
Karsten Hopp 14f504
! 	if (p->pDacl)
Karsten Hopp 14f504
! 	{
Karsten Hopp 14f504
! 	    sec_info |= DACL_SECURITY_INFORMATION;
Karsten Hopp 14f504
! 	    /* Do not inherit its parent's DACL.
Karsten Hopp 14f504
! 	     * If the DACL is inherited, Cygwin permissions would be changed.
Karsten Hopp 14f504
! 	     */
Karsten Hopp 14f504
! 	    if (!is_acl_inherited(p->pDacl))
Karsten Hopp 14f504
! 		sec_info |= PROTECTED_DACL_SECURITY_INFORMATION;
Karsten Hopp 14f504
! 	}
Karsten Hopp 14f504
! 	if (p->pSacl)
Karsten Hopp 14f504
! 	    sec_info |= SACL_SECURITY_INFORMATION;
Karsten Hopp 14f504
! 
Karsten Hopp 14f504
! # ifdef FEAT_MBYTE
Karsten Hopp 14f504
! 	if (enc_codepage >= 0 && (int)GetACP() != enc_codepage)
Karsten Hopp 14f504
! 	    wn = enc_to_utf16(fname, NULL);
Karsten Hopp 14f504
! 	if (wn != NULL)
Karsten Hopp 14f504
! 	{
Karsten Hopp 14f504
! 	    (void)pSetNamedSecurityInfoW(
Karsten Hopp 14f504
! 			wn,			// Abstract filename
Karsten Hopp 14f504
! 			SE_FILE_OBJECT,		// File Object
Karsten Hopp 14f504
! 			sec_info,
Karsten Hopp 14f504
! 			p->pSidOwner,		// Ownership information.
Karsten Hopp 14f504
! 			p->pSidGroup,		// Group membership.
Karsten Hopp 14f504
! 			p->pDacl,		// Discretionary information.
Karsten Hopp 14f504
! 			p->pSacl		// For auditing purposes.
Karsten Hopp 14f504
! 			);
Karsten Hopp 14f504
! 	    vim_free(wn);
Karsten Hopp 14f504
! 	}
Karsten Hopp 14f504
! 	else
Karsten Hopp 14f504
! # endif
Karsten Hopp 14f504
! 	{
Karsten Hopp 14f504
! 	    (void)pSetNamedSecurityInfo(
Karsten Hopp 14f504
! 			(LPSTR)fname,		// Abstract filename
Karsten Hopp 14f504
! 			SE_FILE_OBJECT,		// File Object
Karsten Hopp 14f504
! 			sec_info,
Karsten Hopp 14f504
! 			p->pSidOwner,		// Ownership information.
Karsten Hopp 14f504
! 			p->pSidGroup,		// Group membership.
Karsten Hopp 14f504
! 			p->pDacl,		// Discretionary information.
Karsten Hopp 14f504
! 			p->pSacl		// For auditing purposes.
Karsten Hopp 14f504
! 			);
Karsten Hopp 14f504
! 	}
Karsten Hopp 14f504
!     }
Karsten Hopp 14f504
  #endif
Karsten Hopp 14f504
  }
Karsten Hopp 14f504
  
Karsten Hopp 14f504
*** ../vim-7.3.1266/src/version.c	2013-06-29 15:19:17.000000000 +0200
Karsten Hopp 14f504
--- src/version.c	2013-06-29 15:35:23.000000000 +0200
Karsten Hopp 14f504
***************
Karsten Hopp 14f504
*** 730,731 ****
Karsten Hopp 14f504
--- 730,733 ----
Karsten Hopp 14f504
  {   /* Add new patch number below this line */
Karsten Hopp 14f504
+ /**/
Karsten Hopp 14f504
+     1267,
Karsten Hopp 14f504
  /**/
Karsten Hopp 14f504
Karsten Hopp 14f504
-- 
Karsten Hopp 14f504
We do not stumble over mountains, but over molehills.
Karsten Hopp 14f504
				Confucius
Karsten Hopp 14f504
Karsten Hopp 14f504
 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
Karsten Hopp 14f504
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
Karsten Hopp 14f504
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
Karsten Hopp 14f504
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///