Reputation: 423
We are using Inno Setup(version 5.4.2) as the packaging tool to generate our installer. We are passing some password values as command line arguments. In Inno Setup all command line arguments are logging into installation log automatically with "Setup command line:" entry. Is any way to suppress the "Setup Command Line" logging into log.
Upvotes: 2
Views: 927
Reputation: 3046
As an alternative, you could ask the user to provide an INI file via the command line instead:
[credentials]
username=foo
password=bar
setup.exe /CONFIGFILE=config.ini
Note that some of this is untested, please use it at your own risk.
function CommandLineSwitchIsPresent(Param : String): Boolean;
var
i: Integer;
begin
Result := False;
if not StartsWith('/', Param) then
begin
Param := '/' + Param;
end;
for i:= 0 to ParamCount do
begin
if (CompareText(Param, ParamStr(i)) = 0)
or StartsWith(Param + '=', ParamStr(i)) then
begin
Result := True;
break;
end;
end;
end;
function GetCommandlineParam(Param: String; var OutStr: String): Boolean;
var
ParamNameAndValue: String;
i: Integer;
j: Integer;
begin
Result := False;
Param := Param + '=';
if not StartsWith('/', Param) then
begin
Param := '/' + Param;
end;
for i := 0 to ParamCount do
begin
ParamNameAndValue := ParamStr(i);
if StartsWith(AnsiUppercase(Param), AnsiUppercase(ParamNameAndValue)) then
begin
for j := 0 to Length(ParamNameAndValue) do
begin
if j > Length(Param) then
begin
OutStr := OutStr + ParamNameAndValue[j];
end;
end;
Result := True;
break;
end;
end;
end;
function GetConfig(Section: String; Key: String; ConfigFile: String): String;
begin
if IniKeyExists('credentials', Key, ConfigFile) then
begin
Result := GetIniString('credentials', Key, '', ConfigFile);
end
else begin
RaiseException(
Format(
'%s key not found in [%s] section in %s', [Key, Section, ConfigFile]
);
end;
end;
var
_gConfigFile: String;
procedure DoStuffWithPassword();
var
Username: String;
Password: String;
ShortPath: String;
ExpandedPath: String;
begin
if not GetCommandlineParam('CONFIGFILE', ShortPath) then
begin
RaiseException('CONFIGFILE parameter is required!');
end;
// Go from relative path to absolute
ExpandedPath := ExpandFileName(ShortPath);
if FileExists(ExpandedPath) then
begin
_gConfigFile := ExpandedPath;
end
else begin
RaiseException('CONFIGFILE file ' + ShortPath + ' not found!');
end;
Username := GetConfig('credentials', 'username', _gConfigFile);
Password := GetConfig('credentials', 'password', _gConfigFile);
end;
Upvotes: 1
Reputation: 76713
No. You can disable only the overall logging. Here's the excerpt from the relevant part of the source code
:
...
Log('Setup version: ' + SetupTitle + ' version ' + SetupVersion);
Log('Original Setup EXE: ' + SetupLdrOriginalFilename);
Log('Setup command line: ' + GetCmdTail);
LogWindowsVersion;
...
As you can see there is no condition before the Log
procedure call for the command line tail as well as the Log
procedure itself does not contain a way to filter out certain log messages. So, at this time the only way to prevent this potential security issue is disabling the overall logging .
Since this might be a security issue, I would suggest you to file a feature request report.
Upvotes: 2