-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Renamed /ExportDescriptor To /SaveSecurity
Added /RestoreSecurity Special /Path Handling For Root Of Drive
- Loading branch information
1 parent
08e9526
commit 4e912f7
Showing
14 changed files
with
237 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include "OperationRestoreSecurity.h" | ||
#include "InputOutput.h" | ||
#include "Functions.h" | ||
|
||
#include <fstream> | ||
#include <iostream> | ||
#include <locale> | ||
#include <codecvt> | ||
|
||
ClassFactory<OperationRestoreSecurity> * OperationRestoreSecurity::RegisteredFactory = | ||
new ClassFactory<OperationRestoreSecurity>(GetCommand()); | ||
|
||
OperationRestoreSecurity::OperationRestoreSecurity(std::queue<std::wstring> & oArgList) : Operation(oArgList) | ||
{ | ||
// exit if there are not enough arguments to part | ||
std::vector<std::wstring> sSubArgs = ProcessAndCheckArgs(1, oArgList, L"\\0"); | ||
|
||
// open the file | ||
std::wifstream fFile(sSubArgs[0].c_str()); | ||
|
||
// adapt the stream to read windows unicode files | ||
fFile.imbue(std::locale(fFile.getloc(), new std::codecvt_utf16<wchar_t, | ||
0x10ffff, std::consume_header>)); | ||
|
||
// read the file line-by-line | ||
std::wstring sLine; | ||
while (std::getline(fFile, sLine)) | ||
{ | ||
// parse the file name and descriptor which are separated by a '|' character | ||
std::vector<std::wstring> oLineItems = SplitArgs(sLine, L"\\|"); | ||
|
||
// convert the long string descriptor its binary equivalent | ||
PSECURITY_DESCRIPTOR tDesc; | ||
if (ConvertStringSecurityDescriptorToSecurityDescriptor(oLineItems.at(1).c_str(), | ||
SDDL_REVISION_1, &tDesc, NULL) == 0) | ||
{ | ||
InputOutput::AddError(L"ERROR: Unable to parse string security descriptor."); | ||
exit(-1); | ||
} | ||
|
||
// update the map | ||
oImportMap[oLineItems.at(0)] = tDesc; | ||
} | ||
|
||
// cleanup | ||
fFile.close(); | ||
|
||
// flag this as being an ace-level action | ||
AppliesToSd = true; | ||
AppliesToDacl = true; | ||
AppliesToSacl = true; | ||
AppliesToOwner = true; | ||
AppliesToGroup = true; | ||
} | ||
|
||
bool OperationRestoreSecurity::ProcessSdAction(std::wstring & sFileName, ObjectEntry & tObjectEntry, PSECURITY_DESCRIPTOR & tDescriptor, bool & bDescReplacement) | ||
{ | ||
std::map<std::wstring, PSECURITY_DESCRIPTOR>::iterator oSecInfo = oImportMap.find(sFileName); | ||
if (oSecInfo != oImportMap.end()) | ||
{ | ||
// lookup the string in the map | ||
if (bDescReplacement) LocalFree(tDescriptor); | ||
tDescriptor = oSecInfo->second; | ||
bDescReplacement = true; | ||
} | ||
else | ||
{ | ||
// update the sid in the ace | ||
InputOutput::AddError(L"Import File Did Not Contain Descriptor"); | ||
} | ||
|
||
// cleanup | ||
return true; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "Operation.h" | ||
|
||
class OperationRestoreSecurity : public Operation | ||
{ | ||
private: | ||
|
||
// statics used by command registration utility | ||
static std::wstring GetCommand() { return L"RestoreSecurity"; } | ||
static ClassFactory<OperationRestoreSecurity> * RegisteredFactory; | ||
|
||
std::map<std::wstring, PSECURITY_DESCRIPTOR> oImportMap; | ||
std::wstring sFile = L""; | ||
|
||
public: | ||
|
||
// overrides | ||
bool ProcessSdAction(std::wstring & sFileName, ObjectEntry & tObjectEntry, PSECURITY_DESCRIPTOR & tDescriptor, bool & bDescReplacement) override; | ||
|
||
// constructors | ||
OperationRestoreSecurity(std::queue<std::wstring> & oArgList); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "Operation.h" | ||
|
||
class OperationSaveSecurity : public Operation | ||
{ | ||
private: | ||
|
||
// statics used by command registration utility | ||
static std::wstring GetCommand() { return L"SaveSecurity"; } | ||
static ClassFactory<OperationSaveSecurity> * RegisteredFactory; | ||
|
||
HANDLE hFile = INVALID_HANDLE_VALUE; | ||
std::wstring sFile = L""; | ||
|
||
public: | ||
|
||
// overrides | ||
bool ProcessSdAction(std::wstring & sFileName, ObjectEntry & tObjectEntry, PSECURITY_DESCRIPTOR & tDescriptor, bool & bDescReplacement) override; | ||
|
||
// constructors | ||
OperationSaveSecurity(std::queue<std::wstring> & oArgList); | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
#pragma once | ||
|
||
#define VERSION_STRING "1.7.0.3" | ||
#define VERSION_STRING "1.8.0.0" |
Oops, something went wrong.