From c9496336fe740d254111c75700fe9ecad52752f6 Mon Sep 17 00:00:00 2001 From: Bryan Berns Date: Sat, 28 Jan 2017 14:18:03 -0500 Subject: [PATCH] Address Newline Parsing Issue In /RestoreSecurity Adjusted Parsing Error Message --- OperationDomainPaths.cpp | 2 +- OperationRestoreSecurity.cpp | 9 ++++++--- OperationSaveSecurity.cpp | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/OperationDomainPaths.cpp b/OperationDomainPaths.cpp index f4ea15c..d9834fd 100644 --- a/OperationDomainPaths.cpp +++ b/OperationDomainPaths.cpp @@ -67,7 +67,7 @@ OperationDomainPaths::OperationDomainPaths(std::queue & 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" }; diff --git a/OperationRestoreSecurity.cpp b/OperationRestoreSecurity.cpp index 1aef8fb..a9a1ca9 100644 --- a/OperationRestoreSecurity.cpp +++ b/OperationRestoreSecurity.cpp @@ -27,14 +27,17 @@ OperationRestoreSecurity::OperationRestoreSecurity(std::queue & oA while (std::getline(fFile, sLine)) { // parse the file name and descriptor which are separated by a '|' character - std::vector 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 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); } diff --git a/OperationSaveSecurity.cpp b/OperationSaveSecurity.cpp index 7382a22..c26711d 100644 --- a/OperationSaveSecurity.cpp +++ b/OperationSaveSecurity.cpp @@ -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);