Inno Setup - suppress “Setup command line:” log en

2019-01-28 13:50发布

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.

标签: inno-setup
2条回答
不美不萌又怎样
2楼-- · 2019-01-28 13:57

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.

查看更多
仙女界的扛把子
3楼-- · 2019-01-28 14:19

As an alternative, you could ask the user to provide an INI file via the command line instead:

config.ini

[credentials]
username=foo
password=bar

command line invocation

setup.exe /CONFIGFILE=config.ini

PascalScript

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;
查看更多
登录 后发表回答