Forum: CFEngine Help Subject: Regular expression error "nothing to repeat" Author: dpullman Link to topic: https://cfengine.com/forum/read.php?3,26109,26109#msg-26109
I'm trying to use Diego Zamboni's bundle set_config_values to edit syslog.conf. It works with one selector field, but when I subsequently added a more complicated line, I started to get the error, Regular expression error "nothing to repeat" in expression. It worked fine with the selector local4.info, and it inserted the more complicated selector for loghost, but once it was in the file I started to get two error messages on every run. My agent bundle is: bundle agent base_config { vars: any:: "syslog_conf" string => "@cf3test.el.nist.gov"; "syslog_conf[*.notice;auth.info;authpriv.*;remoteauto.crit;ftp,install,internal.none]" string => "@loghost.mel.nist.gov"; files: "/etc/syslog.conf" edit_line => set_config_values("base_config.syslog_conf"), classes => if_repaired("restart_syslogd"); processes: restart_syslogd:: "syslogd" signals => { "hup" }; } The error is: 2012 Jun 1 14:53:01 jefferson cf3[35860]: Regular expression error "nothing to repeat" in expression "#+*.notice;auth.info;authpriv.*;remoteauto.crit;ftp,install,internal.none\s+.*" at 2 2012 Jun 1 14:53:01 jefferson cf3[35860]: Regular expression error "nothing to repeat" in expression "*.notice;auth.info;authpriv.*;remoteauto.crit;ftp,install,internal.none\s+.*" at 0 The bundle due to Diego is documented at https://gist.github.com/714948. He describes it there using it for sshd_config, but he has also suggested that it would be useful for syslog.conf. I've copied it here: bundle edit_line set_config_values(v) # Sets the RHS of configuration items in the file of the form # LHS RHS # If the line is commented out with #, it gets uncommented first. # Adds a new line if none exists. # The argument is an associative array containing v="rhs" # Based on set_variable_values from cfengine_stdlib.cf, modified to # use whitespace as separator, and to handle commented-out lines. { vars: "index" slist => getindices("$(v)"); # Be careful if the index string contains funny chars "cindex[$(index)]" string => canonify("$(index)"); field_edits: # If the line is there, but commented out, first uncomment it "#+$(index)\s+.*" edit_field => col("\s+","1","$(index)","set"); # match a line starting like the key something "$(index)\s+.*" edit_field => col("\s+","2","$($(v)[$(index)])","set"), classes => if_ok("not_$(cindex[$(index)])"); insert_lines: "$(index) $($(v)[$(index)])", ifvarclass => "!not_$(cindex[$(index)])"; } So it seems that the field edits are seeing the content of the selector as a regex? Is there a way to escape this somehow? Thanks very much! -- David _______________________________________________ Help-cfengine mailing list Help-cfengine@cfengine.org https://cfengine.org/mailman/listinfo/help-cfengine