-
Notifications
You must be signed in to change notification settings - Fork 56
Add sshdconfig set for "regular" keywords & clobber = true #1275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements the set command functionality for the sshdconfig resource, focusing on support for clobber: true mode with regular (non-repeatable, non-multi-arg) SSH configuration keywords. The implementation includes comprehensive validation using sshd -T, automatic backup of existing non-DSC-managed configurations, and integration of the -s (setting) parameter to distinguish between sshd_config and windows-global settings.
Key Changes
- Added
set_sshd_configfunction that creates temporary config files, validates them withsshd -T, backs up existing configs if not DSC-managed, and writes the new configuration - Refactored filepath handling from
StringtoPathBufthroughout the codebase for better type safety - Added comprehensive Pester tests covering valid configurations, backup creation, DSC-managed file detection, and error handling scenarios
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| resources/sshdconfig/tests/sshdconfig.set.tests.ps1 | New comprehensive test suite for sshd_config set operations, testing valid configs, backup behavior, and error cases |
| resources/sshdconfig/tests/defaultshell.tests.ps1 | Updated all set command calls to include -s windows-global flag; corrected test name for empty string handling |
| resources/sshdconfig/sshd-windows.dsc.resource.json | Added -s windows-global arguments to set command configuration |
| resources/sshdconfig/src/util.rs | Added get_default_sshd_config_path helper, refactored to use PathBuf, added get_bool_or_default helper for cleaner boolean extraction |
| resources/sshdconfig/src/set.rs | Implemented set_sshd_config function with temp file validation, backup logic, and DSC header detection; updated set_default_shell signature |
| resources/sshdconfig/src/metadata.rs | Added constants for DSC header and default config paths for both Unix and Windows |
| resources/sshdconfig/src/main.rs | Updated set command to pass setting parameter to invoke_set |
| resources/sshdconfig/src/inputs.rs | Added clobber field to CommandInfo; changed filepath types from String to PathBuf |
| resources/sshdconfig/src/args.rs | Added required setting parameter to Set command with hidden flag |
| resources/sshdconfig/locales/en-us.toml | Added new localization strings for set operations, debug messages, and error handling |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
PR Summary
clobber: trueand regular keyword (no objects/arrays yet)setcommand: create temp file based on input, validate temp file usingsshd -T, back-up any existing sshd_config file (only if it is not already managed by this resource), then update/create sshd_config file