Skip to content

openssh: Add helper scripts to fix service binPath and autostart#7666

Open
SwingURM wants to merge 3 commits intoScoopInstaller:masterfrom
SwingURM:openssh-fix-service-binpath
Open

openssh: Add helper scripts to fix service binPath and autostart#7666
SwingURM wants to merge 3 commits intoScoopInstaller:masterfrom
SwingURM:openssh-fix-service-binpath

Conversation

@SwingURM
Copy link

@SwingURM SwingURM commented Feb 21, 2026

Closes #7665

  • Use conventional PR title: <manifest-name[@version]|chore>: <general summary of the pull request>
  • I have read the Contributing Guide

Add post_install scripts that are generated on install:

  • fix.ps1 — Rewrites sshd and ssh-agent service binPath to the real absolute path.
  • autostart-sshd.ps1 — Sets both sshd and ssh-agent services to Automatic startup type.

Summary by CodeRabbit

  • New Features

    • Added automated post-install setup for SSH services to resolve installation paths, apply post-install fixes, and enable automatic startup.
  • Chores

    • Updated installation notes to keep uninstall instructions and add steps for running the post-install fix and enabling SSH autostart.

@github-actions
Copy link
Contributor

All changes look good.

Wait for review from human collaborators.

openssh

  • Lint
  • Description
  • License
  • Hashes
  • Checkver
  • Autoupdate

Check the full log for details.

@SwingURM
Copy link
Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 88940d9 and 25be462.

📒 Files selected for processing (1)
  • bucket/openssh.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • bucket/openssh.json

📝 Walkthrough

Walkthrough

Adds a post-install step to the OpenSSH manifest that resolves the real installation path (following the current symlink), writes fix.ps1 to rewrite sshd/ssh-agent service binPath to absolute targets, and writes autostart-sshd.ps1 to set those services to Automatic startup.

Changes

Cohort / File(s) Summary
OpenSSH Manifest
bucket/openssh.json
Added post_install array with PowerShell commands to: resolve the real directory behind the current symlink, create fix.ps1 (rewrites sshd/ssh-agent service binPath to absolute paths), and create autostart-sshd.ps1 (sets services StartupType = Automatic). Notes updated to mention uninstall, fix, and autostart instructions.

Sequence Diagram(s)

sequenceDiagram
  participant Installer as Installer (Scoop)
  participant PostInstall as post_install script
  participant FS as Filesystem (symlink resolution)
  participant FixPS as fix.ps1
  participant SCM as Service Control Manager (registry)
  participant AutostartPS as autostart-sshd.ps1

  Installer->>PostInstall: execute post_install commands
  PostInstall->>FS: resolve real directory for `current` symlink
  PostInstall->>FixPS: write fix.ps1 with absolute binPath targets
  FixPS->>SCM: update `sshd` and `ssh-agent` service `ImagePath`/binPath
  PostInstall->>AutostartPS: write autostart-sshd.ps1
  AutostartPS->>SCM: set `sshd` and `ssh-agent` StartupType = Automatic
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: adding helper scripts to fix service binPath and autostart for openssh.
Description check ✅ Passed The PR description includes the issue reference (#7665), explains the purpose of the changes, and indicates both required checklist items are completed.
Linked Issues check ✅ Passed The PR addresses the requirements from issue #7665 by implementing post_install scripts that rewrite service binPath to absolute paths and provide autostart functionality.
Out of Scope Changes check ✅ Passed All changes to openssh.json are directly related to resolving the symlink/junction path issue in issue #7665; no unrelated modifications are present.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
bucket/openssh.json (1)

47-47: Note the re-run requirement after scoop update in the notes.

fix.ps1 embeds the resolved absolute versioned path at install time (e.g., ...\openssh\10.0.0.0p2\sshd.exe). Scoop runs post_install on updates as well, expanding $dir to the current junction path, so each update regenerates fix.ps1 with the new version's path — but the service registry entry is not automatically updated. Users must re-run sudo fix.ps1 after every scoop update openssh for the service to point to the new binary.

Consider expanding the note to reflect this:

📝 Proposed note update
-        "Run 'sudo $dir\\fix.ps1' to fix service binPath to absolute path.",
+        "Run 'sudo $dir\\fix.ps1' to fix service binPath to absolute path. Re-run after every 'scoop update openssh'.",

Also applies to: 54-54

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bucket/openssh.json` at line 47, The post_install script writes fix.ps1
embedding the resolved versioned path (via Set-Content writing to
"$dir\\fix.ps1"), but Scoop re-runs post_install on updates using the current
junction path and does not update existing Windows service registry entries, so
users must re-run sudo fix.ps1 after every scoop update openssh to repoint
services to the new binary; update the notes referenced (and the duplicate at
the second occurrence) to explicitly state that after running scoop update
openssh the user must re-run sudo fix.ps1 (or re-create the sshd/ssh-agent
service entries) to update the service binPath to the new version.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bucket/openssh.json`:
- Line 45: The post_install line using [IO.Directory]::ResolveLinkTarget($dir,
$true).FullName is a .NET 6+ API and will throw on Windows PowerShell 5.1;
replace that call with the PowerShell 5.0+ compatible approach using (Get-Item
$dir -Force).Target and keep the existing fallback logic (i.e., assign the
target to $real and if it's null/empty set $real = $dir) so junction targets are
resolved when present but the script continues when not a link; update the
expression that sets $real to use the (Get-Item ...).Target lookup and preserve
the subsequent if (!$real) { $real = $dir } behavior.

---

Nitpick comments:
In `@bucket/openssh.json`:
- Line 47: The post_install script writes fix.ps1 embedding the resolved
versioned path (via Set-Content writing to "$dir\\fix.ps1"), but Scoop re-runs
post_install on updates using the current junction path and does not update
existing Windows service registry entries, so users must re-run sudo fix.ps1
after every scoop update openssh to repoint services to the new binary; update
the notes referenced (and the duplicate at the second occurrence) to explicitly
state that after running scoop update openssh the user must re-run sudo fix.ps1
(or re-create the sshd/ssh-agent service entries) to update the service binPath
to the new version.

@SwingURM
Copy link
Author

@coderabbitai review

@coderabbitai
Copy link

coderabbitai bot commented Feb 21, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
bucket/openssh.json (1)

44-45: (Get-Item $dir -Force).Target addresses the previous PS 5.1 compatibility concern.

The .ResolveLinkTarget issue from the prior review is resolved. Two small notes:

  • .Target resolves only one level of indirection, unlike the earlier ResolveLinkTarget($dir, $true) (recursive). For Scoop's single-layer current junction this is sufficient.
  • Get-Item $dir treats the path as a glob pattern, so a Scoop root containing [, ], or * characters would silently fail to match. -LiteralPath avoids this:
🔧 Optional: use -LiteralPath
-        "$real = (Get-Item $dir -Force).Target; if (!$real) { $real = $dir }",
+        "$real = (Get-Item -LiteralPath $dir -Force).Target; if (!$real) { $real = $dir }",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@bucket/openssh.json` around lines 44 - 45, The current post_install snippet
uses (Get-Item $dir -Force).Target which works but treats $dir as a glob; update
the Get-Item call to use -LiteralPath to avoid accidental glob expansion (i.e.,
replace Get-Item $dir -Force with Get-Item -LiteralPath $dir -Force) while
keeping the existing $real fallback logic (post_install, $real, and the !$real
check) intact; note that .Target is single-level resolution which is acceptable
for Scoop's single-layer junction usage.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@bucket/openssh.json`:
- Around line 46-47: The generated fix.ps1 currently uses a $q helper and writes
sc.exe config lines that lose their surrounding double-quotes when PowerShell
evaluates them; remove the "$q = [char]34" helper and change the two sc.exe
strings written by Set-Content (the sc.exe config sshd binPath= ... and sc.exe
config ssh-agent binPath= ... entries) to use a parenthesised single-quoted
expression that includes literal double-quote characters around the real path
(e.g. use ('"'+ <real path> + '"' ) style so the resulting ImagePath in the
registry includes the quote characters and preserves paths with spaces).

---

Nitpick comments:
In `@bucket/openssh.json`:
- Around line 44-45: The current post_install snippet uses (Get-Item $dir
-Force).Target which works but treats $dir as a glob; update the Get-Item call
to use -LiteralPath to avoid accidental glob expansion (i.e., replace Get-Item
$dir -Force with Get-Item -LiteralPath $dir -Force) while keeping the existing
$real fallback logic (post_install, $real, and the !$real check) intact; note
that .Target is single-level resolution which is acceptable for Scoop's
single-layer junction usage.

@coderabbitai
Copy link

coderabbitai bot commented Feb 25, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: symlink in OpenSSH service binPath causes issues

1 participant