From owner-svn-src-all@freebsd.org Thu Nov 1 18:33:17 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 47B0D10FB283 for ; Thu, 1 Nov 2018 18:33:17 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: from mail-yw1-xc2b.google.com (mail-yw1-xc2b.google.com [IPv6:2607:f8b0:4864:20::c2b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id C043784BA9 for ; Thu, 1 Nov 2018 18:33:16 +0000 (UTC) (envelope-from oliver.pinter@hardenedbsd.org) Received: by mail-yw1-xc2b.google.com with SMTP id j75-v6so8293259ywj.10 for ; Thu, 01 Nov 2018 11:33:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=wAYMjrPKKbQr94XjexgMtdfF0iRwgNA5RXpe6DIkQbo=; b=Rfn9XfTuvbdS/dyUj9Eepu9+1qdLoN01eOB5EiLEA8CPjvrg4oB5j2044bTQdReLpJ PAvI4NK3Zk3EPqboKe7tm0V38Wh4ebU+opEWdtIdczbkyWdruymqSAoNAuaiWKPMF7s6 faL2bwkmrX94jJ+gpXZcrCvMM6Yi+3iCYoagKZbtGrWN3nwtC8iXAfKU25s5EVuNO5Iq k+SnNRYjQqFOtGDjD8j1TwFANvr+EqSclgRBgt8/iWYJluUrdWP1cjItizFK4PVaL0sH Eebf9rPIbmxnNQvZiz92le0+PtieqiA2LFoONS/UOLW8af8wxc0L7w/eebslDZXDjyS6 wEBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=wAYMjrPKKbQr94XjexgMtdfF0iRwgNA5RXpe6DIkQbo=; b=Cp1HkeVYgDeywyV7mxuqnzmaOgXGMZG2HVGbRPMkA4WA+UQXrhDjJ0ZZ1/XTw69/bn aX1P4E7UeqIvn9syYBTeaF91kQjQDEW5VIF5FWfjJLOVN1Z1VNQ2bNtZeIpkVBQaJDaC JZAm9lOH6s1cQzeAkIDZuSHfjhmochWC0MwCX9aghiuHLxXxUvbLCpiOlXJCy8ejv7Dt IO5MfLods1laTbSGt5Bky+sFBJKdwqfUoFStmOEn6gmMabXbfAJGAAuDDpXcmw5Rb+BR qYb7icCGWQJQhMR6zj6j+C34USExQbOipkRcdQ/WscdhqO/Xx1UTWbAXsQc/oNZckwHd HD2w== X-Gm-Message-State: AGRZ1gKd41NN1E/2hy0jLj5yJF5e6ccTMLJS5iEuSX3qFlH5M0yZSfW3 Ii2VJDaOhk+KB774ey5fGYUIbm+UL9IVFW/lnB0N3A== X-Google-Smtp-Source: AJdET5ccELwoFG7QOki0Ih8HNYcUktgy7SZoH8qr6dyQ+LA9zr8D1B7/lx6dBERZ6XLR39jzVwQEQI+CxWia7xvTnWY= X-Received: by 2002:a81:37d4:: with SMTP id e203-v6mr8361343ywa.79.1541097196003; Thu, 01 Nov 2018 11:33:16 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a25:b901:0:0:0:0:0 with HTTP; Thu, 1 Nov 2018 11:33:15 -0700 (PDT) In-Reply-To: <201810312037.w9VKbCCX029120@repo.freebsd.org> References: <201810312037.w9VKbCCX029120@repo.freebsd.org> From: Oliver Pinter Date: Thu, 1 Nov 2018 19:33:15 +0100 Message-ID: Subject: Re: svn commit: r339971 - in head: libexec/rc share/man/man5 share/man/man8 To: Devin Teske Cc: "src-committers@freebsd.org" , "svn-src-all@freebsd.org" , "svn-src-head@freebsd.org" Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Nov 2018 18:33:17 -0000 On Wednesday, October 31, 2018, Devin Teske wrote: > Author: dteske > Date: Wed Oct 31 20:37:12 2018 > New Revision: 339971 > URL: https://svnweb.freebsd.org/changeset/base/339971 > > Log: > Add new rc keywords: enable, disable, delete > > This adds new keywords to rc/service to enable/disable a service's > rc.conf(5) variable and "delete" to remove the variable. > > When the "service_delete_empty" variable in rc.conf(5) is set to "YES" > (default is "NO") an rc.conf.d file (in /etc/ or /usr/local/etc) is > deleted if empty after modification using "service $foo delete". > > Submitted by: lme (modified) > Reviewed by: 0mp (previous version), lme, bcr > Relnotes: yes > Sponsored by: Smule, Inc. > Differential Revision: https://reviews.freebsd.org/D17113 Hi! Really nice. Do you plan to MFC this commit to stable branches? > > Modified: > head/libexec/rc/rc.conf > head/libexec/rc/rc.subr > head/share/man/man5/rc.conf.5 > head/share/man/man8/rc.8 > > Modified: head/libexec/rc/rc.conf > ============================================================ > ================== > --- head/libexec/rc/rc.conf Wed Oct 31 19:59:20 2018 (r339970) > +++ head/libexec/rc/rc.conf Wed Oct 31 20:37:12 2018 (r339971) > @@ -617,6 +617,7 @@ savecore_enable="YES" # Extract core from dump > devices > savecore_flags="-m 10" # Used if dumpdev is enabled above, and present. > # By default, only the 10 most recent kernel dumps > # are saved. > +service_delete_empty="NO" # Have 'service delete' remove empty rc.conf.d > files. > crashinfo_enable="YES" # Automatically generate crash dump summary. > crashinfo_program="/usr/sbin/crashinfo" # Script to generate > crash dump summary. > quota_enable="NO" # turn on quotas on startup (or NO). > > Modified: head/libexec/rc/rc.subr > ============================================================ > ================== > --- head/libexec/rc/rc.subr Wed Oct 31 19:59:20 2018 (r339970) > +++ head/libexec/rc/rc.subr Wed Oct 31 20:37:12 2018 (r339971) > @@ -922,7 +922,7 @@ run_rc_command() > eval _override_command=\$${name}_program > command=${_override_command:-$command} > > - _keywords="start stop restart rcvar enabled describe extracommands > $extra_commands" > + _keywords="start stop restart rcvar enable disable delete enabled > describe extracommands $extra_commands" > rc_pid= > _pidcmd= > _procname=${procname:-${command}} > @@ -977,12 +977,13 @@ run_rc_command() > if [ "$_elem" != "$rc_arg" ]; then > continue > fi > - # if ${rcvar} is set, $1 is not > "rcvar" and not "describe" > - # and ${rc_pid} is not set, then > run > + # if ${rcvar} is set, $1 is not > "rcvar", "describe", > + # "enable" or "delete", and > ${rc_pid} is not set, run: > # checkyesno ${rcvar} > # and return if that failed > # > if [ -n "${rcvar}" -a "$rc_arg" != "rcvar" -a "$rc_arg" != > "stop" \ > + -a "$rc_arg" != "delete" -a "$rc_arg" != "enable" \ > -a "$rc_arg" != "describe" ] || > [ -n "${rcvar}" -a "$rc_arg" = "stop" -a -z > "${rc_pid}" ]; then > if ! checkyesno ${rcvar}; then > @@ -1028,6 +1029,31 @@ run_rc_command() > > extracommands) > echo "$extra_commands" > + ;; > + > + enable) > + _out=$(/usr/sbin/sysrc -vs "$name" "$rcvar=YES") && > + echo "$name enabled in ${_out%%:*}" > + ;; > + > + disable) > + _out=$(/usr/sbin/sysrc -vs "$name" "$rcvar=NO") && > + echo "$name disabled in ${_out%%:*}" > + ;; > + > + delete) > + _files= > + for _file in $(sysrc -lEs "$name"); do > + _out=$(sysrc -Fif $_file "$rcvar") && > _files="$_files $_file" > + done > + /usr/sbin/sysrc -x "$rcvar" && echo "$rcvar > deleted in ${_files# }" > + # delete file in rc.conf.d if desired and > empty. > + checkyesno service_delete_empty || _files= > + for _file in $_files; do > + [ "$_file" = "${_file#*/rc.conf.d/}" ] && > continue > + [ $(/usr/bin/stat -f%z $_file) -gt 0 ] && > continue > + /bin/rm "$_file" && echo "Empty file > $_file removed" > + done > ;; > > status) > > Modified: head/share/man/man5/rc.conf.5 > ============================================================ > ================== > --- head/share/man/man5/rc.conf.5 Wed Oct 31 19:59:20 2018 > (r339970) > +++ head/share/man/man5/rc.conf.5 Wed Oct 31 20:37:12 2018 > (r339971) > @@ -24,7 +24,7 @@ > .\" > .\" $FreeBSD$ > .\" > -.Dd August 22, 2018 > +.Dd October 24, 2018 > .Dt RC.CONF 5 > .Os > .Sh NAME > @@ -4509,6 +4509,14 @@ at boot time. > The directory where the files exported by USB LUN are located. > The default directory is > .Pa /var/cfumass . > +.It Va service_delete_empty > +.Pq Vt bool > +If set to > +.Dq Li YES , > +.Ql Li service delete > +removes empty > +.Dq Li rc.conf.d > +files. > .El > .Sh FILES > .Bl -tag -width ".Pa /etc/defaults/rc.conf" -compact > @@ -4597,6 +4605,7 @@ The default directory is > .Xr rwhod 8 , > .Xr savecore 8 , > .Xr sdpd 8 , > +.Xr service 8 , > .Xr sshd 8 , > .Xr swapon 8 , > .Xr sysctl 8 , > > Modified: head/share/man/man8/rc.8 > ============================================================ > ================== > --- head/share/man/man8/rc.8 Wed Oct 31 19:59:20 2018 (r339970) > +++ head/share/man/man8/rc.8 Wed Oct 31 20:37:12 2018 (r339971) > @@ -31,7 +31,7 @@ > .\" @(#)rc.8 8.2 (Berkeley) 12/11/93 > .\" $FreeBSD$ > .\" > -.Dd April 25, 2017 > +.Dd September 18, 2018 > .Dt RC 8 > .Os > .Sh NAME > @@ -327,6 +327,21 @@ If the script starts a process (rather than performing > operation), show the status of the process. > Otherwise it is not necessary to support this argument. > Defaults to displaying the process ID of the program (if running). > +.It Cm enable > +Enable the service in > +.Xr rc.conf 5 . > +.It Cm disable > +Disable the service in > +.Xr rc.conf 5 . > +.It Cm delete > +Remove the service from > +.Xr rc.conf 5 . > +If > +.Ql Li service_delete_empty > +is set to > +.Dq Li YES , > +.Pa /etc/rc.conf.d/$servicename > +will be deleted if empty after modification. > .It Cm describe > Print a short description of what the script does. > .It Cm extracommands > _______________________________________________ > svn-src-head@freebsd.org mailing list > https://lists.freebsd.org/mailman/listinfo/svn-src-head > To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org" >