diff options
author | Rebecca Cran <bcran@FreeBSD.org> | 2020-01-15 00:45:05 +0000 |
---|---|---|
committer | Rebecca Cran <bcran@FreeBSD.org> | 2020-01-15 00:45:05 +0000 |
commit | a107ddbb83a7a93d3c4e40f5355e158d6976bf90 (patch) | |
tree | 63c29cb9b8cdcd133b18b747e6ec395d01ceafde /usr.sbin/bsdinstall/partedit | |
parent | 0297c1384ac831c774c901713912df4851242c05 (diff) |
bsdinstall: Use TMPDIR if set
Submitted by: Ryan Moeller <ryan@freqlabs.com>
Reviewed by: bcran, Nick Wolff <darkfiberiru@gmail.com>
Differential Revision: https://reviews.freebsd.org/D22979/
Notes
Notes:
svn path=/head/; revision=356740
Diffstat (limited to 'usr.sbin/bsdinstall/partedit')
-rw-r--r-- | usr.sbin/bsdinstall/partedit/gpart_ops.c | 5 | ||||
-rw-r--r-- | usr.sbin/bsdinstall/partedit/partedit.c | 16 | ||||
-rw-r--r-- | usr.sbin/bsdinstall/partedit/partedit.h | 2 |
3 files changed, 20 insertions, 3 deletions
diff --git a/usr.sbin/bsdinstall/partedit/gpart_ops.c b/usr.sbin/bsdinstall/partedit/gpart_ops.c index 87e45e348426..517972641134 100644 --- a/usr.sbin/bsdinstall/partedit/gpart_ops.c +++ b/usr.sbin/bsdinstall/partedit/gpart_ops.c @@ -711,10 +711,11 @@ set_default_part_metadata(const char *name, const char *scheme, 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); } diff --git a/usr.sbin/bsdinstall/partedit/partedit.c b/usr.sbin/bsdinstall/partedit/partedit.c index 80430c64ba1c..0fa03c99b369 100644 --- a/usr.sbin/bsdinstall/partedit/partedit.c +++ b/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 @@ sigint_handler(int sig) end_dialog(); + close(tmpdfd); + exit(1); } @@ -73,7 +78,7 @@ int 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 @@ main(int argc, const char **argv) 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 @@ main(int argc, const char **argv) geom_deletetree(&mesh); free(items); end_dialog(); + close(tmpdfd); return (error); } diff --git a/usr.sbin/bsdinstall/partedit/partedit.h b/usr.sbin/bsdinstall/partedit/partedit.h index 1dccc653aea1..e989decc2359 100644 --- a/usr.sbin/bsdinstall/partedit/partedit.h +++ b/usr.sbin/bsdinstall/partedit/partedit.h @@ -39,6 +39,8 @@ struct gprovider; struct gmesh; struct ggeom; +extern int tmpdfd; + TAILQ_HEAD(pmetadata_head, partition_metadata); extern struct pmetadata_head part_metadata; |