Skip to content

Commit

Permalink
Address Newline Parsing Issue In /RestoreSecurity
Browse files Browse the repository at this point in the history
Adjusted Parsing Error Message
  • Loading branch information
NoMoreFood committed Jan 28, 2017
1 parent 4e912f7 commit c949633
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion OperationDomainPaths.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ OperationDomainPaths::OperationDomainPaths(std::queue<std::wstring> & oArgList)

// create the search filter
WCHAR sSearchFilter[] = L"(&(objectCategory=computer)(|(operatingSystem=*server*)(operatingSystem=*ontap*)(operatingSystem=*netapp*))" \
"(!(userAccountControl:1.2.840.113556.1.4.803:=8192))(!(userAccountControl:1.2.840.113556.1.4.803:=2))(!(msDS-IsRodc=true)))";
"(!(userAccountControl:1.2.840.113556.1.4.803:=8192))(!(userAccountControl:1.2.840.113556.1.4.803:=2))(!(msDS-isRODC=true)))";

// execute the search.
LPWSTR sAttributes[] = { L"cn" };
Expand Down
9 changes: 6 additions & 3 deletions OperationRestoreSecurity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,17 @@ OperationRestoreSecurity::OperationRestoreSecurity(std::queue<std::wstring> & oA
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"\\|");
// also, sometimes a character return appears in the input stream so adding
// it here ensures it is stripped from the very end
std::vector<std::wstring> oLineItems = SplitArgs(sLine, L"=|\r");

// convert the long string descriptor its binary equivalent
PSECURITY_DESCRIPTOR tDesc;
if (ConvertStringSecurityDescriptorToSecurityDescriptor(oLineItems.at(1).c_str(),
if (oLineItems.size() != 2 ||
ConvertStringSecurityDescriptorToSecurityDescriptor(oLineItems.at(1).c_str(),
SDDL_REVISION_1, &tDesc, NULL) == 0)
{
InputOutput::AddError(L"ERROR: Unable to parse string security descriptor.");
wprintf(L"ERROR: Unable to parse string security descriptor file for restoration.");
exit(-1);
}

Expand Down
2 changes: 1 addition & 1 deletion OperationSaveSecurity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ bool OperationSaveSecurity::ProcessSdAction(std::wstring & sFileName, ObjectEntr

// write the string to a file
DWORD iBytes = 0;
std::wstring sToWrite = sFileName + L"|" + sInfo + L"\r\n";
std::wstring sToWrite = sFileName + L"=" + sInfo + L"\r\n";
if (WriteFile(hFile, sToWrite.c_str(), (DWORD)sToWrite.size() * sizeof(WCHAR), &iBytes, NULL) == 0)
{
LocalFree(sInfo);
Expand Down

0 comments on commit c949633

Please sign in to comment.