Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F112002255
D22979.id.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
8 KB
Referenced Files
None
Subscribers
None
D22979.id.diff
View Options
Index: usr.sbin/bsdinstall/bsdinstall
===================================================================
--- usr.sbin/bsdinstall/bsdinstall
+++ usr.sbin/bsdinstall/bsdinstall
@@ -40,13 +40,15 @@
############################################################ GLOBALS
-: ${BSDINSTALL_TMPETC="/tmp/bsdinstall_etc"}; export BSDINSTALL_TMPETC
-: ${BSDINSTALL_TMPBOOT="/tmp/bsdinstall_boot"}; export BSDINSTALL_TMPBOOT
+: ${TMPDIR:="/tmp"}; export TMPDIR
+
+: ${BSDINSTALL_TMPETC="${TMPDIR}/bsdinstall_etc"}; export BSDINSTALL_TMPETC
+: ${BSDINSTALL_TMPBOOT="${TMPDIR}/bsdinstall_boot"}; export BSDINSTALL_TMPBOOT
: ${PATH_FSTAB="$BSDINSTALL_TMPETC/fstab"}; export PATH_FSTAB
: ${BSDINSTALL_DISTDIR="/usr/freebsd-dist"}; export BSDINSTALL_DISTDIR
: ${BSDINSTALL_CHROOT="/mnt"}; export BSDINSTALL_CHROOT
-export debugFile="${debugFile-${BSDINSTALL_LOG-/tmp/bsdinstall_log}}"
+export debugFile="${debugFile-${BSDINSTALL_LOG-${TMPDIR}/bsdinstall_log}}"
############################################################ MAIN
Index: usr.sbin/bsdinstall/bsdinstall.8
===================================================================
--- usr.sbin/bsdinstall/bsdinstall.8
+++ usr.sbin/bsdinstall/bsdinstall.8
@@ -259,6 +259,10 @@
Others are set by various interactive user prompts, and can be usefully
overridden when making scripted or customized installers.
.Bl -tag -width ".Ev BSDINSTALL_DISTSITE"
+.It Ev TMPDIR
+The directory to use for temporary files.
+Default:
+.Dq Pa /tmp
.It Ev DISTRIBUTIONS
The set of distributions to install, e.g., "base.txz kernel.txz ports.txz".
Default: unset
@@ -291,7 +295,7 @@
.It Ev BSDINSTALL_LOG
Path to a log file for the installation.
Default:
-.Dq Pa /tmp/bsdinstall_log
+.Dq Pa $TMPDIR/bsdinstall_log
.It Ev BSDINSTALL_TMPETC
Directory where files destined for the new system's
.Pa /etc
@@ -300,7 +304,7 @@
target is executed.
If this directory does not already exist, it will be created.
Default:
-.Dq Pa /tmp/bsdinstall_etc
+.Dq Pa $TMPDIR/bsdinstall_etc
.It Ev BSDINSTALL_TMPBOOT
Directory where files destined for the new system's
.Pa /boot
@@ -309,7 +313,7 @@
target is executed.
If this directory does not already exist, it will be created.
Default:
-.Dq Pa /tmp/bsdinstall_boot
+.Dq Pa $TMPDIR/bsdinstall_boot
.It Ev ZFSBOOT_POOL_NAME
Name for the pool containing the base system.
Default:
Index: usr.sbin/bsdinstall/partedit/gpart_ops.c
===================================================================
--- usr.sbin/bsdinstall/partedit/gpart_ops.c
+++ usr.sbin/bsdinstall/partedit/gpart_ops.c
@@ -711,10 +711,11 @@
if (strcmp(type, bootpart_type(scheme, &default_bootmount)) == 0) {
if (default_bootmount == NULL) {
- int fd = open("/tmp/bsdinstall-esps", O_CREAT | O_WRONLY | O_APPEND,
- 0600);
+ int fd = openat(tmpdfd, "bsdinstall-esps",
+ O_CREAT | O_WRONLY | O_APPEND, 0600);
if (fd > 0) {
write(fd, md->name, strlen(md->name));
+ write(fd, "\n", 1);
close(fd);
}
Index: usr.sbin/bsdinstall/partedit/partedit.h
===================================================================
--- usr.sbin/bsdinstall/partedit/partedit.h
+++ usr.sbin/bsdinstall/partedit/partedit.h
@@ -39,6 +39,8 @@
struct gmesh;
struct ggeom;
+extern int tmpdfd;
+
TAILQ_HEAD(pmetadata_head, partition_metadata);
extern struct pmetadata_head part_metadata;
Index: usr.sbin/bsdinstall/partedit/partedit.c
===================================================================
--- usr.sbin/bsdinstall/partedit/partedit.c
+++ usr.sbin/bsdinstall/partedit/partedit.c
@@ -32,17 +32,20 @@
#include <dialog.h>
#include <dlg_keys.h>
+#include <err.h>
#include <errno.h>
#include <fstab.h>
#include <inttypes.h>
#include <libgeom.h>
#include <libutil.h>
#include <stdlib.h>
+#include <sysexits.h>
#include "diskeditor.h"
#include "partedit.h"
struct pmetadata_head part_metadata;
+int tmpdfd;
static int sade_mode = 0;
static int apply_changes(struct gmesh *mesh);
@@ -66,6 +69,8 @@
end_dialog();
+ close(tmpdfd);
+
exit(1);
}
@@ -73,7 +78,7 @@
main(int argc, const char **argv)
{
struct partition_metadata *md;
- const char *progname, *prompt;
+ const char *progname, *prompt, *tmpdir;
struct partedit_item *items = NULL;
struct gmesh mesh;
int i, op, nitems, nscroll;
@@ -85,6 +90,14 @@
TAILQ_INIT(&part_metadata);
+ tmpdir = getenv("TMPDIR");
+ if (tmpdir == NULL)
+ tmpdir = "/tmp";
+ tmpdfd = open(tmpdir, O_RDWR | O_DIRECTORY);
+ if (tmpdfd < 0)
+ err(EX_OSERR, "%s", tmpdir);
+ unlinkat(tmpdfd, "bsdinstall-esps", 0);
+
init_fstab_metadata();
init_dialog(stdin, stdout);
@@ -220,6 +233,7 @@
geom_deletetree(&mesh);
free(items);
end_dialog();
+ close(tmpdfd);
return (error);
}
Index: usr.sbin/bsdinstall/scripts/bootconfig
===================================================================
--- usr.sbin/bsdinstall/scripts/bootconfig
+++ usr.sbin/bsdinstall/scripts/bootconfig
@@ -30,6 +30,8 @@
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
+: ${TMPDIR:="/tmp"}
+
die() {
echo $*
exit 1
@@ -50,8 +52,8 @@
fi
if [ "$(uname -m)" = "arm64" ] || [ "$X86_BOOTMETHOD" = "UEFI" ]; then
- UFSBOOT_ESPS=$(cat /tmp/bsdinstall-esps 2>/dev/null)
- ZFSBOOT_DISKS=$(cat /tmp/bsdinstall-zfsboot 2>/dev/null)
+ UFSBOOT_ESPS=$(cat $TMPDIR/bsdinstall-esps 2>/dev/null)
+ ZFSBOOT_DISKS=$(cat $TMPDIR/bsdinstall-zfsboot 2>/dev/null)
num_esps=0
if [ -n "$ZFSBOOT_DISKS" ]; then
@@ -99,7 +101,7 @@
continue
fi
- mntpt=$(mktemp -d /tmp/stand-test.XXXXXX)
+ mntpt=$(mktemp -d $TMPDIR/stand-test.XXXXXX)
if [ -e "/dev/${geom}p${index}" ]; then
dev=${geom}p${index}
elif [ -e "/dev/${geom}s${index}" ]; then
@@ -129,7 +131,7 @@
die "Failed to format ESP $esp as FAT32"
fi
- mntpt=$(mktemp -d /tmp/stand-test.XXXXXX)
+ mntpt=$(mktemp -d $TMPDIR/stand-test.XXXXXX)
f_dprintf "Mounting ESP /dev/${esp}"
mount -t msdosfs "/dev/${esp}" "${mntpt}"
if [ $? -ne 0 ]; then
Index: usr.sbin/bsdinstall/scripts/mount
===================================================================
--- usr.sbin/bsdinstall/scripts/mount
+++ usr.sbin/bsdinstall/scripts/mount
@@ -26,7 +26,7 @@
#
# $FreeBSD$
-TMP_FSTAB=/tmp/bsdinstall-tmp-fstab
+TMP_FSTAB=${TMPDIR:-"/tmp"}/bsdinstall-tmp-fstab
cat $PATH_FSTAB | awk -v BSDINSTALL_CHROOT=$BSDINSTALL_CHROOT '{
if ($2 ~ "^/.*") {
Index: usr.sbin/bsdinstall/scripts/script
===================================================================
--- usr.sbin/bsdinstall/scripts/script
+++ usr.sbin/bsdinstall/scripts/script
@@ -49,6 +49,8 @@
############################################################ GLOBALS
+: ${TMPDIR:="/tmp"}
+
#
# Strings that should be moved to an i18n file and loaded with f_include_lang()
#
@@ -88,9 +90,9 @@
rm -rf $BSDINSTALL_TMPETC
mkdir $BSDINSTALL_TMPETC
-split -a 2 -p '^#!.*' "$SCRIPT" /tmp/bsdinstall-installscript-
+split -a 2 -p '^#!.*' "$SCRIPT" $TMPDIR/bsdinstall-installscript-
-. /tmp/bsdinstall-installscript-aa
+. $TMPDIR/bsdinstall-installscript-aa
: ${DISTRIBUTIONS="kernel.txz base.txz"}; export DISTRIBUTIONS
export BSDINSTALL_DISTDIR
@@ -135,8 +137,8 @@
fi
# Run post-install script
-if [ -f /tmp/bsdinstall-installscript-ab ]; then
- cp /tmp/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript
+if [ -f $TMPDIR/bsdinstall-installscript-ab ]; then
+ cp $TMPDIR/bsdinstall-installscript-ab $BSDINSTALL_CHROOT/tmp/installscript
chmod a+x $BSDINSTALL_CHROOT/tmp/installscript
mount -t devfs devfs "$BSDINSTALL_CHROOT/dev"
chroot $BSDINSTALL_CHROOT /tmp/installscript $@ 2>&1
Index: usr.sbin/bsdinstall/scripts/umount
===================================================================
--- usr.sbin/bsdinstall/scripts/umount
+++ usr.sbin/bsdinstall/scripts/umount
@@ -26,7 +26,7 @@
#
# $FreeBSD$
-TMP_FSTAB=/tmp/bsdinstall-tmp-fstab
+TMP_FSTAB=${TMPDIR:-"/tmp"}/bsdinstall-tmp-fstab
cat $PATH_FSTAB | awk -v BSDINSTALL_CHROOT=$BSDINSTALL_CHROOT '{
if ($2 ~ "^/.*") {
Index: usr.sbin/bsdinstall/scripts/zfsboot
===================================================================
--- usr.sbin/bsdinstall/scripts/zfsboot
+++ usr.sbin/bsdinstall/scripts/zfsboot
@@ -1171,7 +1171,7 @@
f_dprintf "$funcname: For encrypted root disk..."
# Create parent directory for boot pool
- f_eval_catch -d $funcname umount "$UMOUNT" /mnt
+ f_eval_catch -d $funcname umount "$UMOUNT" "$BSDINSTALL_CHROOT"
f_eval_catch $funcname mount "$MOUNT_TYPE" tmpfs none \
$BSDINSTALL_CHROOT || return $FAILURE
@@ -1273,7 +1273,8 @@
# Clean up
f_eval_catch $funcname zfs "$ZFS_UNMOUNT" "$bootpool_name" ||
return $FAILURE
- f_eval_catch -d $funcname umount "$UMOUNT" /mnt # tmpfs
+ # tmpfs
+ f_eval_catch -d $funcname umount "$UMOUNT" "$BSDINSTALL_CHROOT"
fi
#
@@ -1657,7 +1658,7 @@
"$vdev_type" $ZFSBOOT_DISKS || continue
# To be reused by bootconfig
- echo "$ZFSBOOT_DISKS" > /tmp/bsdinstall-zfsboot
+ echo "$ZFSBOOT_DISKS" > ${TMPDIR:-"/tmp"}/bsdinstall-zfsboot
break # to success
;;
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Mar 12, 10:21 AM (7 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17117785
Default Alt Text
D22979.id.diff (8 KB)
Attached To
Mode
D22979: bsdinstall: Use TMPDIR if set
Attached
Detach File
Event Timeline
Log In to Comment