Path: blob/main/website/static/security/patches/EN-15:04/freebsd-update-8.patch
18096 views
Index: usr.sbin/freebsd-update/freebsd-update.81===================================================================2--- usr.sbin/freebsd-update/freebsd-update.8 (revision 282245)3+++ usr.sbin/freebsd-update/freebsd-update.8 (working copy)4@@ -25,7 +25,7 @@5.\"6.\" $FreeBSD$7.\"8-.Dd July 14, 20109+.Dd March 2, 201510.Dt FREEBSD-UPDATE 811.Os FreeBSD12.Sh NAME13@@ -36,10 +36,12 @@14.Op Fl b Ar basedir15.Op Fl d Ar workdir16.Op Fl f Ar conffile17+.Op Fl F18.Op Fl k Ar KEY19.Op Fl r Ar newrelease20.Op Fl s Ar server21.Op Fl t Ar address22+.Op Fl -not-running-from-cron23.Cm command ...24.Sh DESCRIPTION25The26@@ -49,21 +51,21 @@ updates to the FreeBSD base system.27Note that updates are only available if they are being built for the28FreeBSD release and architecture being used; in particular, the29.Fx30-Security Team only builds updates for releases shipped in binary form31+Security Team only builds updates for releases shipped in binary form32by the33.Fx34Release Engineering Team, e.g.,35.Fx36-7.3-RELEASE and37+9.3-RELEASE and38.Fx39-8.0, but not40+10.1-RELEASE, but not41.Fx42-6.3-STABLE or43+9.3-STABLE or44.Fx45-9.0-CURRENT.46+11-CURRENT.47.Sh OPTIONS48The following options are supported:49-.Bl -tag -width "-f conffile"50+.Bl -tag -width "-r newrelease"51.It Fl b Ar basedir52Operate on a system mounted at53.Ar basedir .54@@ -81,6 +83,10 @@ Read configuration options from55.Ar conffile .56(default:57.Pa /etc/freebsd-update.conf )58+.It Fl F59+Force60+.Nm Cm fetch61+to proceed where it normally would not, such as an unfinished upgrade62.It Fl k Ar KEY63Trust an RSA key with SHA256 of64.Ar KEY .65@@ -98,13 +104,21 @@ Mail output of66command, if any, to67.Ar address .68(default: root, or as given in the configuration file.)69+.It Fl -not-running-from-cron70+Force71+.Nm Cm fetch72+to proceed when there is no controlling tty.73+This is for use by automated scripts and orchestration tools.74+Please do not run75+.Nm Cm fetch76+from crontab or similar using this flag, see:77+.Nm Cm cron78.El79.Sh COMMANDS80The81.Cm command82can be any one of the following:83-.Pp84-.Bl -tag -width "-f conffile"85+.Bl -tag -width "rollback"86.It Cm fetch87Based on the currently installed world and the configuration88options set, fetch all available binary updates.89@@ -128,6 +142,11 @@ Fetch files necessary for upgrading to a90Before using this command, make sure that you read the91announcement and release notes for the new release in92case there are any special steps needed for upgrading.93+Note that this command may require up to 500 MB of space in94+.Ar workdir95+depending on which components of the96+.Fx97+base system are installed.98.It Cm install99Install the most recently fetched updates or upgrade.100.It Cm rollback101@@ -149,7 +168,7 @@ other than 3AM, to avoid overly imposing102on the server(s) hosting the updates.103.It104In spite of its name,105-.Cm106+.Nm107IDS should not be relied upon as an "Intrusion Detection108System", since if the system has been tampered with109it cannot be trusted to operate correctly.110@@ -158,11 +177,11 @@ purposes, make sure you boot from a secu111.El112.Sh FILES113.Bl -tag -width "/etc/freebsd-update.conf"114-.It /etc/freebsd-update.conf115+.It Pa /etc/freebsd-update.conf116Default location of the117.Nm118configuration file.119-.It /var/db/freebsd-update/120+.It Pa /var/db/freebsd-update/121Default location where122.Nm123stores temporary files and downloaded updates.124@@ -170,4 +189,4 @@ stores temporary files and downloaded up125.Sh SEE ALSO126.Xr freebsd-update.conf 5127.Sh AUTHORS128-.An Colin Percival Aq [email protected]129+.An Colin Percival Aq Mt [email protected]130Index: usr.sbin/freebsd-update/freebsd-update.sh131===================================================================132--- usr.sbin/freebsd-update/freebsd-update.sh (revision 282245)133+++ usr.sbin/freebsd-update/freebsd-update.sh (working copy)134@@ -43,12 +43,15 @@ Options:135(default: /var/db/freebsd-update/)136-f conffile -- Read configuration options from conffile137(default: /etc/freebsd-update.conf)138+ -F -- Force a fetch operation to proceed139-k KEY -- Trust an RSA key with SHA256 hash of KEY140-r release -- Target for upgrade (e.g., 6.2-RELEASE)141-s server -- Server from which to fetch updates142(default: update.FreeBSD.org)143-t address -- Mail output of cron command, if any, to address144(default: root)145+ --not-running-from-cron146+ -- Run without a tty, for use by automated tools147Commands:148fetch -- Fetch updates from server149cron -- Sleep rand(3600) seconds, fetch updates, and send an150@@ -284,6 +287,9 @@ config_TargetRelease () {151else152return 1153fi154+ if echo ${TARGETRELEASE} | grep -qE '^[0-9.]+$'; then155+ TARGETRELEASE="${TARGETRELEASE}-RELEASE"156+ fi157}158159# Define what happens to output of utilities160@@ -396,6 +402,12 @@ init_params () {161162# No commands specified yet163COMMANDS=""164+165+ # Force fetch to proceed166+ FORCEFETCH=0167+168+ # Run without a TTY169+ NOTTYOK=0170}171172# Parse the command line173@@ -408,6 +420,12 @@ parse_cmdline () {174if [ ! -z "${CONFFILE}" ]; then usage; fi175shift; CONFFILE="$1"176;;177+ -F)178+ FORCEFETCH=1179+ ;;180+ --not-running-from-cron)181+ NOTTYOK=1182+ ;;183184# Configuration file equivalents185-b)186@@ -569,7 +587,7 @@ fetch_setup_verboselevel () {187# running *-p[0-9]+, strip off the last part; if the188# user is running -SECURITY, call it -RELEASE. Chdir189# into the working directory.190-fetch_check_params () {191+fetchupgrade_check_params () {192export HTTP_USER_AGENT="freebsd-update (${COMMAND}, `uname -r`)"193194_SERVERNAME_z=\195@@ -577,6 +595,7 @@ fetch_check_params () {196_KEYPRINT_z="Key must be given via -k option or configuration file."197_KEYPRINT_bad="Invalid key fingerprint: "198_WORKDIR_bad="Directory does not exist or is not writable: "199+ _WORKDIR_bad2="Directory is not on a persistent filesystem: "200201if [ -z "${SERVERNAME}" ]; then202echo -n "`basename $0`: "203@@ -600,6 +619,13 @@ fetch_check_params () {204echo ${WORKDIR}205exit 1206fi207+ case `df -T ${WORKDIR}` in */dev/md[0-9]* | *tmpfs*)208+ echo -n "`basename $0`: "209+ echo -n "${_WORKDIR_bad2}"210+ echo ${WORKDIR}211+ exit 1212+ ;;213+ esac214chmod 700 ${WORKDIR}215cd ${WORKDIR} || exit 1216217@@ -652,9 +678,29 @@ fetch_check_params () {218BDHASH=`echo ${BASEDIR} | sha256 -q`219}220221+# Perform sanity checks etc. before fetching updates.222+fetch_check_params () {223+ fetchupgrade_check_params224+225+ if ! [ -z "${TARGETRELEASE}" ]; then226+ echo -n "`basename $0`: "227+ echo -n "-r option is meaningless with 'fetch' command. "228+ echo "(Did you mean 'upgrade' instead?)"229+ exit 1230+ fi231+232+ # Check that we have updates ready to install233+ if [ -f ${BDHASH}-install/kerneldone -a $FORCEFETCH -eq 0 ]; then234+ echo "You have a partially completed upgrade pending"235+ echo "Run '$0 install' first."236+ echo "Run '$0 fetch -F' to proceed anyway."237+ exit 1238+ fi239+}240+241# Perform sanity checks etc. before fetching upgrades.242upgrade_check_params () {243- fetch_check_params244+ fetchupgrade_check_params245246# Unless set otherwise, we're upgrading to the same kernel config.247NKERNCONF=${KERNCONF}248@@ -1185,7 +1231,7 @@ fetch_metadata_sanity () {249# Some aliases to save space later: ${P} is a character which can250# appear in a path; ${M} is the four numeric metadata fields; and251# ${H} is a sha256 hash.252- P="[-+./:=%@_[~[:alnum:]]"253+ P="[-+./:=,%@_[~[:alnum:]]"254M="[0-9]+\|[0-9]+\|[0-9]+\|[0-9]+"255H="[0-9a-f]{64}"256257@@ -1456,7 +1502,7 @@ fetch_inspect_system () {258sort -k 3,3 -t '|' > $2.tmp259rm filelist260261- # Check if an error occured during system inspection262+ # Check if an error occurred during system inspection263if [ -f .err ]; then264return 1265fi266@@ -2240,6 +2286,19 @@ upgrade_oldall_to_oldnew () {267mv $2 $3268}269270+# Helper for upgrade_merge: Return zero true iff the two files differ only271+# in the contents of their RCS tags.272+samef () {273+ X=`sed -E 's/\\$FreeBSD.*\\$/\$FreeBSD\$/' < $1 | ${SHA256}`274+ Y=`sed -E 's/\\$FreeBSD.*\\$/\$FreeBSD\$/' < $2 | ${SHA256}`275+276+ if [ $X = $Y ]; then277+ return 0;278+ else279+ return 1;280+ fi281+}282+283# From the list of "old" files in $1, merge changes in $2 with those in $3,284# and update $3 to reflect the hashes of merged files.285upgrade_merge () {286@@ -2323,6 +2382,14 @@ upgrade_merge () {287288# Ask the user to handle any files which didn't merge.289while read F; do290+ # If the installed file differs from the version in291+ # the old release only due to RCS tag expansion292+ # then just use the version in the new release.293+ if samef merge/old/${F} merge/${OLDRELNUM}/${F}; then294+ cp merge/${RELNUM}/${F} merge/new/${F}295+ continue296+ fi297+298cat <<-EOF299300The following file could not be merged automatically: ${F}301@@ -2337,9 +2404,18 @@ manually...302# Ask the user to confirm that he likes how the result303# of merging files.304while read F; do305- # Skip files which haven't changed.306- if [ -f merge/new/${F} ] &&307- cmp -s merge/old/${F} merge/new/${F}; then308+ # Skip files which haven't changed except possibly309+ # in their RCS tags.310+ if [ -f merge/old/${F} ] && [ -f merge/new/${F} ] &&311+ samef merge/old/${F} merge/new/${F}; then312+ continue313+ fi314+315+ # Skip files where the installed file differs from316+ # the old file only due to RCS tags.317+ if [ -f merge/old/${F} ] &&318+ [ -f merge/${OLDRELNUM}/${F} ] &&319+ samef merge/old/${F} merge/${OLDRELNUM}/${F}; then320continue321fi322323@@ -2526,6 +2602,10 @@ upgrade_run () {324# Leave a note behind to tell the "install" command that the kernel325# needs to be installed before the world.326touch ${BDHASH}-install/kernelfirst327+328+ # Remind the user that they need to run "freebsd-update install"329+ # to install the downloaded bits, in case they didn't RTFM.330+ echo "To install the downloaded upgrades, run \"$0 install\"."331}332333# Make sure that all the file hashes mentioned in $@ have corresponding334@@ -2577,14 +2657,14 @@ backup_kernel_finddir () {335while true ; do336# Pathname does not exist, so it is OK use that name337# for backup directory.338- if [ ! -e $BACKUPKERNELDIR ]; then339+ if [ ! -e $BASEDIR/$BACKUPKERNELDIR ]; then340return 0341fi342343# If directory do exist, we only use if it has our344# marker file.345- if [ -d $BACKUPKERNELDIR -a \346- -e $BACKUPKERNELDIR/.freebsd-update ]; then347+ if [ -d $BASEDIR/$BACKUPKERNELDIR -a \348+ -e $BASEDIR/$BACKUPKERNELDIR/.freebsd-update ]; then349return 0350fi351352@@ -2592,7 +2672,7 @@ backup_kernel_finddir () {353# the end and try again.354CNT=$((CNT + 1))355if [ $CNT -gt 9 ]; then356- echo "Could not find valid backup dir ($BACKUPKERNELDIR)"357+ echo "Could not find valid backup dir ($BASEDIR/$BACKUPKERNELDIR)"358exit 1359fi360BACKUPKERNELDIR="`echo $BACKUPKERNELDIR | sed -Ee 's/[0-9]\$//'`"361@@ -2619,17 +2699,17 @@ backup_kernel () {362# Remove old kernel backup files. If $BACKUPKERNELDIR was363# "not ours", backup_kernel_finddir would have exited, so364# deleting the directory content is as safe as we can make it.365- if [ -d $BACKUPKERNELDIR ]; then366- rm -fr $BACKUPKERNELDIR367+ if [ -d $BASEDIR/$BACKUPKERNELDIR ]; then368+ rm -fr $BASEDIR/$BACKUPKERNELDIR369fi370371# Create directories for backup.372- mkdir -p $BACKUPKERNELDIR373- mtree -cdn -p "${KERNELDIR}" | \374- mtree -Ue -p "${BACKUPKERNELDIR}" > /dev/null375+ mkdir -p $BASEDIR/$BACKUPKERNELDIR376+ mtree -cdn -p "${BASEDIR}/${KERNELDIR}" | \377+ mtree -Ue -p "${BASEDIR}/${BACKUPKERNELDIR}" > /dev/null378379# Mark the directory as having been created by freebsd-update.380- touch $BACKUPKERNELDIR/.freebsd-update381+ touch $BASEDIR/$BACKUPKERNELDIR/.freebsd-update382if [ $? -ne 0 ]; then383echo "Could not create kernel backup directory"384exit 1385@@ -2647,8 +2727,8 @@ backup_kernel () {386fi387388# Backup all the kernel files using hardlinks.389- (cd $KERNELDIR && find . -type f $FINDFILTER -exec \390- cp -pl '{}' ${BACKUPKERNELDIR}/'{}' \;)391+ (cd ${BASEDIR}/${KERNELDIR} && find . -type f $FINDFILTER -exec \392+ cp -pl '{}' ${BASEDIR}/${BACKUPKERNELDIR}/'{}' \;)393394# Re-enable patchname expansion.395set +f396@@ -2746,7 +2826,7 @@ install_files () {397398# Update linker.hints if necessary399if [ -s INDEX-OLD -o -s INDEX-NEW ]; then400- kldxref -R /boot/ 2>/dev/null401+ kldxref -R ${BASEDIR}/boot/ 2>/dev/null402fi403404# We've finished updating the kernel.405@@ -2797,14 +2877,14 @@ Kernel updates have been installed. Ple406install_delete INDEX-OLD INDEX-NEW || return 1407408# Rebuild /etc/spwd.db and /etc/pwd.db if necessary.409- if [ /etc/master.passwd -nt /etc/spwd.db ] ||410- [ /etc/master.passwd -nt /etc/pwd.db ]; then411- pwd_mkdb /etc/master.passwd412+ if [ ${BASEDIR}/etc/master.passwd -nt ${BASEDIR}/etc/spwd.db ] ||413+ [ ${BASEDIR}/etc/master.passwd -nt ${BASEDIR}/etc/pwd.db ]; then414+ pwd_mkdb -d ${BASEDIR}/etc ${BASEDIR}/etc/master.passwd415fi416417# Rebuild /etc/login.conf.db if necessary.418- if [ /etc/login.conf -nt /etc/login.conf.db ]; then419- cap_mkdb /etc/login.conf420+ if [ ${BASEDIR}/etc/login.conf -nt ${BASEDIR}/etc/login.conf.db ]; then421+ cap_mkdb ${BASEDIR}/etc/login.conf422fi423424# We've finished installing the world and deleting old files425@@ -3011,21 +3091,8 @@ IDS_compare () {426mv INDEX-NOTMATCHING.tmp INDEX-NOTMATCHING427428# Go through the lines and print warnings.429- while read LINE; do430- FPATH=`echo "${LINE}" | cut -f 1 -d '|'`431- TYPE=`echo "${LINE}" | cut -f 2 -d '|'`432- OWNER=`echo "${LINE}" | cut -f 3 -d '|'`433- GROUP=`echo "${LINE}" | cut -f 4 -d '|'`434- PERM=`echo "${LINE}" | cut -f 5 -d '|'`435- HASH=`echo "${LINE}" | cut -f 6 -d '|'`436- LINK=`echo "${LINE}" | cut -f 7 -d '|'`437- P_TYPE=`echo "${LINE}" | cut -f 8 -d '|'`438- P_OWNER=`echo "${LINE}" | cut -f 9 -d '|'`439- P_GROUP=`echo "${LINE}" | cut -f 10 -d '|'`440- P_PERM=`echo "${LINE}" | cut -f 11 -d '|'`441- P_HASH=`echo "${LINE}" | cut -f 12 -d '|'`442- P_LINK=`echo "${LINE}" | cut -f 13 -d '|'`443-444+ local IFS='|'445+ while read FPATH TYPE OWNER GROUP PERM HASH LINK P_TYPE P_OWNER P_GROUP P_PERM P_HASH P_LINK; do446# Warn about different object types.447if ! [ "${TYPE}" = "${P_TYPE}" ]; then448echo -n "${FPATH} is a "449@@ -3153,7 +3220,7 @@ get_params () {450# Fetch command. Make sure that we're being called451# interactively, then run fetch_check_params and fetch_run452cmd_fetch () {453- if [ ! -t 0 ]; then454+ if [ ! -t 0 -a $NOTTYOK -eq 0 ]; then455echo -n "`basename $0` fetch should not "456echo "be run non-interactively."457echo "Run `basename $0` cron instead."458459460