summaryrefslogtreecommitdiff
path: root/regress/sys/kern/setuid/Makefile
blob: aad454875d6d5e4fedab8fe8784e501ab7c9a29b (plain)
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
#	$OpenBSD: Makefile,v 1.3 2016/10/05 16:53:34 bluhm Exp $

MOUNT_NOSUID != mount | grep ^$$(df -P . | tail -1 | awk '{ print $$1 }') | \
    grep nosuid || true

.if ! empty (MOUNT_NOSUID)
regress:
	echo '${MOUNT_NOSUID}'
	echo object directory is mounted nosuid, test needs set user id
	echo SKIPPED
.endif

CFLAGS			+= -Wall -Wformat -pedantic

REGRESS_TARGETS+=	run-regress-setuid_none
REGRESS_TARGETS+=	run-regress-setgid_none
REGRESS_TARGETS+=	run-regress-setuid
REGRESS_TARGETS+=	run-regress-setgid
REGRESS_TARGETS+=	run-regress-seteuid
REGRESS_TARGETS+=	run-regress-setegid
REGRESS_TARGETS+=	run-regress-setuid_child
REGRESS_TARGETS+=	run-regress-setgid_child
REGRESS_TARGETS+=	run-regress-setresuid
REGRESS_TARGETS+=	run-regress-setresgid
REGRESS_TARGETS+=	run-regress-suidexec-on-inherit-on
REGRESS_TARGETS+=	run-regress-suidexec-on-inherit-inherit
REGRESS_TARGETS+=	run-regress-suidexec-off-on-inherit
REGRESS_TARGETS+=	run-regress-suidexec-off-off-on
REGRESS_TARGETS+=	run-regress-sgidexec-on-inherit-on
REGRESS_TARGETS+=	run-regress-sgidexec-on-inherit-inherit
REGRESS_TARGETS+=	run-regress-sgidexec-off-on-inherit
REGRESS_TARGETS+=	run-regress-sgidexec-off-off-on
REGRESS_TARGETS+=	run-regress-suidexec-real-exec-inherit
REGRESS_TARGETS+=	run-regress-suidexec-effective-exec-inherit
REGRESS_TARGETS+=	run-regress-suidexec-saved-exec-inherit
REGRESS_TARGETS+=	run-regress-sgidexec-real-exec-inherit
REGRESS_TARGETS+=	run-regress-sgidexec-effective-exec-inherit
REGRESS_TARGETS+=	run-regress-sgidexec-saved-exec-inherit

CLEANFILES+=	*.o
CLEANFILES+=	setuid_none
CLEANFILES+=	setgid_none
CLEANFILES+=	setuid
CLEANFILES+=	setgid
CLEANFILES+=	seteuid
CLEANFILES+=	setegid
CLEANFILES+=	setuid_child
CLEANFILES+=	setgid_child
CLEANFILES+=	setresuid
CLEANFILES+=	setresgid
CLEANFILES+=	setresuid_real_exec
CLEANFILES+=	setresuid_effective_exec
CLEANFILES+=	setresuid_saved_exec
CLEANFILES+=	suidexec_none
CLEANFILES+=	suidexec
CLEANFILES+=	sgidexec
CLEANFILES+=	setresgid_real_exec
CLEANFILES+=	setresgid_effective_exec
CLEANFILES+=	setresgid_saved_exec
CLEANFILES+=	sgidexec_none
CLEANFILES+=	suidexec_inherit
CLEANFILES+=	sgidexec_inherit
CLEANFILES+=	setuid_exec_inherit
CLEANFILES+=	setgid_exec_inherit

run-regress-setuid_none: setuid_none
	./setuid_none
run-regress-setgid_none: setgid_none
	./setgid_none
run-regress-setuid: setuid
	${SUDO} ./setuid
run-regress-setgid: setgid
	${SUDO} ./setgid
run-regress-seteuid: seteuid
	${SUDO} ./seteuid
run-regress-setegid: setegid
	${SUDO} ./setegid
run-regress-setuid_child: setuid_child
	${SUDO} ./setuid_child
run-regress-setgid_child: setgid_child
	${SUDO} ./setgid_child
run-regress-setresuid: setresuid
	${SUDO} ./setresuid
run-regress-setresgid: setresgid
	${SUDO} ./setresgid

run-regress-suidexec-on-inherit-on: suidexec-install
	${SUDO} ./suidexec ./suidexec_inherit ./suidexec
run-regress-suidexec-off-on-inherit: suidexec-install
	${SUDO} ./suidexec_none ./suidexec ./suidexec_inherit
run-regress-suidexec-on-inherit-inherit: suidexec-install
	${SUDO} ./suidexec ./suidexec_inherit ./suidexec_inherit
run-regress-suidexec-off-off-on: suidexec-install
	${SUDO} ./suidexec_none ./suidexec_none ./suidexec
run-regress-suidexec-real-exec-inherit: suidexec-install
	${SUDO} ./setresuid_real_exec ./setuid_exec_inherit
run-regress-suidexec-effective-exec-inherit: suidexec-install
	${SUDO} ./setresuid_effective_exec ./setuid_exec_inherit
run-regress-suidexec-saved-exec-inherit: suidexec-install
	${SUDO} ./setresuid_saved_exec ./setuid_exec_inherit

run-regress-sgidexec-on-inherit-on: sgidexec-install
	${SUDO} ./sgidexec ./sgidexec_inherit ./sgidexec
run-regress-sgidexec-off-on-inherit: sgidexec-install
	${SUDO} ./sgidexec_none ./sgidexec ./sgidexec_inherit
run-regress-sgidexec-on-inherit-inherit: sgidexec-install
	${SUDO} ./sgidexec ./sgidexec_inherit ./sgidexec_inherit
run-regress-sgidexec-off-off-on: sgidexec-install
	${SUDO} ./sgidexec_none ./sgidexec_none ./sgidexec
run-regress-sgidexec-real-exec-inherit: sgidexec-install
	${SUDO} ./setresgid_real_exec ./setgid_exec_inherit
run-regress-sgidexec-effective-exec-inherit: sgidexec-install
	${SUDO} ./setresgid_effective_exec ./setgid_exec_inherit
run-regress-sgidexec-saved-exec-inherit: sgidexec-install
	${SUDO} ./setresgid_saved_exec ./setgid_exec_inherit

suidexec-install: suidexec suidexec_none suidexec_inherit setresuid_real_exec setresuid_effective_exec setresuid_saved_exec setuid_exec_inherit
	${SUDO} chown nobody:nobody ./suidexec
	${SUDO} chmod 4555 ./suidexec

sgidexec-install: sgidexec sgidexec_none sgidexec_inherit setresgid_real_exec setresgid_effective_exec setresgid_saved_exec setgid_exec_inherit
	${SUDO} chown nobody:nobody ./sgidexec
	${SUDO} chmod 2555 ./sgidexec

.include <bsd.regress.mk>

.ifmake all || regress
.END:
	${SUDO} chmod 0555 ./suidexec ./sgidexec
.endif