Bug 268686 - freebsd-update cannot handle spaces in file paths
Summary: freebsd-update cannot handle spaces in file paths
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 13.1-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-31 22:33 UTC by 06-birds-herald
Modified: 2023-12-27 11:44 UTC (History)
1 user (show)

See Also:


Attachments
Modifications to freebsd-update to make it work with spaces in the file paths (11.53 KB, patch)
2022-12-31 22:33 UTC, 06-birds-herald
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description 06-birds-herald 2022-12-31 22:33:42 UTC
Created attachment 239169 [details]
Modifications to freebsd-update to make it work with spaces in the file paths

If freebsd-update is run with the -b -d or -f options followed by a path with a space, freebsd-update prints its usage and exits instead of updating. This is because it further splits arguments by spaces into more arguments internally, causing it to incorrectly parse them. There are also problems with the internal handling of the $BASEDIR and other path variables. This makes it difficult to update certain installations, for example a jail located at a non-root location with a space in its path.

This can be fixed by simply adding quotes to the necessary locations in the script, and changing the use of xargs in one location. I have attached a diff of what I had to do to get it to work for my usage (fetch, upgrade, and install). certctl, which is run by freebsd-update, also has a problem with spaces and would also need to be fixed in a similar manner.

The script also doesn't return a nonzero error code upon failure to parse its arguments.
Comment 1 Ed Maste freebsd_committer freebsd_triage 2023-03-03 00:06:08 UTC
Would you mind attaching a git format patch, so that we can preserve the appropriate metadata (in particular, your author details), or if you already have a GitHub account you can submit as a pull request there.

Alternatively, I can commit the change with a "Submitted by" tag with your preferred author info.
Comment 2 Ed Maste freebsd_committer freebsd_triage 2023-09-29 19:48:33 UTC
-		WORKDIR=$1
+		WORKDIR="$1"

This isn't necessary; spaces in $1 will be retained when assigning WORKDIR. Same for BASEDIR=$1 and perhaps other cases in the file. Quotes are indeed needed on e.g. [ -z "${BASEDIR}" ].