1From 12bc62ac26df012fc143913b6e046a3cf5127db2 Mon Sep 17 00:00:00 2001
2From: Khem Raj <raj.khem@gmail.com>
3Date: Sat, 23 Apr 2022 09:20:49 -0700
4Subject: [PATCH] make: Define SBINDIR flag
5
6Provides a facility to control install locations of /sbin elements from
7environment
8
9Upstream-Status: Pending
10Signed-off-by: Khem Raj <raj.khem@gmail.com>
11---
12 Makefile | 17 +++++++++--------
13 1 file changed, 9 insertions(+), 8 deletions(-)
14
15diff --git a/Makefile b/Makefile
16index deed94c..9190fe9 100644
17--- a/Makefile
18+++ b/Makefile
19@@ -25,6 +25,7 @@ MKNOD=/bin/mknod
20 CC=/usr/bin/gcc
21 FIND=/usr/bin/find
22 LIBS := $(shell if [ "`uname -m`" != "sparc64" -a "`uname -m`" != "x86_64" ]; then echo "-lfl" ; else echo "" ; fi)
23+SBINDIR=/sbin
24 OPT_FLAGS := -O2
25 # for older versions of grsecurity, comment the above line and uncomment the below:
26 #OPT_FLAGS := $(shell if [ "`uname -m`" != "sparc64" ] && [ "`uname -m`" != "x86_64" ]; then echo "-O2" ; else echo "-O2 -m64" ; fi)
27@@ -136,15 +137,15 @@ lex.learn_pass1.o: lex.learn_pass1.c learn_pass1.tab.h
28 lex.learn_pass2.o: lex.learn_pass2.c learn_pass2.tab.h
29
30 install: $(GRADM_BIN) gradm.8 policy grlearn
31-	@mkdir -p $(DESTDIR)/sbin
32+	@mkdir -p $(DESTDIR)$(SBINDIR)
33 	@echo "Installing gradm..."
34-	@$(INSTALL) -m 0755 $(GRADM_BIN) $(DESTDIR)/sbin
35+	@$(INSTALL) -m 0755 $(GRADM_BIN) $(DESTDIR)$(SBINDIR)
36 	@if [ -f $(GRADM_PAM) ] ; then \
37 		echo "Installing gradm_pam..." ; \
38-		$(INSTALL) -m 4755 $(GRADM_PAM) $(DESTDIR)/sbin ; \
39+		$(INSTALL) -m 4755 $(GRADM_PAM) $(DESTDIR)$(SBINDIR) ; \
40 	fi
41 	@echo "Installing grlearn..."
42-	@$(INSTALL) -m 0700 grlearn $(DESTDIR)/sbin
43+	@$(INSTALL) -m 0700 grlearn $(DESTDIR)$(SBINDIR)
44 	@mkdir -p -m 700 $(DESTDIR)$(GRSEC_DIR)
45 	@if [ ! -f $(DESTDIR)$(GRSEC_DIR)/policy ] ; then \
46 		if [ -f $(DESTDIR)$(GRSEC_DIR)/acl ] ; then \
47@@ -170,15 +171,15 @@ install: $(GRADM_BIN) gradm.8 policy grlearn
48 		echo "KERNEL==\"grsec\",          MODE=\"0622\"" >> $(DESTDIR)/etc/udev/rules.d/80-grsec.rules ; \
49 		echo "LABEL=\"permissions_end\"" >> $(DESTDIR)/etc/udev/rules.d/80-grsec.rules ; \
50 	fi
51-	@if [ -f $(DESTDIR)/sbin/udevadm ] ; then \
52-		$(DESTDIR)/sbin/udevadm trigger --action=change ; \
53+	@if [ -f $(DESTDIR)$(SBINDIR)/udevadm ] ; then \
54+		$(DESTDIR)$(SBINDIR)/udevadm trigger --action=change ; \
55 	fi
56 	@echo "Installing gradm manpage..."
57 	@mkdir -p $(DESTDIR)$(MANDIR)/man8
58 	@$(INSTALL) -m 0644 gradm.8 $(DESTDIR)$(MANDIR)/man8/$(GRADM_BIN).8
59-	@if [ -x /sbin/$(GRADM_BIN) ] ; then \
60+	@if [ -x $(SBINDIR)/$(GRADM_BIN) ] ; then \
61 		if [ -z $(DESTDIR) ] && [ ! -f $(GRSEC_DIR)/pw ] ; then \
62-			/sbin/$(GRADM_BIN) -P ; \
63+			$(SBINDIR)/$(GRADM_BIN) -P ; \
64 		fi \
65 	fi
66 	@true
67--
682.36.0
69
70