-
Notifications
You must be signed in to change notification settings - Fork 23.9k
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
win_regedit: added function to load a dat file for editing #31289
Conversation
Fail-Json -obj $result -message "hive at path '$hive' is not valid or accessible, cannot load hive" | ||
} | ||
if (Test-Path -Path HKLM:\ANSIBLE) { | ||
Fail-Json -obj $result -message "hive already loaded at HKLM:\ANSIBLE, cannot load another hive until this is manually unloaded" |
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.
This to me is problematic. We can end up in a situation where the only way to get out of this is to do something outside of Ansible. Ideally it would only be loaded within its own context, and automatically unloaded.
I wonder if we could either make this path unique to the session, and have a clean-up function for older sessions.
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.
We could make the path unique but would need more complex handling around how someone would set the path. This isn’t too much of an issue as keys can’t be created at the root folder and this would only fire if a hive has been manually loaded before.
I’ll let others comment on this before changing though as I traded convenience for simpler code in this case.
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.
Hey @dagwieers, I've updated the code so that it will unload the hive if it has been set and output a warning if this happens.
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.
That's very useful, but doesn't mitigate the possibility of conflicts, so maybe a better implementation (in time) is warranted. Maybe adding a note in the code wrt. this.
Is the unloading of a hive guaranteed to work, or could it fail when in use ?
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.
We will want to make the decision before merging this in as it would affect what the user would put in their path
. In the current case the hive is accessed with HKLM:\ANSIBLE\*
while in your suggestion it would come under its own root. I'm not even sure if you can create a Registry PSDrive and map it to a subkey on an existing drive.
As with all things it can fail, the main reason would be if someone had loaded the hive manually before hand and still had a handle open to it. Even if we were to use unique names you cannot load a hive file again once it has been loaded once under a different name.
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.
Ouch, if it can only be loaded once... This is fine by me.
5e94183
to
52fff14
Compare
CI failure in integration tests: https://app.shippable.com/github/ansible/ansible/runs/40723/8/tests |
58146ba
to
ba737fa
Compare
SUMMARY
Feature for #20123. Allows a user to specify a registry hive to load so it can be manipulated with
win_regedit
. When specified the hive is always loaded at the fixed position ofHKLM:\ANSIBLE
.ISSUE TYPE
COMPONENT NAME
win_regedit
ANSIBLE VERSION