[master] 752489b Respect TMPDIR if present

Federico G. Schwindt fgsch at lodoss.net
Thu Nov 30 23:17:08 UTC 2017


commit 752489b5c296f61c56010b748e6594da57708d0f
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Thu Nov 30 14:37:41 2017 +0000

    Respect TMPDIR if present

diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 9aee532..f460f5e 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -66,7 +66,7 @@ int			exit_status = 0;
 struct vsb		*vident;
 struct VSC_mgt		*VSC_C_mgt;
 static int		I_fd = -1;
-static char		Cn_arg[] = "/tmp/varnishd_C_XXXXXXX";
+static char 		*Cn_arg;
 
 static struct vpf_fh *pfh1 = NULL;
 static struct vpf_fh *pfh2 = NULL;
@@ -687,6 +687,17 @@ main(int argc, char * const *argv)
 
 	if (C_flag) {
 		if (n_arg == NULL) {
+			vsb = VSB_new_auto();
+			AN(vsb);
+			if (getenv("TMPDIR") != NULL)
+				VSB_printf(vsb, "%s", getenv("TMPDIR"));
+			else
+				VSB_printf(vsb, "/tmp");
+			VSB_printf(vsb, "/varnishd_C_XXXXXXX");
+			AZ(VSB_finish(vsb));
+			Cn_arg = strdup(VSB_data(vsb));
+			AN(Cn_arg);
+			VSB_destroy(&vsb);
 			AN(mkdtemp(Cn_arg));
 			AZ(chmod(Cn_arg, 0755));
 			AZ(atexit(mgt_Cflag_atexit));


More information about the varnish-commit mailing list