Skip to content
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

Add REG output option to rdctl settings #4562

Closed
Tracked by #1935 ...
jandubois opened this issue Apr 27, 2023 · 8 comments · Fixed by #5006
Closed
Tracked by #1935 ...

Add REG output option to rdctl settings #4562

jandubois opened this issue Apr 27, 2023 · 8 comments · Fixed by #5006
Assignees
Labels
area/deployment Deployment profiles component/rdctl kind/story Work item that is linked from a kind/epic
Milestone

Comments

@jandubois
Copy link
Member

jandubois commented Apr 27, 2023

We need to be able to create deployment profiles from the current settings, and creating *.reg files is one way to do this.

There are 4 different files we should be able to create:

  • either HKLM or HKCU
  • either defaults or locked profiles

Not sure yet what the best way to specify the options are; starting point:

--output=reg,hklm,defaults
--output=reg,hklm,locked
--output=reg,hkcu,defaults
--output=reg,hkcu,locked

Defaults should be hklm and defaults, so

  • --output=reg would mean --output=reg,hklm,defaults
  • --output=reg,locked would mean --output=reg,hklm,locked
  • --output=reg,hkcu means --output=reg,hkcu,defaults

Suggestion for a better option format welcome!

@ericpromislow
Copy link
Contributor

The above options look fine

Request to support all the options from set to modify current settings.
Also possibly add support for --body { ... JSON } or --input-file PATH-TO-JSON for more settings.

@ericpromislow
Copy link
Contributor

Also a --output PATH option, otherwise output goes to stdout. Meaning all other output has to go to stderr

@ericpromislow
Copy link
Contributor

ericpromislow commented May 8, 2023

Note that to be useful the reg file output should be encoded as UCS-2 with a BOM of `\uFEFF`

I'm wondering if an encoding=X flag that defaults to UCS-2 (UCS2 accepted as an alias), but
an option of UTF-8 or UTF8 might help testing.

@mook-as
Copy link
Contributor

mook-as commented May 9, 2023

I believe reg.exe can import registry files encoded as ASCII fine (without BOM). For something like non-ASCII, it's probably best to do "foo"=hex(1):3d,d8,25,dd (where 1 is REG_SZ, and the encoded bytes is little-endian UTF-16 for fire).

@jandubois
Copy link
Member Author

import registry files encoded as ASCII fine (without BOM)

I think technically it assumes ANSI (Windows-1252) character set when there is no BOM, but probably best to only rely on 7-bit ASCII. Using UTF8 with a BOM does not work.

We already need to do the =hex(x)... encoding for REG_SZ_MULTI strings to get the embedded NUL characters.

@ericpromislow
Copy link
Contributor

My mistake... in the tests in PR 4251 the reg files are encoded as 'latin1', and it seems like no BOM is necessary (although I had problems earlier getting reg to import the file when there was no BOM, but that probably wasn't the problem.

Thanks for pointing out what the hex(N) notation means.

@mook-as
Copy link
Contributor

mook-as commented Jun 23, 2023

Review comment from #5006 that Eric thinks should be discussed here (and that makes sense):

Currently, the command is specified to take --output=reg,hklm,defaults etc. This ends up complicating the help text a bunch, because it's difficult to explain the multiple sub-flags inside a single flag comment (which is a plain, single-line, string).

I believe this would be a lot easier to understand for the user, and a lot easier to implement, if we made it into multiple flags: --output=reg --reg-hive=hklm --section=defaults. That way we get a help comment per flag, and when we parse it we don't need the custom code (unless we only allow valid values in enums, in which case there would be some code for that).

/cc @jandubois

@jandubois
Copy link
Member Author

I believe this would be a lot easier to understand for the user, and a lot easier to implement, if we made it into multiple flags: --output=reg --reg-hive=hklm --section=defaults. That way we get a help comment per flag, and when we parse it we don't need the custom code

I agree, let's do that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/deployment Deployment profiles component/rdctl kind/story Work item that is linked from a kind/epic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants