Skip to content

Commit

Permalink
v1.26.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill-Stewart committed Nov 6, 2023
1 parent 373f5d9 commit bd3eb36
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 39 deletions.
30 changes: 15 additions & 15 deletions Install-SyncthingService.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -708,21 +708,6 @@ function InstallService {
New-Item $SyncthingConfigPath -ItemType Directory -ErrorAction SilentlyContinue | Out-Null
if ( -not $? ) { return $ERROR_CANNOT_MAKE }
}
# Reset permissions for config directory
$argList = @(
'"{0}"' -f $SyncthingConfigPath
'/reset'
'/t'
)
Start-Program $ICACLS $argList | Out-Null
$argList = @(
'"{0}"' -f $SyncthingConfigPath
'/inheritance:r'
'/grant "*S-1-5-18:(OI)(CI)F"'
'/grant "*S-1-5-32-544:(OI)(CI)F"'
'/grant "{0}:(OI)(CI)M"' -f $serviceAccountUserName
)
Start-Program $ICACLS $argList | Out-Null
# Reset "i" attribute for config directory (paradoxically, "+i" means
# "not content indexed")
$argList = @(
Expand All @@ -746,6 +731,21 @@ function InstallService {
if ( $result -ne 0 ) { return $result }
$result = Grant-UserRight $serviceAccountUserName SeServiceLogonRight
if ( $result -ne 0 ) { return $result }
# Reset permissions for config directory
$argList = @(
'"{0}"' -f $SyncthingConfigPath
'/reset'
'/t'
)
Start-Program $ICACLS $argList | Out-Null
$argList = @(
'"{0}"' -f $SyncthingConfigPath
'/inheritance:r'
'/grant "*S-1-5-18:(OI)(CI)F"'
'/grant "*S-1-5-32-544:(OI)(CI)F"'
'/grant "{0}:(OI)(CI)M"' -f $serviceAccountUserName
)
Start-Program $ICACLS $argList | Out-Null
# Install service if not installed
if ( -not (Test-Service $serviceName) ) {
$argList = @(
Expand Down
9 changes: 5 additions & 4 deletions Messages-en.isl
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ ShortcutNameStartSyncthingComment=Starts Syncthing as the current user.
ShortcutNameStopSyncthing=Stop Syncthing
ShortcutNameStopSyncthingComment=Stops Syncthing.
; [Tasks]
TasksStartAtBoot=&Start Syncthing service automatically when system boots
TasksStartAtLogon=&Start Syncthing automatically when logging on
TasksStartAtBoot=Start Syncthing service &automatically when system boots
TasksStartServiceAfterInstall=Start Syncthing service after &installation
TasksStartAtLogon=Start Syncthing &automatically when logging on
TasksStartAfterInstall=Start Syncthing after &installation
; [Run]
RunStatusMsg=Completing setup tasks...
RunPostInstallStartServiceDescription=&Start Syncthing service
RunPostInstallStartDescription=&Start Syncthing
RunPostInstallOpenConfigPage=&Open Syncthing configuration page
; Configuration pages
ConfigPage0Caption=Select Configuration Settings
ConfigPage0Description=How should Setup configure Syncthing?
Expand Down
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ Parameter | Description
`/listenport=`_port_ | **[*]** Specifies the TCP port number for the web GUI configuration page. The default port number is **8384**.
`/relaysenabled=`_value_ | **[*]** Specifies whether relays are enabled (_value_ must be either **true** or **false**). The default value is **true** (i.e., relays are enabled).
`/serviceaccountusername=`_username_ | For administrative installation mode, specifies the local service user account user name. The default user name is **SyncthingServiceAcct**.
`/nostart` | Prevents Syncthing from starting automatically after the installation completes. The default is to start Syncthing when installation completes.

Please note the following:

Expand Down Expand Up @@ -222,10 +221,12 @@ Once the local service user account has "Modify" permissions for the folder, you

The **Select Additional Tasks** wizard page in Setup specifies additional tasks that Setup should perform. Available tasks depend on whether Setup runs in administrative (all users) or non administrative (current user) installation mode.

Task Description | Name | Installation Mode
---------------- | ---- | -----------------
Start Syncthing service automatically when system boots | `startatboot` | All users
Start Syncthing automatically when logging on | `startatlogon` | Current user
Task Description | Name | Installation Mode
---------------- | ---- | -----------------
Start Syncthing service automatically when system boots | `startatboot` | All users
Start Syncthing service after installation | `startserviceafterinstall` | All users
Start Syncthing automatically when logging on | `startatlogon` | Current user
Start Syncthing after installation | `startafterinstall` | Current user

The `/tasks` and `/mergetasks` command line parameters (see [Setup Command Line Parameters](#setup-command-line-parameters)) specify which tasks are selected (by default, all tasks are selected).

Expand Down
56 changes: 41 additions & 15 deletions Syncthing.iss
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,16 @@ Filename: "{app}\{#ConfigurationPageName}.url"; \
Name: startatboot; \
Description: "{cm:TasksStartAtBoot}"; \
Check: IsAdminInstallMode()
Name: startserviceafterinstall; \
Description: "{cm:TasksStartServiceAfterInstall}"; \
Check: IsAdminInstallMode()
; Non-admin
Name: startatlogon; \
Description: "{cm:TasksStartAtLogon}"; \
Check: (not IsAdminInstallMode()) and (not LogonTaskExists())
Name: startafterinstall; \
Description: "{cm:TasksStartAfterInstall}"; \
Check: not IsAdminInstallMode()

[Run]
; Admin: Add firewall rule silently
Expand All @@ -176,18 +182,18 @@ Filename: "{sys}\cscript.exe"; \
Flags: runhidden; \
StatusMsg: "{cm:RunStatusMsg}"; \
Tasks: startatlogon
; Admin post-install
Filename: "{sys}\net.exe"; \
Parameters: "START ""{#ServiceName}"""; \
Description: "{cm:RunPostInstallStartServiceDescription}"; \
Flags: runascurrentuser runhidden nowait postinstall; \
Check: IsAdmininstallMode() and GetStartAfterInstall() and ServiceExists() and (not ServiceRunning())
; Non-admin post-install
; 'startafterinstall' task
Filename: "{sys}\cscript.exe"; \
Parameters: """{app}\{#ScriptNameStartSyncthing}"" /silent"; \
Description: "{cm:RunPostInstallStartDescription}"; \
Flags: runhidden nowait postinstall; \
Check: (not IsAdminInstallMode()) and GetStartAfterInstall() and FirewallRuleExists()
Flags: runhidden; \
StatusMsg: "{cm:RunStatusMsg}"; \
Check: (not IsAdminInstallMode()) and FirewallRuleExists(); \
Tasks: startafterinstall
; postinstall
Filename: "{app}\{#ConfigurationPageName}.url"; \
Description: "{cm:RunPostInstallOpenConfigPage}"; \
Flags: shellexec postinstall skipifsilent; \
Check: IsSyncthingRunning()

[UninstallRun]
; Admin: remove firewall rule
Expand Down Expand Up @@ -371,6 +377,25 @@ begin
end;
end;
function IsSyncthingRunning(): Boolean;
var
AppDir, WQLQuery: string;
SWbemLocator, WMIService, SWbemObjectSet: Variant;
begin
result := false;
AppDir := AddBackslash(ExpandConstant('{app}'));
StringChangeEx(AppDir, '\', '\\', true);
WQLQuery := Format('SELECT Name FROM Win32_Process' +
' WHERE (ExecutablePath LIKE "%s%%") AND (Name = "syncthing.exe")', [AppDir]);
try
SWbemLocator := CreateOleObject('WbemScripting.SWbemLocator');
WMIService := SWbemLocator.ConnectServer('', 'root\CIMV2');
SWbemObjectSet := WMIService.ExecQuery(WQLQuery);
result := (not VarIsNull(SWbemObjectSet)) and (SWbemObjectSet.Count > 0);
except
end; //try
end;
// Returns the 'Arguments' portion of the specified shortcut (lnk) file
function GetLinkFileArguments(const FileName: string): string;
var
Expand Down Expand Up @@ -648,11 +673,6 @@ begin
result := '(current user)';
end;
function GetStartAfterInstall(): Boolean;
begin
result := not ParamStrExists('/nostart');
end;
function ExecEx(const FileName, Params: string; const Hide: Boolean): Integer;
var
ShowCmd: Integer;
Expand Down Expand Up @@ -707,6 +727,12 @@ begin
Params := Params + 'demand';
Params := Params + ' -ServiceShutdownTimeout {#ServiceShutdownTimeout}';
result := ExecEx(FileName, Params, true);
if WizardIsTaskSelected('startserviceafterinstall') then
begin
FileName := ExpandConstant('{sys}\net.exe');
Params := ExpandConstant('START "{#ServiceName}"');
result := ExecEx(FileName, Params, true);
end;
end;
function SetAppDirectoryPermissions(): Integer;
Expand Down
10 changes: 10 additions & 0 deletions history.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

Below are the release notes for Syncthing Windows Setup (herein after referred to as Setup).

## 1.26.0 (2023-11-06)

* Fixed: Configuration file path permission not set correctly for admin installs when service account doesn't yet exist.

* Changed:

* Removed Setup `/nostart` command line parameter. Use the `startserviceafterinstall` (admin install mode) or `startafterinstall` (non admin install mode) tasks instead.

* Updated post-install page to allow user to open the Syncthing configuration page.

## 1.25.0 (2023-10-03)

* Due to a number of security vendors automatically assuming NSSM is malware (even though it was being used legitimately), Setup now uses [shawl](https://github.com/mtkennerly/shawl) to run the Windows service. (The hope is that this will reduce the number of security software false positive malware notitifications when downloading and running Setup.)
Expand Down

0 comments on commit bd3eb36

Please sign in to comment.