1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
|
From 3249c2696468bc82ec45f4fcabddc390473a45da Mon Sep 17 00:00:00 2001
From: David Seifert <soap@gentoo.org>
Date: Sat, 4 Sep 2021 10:39:34 +0200
Subject: [PATCH 1/3] Build system fixes
Summary:
- Always keep $(WARNINGS) when overriding CFLAGS
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
---
Make.Rules | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/Make.Rules b/Make.Rules
index 3eeb098..00f2a03 100644
--- a/Make.Rules
+++ b/Make.Rules
@@ -78,10 +78,11 @@ OBJCOPY := $(CROSS_COMPILE)objcopy
DEBUG = # -g -DDEBUG
WARNINGS=-Wall -Wwrite-strings -Wpointer-arith -Wcast-qual -Wcast-align \
- -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs \
+ -Wstrict-prototypes -Wmissing-prototypes -Wnested-externs \
-Winline -Wshadow
COPTS ?= -O2
-CFLAGS ?= $(COPTS) $(WARNINGS) $(DEBUG)
+CFLAGS ?= $(COPTS) $(DEBUG)
+CFLAGS += $(WARNINGS)
CPPFLAGS += -Dlinux $(DEFINES) $(LIBCAP_INCLUDES)
LDFLAGS ?= # -g
--
2.33.0
From 99799844ad9272d43892881d1090369e6032aec2 Mon Sep 17 00:00:00 2001
From: "Andrew G. Morgan" <morgan@kernel.org>
Date: Sat, 4 Sep 2021 11:42:24 -0700
Subject: [PATCH 2/3] Don't build the tests/binaries until we want to run them
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
---
tests/Makefile | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/tests/Makefile b/tests/Makefile
index dd78432..ecb7d1b 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -8,12 +8,10 @@ include ../Make.Rules
#
all:
- $(MAKE) libcap_launch_test uns_test
-ifeq ($(PTHREADS),yes)
- $(MAKE) psx_test libcap_psx_test libcap_psx_launch_test
-endif
+ @echo leave test building to test target
-install: all
+install:
+ @echo nothing to install from tests
ifeq ($(DYNAMIC),yes)
LINKEXTRA=-Wl,-rpath,../libcap
--
2.33.0
From 5ef14d07420c299ecd8de96928a5d1ce1e232df3 Mon Sep 17 00:00:00 2001
From: "Andrew G. Morgan" <morgan@kernel.org>
Date: Sat, 4 Sep 2021 14:05:11 -0700
Subject: [PATCH 3/3] Refactor top level Makefile to reduce redundant building
Make build a bit quicker for folk that don't want to run tests.
Signed-off-by: Andrew G. Morgan <morgan@kernel.org>
---
Makefile | 28 +++++-----------------------
doc/Makefile | 6 ++++++
go/Makefile | 5 +++--
libcap/Makefile | 3 +++
pam_cap/Makefile | 2 +-
progs/Makefile | 5 +++--
6 files changed, 21 insertions(+), 28 deletions(-)
diff --git a/Makefile b/Makefile
index 1c195dd..9ee11c8 100644
--- a/Makefile
+++ b/Makefile
@@ -8,7 +8,7 @@ include Make.Rules
# flags
#
-all install clean: %: %-here
+all test sudotest install clean: %: %-here
$(MAKE) -C libcap $@
ifneq ($(PAM_CAP),no)
$(MAKE) -C pam_cap $@
@@ -20,10 +20,13 @@ endif
$(MAKE) -C tests $@
$(MAKE) -C progs $@
$(MAKE) -C doc $@
- $(MAKE) -C kdebug $@
all-here:
+test-here:
+
+sudotest-here:
+
install-here:
clean-here:
@@ -41,30 +44,9 @@ distclean: clean
release: distclean
cd .. && ln -s libcap libcap-$(VERSION).$(MINOR) && tar cvf libcap-$(VERSION).$(MINOR).tar --exclude patches libcap-$(VERSION).$(MINOR)/* && rm libcap-$(VERSION).$(MINOR)
-test: all
- $(MAKE) -C libcap $@
- $(MAKE) -C tests $@
-ifneq ($(PAM_CAP),no)
- $(MAKE) -C pam_cap $@
-endif
-ifeq ($(GOLANG),yes)
- $(MAKE) -C go $@
-endif
- $(MAKE) -C progs $@
-
ktest: all
$(MAKE) -C kdebug test
-sudotest: all
- $(MAKE) -C tests $@
-ifneq ($(PAM_CAP),no)
- $(MAKE) -C pam_cap $@
-endif
-ifeq ($(GOLANG),yes)
- $(MAKE) -C go $@
-endif
- $(MAKE) -C progs $@
-
distcheck:
./distcheck.sh
$(MAKE) DYNAMIC=no COPTS="-D_FORTIFY_SOURCE=2 -O1 -g" clean test
diff --git a/doc/Makefile b/doc/Makefile
index e2802dc..9614180 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -32,6 +32,12 @@ MANS = $(MAN1S) $(MAN3S) $(MAN8S)
all: $(MANS)
+test:
+ @echo no doc tests available
+
+sudotest:
+ @echo no doc sudotests available
+
.PHONY: html
html:
mkdir -p html
diff --git a/go/Makefile b/go/Makefile
index 5af5321..2b2061b 100644
--- a/go/Makefile
+++ b/go/Makefile
@@ -14,8 +14,9 @@ IMPORTDIR=kernel.org/pub/linux/libs/security/libcap
PKGDIR=pkg/$(GOOSARCH)/$(IMPORTDIR)
DEPS=../libcap/libcap.a ../libcap/libpsx.a
+TESTS=compare-cap try-launching psx-signals
-all: PSXGOPACKAGE CAPGOPACKAGE web setid gowns captree compare-cap try-launching psx-signals
+all: PSXGOPACKAGE CAPGOPACKAGE web setid gowns captree
$(DEPS):
$(MAKE) -C ../libcap all
@@ -93,7 +94,7 @@ endif
b210613: b210613.go CAPGOPACKAGE
CC="$(CC)" CGO_ENABLED="$(CGO_REQUIRED)" $(CGO_LDFLAGS_ALLOW) CGO_CFLAGS="$(CGO_CFLAGS)" CGO_LDFLAGS="$(CGO_LDFLAGS)" $(GO) build -mod=vendor $<
-test: all
+test: all $(TESTS)
CC="$(CC)" CGO_ENABLED="$(CGO_REQUIRED)" $(CGO_LDFLAGS_ALLOW) $(GO) test -mod=vendor $(IMPORTDIR)/psx
CC="$(CC)" CGO_ENABLED="$(CGO_REQUIRED)" $(CGO_LDFLAGS_ALLOW) $(GO) test -mod=vendor $(IMPORTDIR)/cap
LD_LIBRARY_PATH=../libcap ./compare-cap
diff --git a/libcap/Makefile b/libcap/Makefile
index 4b96a0c..84340f2 100644
--- a/libcap/Makefile
+++ b/libcap/Makefile
@@ -148,6 +148,9 @@ ifeq ($(PTHREADS),yes)
endif
endif
+sudotest:
+ @echo no sudotests for libcap
+
install: install-static
ifeq ($(SHARED),yes)
$(MAKE) install-shared
diff --git a/pam_cap/Makefile b/pam_cap/Makefile
index b245307..a000978 100644
--- a/pam_cap/Makefile
+++ b/pam_cap/Makefile
@@ -72,7 +72,7 @@ test: testlink test_pam_cap pam_cap.so
LD_LIBRARY_PATH=../libcap ./pam_cap.so --help
@echo "module can be run as an executable!"
-sudotest: test test_pam_cap
+sudotest: test_pam_cap
$(SUDO) ./test_pam_cap root 0x0 0x0 0x0 config=./capability.conf
$(SUDO) ./test_pam_cap root 0x0 0x0 0x0 config=./sudotest.conf
$(SUDO) ./test_pam_cap alpha 0x0 0x0 0x0 config=./capability.conf
diff --git a/progs/Makefile b/progs/Makefile
index 2f887c8..e2bd7fe 100644
--- a/progs/Makefile
+++ b/progs/Makefile
@@ -42,7 +42,8 @@ ifeq ($(RAISE_SETFCAP),yes)
$(FAKEROOT)$(SBINDIR)/setcap cap_setfcap=i $(FAKEROOT)$(SBINDIR)/setcap
endif
-test: $(PROGS) capsh
+test:
+ @echo "no program tests without privilege, try 'make sudotest'"
capshdoc.h.cf: capshdoc.h ./mkcapshdoc.sh
./mkcapshdoc.sh > $@
@@ -60,7 +61,7 @@ uns_test: ../tests/uns_test.c
$(MAKE) -C ../tests uns_test
cp ../tests/uns_test .
-sudotest: test tcapsh-static uns_test
+sudotest: tcapsh-static uns_test
$(SUDO) $(LDPATH) ./quicktest.sh
clean:
--
2.33.0
|