Skip to content

Commit

Permalink
Fix obuscating ServiceConfig command line in log
Browse files Browse the repository at this point in the history
  • Loading branch information
nirbar committed May 27, 2024
1 parent 107994a commit a83ca2e
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 15 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/github-actions-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ on:
psw_wix_version:
description: 'PanelSwWix4 version'
required: true
default: 6.0.0-psw-wix.0268-12
default: 6.0.0-psw-wix.0276-14
type: string

jobs:
Expand All @@ -37,7 +37,7 @@ jobs:
Add-Content -Path ${{ github.env }} -Value "PSW_WIX_VERSION=${{ env.DEFAULT_PSW_WIX_VERSION }}"
}
env:
DEFAULT_PSW_WIX_VERSION: '6.0.0-psw-wix.0268-12'
DEFAULT_PSW_WIX_VERSION: '6.0.0-psw-wix.0276-14'

- name: Prepare for build
run: |
Expand Down
2 changes: 1 addition & 1 deletion src/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
<Wix4Version Condition=" '$(Wix4Version)' == '' ">5.0.0</Wix4Version>
<PanelSwWix4Version Condition=" '$(PanelSwWix4Version)' == '' ">6.0.0-psw-wix.0268-12</PanelSwWix4Version>
<PanelSwWix4Version Condition=" '$(PanelSwWix4Version)' == '' ">6.0.0-psw-wix.0276-14</PanelSwWix4Version>
<SevenZapVersion Condition=" '$(SevenZapVersion)' == '' ">23.1.33</SevenZapVersion>
</PropertyGroup>
<ItemGroup>
Expand Down
17 changes: 9 additions & 8 deletions src/PanelSwCustomActions/ServiceConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ extern "C" UINT __stdcall ServiceConfig(MSIHANDLE hInstall)
if (compAction != WCA_TODO::WCA_TODO_INSTALL)
{
// In case of no-action, we just check if the service is marked for deletion to notify reboot is reqired.
oDeferred.AddServiceConfig(szServiceName, nullptr, nullptr, nullptr, ServciceConfigDetails::ServiceStart::ServciceConfigDetails_ServiceStart_unchanged, nullptr, lstDependencies, ErrorHandling::ignore, ServciceConfigDetails_DelayStart::ServciceConfigDetails_DelayStart_unchanged1, SERVICE_NO_CHANGE);
oDeferred.AddServiceConfig(szServiceName, nullptr, nullptr, nullptr, nullptr, ServciceConfigDetails::ServiceStart::ServciceConfigDetails_ServiceStart_unchanged, nullptr, lstDependencies, ErrorHandling::ignore, ServciceConfigDetails_DelayStart::ServciceConfigDetails_DelayStart_unchanged1, SERVICE_NO_CHANGE);

WcaLog(LOGLEVEL::LOGMSG_STANDARD, "Skipping configuration of service '%ls' since component is not installed", (LPCWSTR)szServiceName);
continue;
Expand Down Expand Up @@ -243,14 +243,14 @@ extern "C" UINT __stdcall ServiceConfig(MSIHANDLE hInstall)
}
}

hr = oRollback.AddServiceConfig((LPCWSTR)szServiceName, pServiceCfg->lpBinaryPathName, pServiceCfg->lpServiceStartName, nullptr, pServiceCfg->dwStartType, pServiceCfg->lpLoadOrderGroup, lstRlbkDependencies, ErrorHandling::ignore, rlbkDelayStart, pServiceCfg->dwServiceType);
hr = oRollback.AddServiceConfig((LPCWSTR)szServiceName, pServiceCfg->lpBinaryPathName, pServiceCfg->lpBinaryPathName, pServiceCfg->lpServiceStartName, nullptr, pServiceCfg->dwStartType, pServiceCfg->lpLoadOrderGroup, lstRlbkDependencies, ErrorHandling::ignore, rlbkDelayStart, pServiceCfg->dwServiceType);
ExitOnFailure(hr, "Failed creating rollback CustomActionData");

ReleaseNullMem(pServiceCfg);
ReleaseServiceHandle(hService);
}

hr = oDeferred.AddServiceConfig(szServiceName, szCommand, szAccount, szPassword, start, szLoadOrderGroup, lstDependencies, (ErrorHandling)errorHandling, (ServciceConfigDetails_DelayStart)nDelayStart, dwServiceType);
hr = oDeferred.AddServiceConfig(szServiceName, (LPCWSTR)szCommand, szCommand.Obfuscated(), szAccount, szPassword, start, szLoadOrderGroup, lstDependencies, (ErrorHandling)errorHandling, (ServciceConfigDetails_DelayStart)nDelayStart, dwServiceType);
ExitOnFailure(hr, "Failed creating CustomActionData");
}

Expand Down Expand Up @@ -281,7 +281,7 @@ CServiceConfig::CServiceConfig()
, _errorPrompter(PSW_MSI_MESSAGES::PSW_MSI_MESSAGES_SERVICE_CONFIG_ERROR)
{ }

HRESULT CServiceConfig::AddServiceConfig(LPCWSTR szServiceName, LPCWSTR szCommandLine, LPCWSTR szAccount, LPCWSTR szPassword, int start, LPCWSTR szLoadOrderGroup, const std::list<LPWSTR> &lstDependencies, ErrorHandling errorHandling, ServciceConfigDetails_DelayStart delayStart, DWORD dwServiceType)
HRESULT CServiceConfig::AddServiceConfig(LPCWSTR szServiceName, LPCWSTR szCommandLine, LPCWSTR szObfuscatedCommandLine, LPCWSTR szAccount, LPCWSTR szPassword, int start, LPCWSTR szLoadOrderGroup, const std::list<LPWSTR>& lstDependencies, ErrorHandling errorHandling, ServciceConfigDetails_DelayStart delayStart, DWORD dwServiceType)
{
HRESULT hr = S_OK;
::com::panelsw::ca::Command* pCmd = nullptr;
Expand All @@ -306,7 +306,8 @@ HRESULT CServiceConfig::AddServiceConfig(LPCWSTR szServiceName, LPCWSTR szComman
}
if (szCommandLine && *szCommandLine)
{
pDetails->set_commandline(szCommandLine, WSTR_BYTE_SIZE(szCommandLine));
pDetails->mutable_commandline()->set_plain(szCommandLine, WSTR_BYTE_SIZE((LPCWSTR)szCommandLine));
pDetails->mutable_commandline()->set_obfuscated(szObfuscatedCommandLine, WSTR_BYTE_SIZE(szObfuscatedCommandLine));
}
if (szLoadOrderGroup) // May be empty
{
Expand Down Expand Up @@ -357,10 +358,10 @@ HRESULT CServiceConfig::DeferredExecute(const ::std::string& command)
szPassword = (LPCWSTR)(LPVOID)details.password().data();
}
}
if (details.commandline().size() > sizeof(WCHAR))
if (details.commandline().plain().size() > sizeof(WCHAR))
{
szCommandLine = (LPCWSTR)(LPVOID)details.commandline().data();
WcaLog(LOGLEVEL::LOGMSG_STANDARD, "Service '%ls' command line '%ls'", szServiceName, szCommandLine);
szCommandLine = (LPCWSTR)(LPVOID)details.commandline().plain().data();
WcaLog(LOGLEVEL::LOGMSG_STANDARD, "Service '%ls' command line '%ls'", szServiceName, (LPCWSTR)(LPVOID)details.commandline().obfuscated().data());
}
if (details.loadordergroup().size() > 0) // May be empty
{
Expand Down
2 changes: 1 addition & 1 deletion src/PanelSwCustomActions/ServiceConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class CServiceConfig :

CServiceConfig();

HRESULT AddServiceConfig(LPCWSTR szServiceName, LPCWSTR szCommandLine, LPCWSTR szAccount, LPCWSTR szPassword, int start, LPCWSTR szLoadOrderGroup, const std::list<LPWSTR> &lstDependencies, ::com::panelsw::ca::ErrorHandling errorHandling, ::com::panelsw::ca::ServciceConfigDetails_DelayStart delayStart, DWORD dwServiceType);
HRESULT AddServiceConfig(LPCWSTR szServiceName, LPCWSTR szCommandLine, LPCWSTR szObfuscatedCommandLine, LPCWSTR szAccount, LPCWSTR szPassword, int start, LPCWSTR szLoadOrderGroup, const std::list<LPWSTR> &lstDependencies, ::com::panelsw::ca::ErrorHandling errorHandling, ::com::panelsw::ca::ServciceConfigDetails_DelayStart delayStart, DWORD dwServiceType);

protected:

Expand Down
3 changes: 2 additions & 1 deletion src/ProtoCaLib/servciceConfigDetails.proto
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ syntax = "proto3";
package com.panelsw.ca;
option optimize_for = LITE_RUNTIME;
import "ErrorHandling.proto";
import "obfuscatedString.proto";

message ServciceConfigDetails{

Expand All @@ -22,7 +23,7 @@ message ServciceConfigDetails{
}

bytes name = 1;
bytes commandLine = 2;
ObfuscatedString commandLine = 2;
bytes account = 3;
bytes password = 4;
ServiceStart start = 5;
Expand Down
2 changes: 1 addition & 1 deletion src/TidyBuild.custom.props
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Project ToolsVersion="16.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildThisFileDirectory)TidyBuild.user.props" Condition="Exists('$(MSBuildThisFileDirectory)TidyBuild.user.props')"/>
<PropertyGroup>
<FullVersion>5.0.2</FullVersion>
<FullVersion>5.0.3</FullVersion>
<FullVersion Condition=" '$(GITHUB_RUN_NUMBER)'!='' ">$(FullVersion).$(GITHUB_RUN_NUMBER)</FullVersion>
<ProductName>PanelSwWixExtension</ProductName>
<Manufacturer>Panel::Software</Manufacturer>
Expand Down
2 changes: 1 addition & 1 deletion src/global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"msbuild-sdks": {
"WixToolset.Sdk": "5.0.0",
"PanelSwWix4.Sdk": "6.0.0-psw-wix.0268-12",
"PanelSwWix4.Sdk": "6.0.0-psw-wix.0276-14",
"Microsoft.Build.Traversal": "4.0.0"
}
}

0 comments on commit a83ca2e

Please sign in to comment.