From owner-freebsd-bugs@FreeBSD.ORG Wed Sep 17 01:24:42 2014 Return-Path: Delivered-To: freebsd-bugs@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4224722F for ; Wed, 17 Sep 2014 01:24:42 +0000 (UTC) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 21F75A19 for ; Wed, 17 Sep 2014 01:24:42 +0000 (UTC) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.14.9/8.14.9) with ESMTP id s8H1OgZV089276 for ; Wed, 17 Sep 2014 01:24:42 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: freebsd-bugs@FreeBSD.org Subject: [Bug 193701] New: [patch] rc.conf.d subdirectory support added in 271260 potentially sources /rc.conf.d/ Date: Wed, 17 Sep 2014 01:24:42 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: conf X-Bugzilla-Version: 10.1-BETA1 X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Many People X-Bugzilla-Who: code.jpe@gmail.com X-Bugzilla-Status: Needs Triage X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: freebsd-bugs@FreeBSD.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Sep 2014 01:24:42 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D193701 Bug ID: 193701 Summary: [patch] rc.conf.d subdirectory support added in 271260 potentially sources /rc.conf.d/ Product: Base System Version: 10.1-BETA1 Hardware: Any OS: Any Status: Needs Triage Severity: Affects Many People Priority: --- Component: conf Assignee: freebsd-bugs@FreeBSD.org Reporter: code.jpe@gmail.com Created attachment 147389 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D147389&action= =3Dedit Proposed patch to etc/defaults/rc.conf and etc/rc.subr Hi, the newly added support for directories under rc.conf.d (MFC in 271260) has= two issues in my opinion. 1) it uses the shell variable $local_startup from /etc/defaults/rc.conf to construct one of the paths to source files from. But the rc.conf loading handler in rc.subr still has support to source /etc/rc.conf directly if /etc/defaults/rc.conf does not exist. For this reason, $local_startup may be empty. In this case, rc.subr will actually test "/rc.conf.d/$_name" for sourcing. 2) we have the variable $rc_conf_files that defines the locations of rc.conf files. This variable does not contain /usr/local/etc/rc.conf. Probably for = this reason, the patch introduces rc.conf.d directories relative to the value of= the $local_startup variable. Similarly, /etc/rc.conf.d is used without any rela= tion to the value of $rc_conf_files. Deriving a rc.conf.d location relative to t= he path of startup scripts is incorrect in my opinion, because it introduced a dependency between the paths that was previously not there. This results in the following sourcing order, assuming /etc/defaults/rc.conf exists and default values for $rc_conf_files: 1. /etc/defaults/rc.conf 2. /etc/rc.conf 3. /etc/rc.conf.local 4. /etc/rc.conf.d/$_name OR /etc/rc.conf.d/$_name/* 5. /usr/local/etc/rc.conf.d/$_name OR /usr/local/etc/rc.conf.d/$_name/* I propose the attached patch, which introduces the following behavior. It applies to 10.1-BETA1, I have not tested it against HEAD. * extend /etc/defaults/rc.conf with the new variable $extra_rc_conf_files w= hich defaults to /usr/local/etc/rc.conf * in /etc/rc.subr check if the variable $source_rc_confs_defined has been s= et, as an indicator if the regular /etc/defaults/rc.conf, or the fallback direct /etc/rc.conf sourcing happened * if regular sourcing happened: -- construct the rc.conf.d-directory paths $_d by appending .d to the values from $rc_conf_files (with duplicate definition checks). Skip over rc.conf.l= ocal -- check if $_d/$_name exists. Source it or $_d/$_name/* depending on if it= is a file or directory -- for every entry in $extra_rc_conf_files, source it. then construct the $= _d directory from it and check that as well * if the fallback sourcing happened -- try sourcing from /etc/rc.conf.d and /usr/local/etc/rc.conf.d directly This results in the following sourcing order, assuming the /etc/defaults/rc.conf exists and the following values are set: rc_conf_files=3D"/etc/rc.conf /etc/rc.conf.local" extra_rc_conf_files=3D"/usr/local/etc/rc.conf /foo/bar/baz.conf" 1. /etc/defaults/rc.conf 2. /etc/rc.conf 3. /etc/rc.conf.local 4. /etc/rc.conf.d/$_name OR /etc/rc.conf.d/$_name/* 5. --skip /etc/rc.conf.local.d -- 6. /usr/local/etc/rc.conf 7. /usr/local/etc/rc.conf.d/$_name OR /usr/local/etc/rc.conf.d/$_name/* 8. /foo/bar/baz.conf 9. /foo/bar/baz.conf.d/$_name OR /foo/bar/baz.conf.d/$_name/* Since the directory paths are defined relative to the values of $rc_conf_fi= les and $extra_rc_conf_files, every entry in it automatically gets the "there m= ay be a .d directory for it" treatment as shown with the /foo/bar/baz.conf example. The $extra_rc_conf_files variable should really be called $local_rc_conf_fi= les, but this is confusing while /etc/rc.conf.local is still supported. Folding /usr/local/etc/rc.conf into rc_conf_files with the current behavior= of sourcing the .d directories in rc.subr would result in /etc/rc.conf.d/$_name overwriting /usr/local/etc/rc.conf which I consider a POLA violation. Example of a FreeBSD 10.1-BETA1 system with the applied patch: :~ # mkdir -p /etc/rc.conf.d/syslogd /usr/local/etc/rc.conf.d/syslogd :~ # service syslogd rcvar # syslogd # syslogd_enable=3D"YES" # (default: "") :~ # echo 'syslogd_enable=3D"NO"' > /etc/rc.conf.d/syslogd/enable :~ # service syslogd rcvar # syslogd # syslogd_enable=3D"NO" # (default: "") :~ # echo 'syslogd_enable=3D"YES"' > /usr/local/etc/rc.conf :~ # service syslogd rcvar # syslogd # syslogd_enable=3D"YES" # (default: "") :~ # echo 'syslogd_enable=3D"NO"' > /usr/local/etc/rc.conf.d/syslogd/enable :~ # service syslogd rcvar # syslogd # syslogd_enable=3D"NO" # (default: "") Regards, J=C3=B6rg --=20 You are receiving this mail because: You are the assignee for the bug.=