[master] 8de6262f3 Removing files and directories needs Jail attention

Poul-Henning Kamp phk at FreeBSD.org
Mon May 25 08:17:07 UTC 2020


commit 8de6262f3c838aa8f23ab1fbbcd9aa45dfdc1121
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon May 25 08:13:27 2020 +0000

    Removing files and directories needs Jail attention
    
    Add VJ_unlink() and VJ_rmdir() to do so.

diff --git a/bin/varnishd/mgt/mgt.h b/bin/varnishd/mgt/mgt.h
index 54b42ad80..0456d84b4 100644
--- a/bin/varnishd/mgt/mgt.h
+++ b/bin/varnishd/mgt/mgt.h
@@ -147,6 +147,8 @@ void VJ_subproc(enum jail_subproc_e);
 int VJ_make_workdir(const char *);
 int VJ_make_subdir(const char *, const char *, struct vsb *);
 void VJ_fix_fd(int, enum jail_fixfd_e);
+void VJ_unlink(const char *);
+void VJ_rmdir(const char *);
 
 extern const struct jail_tech jail_tech_unix;
 extern const struct jail_tech jail_tech_solaris;
diff --git a/bin/varnishd/mgt/mgt_jail.c b/bin/varnishd/mgt/mgt_jail.c
index 36b426ebf..615f6735d 100644
--- a/bin/varnishd/mgt/mgt_jail.c
+++ b/bin/varnishd/mgt/mgt_jail.c
@@ -196,6 +196,28 @@ VJ_make_subdir(const char *dname, const char *what, struct vsb *vsb)
 	return (0);
 }
 
+void
+VJ_unlink(const char *fname)
+{
+	VJ_master(JAIL_MASTER_FILE);
+	if (unlink(fname)) {
+		fprintf(stderr, "Could not delete '%s': %s\n",
+		    fname, strerror(errno));
+	}
+	VJ_master(JAIL_MASTER_LOW);
+}
+
+void
+VJ_rmdir(const char *dname)
+{
+	VJ_master(JAIL_MASTER_FILE);
+	if (rmdir(dname)) {
+		fprintf(stderr, "Could not rmdir '%s': %s\n",
+		    dname, strerror(errno));
+	}
+	VJ_master(JAIL_MASTER_LOW);
+}
+
 void
 VJ_fix_fd(int fd, enum jail_fixfd_e what)
 {


More information about the varnish-commit mailing list