diff options
author | Dave Eddy <dave@daveeddy.com> | 2014-08-14 11:48:18 -0700 |
---|---|---|
committer | Bryan McLellan <btm@loftninjas.org> | 2014-08-29 07:58:39 -0400 |
commit | 0cb2bf8dfcec65b0f6f69f126983d585f7c2d2aa (patch) | |
tree | 6ae495a438910685a4651fa5c0ba98c6be52ade1 /lib | |
parent | e6a8b4a865b6fa3eab7a60378922153501c0f1bf (diff) | |
download | chef-0cb2bf8dfcec65b0f6f69f126983d585f7c2d2aa.tar.gz |
tighten up /etc/rc.conf regex
I've run into a fun issue on FreeBSD 10 when trying to disable `syslogd`,
and enable `rsyslogd`.
Initially, the /etc/rc.conf config file may look something like this
syslogd_enable="YES"
rsyslogd_enable="NO"
And after chef it *should* look this
rsyslogd_enable="YES"
syslogd_enable="NO"
However, because the regex isn't as tight as it could be, it will search for
`syslogd_enable="(\w+)"`, and erroneously match the `rsyslogd`, which leads
Chef to believe that `syslogd` is enabled, when in reality it isn't. This change
simply anchors the regex with `^` so the pattern must match at the beginning of
the line.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider/service/freebsd.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/chef/provider/service/freebsd.rb b/lib/chef/provider/service/freebsd.rb index 800cd4ec13..36885d2693 100644 --- a/lib/chef/provider/service/freebsd.rb +++ b/lib/chef/provider/service/freebsd.rb @@ -47,7 +47,7 @@ class Chef if ::File.exists?("/etc/rc.conf") && var_name read_rc_conf.each do |line| case line - when /#{Regexp.escape(var_name)}="(\w+)"/ + when /^#{Regexp.escape(var_name)}="(\w+)"/ @enabled_state_found = true if $1 =~ /[Yy][Ee][Ss]/ @current_resource.enabled true |