-
-
Notifications
You must be signed in to change notification settings - Fork 655
Description
Describe the bug
(This supersedes discussion 3902.)
I think I've encountered a long-standing bug as I try to mimic autoinstall_snippets/keep_files in our non-Cobbler kickstart.
In brief: when attempting to preserve multiple different key types (the code offers three: ssh, cfengine, rhn) the shell variable keys_found is too global in scope to handle "found one but not found another".
In our case, we use ssh and cfengine. Suppose the previous system had keys ssh but not cfengine.
Each call to search_for_keys immediately sets keys_found=no.
- The first call (for
ssh) finds the keys, so (correctly) setskeys_found=yes. - The second call (for
cfengine) immediately setskeys_found=no. Because there were no previous CFEngine keys,keys_foundremains asno. - The subsequent calls to
restore_keysthen BOTH (i.esshandcfengine) interrogate the single variablekeys_foundand BOTH find it "no" (from the final key), even though the earliersshresult had been "yes".
So I think that the single keys_found variable needs to be replaced by a variable-per-key implementation.
Steps to reproduce
It was somewhat over 12 years ago, in a previous job, that I used Cobbler. My current job uses kickstart but not Cobbler. We want to mimic Cobbler's keep_files functionality, so I'm adapting the code into our use and find this problem. (In the previous job, we only attempted a single key so didn't encounter this bug.)
My suggested reproduce steps are:
- Cobbler environment with
preserve_files_kshaving at least two cases; e.g. "ssh" and "cfengine" in that order. - Reinstall a previous OS that had "ssh" but not "cfengine"; that is, keys for an early item in that
preserve_files_kslist but, crucially, absent for the final item in the list. - Observe that valid keys (in this case "ssh") fail to be preserved.
Expected behavior
keep_files should attempt to keep keys it finds, even if other keys (whose preservation is being attempted) had been absent,
Cobbler version
N/A, but believed to be all.
Operating system
RHEL
Additional information
I could easily attempt a blind patch, based on our own non-Cobbler adaptation of the Cobbler code.
But also:
- There doesn't appear to be any sort of unit test or similar for
keep_files. (Have I overlooked it?) - The
keep_filescode would benefit from wider tidy-up that would interact considerably with any proposed patch. Should I attempt a minimal patch (i.e. limited to thiskeys_foundbug)? Or can I work on the broader matters with someone with access to a Cobbler environment?
Metadata
Metadata
Assignees
Labels
Type
Projects
Status