summaryrefslogtreecommitdiff
path: root/regress/sys/kern/setuid/Makefile
blob: 2429092f96274a5f6ecae072a9a9b178de780610 (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
131
132
133
134
135
136
#	$OpenBSD: Makefile,v 1.4 2016/11/28 22:27:10 bluhm Exp $

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

.if ! empty (MOUNT_NOSUID)
regress:
	echo '${MOUNT_NOSUID}'
	echo temporary 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

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

CLEANFILES+=	*.o ${BINFILES}

.ifmake !clean && !cleandir && !depend && !obj
DIR !!=		mktemp -d -t setuid-regress-XXXXXXXXXX
.BEGIN:
	@chmod 755 ${DIR}
.END:
	@rm -rf -- ${DIR}
.endif

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

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

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

install-suidexec: suidexec
	@${INSTALL} -o nobody -m 4555 suidexec ${DIR}
install-sgidexec: sgidexec
	@${INSTALL} -g nobody -m 2555 sgidexec ${DIR}
.for f in ${BINFILES}
install: install-${f}
install-${f}: ${f}
	@${INSTALL} $f ${DIR}
.endfor

.include <bsd.regress.mk>