[master] fe2ff86 Always use a throw-away -n argument with -C and clean it up afterwards.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Oct 17 11:05:05 CEST 2016
commit fe2ff86ad636bbee0f18cff7f6e34980d0bb4cf7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Thu Oct 13 08:15:04 2016 +0000
Always use a throw-away -n argument with -C and clean it up afterwards.
diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index a4d835a..8565f82 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -176,7 +176,7 @@ char *mgt_VccCompile(struct cli *, struct vclprog *, const char *vclname,
const char *vclsrc, const char *vclsrcfile, int C_flag);
void mgt_vcl_init(void);
-void mgt_vcc_startup(struct cli *, const char *b_arg, const char *f_arg,
+void mgt_vcl_startup(struct cli *, const char *b_arg, const char *f_arg,
const char *vclsrc, int Cflag);
int mgt_push_vcls_and_start(struct cli *, unsigned *status, char **p);
void mgt_vcl_export_labels(struct vcc *);
diff --git a/bin/varnishd/mgt/mgt_main.c b/bin/varnishd/mgt/mgt_main.c
index 97a814f..29e1cb6 100644
--- a/bin/varnishd/mgt/mgt_main.c
+++ b/bin/varnishd/mgt/mgt_main.c
@@ -512,6 +512,7 @@ main(int argc, char * const *argv)
char **av;
unsigned clilim;
int jailed = 0;
+ char Cn_arg[] = "/tmp/varnishd_C_XXXXXXX";
/* Set up the mgt counters */
memset(&static_VSC_C_mgt, 0, sizeof static_VSC_C_mgt);
@@ -685,6 +686,13 @@ main(int argc, char * const *argv)
}
}
+ if (C_flag) {
+ if (b_arg == NULL && f_arg == NULL)
+ ARGV_ERR("-C only good with -b or -f\n");
+ AN(mkdtemp(Cn_arg));
+ n_arg = Cn_arg;
+ }
+
if (!jailed)
VJ_Init(NULL);
@@ -738,7 +746,6 @@ main(int argc, char * const *argv)
ARGV_ERR("Cannot create working directory (%s): %s\n",
dirname, strerror(errno));
- /* XXX: should this be relative to the -n arg ? */
VJ_master(JAIL_MASTER_FILE);
if (P_arg && (pfh = VPF_Open(P_arg, 0644, NULL)) == NULL)
ARGV_ERR("Could not open pid/lock (-P) file (%s): %s\n",
@@ -755,16 +762,16 @@ main(int argc, char * const *argv)
mgt_vcl_init();
if (b_arg != NULL || f_arg != NULL) {
- mgt_vcc_startup(cli, b_arg, f_arg, vcl, C_flag);
- if (C_flag && cli->result == CLIS_OK) {
- AZ(VSB_finish(cli->sb));
- fprintf(stderr, "%s\n", VSB_data(cli->sb));
+ mgt_vcl_startup(cli, b_arg, f_arg, vcl, C_flag);
+ if (C_flag) {
+ AZ(rmdir(Cn_arg));
+ cli_check(cli);
exit(0);
}
cli_check(cli);
free(vcl);
- } else if (C_flag)
- ARGV_ERR("-C only good with -b or -f\n");
+ }
+ AZ(C_flag);
if (VTAILQ_EMPTY(&heritage.socks))
MAC_Arg(":80");
diff --git a/bin/varnishd/mgt/mgt_vcl.c b/bin/varnishd/mgt/mgt_vcl.c
index bbf590e..e34b0cb 100644
--- a/bin/varnishd/mgt/mgt_vcl.c
+++ b/bin/varnishd/mgt/mgt_vcl.c
@@ -369,7 +369,7 @@ mgt_new_vcl(struct cli *cli, const char *vclname, const char *vclsrc,
/*--------------------------------------------------------------------*/
void
-mgt_vcc_startup(struct cli *cli, const char *b_arg, const char *f_arg,
+mgt_vcl_startup(struct cli *cli, const char *b_arg, const char *f_arg,
const char *vclsrc, int C_flag)
{
char buf[BUFSIZ];
More information about the varnish-commit
mailing list