MCPcopy
hub / github.com/hardentools/hardentools / markStatus

Function markStatus

utils.go:139–165  ·  view source on GitHub ↗

markStatus sets hardentools status registry key (that tells if user environment is hardened / not hardened).

(hardened bool)

Source from the content-addressed store, hash-verified

137// markStatus sets hardentools status registry key
138// (that tells if user environment is hardened / not hardened).
139func markStatus(hardened bool) {
140
141 if hardened {
142 key, _, err := registry.CreateKey(registry.CURRENT_USER,
143 hardentoolsKeyPath, registry.ALL_ACCESS)
144 if err != nil {
145 Info.Println(err.Error())
146 panic(err)
147 }
148 defer key.Close()
149
150 // Set value that states that we have hardened the system.
151 err = key.SetDWordValue("Harden", 1)
152 if err != nil {
153 Info.Println(err.Error())
154 showErrorDialog("Could not set hardentools registry keys - restore will not work!")
155 panic(err)
156 }
157 } else {
158 // On restore delete all hardentools registry keys afterwards.
159 err := registry.DeleteKey(registry.CURRENT_USER, hardentoolsKeyPath)
160 if err != nil {
161 Info.Println(err.Error())
162 ShowFailure("Remove hardentools registry keys", "Could not remove")
163 }
164 }
165}
166
167// triggerAll is used for harden and restore, depending on the harden parameter.
168// harden == true => harden

Callers 4

cmdHardenRestoreFunction · 0.85
hardenAllFunction · 0.85
restoreAllFunction · 0.85
hardenDefaultsAgainFunction · 0.85

Calls 2

showErrorDialogFunction · 0.70
ShowFailureFunction · 0.70

Tested by

no test coverage detected