prior to this commit SBOMs would have inconsistency in their hashing on
the configuration file.
The representation of the config file in fact would differ at certain
stages of the gok commands lifecycle, where at packer running time,
an extra InternalCompatibilityFlag, Sudo, would be added in memory
(while that not being the case at `gok sbom` time),
resulting in a differing config and as such differing SBOM hashes, same
goes for the differing pointer addresses that were skew the hashing
results.
This is now fixed by using the SudoOrDefault() accessor,
as well as converting the config into a string before computing the hash,
to avoid differing pointer problems.
Without passing $HOME into the `sudo` invocation the instance parent
directory detection
(https://github.com/gokrazy/internal/blob/main/instanceflag/instanceflag.go#L19)
fails:
$ gok -i test overwrite --full /dev/sdc
[..]
2023/01/25 22:13:04 partitioning /dev/sdc (GPT + Hybrid MBR)
2023/01/25 22:13:04 Using sudo to gain permission to format /dev/sdc
2023/01/25 22:13:04 If you prefer, cancel and use: sudo setfacl -m u:${USER}:rw /dev/sdc
2023/01/25 22:13:04 open os.UserHomeDir failed: $HOME is not defined/gokrazy/test/config.json: no such file or directory
2023/01/25 22:13:04 exit status 1
This commit does the necessary passing.