Skip to contentSkip to conversation

secilc/docs: fix use of TMPDIR #240

PATCH Superseded Topi Miettinen 1 participant 1 message May 15, 2020 SELinux security module

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 secilc/docs: fix use of TMPDIR #240

Environment variable TMPDIR may be already set for the user building and this could be equal to $XDG_RUNTIME_DIR or /tmp which are existing directories. Then when running 'make clean', there are unintended side effects:

rm -rf /run/user/1000
rm: cannot remove '/run/user/1000/dconf/user': Permission denied
rm: cannot remove '/run/user/1000/systemd': Permission denied
rm: cannot remove '/run/user/1000/gnupg': Permission denied
rm: cannot remove '/run/user/1000/dbus-1': Is a directory
rm: cannot remove '/run/user/1000/inaccessible': Permission denied make[1]: *** [Makefile:68: clean] Error 1

Fix by using a different name.

---
 secilc/docs/Makefile | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
secilc/docs/Makefile +10 -10
index 6b07ce7f..90214e0d 100644
@@ -1,7 +1,7 @@
 CWD ?= $(shell pwd)
 HTMLDIR ?= $(CWD)/html
 PDFDIR ?= $(CWD)/pdf
-TMPDIR ?= $(CWD)/tmp
+TMP_DIR ?= $(CWD)/tmp
 TESTDIR ?= $(CWD)/../test
 
 # All the markdown files that make up the guide:
@@ -26,7 +26,7 @@ FILE_LIST ?= cil_introduction.md \
 	cil_infiniband_statements.md \
 	cil_xen_statements.md
 
-PANDOC_FILE_LIST = $(addprefix $(TMPDIR)/,$(FILE_LIST))
+PANDOC_FILE_LIST = $(addprefix $(TMP_DIR)/,$(FILE_LIST))
 
 PDF_OUT=CIL_Reference_Guide.pdf
 HTML_OUT=CIL_Reference_Guide.html
@@ -40,29 +40,29 @@ endif
 
 all: html pdf
 
-$(TMPDIR):
-	mkdir -p $(TMPDIR)
+$(TMP_DIR):
+	mkdir -p $(TMP_DIR)
 
-$(TMPDIR)/%.md: %.md | $(TMPDIR)
-	cp -f $< $(TMPDIR)/
+$(TMP_DIR)/%.md: %.md | $(TMP_DIR)
+	cp -f $< $(TMP_DIR)/
 	@# Substitute markdown links for conversion into PDF links
 	$(SED) -i -re 's:(\[`[^`]*`\])\([^#]*([^\)]):\1\(\2:g' $@
 
-$(TMPDIR)/policy.cil: $(TESTDIR)/policy.cil
+$(TMP_DIR)/policy.cil: $(TESTDIR)/policy.cil
 	cp -f $< $@
 	@# add a title for the TOC to policy.cil. This is needed to play nicely with the PDF conversion.
 	$(SED) -i '1i Example Policy\n=========\n```' $@
 	echo '```' >> $@
 
-html: $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil
+html: $(PANDOC_FILE_LIST) $(TMP_DIR)/policy.cil
 	mkdir -p $(HTMLDIR)
 	$(PANDOC) -t html $^ -o $(HTMLDIR)/$(HTML_OUT)
 
-pdf: $(PANDOC_FILE_LIST) $(TMPDIR)/policy.cil
+pdf: $(PANDOC_FILE_LIST) $(TMP_DIR)/policy.cil
 	mkdir -p $(PDFDIR)
 	$(PANDOC) --standalone --toc $^ -o $(PDFDIR)/$(PDF_OUT)
 
 clean:
 	rm -rf $(HTMLDIR)
 	rm -rf $(PDFDIR)
-	rm -rf $(TMPDIR)
+	rm -rf $(TMP_DIR)
Signature · 1 line
2.26.2