Repository navigation
core: run reload_check_config test with keepalived's own credentials - #2748
new-sashok724 wants to merge 1 commit into
Conversation
The reload_check_config test ran as uid/gid 0 with no supplementary groups. If keepalived runs as non-root, setgid(0) fails and, unless strict_script_exec is set, the test exits with status 0, so the new config was reloaded unchecked. Clearing the supplementary groups could also stop the test reading config files that keepalived itself can read. Run the test with keepalived's own uid, gid and supplementary groups instead. When keepalived runs as root with gid 0, the only difference is that the test keeps keepalived's supplementary groups. Signed-off-by: Aleksandr Ksenofontov <github@sashok724.net>
|
(I waited until the previous PRs were merged before opening this one, because it depends on #2732 :)) |
|
@new-sashok724 I think what we really want here is not to change the uid/gid or supplementary groups at all, since we want to run with the same uid/gids as keepalived is currently running. I think this can be generalised. If we don't change the uid, then we shouldn't change the supplementary groups, since the supplementary groups are a property of the uid. I think the following does this: Do you have any thoughts on this? Your patch still applies, although it can be simplified by not setting num_sup_grp and sup_grp. |
|
@pqarmitage I agree that the config test shouldn't change credentials. In practice it already doesn't, since the uid and gid are unchanged and However, I'm not sure about skipping More generally, I wonder whether the config reload check should use |
|
@new-sashok724 I have taken the opportunity to, as you suggest, add a new function for config checks instead of The patch is:
I have also simplified specifying the process to execute by always using
The @new-sashok724 Please let me know if this works for you, or you think anything needs changing. |
|
@pqarmitage Thanks, this looks like a much better approach than mine. A few things I noticed:
Nits: I've attached a patch (to be applied on top of your patch) that fixes these issues. Since this replaces my change, should I close this PR? |
The
reload_check_configtest ran as uid/gid 0 with no supplementary groups. If keepalived runs as non-root,setgid(0)fails and, unlessstrict_script_execis set, the test exits with status 0, so the new config was reloaded unchecked. Clearing the supplementary groups could also stop the test reading config files that keepalived itself can read.Run the test with keepalived's own uid, gid and supplementary groups instead. When keepalived runs as root with gid 0, the only difference is that the test keeps keepalived's supplementary groups.