dracut.sh: support --tmpdir as a relative path

Dracut changes working directory before attempting to output files under
$DRACUT_TMPDIR , resulting in an IO failure if $DRACUT_TMPDIR is a path
relative to the working directory when dracut was started.

Fixes: https://github.com/dracutdevs/dracut/issues/156

Signed-off-by: David Disseldorp <ddiss@suse.de>
master
David Disseldorp 2016-10-10 16:27:47 +02:00
parent c85034c91f
commit bafc82e732
1 changed files with 5 additions and 1 deletions

View File

@ -820,7 +820,11 @@ esac

[[ $reproducible == yes ]] && DRACUT_REPRODUCIBLE=1

readonly TMPDIR="$tmpdir"
readonly TMPDIR="$(realpath -e "$tmpdir")"
[ -d "$TMPDIR" ] || {
printf "%s\n" "dracut: Invalid tmpdir '$tmpdir'." >&2
exit 1
}
readonly DRACUT_TMPDIR="$(mktemp -p "$TMPDIR/" -d -t dracut.XXXXXX)"
[ -d "$DRACUT_TMPDIR" ] || {
printf "%s\n" "dracut: mktemp -p '$TMPDIR/' -d -t dracut.XXXXXX failed." >&2