FreeBSD Bugzilla – Attachment 239169 Details for
Bug 268686
freebsd-update cannot handle spaces in file paths
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Modifications to freebsd-update to make it work with spaces in the file paths
freebsd-update.sh.patch (text/plain), 11.53 KB, created by
06-birds-herald
on 2022-12-31 22:33:42 UTC
(
hide
)
Description:
Modifications to freebsd-update to make it work with spaces in the file paths
Filename:
MIME Type:
Creator:
06-birds-herald
Created:
2022-12-31 22:33:42 UTC
Size:
11.53 KB
patch
obsolete
>--- freebsd-update.sh >+++ freebsd-update-spaces.sh >@@ -136,8 +136,8 @@ > > # Set the working directory. > config_WorkDir () { >- if [ -z ${WORKDIR} ]; then >- WORKDIR=$1 >+ if [ -z "${WORKDIR}" ]; then >+ WORKDIR="$1" > else > return 1 > fi >@@ -276,8 +276,8 @@ > > # Work on a FreeBSD installation mounted under $1 > config_BaseDir () { >- if [ -z ${BASEDIR} ]; then >- BASEDIR=$1 >+ if [ -z "${BASEDIR}" ]; then >+ BASEDIR="$1" > else > return 1 > fi >@@ -330,7 +330,7 @@ > JAIL=$1 > UNAME_r=$(freebsd-version -j ${JAIL}) > BASEDIR=$(jls -j ${JAIL} -h path | awk 'NR == 2 {print}') >- if [ -z ${BASEDIR} ] || [ -z ${UNAME_r} ]; then >+ if [ -z "${BASEDIR}" ] || [ -z ${UNAME_r} ]; then > echo "The specified jail either doesn't exist or" \ > "does not have freebsd-version." > exit 1 >@@ -500,35 +500,35 @@ > # Configuration file equivalents > -b) > if [ $# -eq 1 ]; then usage; fi; shift >- config_BaseDir $1 || usage >+ config_BaseDir "$1" || usage > ;; > -d) > if [ $# -eq 1 ]; then usage; fi; shift >- config_WorkDir $1 || usage >+ config_WorkDir "$1" || usage > ;; > -j) > if [ $# -eq 1 ]; then usage; fi; shift >- config_TargetJail $1 || usage >+ config_TargetJail "$1" || usage > ;; > -k) > if [ $# -eq 1 ]; then usage; fi; shift >- config_KeyPrint $1 || usage >+ config_KeyPrint "$1" || usage > ;; > -s) > if [ $# -eq 1 ]; then usage; fi; shift >- config_ServerName $1 || usage >+ config_ServerName "$1" || usage > ;; > -r) > if [ $# -eq 1 ]; then usage; fi; shift >- config_TargetRelease $1 || usage >+ config_TargetRelease "$1" || usage > ;; > -t) > if [ $# -eq 1 ]; then usage; fi; shift >- config_MailTo $1 || usage >+ config_MailTo "$1" || usage > ;; > -v) > if [ $# -eq 1 ]; then usage; fi; shift >- config_VerboseLevel $1 || usage >+ config_VerboseLevel "$1" || usage > ;; > > # Aliases for "-v debug" and "-v nostats" >@@ -566,7 +566,7 @@ > if [ ! -z "${CONFFILE}" ] && [ ! -r "${CONFFILE}" ]; then > echo -n "File does not exist " > echo -n "or is not readable: " >- echo ${CONFFILE} >+ echo "${CONFFILE}" > exit 1 > fi > >@@ -596,7 +596,7 @@ > echo "==> ${LINE}" > exit 1 > fi >- done < ${CONFFILE} >+ done < "${CONFFILE}" > > # Merge the settings read from the configuration file with those > # provided at the command line. >@@ -692,18 +692,18 @@ > if ! [ -d "${WORKDIR}" -a -w "${WORKDIR}" ]; then > echo -n "`basename $0`: " > echo -n "${_WORKDIR_bad}" >- echo ${WORKDIR} >+ echo "${WORKDIR}" > exit 1 > fi >- case `df -T ${WORKDIR}` in */dev/md[0-9]* | *tmpfs*) >+ case `df -T "${WORKDIR}"` in */dev/md[0-9]* | *tmpfs*) > echo -n "`basename $0`: " > echo -n "${_WORKDIR_bad2}" >- echo ${WORKDIR} >+ echo "${WORKDIR}" > exit 1 > ;; > esac >- chmod 700 ${WORKDIR} >- cd ${WORKDIR} || exit 1 >+ chmod 700 "${WORKDIR}" >+ cd "${WORKDIR}" || exit 1 > > # Generate release number. The s/SECURITY/RELEASE/ bit exists > # to provide an upgrade path for FreeBSD Update 1.x users, since >@@ -769,7 +769,7 @@ > fetch_setup_verboselevel > > # Construct a unique name from ${BASEDIR} >- BDHASH=`echo ${BASEDIR} | sha256 -q` >+ BDHASH=`echo "${BASEDIR}" | sha256 -q` > } > > # Perform sanity checks etc. before fetching updates. >@@ -853,13 +853,13 @@ > if ! [ -d "${WORKDIR}" -a -w "${WORKDIR}" ]; then > echo -n "`basename $0`: " > echo -n "${_WORKDIR_bad}" >- echo ${WORKDIR} >+ echo "${WORKDIR}" > exit 1 > fi >- cd ${WORKDIR} || exit 1 >+ cd "${WORKDIR}" || exit 1 > > # Construct a unique name from ${BASEDIR} >- BDHASH=`echo ${BASEDIR} | sha256 -q` >+ BDHASH=`echo "${BASEDIR}" | sha256 -q` > > # Check that we have updates ready to install > if ! [ -L ${BDHASH}-install ]; then >@@ -943,13 +943,13 @@ > if ! [ -d "${WORKDIR}" -a -w "${WORKDIR}" ]; then > echo -n "`basename $0`: " > echo -n "${_WORKDIR_bad}" >- echo ${WORKDIR} >+ echo "${WORKDIR}" > exit 1 > fi >- cd ${WORKDIR} || exit 1 >+ cd "${WORKDIR}" || exit 1 > > # Construct a unique name from ${BASEDIR} >- BDHASH=`echo ${BASEDIR} | sha256 -q` >+ BDHASH=`echo "${BASEDIR}" | sha256 -q` > > # Check that we have updates ready to rollback > if ! [ -L ${BDHASH}-rollback ]; then >@@ -998,10 +998,10 @@ > if ! [ -d "${WORKDIR}" -a -w "${WORKDIR}" ]; then > echo -n "`basename $0`: " > echo -n "${_WORKDIR_bad}" >- echo ${WORKDIR} >+ echo "${WORKDIR}" > exit 1 > fi >- cd ${WORKDIR} || exit 1 >+ cd "${WORKDIR}" || exit 1 > > # Generate release number. The s/SECURITY/RELEASE/ bit exists > # to provide an upgrade path for FreeBSD Update 1.x users, since >@@ -1618,11 +1618,11 @@ > # sorted by device and inode number. > while read F; do > # If the symlink/file/directory does not exist, record this. >- if ! [ -e ${BASEDIR}/${F} ]; then >+ if ! [ -e "${BASEDIR}"/${F} ]; then > echo "${F}|-||||||" > continue > fi >- if ! [ -r ${BASEDIR}/${F} ]; then >+ if ! [ -r "${BASEDIR}"/${F} ]; then > echo "Cannot read file: ${BASEDIR}/${F}" \ > >/dev/stderr > touch .err >@@ -1630,17 +1630,17 @@ > fi > > # Otherwise, output an index line. >- if [ -L ${BASEDIR}/${F} ]; then >+ if [ -L "${BASEDIR}"/${F} ]; then > echo -n "${F}|L|" >- stat -n -f '%d-%i|%u|%g|%Mp%Lp|%Of|' ${BASEDIR}/${F}; >- readlink ${BASEDIR}/${F}; >- elif [ -f ${BASEDIR}/${F} ]; then >+ stat -n -f '%d-%i|%u|%g|%Mp%Lp|%Of|' "${BASEDIR}"/${F}; >+ readlink "${BASEDIR}"/${F}; >+ elif [ -f "${BASEDIR}"/${F} ]; then > echo -n "${F}|f|" >- stat -n -f '%d-%i|%u|%g|%Mp%Lp|%Of|' ${BASEDIR}/${F}; >- sha256 -q ${BASEDIR}/${F}; >- elif [ -d ${BASEDIR}/${F} ]; then >+ stat -n -f '%d-%i|%u|%g|%Mp%Lp|%Of|' "${BASEDIR}"/${F}; >+ sha256 -q "${BASEDIR}"/${F}; >+ elif [ -d "${BASEDIR}"/${F} ]; then > echo -n "${F}|d|" >- stat -f '%d-%i|%u|%g|%Mp%Lp|%Of|' ${BASEDIR}/${F}; >+ stat -f '%d-%i|%u|%g|%Mp%Lp|%Of|' "${BASEDIR}"/${F}; > else > echo "Unknown file type: ${BASEDIR}/${F}" \ > >/dev/stderr >@@ -2281,7 +2281,7 @@ > cut -f 1-3 -d '|' < INDEX-ALL | > tr '|' ' ' | > while read C S F; do >- if [ -e ${BASEDIR}/${F} ]; then >+ if [ -e "${BASEDIR}"/${F} ]; then > echo "+ ${C}|${S}" > fi > echo "= ${C}|${S}" >@@ -2544,7 +2544,7 @@ > manually... > EOF > read dummy </dev/tty >- ${EDITOR} `pwd`/merge/new/${F} < /dev/tty >+ ${EDITOR} "$PWD/merge/new/${F}" < /dev/tty > done < failed.merges > rm failed.merges > >@@ -2787,12 +2787,12 @@ > > # Remove flags > while read F; do >- if ! [ -e ${BASEDIR}/${F} ]; then >+ if ! [ -e "${BASEDIR}/${F}" ]; then > continue > else >- echo ${BASEDIR}/${F} >+ echo "${BASEDIR}/${F}" > fi >- done < filelist | xargs chflags noschg || return 1 >+ done < filelist | tr '\n' '\0' | xargs -0 chflags noschg || return 1 > > # Clean up > rm filelist >@@ -2804,14 +2804,14 @@ > while true ; do > # Pathname does not exist, so it is OK use that name > # for backup directory. >- if [ ! -e $BASEDIR/$BACKUPKERNELDIR ]; then >+ if [ ! -e "$BASEDIR"/$BACKUPKERNELDIR ]; then > return 0 > fi > > # If directory do exist, we only use if it has our > # marker file. >- if [ -d $BASEDIR/$BACKUPKERNELDIR -a \ >- -e $BASEDIR/$BACKUPKERNELDIR/.freebsd-update ]; then >+ if [ -d "$BASEDIR"/$BACKUPKERNELDIR -a \ >+ -e "$BASEDIR"/$BACKUPKERNELDIR/.freebsd-update ]; then > return 0 > fi > >@@ -2846,17 +2846,17 @@ > # Remove old kernel backup files. If $BACKUPKERNELDIR was > # "not ours", backup_kernel_finddir would have exited, so > # deleting the directory content is as safe as we can make it. >- if [ -d $BASEDIR/$BACKUPKERNELDIR ]; then >- rm -fr $BASEDIR/$BACKUPKERNELDIR >+ if [ -d "$BASEDIR"/$BACKUPKERNELDIR ]; then >+ rm -fr "$BASEDIR"/$BACKUPKERNELDIR > fi > > # Create directories for backup. >- mkdir -p $BASEDIR/$BACKUPKERNELDIR >+ mkdir -p "$BASEDIR"/$BACKUPKERNELDIR > mtree -cdn -p "${BASEDIR}/${KERNELDIR}" | \ > mtree -Ue -p "${BASEDIR}/${BACKUPKERNELDIR}" > /dev/null > > # Mark the directory as having been created by freebsd-update. >- touch $BASEDIR/$BACKUPKERNELDIR/.freebsd-update >+ touch "$BASEDIR"/$BACKUPKERNELDIR/.freebsd-update > if [ $? -ne 0 ]; then > echo "Could not create kernel backup directory" > exit 1 >@@ -2874,8 +2874,8 @@ > fi > > # Backup all the kernel files using hardlinks. >- (cd ${BASEDIR}/${KERNELDIR} && find . -type f $FINDFILTER -exec \ >- cp -pl '{}' ${BASEDIR}/${BACKUPKERNELDIR}/'{}' \;) >+ (cd "${BASEDIR}"/${KERNELDIR} && find . -type f $FINDFILTER -exec \ >+ cp -pl '{}' "${BASEDIR}"/${BACKUPKERNELDIR}/'{}' \;) > > # Re-enable patchname expansion. > set +f >@@ -2892,23 +2892,23 @@ > d) > # Create a directory > install -d -o ${OWNER} -g ${GROUP} \ >- -m ${PERM} ${BASEDIR}/${FPATH} >+ -m ${PERM} "${BASEDIR}"/${FPATH} > ;; > f) > if [ -z "${LINK}" ]; then > # Create a file, without setting flags. > gunzip < files/${HASH}.gz > ${HASH} > install -S -o ${OWNER} -g ${GROUP} \ >- -m ${PERM} ${HASH} ${BASEDIR}/${FPATH} >+ -m ${PERM} ${HASH} "${BASEDIR}"/${FPATH} > rm ${HASH} > else > # Create a hard link. >- ln -f ${BASEDIR}/${LINK} ${BASEDIR}/${FPATH} >+ ln -f "${BASEDIR}"/${LINK} "${BASEDIR}"/${FPATH} > fi > ;; > L) > # Create a symlink >- ln -sfh ${HASH} ${BASEDIR}/${FPATH} >+ ln -sfh ${HASH} "${BASEDIR}"/${FPATH} > ;; > esac > done >@@ -2918,7 +2918,7 @@ > while read FPATH TYPE OWNER GROUP PERM FLAGS HASH LINK; do > if [ ${TYPE} = "f" ] && > ! [ ${FLAGS} = "0" ]; then >- chflags ${FLAGS} ${BASEDIR}/${FPATH} >+ chflags ${FLAGS} "${BASEDIR}"/${FPATH} > fi > done > } >@@ -2940,13 +2940,13 @@ > while read FPATH TYPE; do > case ${TYPE} in > d) >- rmdir ${BASEDIR}/${FPATH} >+ rmdir "${BASEDIR}"/${FPATH} > ;; > f) >- rm ${BASEDIR}/${FPATH} >+ rm "${BASEDIR}"/${FPATH} > ;; > L) >- rm ${BASEDIR}/${FPATH} >+ rm "${BASEDIR}"/${FPATH} > ;; > esac > done < killfiles >@@ -2973,7 +2973,7 @@ > > # Update linker.hints if necessary > if [ -s INDEX-OLD -o -s INDEX-NEW ]; then >- kldxref -R ${BASEDIR}/boot/ 2>/dev/null >+ kldxref -R "${BASEDIR}"/boot/ 2>/dev/null > fi > > # We've finished updating the kernel. >@@ -3025,23 +3025,23 @@ > > # Rehash certs if we actually have certctl installed. > if which certctl>/dev/null; then >- env DESTDIR=${BASEDIR} certctl rehash >+# env DESTDIR="${BASEDIR}" certctl rehash > fi > > # Rebuild generated pwd files and /etc/login.conf.db. >- pwd_mkdb -d ${BASEDIR}/etc -p ${BASEDIR}/etc/master.passwd >- cap_mkdb ${BASEDIR}/etc/login.conf >+ pwd_mkdb -d "${BASEDIR}"/etc -p "${BASEDIR}"/etc/master.passwd >+ cap_mkdb "${BASEDIR}"/etc/login.conf > > # Rebuild man page databases, if necessary. > for D in /usr/share/man /usr/share/openssl/man; do >- if [ ! -d ${BASEDIR}/$D ]; then >+ if [ ! -d "${BASEDIR}"/$D ]; then > continue > fi >- if [ -f ${BASEDIR}/$D/mandoc.db ] && \ >- [ -z "$(find ${BASEDIR}/$D -type f -newer ${BASEDIR}/$D/mandoc.db)" ]; then >+ if [ -f "${BASEDIR}"/$D/mandoc.db ] && \ >+ [ -z "$(find "${BASEDIR}/$D" -type f -newer "${BASEDIR}/$D/mandoc.db")" ]; then > continue; > fi >- makewhatis ${BASEDIR}/$D >+ makewhatis "${BASEDIR}"/$D > done > > # We've finished installing the world and deleting old files >@@ -3369,7 +3369,7 @@ > # set all the parameters which are needed later. > get_params () { > init_params >- parse_cmdline $@ >+ parse_cmdline "$@" > parse_conffile > default_params > } >@@ -3426,10 +3426,10 @@ > fi > > # Change into working directory (fail if no permission/directory etc.) >- cd ${WORKDIR} || exit 1 >+ cd "${WORKDIR}" || exit 1 > > # Construct a unique name from ${BASEDIR} >- BDHASH=`echo ${BASEDIR} | sha256 -q` >+ BDHASH=`echo "${BASEDIR}" | sha256 -q` > > # Check that we have updates ready to install > if ! [ -L ${BDHASH}-install ]; then >@@ -3484,7 +3484,7 @@ > # Set LC_ALL in order to avoid problems with character ranges like [A-Z]. > export LC_ALL=C > >-get_params $@ >+get_params "$@" > for COMMAND in ${COMMANDS}; do > cmd_${COMMAND} > done
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 268686
: 239169