From owner-freebsd-rc@FreeBSD.ORG Mon Dec 2 02:20:46 2013 Return-Path: Delivered-To: freebsd-rc@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 1E1CFF8F for ; Mon, 2 Dec 2013 02:20:46 +0000 (UTC) Received: from o3.shared.sendgrid.net (o3.shared.sendgrid.net [208.117.48.85]) by mx1.freebsd.org (Postfix) with SMTP id A60F41679 for ; Mon, 2 Dec 2013 02:20:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sendgrid.info; h=from:mime-version:to:subject:content-type; s=smtpapi; bh=1zLLwnoUsZ529IgdekXGBGaQyxg=; b=Xyoa/fOgkbF4I8oyDdWKADcAKmQdq V/V9reqMErTCchiMTAyY9ZcH+Ym/FeP/OLyRhA3dsK/OF+iTMlppetrtxUfKbtSW IWcXPQoD9ycEheXTZvHa0OeItn13Kcg+Sm0cSkhROFiY54EXxH7Oz+I52rDGJD0D CHu1Lii6+f0qdU= Received: by mf159.sendgrid.net with SMTP id mf159.3669.529BEE765 Mon, 02 Dec 2013 02:20:38 +0000 (GMT) Received: from mail.tarsnap.com (unknown [10.60.208.15]) by mi59 (SG) with ESMTP id 142b11b8035.4d5d.409239 for ; Sun, 01 Dec 2013 20:20:38 -0600 (CST) Received: (qmail 99131 invoked from network); 2 Dec 2013 02:20:37 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by ec2-107-20-205-189.compute-1.amazonaws.com with ESMTP; 2 Dec 2013 02:20:37 -0000 Received: (qmail 19497 invoked from network); 2 Dec 2013 02:18:03 -0000 Received: from unknown (HELO clamshell.daemonology.net) (127.0.0.1) by clamshell.daemonology.net with SMTP; 2 Dec 2013 02:18:03 -0000 Message-ID: <529BEDDB.8010003@freebsd.org> Date: Sun, 01 Dec 2013 18:18:03 -0800 From: Colin Percival User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.0 MIME-Version: 1.0 To: freebsd-rc@FreeBSD.org Subject: RFC: support for re-sourcing /etc/rc.conf X-Enigmail-Version: 1.5.2 Content-Type: multipart/mixed; boundary="------------020807080703050704060006" X-SG-EID: ChUA/E68MWtQtYrYVmEHIGuqNmShXrFL3cq8iGM7RqWf2aG9kWJFKMP/Upunl2C6On6SSqj0OBHkEYpxNfWxkdt/8K0uF/6qb3Nf5OA7evBtU7j96KRSECvNaj+41b+jp1SfFx9gyb6D8/Uac7E7B7+/1G+6H2AzujvBPw+Tdzg= X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Dec 2013 02:20:46 -0000 This is a multi-part message in MIME format. --------------020807080703050704060006 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi all, I'd like to commit the attached patch to /etc/rc. When SIGALRM is received, it reloads /etc/rc.conf; this makes it possible for an rc.d script to perform first-boot system configuration and have it reflected by other rc.d scripts. In particular, this will allow me to provide EC2 user-data of >>/etc/rc.conf firstboot_pkgs_enable="YES" firstboot_pkgs_list="apache22" to an image with the sysutils/ec2-scripts and sysutils/firstboot-pkgs ports installed, and have a system running with apache22 installed moments later. The first signal which came to mind for this was SIGHUP, since that's used by many daemons for "reload configuration file", but for some reason that signal never arrives at /etc/rc -- so I switched to SIGALRM, which works just fine. I'd like to get this into the tree as soon as possible in order to maximize my odds of convincing re@ that "rc.conf can't be re-sourced after it has been modified during boot" is a bug which should be fixed in 10.0-RELEASE. Comments? -- Colin Percival Security Officer Emeritus, FreeBSD | The power to serve Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid --------------020807080703050704060006 Content-Type: text/plain; charset=us-ascii; name="rc-sigalrm.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="rc-sigalrm.patch" Index: etc/rc =================================================================== --- etc/rc (revision 258085) +++ etc/rc (working copy) @@ -71,6 +71,11 @@ . /etc/rc.subr load_rc_config 'XXX' +# If we receive a SIGALRM, re-source /etc/rc.conf; this allows rc.d +# scripts to perform "boot-time configuration" including enabling and +# disabling rc.d scripts which appear later in the boot order. +trap "_rc_conf_loaded=false; load_rc_config 'XXX'" ALRM + skip="-s nostart" if [ `/sbin/sysctl -n security.jail.jailed` -eq 1 ]; then skip="$skip -s nojail" --------------020807080703050704060006--