Forum: CFEngine Help
Subject: Re: Help with managing regions in a config file.
Author: zzamboni
Link to topic: https://cfengine.com/forum/read.php?3,24665,24669#msg-24669
Hi Nick,
The problem seems to be in the definition of the regions. The regular
expressions in select_start and select_end are anchored, so they have to match
the whole line. Changing these bodies to look like this makes it behave
correctly:
body select_region sshd_config_match_user (x)
{
select_start => "Match\s*User\s*$(x)";
select_end => "Match.*";
include_start_delimiter => "true";
include_end_delimiter => "false";
}
body select_region sshd_config_match_group (x) {
select_start => "Match\s*Group\s*$(x)";
select_end => "Match.*";
include_start_delimiter => "true";
include_end_delimiter => "false";
}
The problem was that because the end-marker was not being found, the first
region would extend to the end of the file, overlapping the second region. Thus
all edits would happen on the same part of the file, and because the same lines
are being added in both regions, only one copy of each would remain.
_______________________________________________
Help-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/help-cfengine