Greetings.
Another issue with RedHat not being like everyone else. Consider the
following file:
# cat /tmp/test
test:a:b:c
With the following testcase:
##########################################################################
body common control {
bundlesequence => { "test"};
}
##########################################################################
bundle agent test {
files:
"/tmp/test_copy"
comment => "create a test file",
copy_from => local_copy("/tmp/test"),
create => "true",
classes => cdefine("copied","not_copied"),
edit_line => test_edit;
}
##########################################################################
bundle edit_line test_edit {
vars:
copied::
"no" int => getfields("test:.*","/tmp/test_copy",":","data");
delete_lines:
".*";
reports:
cfengine_3::
"teststring:$(data[2])";
}
##########################################################################
body classes cdefine(pass,fail) {
promise_repaired => { "$(pass)" };
repair_failed => { "$(fail)" };
}
##########################################################################
body copy_from local_copy(from) {
source => "$(from)";
force_update => "true";
}
##########################################################################
On other OS'es, the result should be:
R: teststring:a
However, on RedHat it core dumps. The problem lies in IsCf3VarString
(vars.c ~line 485):
int IsCf3VarString(char *str)
{ char *sp;
char left = 'x', right = 'x';
int dollar = false;
int bracks = 0, vars = 0;
Debug1("IsCf3VarString(%s) - syntax verify\n",str);
for (sp = str; *sp != '\0' ; sp++) /* check for varitems */
When RedHat core dumps, str is NULL. Other OS'es can deal with sp =
str, but RedHat does not. In a layman's attempt to patch, I just did:
int IsCf3VarString(char *str)
{ char *sp;
char left = 'x', right = 'x';
int dollar = false;
int bracks = 0, vars = 0;
Debug1("IsCf3VarString(%s) - syntax verify\n",str);
if ( str == NULL ) {
Debug("Found %d variables in (%s)\n",vars,str);
return vars;
}
for (sp = str; *sp != '\0' ; sp++) /* check for varitems */
It appears to work. I am not sure if this is the right way to do it,
but you get the idea.
Thanks!
_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine