From owner-freebsd-bugs@FreeBSD.ORG Fri Sep 18 00:40:02 2009 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 15D1910656AA for ; Fri, 18 Sep 2009 00:40:02 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id E6A178FC13 for ; Fri, 18 Sep 2009 00:40:01 +0000 (UTC) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id n8I0e1ij072432 for ; Fri, 18 Sep 2009 00:40:01 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id n8I0e1rI072431; Fri, 18 Sep 2009 00:40:01 GMT (envelope-from gnats) Resent-Date: Fri, 18 Sep 2009 00:40:01 GMT Resent-Message-Id: <200909180040.n8I0e1rI072431@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Tom Smith Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7BE0B106566B for ; Fri, 18 Sep 2009 00:32:30 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 6A8398FC08 for ; Fri, 18 Sep 2009 00:32:30 +0000 (UTC) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n8I0WT2N057017 for ; Fri, 18 Sep 2009 00:32:29 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id n8I0WTrQ057016; Fri, 18 Sep 2009 00:32:29 GMT (envelope-from nobody) Message-Id: <200909180032.n8I0WTrQ057016@www.freebsd.org> Date: Fri, 18 Sep 2009 00:32:29 GMT From: Tom Smith To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: bin/138926: [patch] freebsd-update(8) allows unattended upgrade X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Sep 2009 00:40:02 -0000 >Number: 138926 >Category: bin >Synopsis: [patch] freebsd-update(8) allows unattended upgrade >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Fri Sep 18 00:40:01 UTC 2009 >Closed-Date: >Last-Modified: >Originator: Tom Smith >Release: FreeBSD 7.2-RELEASE-p2 i386 >Organization: >Environment: >Description: This patch enables unattended upgrades by a setting in the config file. When Unattended=yes is set, freebsd-update assumes yes for all user prompts and writes everything it would have written and confirmed with the user to standard out without paging. This allows for unattended upgrades to take place only if the user knows what they are doing and specifically takes steps to enable this behavior. It is intended for environments with large numbers of identical or very similar machines where a staging server is used beforehand to verify that the unattended install will proceed correctly. The administrator can send the output to a file or through tee to keep a record of what happened and review it after each step in the upgrade process. >How-To-Repeat: To perform an unattended install with this patch, set Unattended=yes in the freebsd-update.conf file and run freebsd-update as directed in the FreeBSD Handbook. >Fix: The attached patch is for both the freebsd-update script and the default configuration file (where Unattended defaults to no and comments explain impact of setting to yes). Patch attached with submission follows: *** usr.sbin/freebsd-update/freebsd-update.sh.orig Sat Sep 12 14:48:15 2009 --- usr.sbin/freebsd-update/freebsd-update.sh Sat Sep 12 14:51:32 2009 *************** *** 88,94 **** CONFIGOPTIONS="KEYPRINT WORKDIR SERVERNAME MAILTO ALLOWADD ALLOWDELETE KEEPMODIFIEDMETADATA COMPONENTS IGNOREPATHS UPDATEIFUNMODIFIED BASEDIR VERBOSELEVEL TARGETRELEASE STRICTCOMPONENTS MERGECHANGES ! IDSIGNOREPATHS" # Set all the configuration options to "". nullconfig () { --- 88,94 ---- CONFIGOPTIONS="KEYPRINT WORKDIR SERVERNAME MAILTO ALLOWADD ALLOWDELETE KEEPMODIFIEDMETADATA COMPONENTS IGNOREPATHS UPDATEIFUNMODIFIED BASEDIR VERBOSELEVEL TARGETRELEASE STRICTCOMPONENTS MERGECHANGES ! IDSIGNOREPATHS UNATTENDED" # Set all the configuration options to "". nullconfig () { *************** *** 308,313 **** --- 308,333 ---- fi } + # Set whether any interactive prompts or paging will happen + config_Unattended () { + if [ -z ${UNATTENDED} ]; then + case $1 in + [Yy][Ee][Ss]) + UNATTENDED=yes + ;; + [Nn][Oo]) + UNATTENDED=no + ;; + *) + return 1 + ;; + esac + else + return 1 + fi + } + + # Handle one line of configuration configline () { if [ $# -eq 0 ]; then *************** *** 931,946 **** # Function for asking the user if everything is ok continuep () { ! while read -p "Does this look reasonable (y/n)? " CONTINUE; do ! case "${CONTINUE}" in ! y*) ! return 0 ! ;; ! n*) ! return 1 ! ;; ! esac ! done } # Initialize the working directory --- 951,970 ---- # Function for asking the user if everything is ok continuep () { ! if [ ${UNATTENDED} != "yes" ]; then ! while read -p "Does this look reasonable (y/n)? " CONTINUE; do ! case "${CONTINUE}" in ! y*) ! return 0 ! ;; ! n*) ! return 1 ! ;; ! esac ! done ! else ! return 0 ! fi } # Initialize the working directory *************** *** 1783,1791 **** echo "but no changes have" echo -n "been downloaded because the files have been " echo "modified locally:" ! cat modifiedfiles ! fi | more ! rm modifiedfiles # If no files will be updated, tell the user and exit if ! [ -s INDEX-PRESENT ] && --- 1807,1820 ---- echo "but no changes have" echo -n "been downloaded because the files have been " echo "modified locally:" ! cat modifiedfiles ! fi > modifiedfiles.out ! if [ ${UNATTENDED} != "yes" ]; then ! more modifiedfiles.out ! else ! cat modifiedfiles.out ! fi ! rm modifiedfiles.out modifiedfiles # If no files will be updated, tell the user and exit if ! [ -s INDEX-PRESENT ] && *************** *** 1814,1821 **** echo -n "The following files will be removed " echo "as part of updating to ${RELNUM}-p${RELPATCHNUM}:" cat files.removed ! fi | more ! rm files.removed # Report added files, if any if [ -s files.added ]; then --- 1843,1855 ---- echo -n "The following files will be removed " echo "as part of updating to ${RELNUM}-p${RELPATCHNUM}:" cat files.removed ! fi > files.removed.out ! if [ ${UNATTENDED} != "yes" ]; then ! more files.removed.out ! else ! cat files.removed.out ! fi ! rm files.removed.out files.removed # Report added files, if any if [ -s files.added ]; then *************** *** 1823,1840 **** echo -n "The following files will be added " echo "as part of updating to ${RELNUM}-p${RELPATCHNUM}:" cat files.added ! fi | more ! rm files.added # Report updated files, if any if [ -s files.updated ]; then echo echo -n "The following files will be updated " echo "as part of updating to ${RELNUM}-p${RELPATCHNUM}:" - cat files.updated ! fi | more ! rm files.updated # Create a directory for the install manifest. MDIR=`mktemp -d install.XXXXXX` || return 1 --- 1857,1883 ---- echo -n "The following files will be added " echo "as part of updating to ${RELNUM}-p${RELPATCHNUM}:" cat files.added ! fi > files.added.out ! if [ ${UNATTENDED} != "yes" ]; then ! more files.added.out ! else ! cat files.added.out ! fi ! rm files.added.out files.added # Report updated files, if any if [ -s files.updated ]; then echo echo -n "The following files will be updated " echo "as part of updating to ${RELNUM}-p${RELPATCHNUM}:" cat files.updated ! fi > files.updated.out ! if [ ${UNATTENDED} != "yes" ]; then ! more files.updated.out ! else ! cat files.updated.out ! fi ! rm files.updated.out files.updated # Create a directory for the install manifest. MDIR=`mktemp -d install.XXXXXX` || return 1 *************** *** 2244,2264 **** done < $1-paths echo " done." ! # Ask the user to handle any files which didn't merge. ! while read F; do ! cat <<-EOF The following file could not be merged automatically: ${F} Press Enter to edit this file in ${EDITOR} and resolve the conflicts manually... ! EOF ! read dummy Release-Note: >Audit-Trail: >Unformatted: