Skip to content
This repository has been archived by the owner on Mar 4, 2025. It is now read-only.

Inherit ACLs from parent after rename #289

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/wfcopy.c
Original file line number Diff line number Diff line change
Expand Up @@ -3348,10 +3348,28 @@ FileMove(LPTSTR pFrom, LPTSTR pTo, PBOOL pbErrorOnDest, BOOL bSilent)
*pbErrorOnDest = FALSE;

TryAgain:
if (MoveFile((LPTSTR)pFrom, (LPTSTR)pTo))
if (MoveFile((LPTSTR)pFrom, (LPTSTR)pTo)) {
ACL EmptyAcl;
result = 0;
else

//
// Enable ACL inheritance, updating the ACL on the file from its new
// parent. Note this requires Windows 2000 and above. There's not
// much we can do if it fails, since the rename already occurred.
//

InitializeAcl(&EmptyAcl, sizeof(EmptyAcl), ACL_REVISION);
SetNamedSecurityInfo((LPTSTR)pTo,
SE_FILE_OBJECT,
DACL_SECURITY_INFORMATION | UNPROTECTED_DACL_SECURITY_INFORMATION,
NULL,
NULL,
&EmptyAcl,
NULL);

} else {
result = GetLastError();
}

// try to create the destination if it is not there

Expand Down
1 change: 1 addition & 0 deletions src/winfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "fmifs.h"
#include <shellapi.h>
#include <shlwapi.h>
#include <aclapi.h>
#include <strsafe.h>
#include "suggest.h"
#include "numfmt.h"
Expand Down