this burns the tmpdir out of diff, so as to let pledge tmppath work a little
better.
Index: diff.1
===================================================================
RCS file: /cvs/src/usr.bin/diff/diff.1,v
retrieving revision 1.44
diff -u -p -r1.44 diff.1
--- diff.1 5 Oct 2015 20:15:00 -0000 1.44
+++ diff.1 23 Oct 2015 18:21:27 -0000
@@ -425,17 +425,6 @@ As in
identical
pairs (where num1 = num2) are abbreviated as a single
number.
-.Sh ENVIRONMENT
-.Bl -tag -width TMPDIR
-.It Ev TMPDIR
-If the environment variable
-.Ev TMPDIR
-exists,
-.Nm
-will use the directory specified by
-.Ev TMPDIR
-as the temporary directory.
-.El
.Sh FILES
.Bl -tag -width /tmp/diff.XXXXXXXX -compact
.It Pa /tmp/diff. Ns Ar XXXXXXXX
Index: diff.c
===================================================================
RCS file: /cvs/src/usr.bin/diff/diff.c,v
retrieving revision 1.63
diff -u -p -r1.63 diff.c
--- diff.c 9 Oct 2015 01:37:07 -0000 1.63
+++ diff.c 23 Oct 2015 18:21:27 -0000
@@ -211,13 +211,8 @@ main(int argc, char **argv)
argc -= optind;
argv += optind;
- if (getenv("TMPDIR")) {
- if (pledge("stdio rpath wpath cpath", NULL) == -1)
- err(1, "pledge");
- } else {
- if (pledge("stdio rpath tmppath", NULL) == -1)
- err(1, "pledge");
- }
+ if (pledge("stdio rpath tmppath", NULL) == -1)
+ err(1, "pledge");
/*
* Do sanity checks, fill in stb1 and stb2 and call the appropriate
Index: diffreg.c
===================================================================
RCS file: /cvs/src/usr.bin/diff/diffreg.c,v
retrieving revision 1.89
diff -u -p -r1.89 diffreg.c
--- diffreg.c 13 Oct 2015 16:37:17 -0000 1.89
+++ diffreg.c 23 Oct 2015 18:21:27 -0000
@@ -446,7 +446,7 @@ files_differ(FILE *f1, FILE *f2, int fla
static FILE *
opentemp(const char *file)
{
- char buf[BUFSIZ], *tempdir, tempfile[PATH_MAX];
+ char buf[BUFSIZ], tempfile[PATH_MAX];
ssize_t nread;
int ifd, ofd;
@@ -455,16 +455,7 @@ opentemp(const char *file)
else if ((ifd = open(file, O_RDONLY, 0644)) < 0)
return (NULL);
- if ((tempdir = getenv("TMPDIR")) == NULL)
- tempdir = _PATH_TMP;
-
- if (strlcpy(tempfile, tempdir, sizeof(tempfile)) >= sizeof(tempfile) ||
- strlcat(tempfile, "/diff.XXXXXXXX", sizeof(tempfile)) >=
- sizeof(tempfile)) {
- close(ifd);
- errno = ENAMETOOLONG;
- return (NULL);
- }
+ (void)strlcpy(tempfile, _PATH_TMP "/diff.XXXXXXXX", sizeof(tempfile));
if ((ofd = mkstemp(tempfile)) < 0) {
close(ifd);