make tmp dir location a compile-time setting and change gotweb's tmp dir We are not sure whether a gotweb package can own /var/www/tmp on OpenBSD. Moving gotweb's tmp dir to /var/www/got/tmp sidesteps that issue.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
diff --git a/README b/README
index 5061408..7efbdf7 100644
--- a/README
+++ b/README
@@ -61,7 +61,7 @@ This will create the following files:
helper programs from the libexec directory in /var/www/cgi-bin/gotweb/libexec
several template files in /var/www/cgi-bin/gw_tmpl/
html, css, and image files in /var/www/htdocs/gotweb/
- the directory /var/www/tmp/
+ the directory /var/www/got/tmp/
man pages (only installed if building sources from a Got release tarball)
Documentation is available in manual pages:
diff --git a/got/got.c b/got/got.c
index 4329f78..4a5d5fc 100644
--- a/got/got.c
+++ b/got/got.c
@@ -297,8 +297,8 @@ apply_unveil(const char *repo_path, int repo_read_only,
if (worktree_path && unveil(worktree_path, "rwc") != 0)
return got_error_from_errno2("unveil", worktree_path);
- if (unveil("/tmp", "rwc") != 0)
- return got_error_from_errno2("unveil", "/tmp");
+ if (unveil(GOT_TMPDIR_STR, "rwc") != 0)
+ return got_error_from_errno2("unveil", GOT_TMPDIR_STR);
err = got_privsep_unveil_exec_helpers();
if (err != NULL)
@@ -482,7 +482,8 @@ collect_import_msg(char **logmsg, char **logmsg_path, const char *editor,
branch_name) == -1)
return got_error_from_errno("asprintf");
- err = got_opentemp_named_fd(logmsg_path, &fd, "/tmp/got-importmsg");
+ err = got_opentemp_named_fd(logmsg_path, &fd,
+ GOT_TMPDIR_STR "/got-importmsg");
if (err)
goto done;
@@ -3789,7 +3790,7 @@ get_tag_message(char **tagmsg, char **tagmsg_path, const char *commit_id_str,
char *editor = NULL;
int fd = -1;
- if (asprintf(&template, "/tmp/got-tagmsg") == -1) {
+ if (asprintf(&template, GOT_TMPDIR_STR "/got-tagmsg") == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
@@ -5802,7 +5803,8 @@ histedit_edit_logmsg(struct got_histedit_list_entry *hle,
if (err)
goto done;
- err = got_opentemp_named_fd(&logmsg_path, &fd, "/tmp/got-logmsg");
+ err = got_opentemp_named_fd(&logmsg_path, &fd,
+ GOT_TMPDIR_STR "/got-logmsg");
if (err)
goto done;
diff --git a/gotweb/Makefile.inc b/gotweb/Makefile.inc
index 445d054..b892a27 100644
--- a/gotweb/Makefile.inc
+++ b/gotweb/Makefile.inc
@@ -7,10 +7,13 @@ LIBEXECDIR = ${GOTWEB_DIR}/libexec
LIBEXEC_DIR = ${CHROOT_DIR}${LIBEXECDIR}
ETC_DIR = ${CHROOT_DIR}/etc
HTTPD_DIR = ${CHROOT_DIR}/htdocs
-TMP_DIR = ${CHROOT_DIR}/tmp
+GOTWEB_TMP_DIR ?= /got/tmp
+TMP_DIR = ${CHROOT_DIR}${GOTWEB_TMP_DIR}
PROG_DIR = ${HTTPD_DIR}/${PROG}
CGI_DIR = ${CHROOT_DIR}${GOTWEB_DIR}
TMPL_DIR = ${CGI_DIR}/gw_tmpl
PUB_REPOS_DIR = ${CHROOT_DIR}/got/public
WWWUSR ?= www
WWWGRP ?= www
+
+CPPFLAGS += -DGOT_TMPDIR=${GOTWEB_TMP_DIR}
diff --git a/gotweb/gotweb.8 b/gotweb/gotweb.8
index 1b2ecef..d8224f9 100644
--- a/gotweb/gotweb.8
+++ b/gotweb/gotweb.8
@@ -117,7 +117,7 @@ to read Git repositories.
.It Pa /var/www/htdocs/gotweb/
Directory containing HTML, CSS, and image files used by
.Nm .
-.It Pa /var/www/tmp/
+.It Pa /var/www/got/tmp/
Directory for temporary files created by
.Nm .
.El
diff --git a/gotweb/gotweb.c b/gotweb/gotweb.c
index fbf1ba3..509390f 100644
--- a/gotweb/gotweb.c
+++ b/gotweb/gotweb.c
@@ -296,8 +296,8 @@ gw_apply_unveil(const char *repo_path)
if (repo_path && unveil(repo_path, "r") != 0)
return got_error_from_errno2("unveil", repo_path);
- if (unveil("/tmp", "rwc") != 0)
- return got_error_from_errno2("unveil", "/tmp");
+ if (unveil(GOT_TMPDIR_STR, "rwc") != 0)
+ return got_error_from_errno2("unveil", GOT_TMPDIR_STR);
err = got_privsep_unveil_exec_helpers();
if (err != NULL)
diff --git a/include/got_opentemp.h b/include/got_opentemp.h
index 86beac8..82d4fbd 100644
--- a/include/got_opentemp.h
+++ b/include/got_opentemp.h
@@ -16,6 +16,13 @@
/* Utilities for opening temporary files. */
+#ifndef GOT_TMPDIR
+#define GOT_TMPDIR /tmp
+#endif
+#define GOT_STRINGIFY_TMP(x) #x
+#define GOT_STRINGVAL_TMP(x) GOT_STRINGIFY_TMP(x)
+#define GOT_TMPDIR_STR GOT_STRINGVAL_TMP(GOT_TMPDIR)
+
/* Open a file descriptor to a new temporary file for writing.
* The file is not visible in the filesystem. */
int got_opentempfd(void);
diff --git a/include/got_version.h b/include/got_version.h
index eacaf1a..e8abac2 100644
--- a/include/got_version.h
+++ b/include/got_version.h
@@ -18,10 +18,10 @@
#error "GOT_VERSION is undefined"
#endif
-#define GOT_STRINGIFY(x) #x
-#define GOT_STRINGVAL(x) GOT_STRINGIFY(x)
+#define GOT_STRINGIFY_VERSION(x) #x
+#define GOT_STRINGVAL_VERSION(x) GOT_STRINGIFY_VERSION(x)
-#define GOT_VERSION_STR GOT_STRINGVAL(GOT_VERSION)
+#define GOT_VERSION_STR GOT_STRINGVAL_VERSION(GOT_VERSION)
static inline void
got_version_print_str(void)
diff --git a/lib/diff3.c b/lib/diff3.c
index 9d0709e..f17c676 100644
--- a/lib/diff3.c
+++ b/lib/diff3.c
@@ -219,7 +219,8 @@ diffreg(BUF **d, const char *path1, const char *path2)
goto done;
}
- err = got_opentemp_named(&outpath, &outfile, "/tmp/got-diffreg");
+ err = got_opentemp_named(&outpath, &outfile,
+ GOT_TMPDIR_STR "/got-diffreg");
if (err)
goto done;
@@ -305,15 +306,15 @@ got_merge_diff3(int *overlapcnt, int outfd, const char *p1, const char *p2,
if (err)
goto out;
- if (asprintf(&path1, "/tmp/got-diff1.XXXXXXXX") == -1) {
+ if (asprintf(&path1, GOT_TMPDIR_STR "/got-diff1.XXXXXXXX") == -1) {
err = got_error_from_errno("asprintf");
goto out;
}
- if (asprintf(&path2, "/tmp/got-diff2.XXXXXXXX") == -1) {
+ if (asprintf(&path2, GOT_TMPDIR_STR "/got-diff2.XXXXXXXX") == -1) {
err = got_error_from_errno("asprintf");
goto out;
}
- if (asprintf(&path3, "/tmp/got-diff3.XXXXXXXX") == -1) {
+ if (asprintf(&path3, GOT_TMPDIR_STR "/got-diff3.XXXXXXXX") == -1) {
err = got_error_from_errno("asprintf");
goto out;
}
@@ -345,7 +346,7 @@ got_merge_diff3(int *overlapcnt, int outfd, const char *p1, const char *p2,
goto out;
}
- if (asprintf(&dp13, "/tmp/got-d13.XXXXXXXXXX") == -1) {
+ if (asprintf(&dp13, GOT_TMPDIR_STR "/got-d13.XXXXXXXXXX") == -1) {
err = got_error_from_errno("asprintf");
goto out;
}
@@ -356,7 +357,7 @@ got_merge_diff3(int *overlapcnt, int outfd, const char *p1, const char *p2,
buf_free(d1);
d1 = NULL;
- if (asprintf(&dp23, "/tmp/got-d23.XXXXXXXXXX") == -1) {
+ if (asprintf(&dp23, GOT_TMPDIR_STR "/got-d23.XXXXXXXXXX") == -1) {
err = got_error_from_errno("asprintf");
goto out;
}
diff --git a/lib/opentemp.c b/lib/opentemp.c
index 8476310..9bc6f86 100644
--- a/lib/opentemp.c
+++ b/lib/opentemp.c
@@ -29,7 +29,8 @@ got_opentempfd(void)
char name[PATH_MAX];
int fd;
- if (strlcpy(name, "/tmp/got.XXXXXXXX", sizeof(name)) >= sizeof(name))
+ if (strlcpy(name, GOT_TMPDIR_STR "/got.XXXXXXXX", sizeof(name))
+ >= sizeof(name))
return -1;
fd = mkstemp(name);
diff --git a/regress/delta/delta_test.c b/regress/delta/delta_test.c
index 5f086a5..0ee8340 100644
--- a/regress/delta/delta_test.c
+++ b/regress/delta/delta_test.c
@@ -137,7 +137,7 @@ main(int argc, const char *argv[])
if (pledge("stdio rpath wpath cpath unveil", NULL) == -1)
err(1, "pledge");
#endif
- if (unveil("/tmp", "rwc") != 0)
+ if (unveil(GOT_TMPDIR_STR, "rwc") != 0)
err(1, "unveil");
if (unveil(NULL, NULL) != 0)
diff --git a/tog/tog.c b/tog/tog.c
index ca4cead..e6738ac 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -2466,8 +2466,8 @@ apply_unveil(const char *repo_path, const char *worktree_path)
if (worktree_path && unveil(worktree_path, "rwc") != 0)
return got_error_from_errno2("unveil", worktree_path);
- if (unveil("/tmp", "rwc") != 0)
- return got_error_from_errno2("unveil", "/tmp");
+ if (unveil(GOT_TMPDIR_STR, "rwc") != 0)
+ return got_error_from_errno2("unveil", GOT_TMPDIR_STR);
error = got_privsep_unveil_exec_helpers();
if (error != NULL)