-
Notifications
You must be signed in to change notification settings - Fork 91
222 lines (186 loc) · 6.76 KB
/
ci-deb.yml
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
name: "CI DEB"
on:
push:
branches-ignore:
- coverity_scan
pull_request:
env:
DEBIAN_FRONTEND: noninteractive
CI: 1
CI_TEST_USER: tapioca
CI_TEST_PASS: queijo
GH_ACTIONS: 1
jobs:
pre-ci:
runs-on: ubuntu-latest
# Map a step output to a job output
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
steps:
- id: skip_check
uses: fkirc/skip-duplicate-actions@master
deb-build:
# If branch protection is in place with status checks enabled, ensure
# names are updated if new matrix entries are added or the name format
# changes.
name: "DEB Build (${{ matrix.env.NAME }})"
needs: pre-ci
if: ${{ needs.pre-ci.outputs.should_skip != 'true' }}
runs-on: ubuntu-latest
container:
image: ${{ matrix.env.OS }}
strategy:
fail-fast: false
matrix:
env:
- { "NAME": "ubuntu20", "OS": "ubuntu:20.04", "DIST": "ubuntu" }
- { "NAME": "ubuntu22", "OS": "ubuntu:22.04", "DIST": "ubuntu" }
- { "NAME": "ubuntu24", "OS": "ubuntu:24.04", "DIST": "ubuntu" }
- { "NAME": "debian10", "OS": "debian:10", "DIST": "debian" }
- { "NAME": "debian11", "OS": "debian:11", "DIST": "debian" }
- { "NAME": "debian12", "OS": "debian:12", "DIST": "debian" }
steps:
- name: "Package manager performance improvements"
run: |
sh -c 'echo force-unsafe-io > /etc/dpkg/dpkg.cfg.d/02speedup'
- name: "Install prerequisites"
run: |
apt-get update
apt-get install -y --no-install-recommends \
build-essential \
devscripts \
equivs \
fakeroot \
quilt \
libpam0g-dev
- uses: actions/checkout@v4
with:
lfs: false
path: pam_radius
- name: "Install build dependencies"
working-directory: pam_radius
run: |
mk-build-deps -irt"apt-get -y --no-install-recommends" scripts/ci/extra-packages.debian.control
- name: "Build pam_radius packages"
working-directory: pam_radius
run: |
make deb
- name: "Install pam_radius package"
run: |
echo "#######################################################"
echo "# Install package"
dpkg -i libpam-radius-auth_*.deb
echo "#######################################################"
echo "# Show package info"
dpkg -s libpam-radius-auth
echo "#######################################################"
echo "# List package contents"
dpkg -L libpam-radius-auth
- name: "Create test user"
run: |
useradd -d /tmp ${CI_TEST_USER}
id ${CI_TEST_USER}
- name: "Install packages for testing"
run: |
apt-get update
apt-get install -y --no-install-recommends \
freeradius \
freeradius-utils \
freeradius-config \
openssh-server \
rsyslog \
sshpass
- name: "Setup FreeRADIUS, sshd, rsyslog and PAM"
working-directory: pam_radius
run: |
echo "#######################################################"
echo "# Kill services"
pkill -9 rsyslogd || :
pkill -9 freeradius || :
pkill -9 sshd || :
echo "#######################################################"
echo "# Run setup scripts"
export CI_TEST_USER="$CI_TEST_USER" CI_TEST_PASS="$CI_TEST_PASS"
for FILE in setup-rsyslog.sh setup-pam_radius.sh setup-freeradius.sh setup-sshd.sh; do
SCRIPT="${PWD}/scripts/ci/$FILE"
echo "Calling $FILE"
$SCRIPT
done
echo "#######################################################"
echo "# Start services"
/usr/sbin/rsyslogd
/usr/sbin/sshd
/usr/sbin/freeradius
echo "#######################################################"
echo "# Show processes"
ps -ef
- name: "Show config files"
run: |
for FILE in \
/etc/ssh/sshd_config \
/etc/pam.d/sshd \
/etc/pam_radius_auth.conf
do
echo "#####################################################"
echo "# $FILE"
echo
cat "$FILE"
echo
done
- name: "Positive authentication tests"
run: |
: > /var/log/auth.log
radtest -x "$CI_TEST_USER" "$CI_TEST_PASS" localhost 0 testing123
sshpass -p "${CI_TEST_PASS}" -v \
/usr/bin/ssh -T -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 22 ${CI_TEST_USER}@localhost \
"echo 'User logged in successfully' > /tmp/OK"
cat /tmp/OK
grep -q "pam_radius_auth: authentication succeeded" /var/log/auth.log
! grep -q "pam_radius_auth: authentication failed" /var/log/auth.log
- name: "Show positive auth logs"
run: |
cat -n /var/log/auth.log
- name: "Negative authentication tests"
run: |
: > /var/log/auth.log
if radtest -x "$CI_TEST_USER" "not$CI_TEST_PASS" localhost 0 testing123; then
echo "Something bad happened - this radtest authentication should have failed"
exit 1
fi
if sshpass -p "not$CI_TEST_PASS" -v \
/usr/bin/ssh -T -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -p 22 ${CI_TEST_USER}@localhost \
"echo NOTOK > /tmp/NOTOK"; then
echo "Something bad happened - this ssh authentication should have failed"
exit 1
fi
grep -q "pam_radius_auth: authentication failed" /var/log/auth.log
! grep -q "pam_radius_auth: authentication succeeded" /var/log/auth.log
- name: "Show negative auth logs"
if: ${{ success() || failure() }}
run: |
cat -n /var/log/auth.log
#
# If the CI has failed and the branch is ci-debug then we start a tmate
# session to provide interactive shell access to the session.
#
# The SSH rendezvous point will be emitted continuously in the job output,
# which will look something like:
#
# SSH: ssh [email protected]
#
# For example:
#
# git push origin ci-debug --force
#
# Look at the job output in: https://github.com/FreeRADIUS/freeradius-server/actions
#
# ssh [email protected]
#
# Access requires that you have the private key corresponding to the
# public key of the GitHub user that initiated the job.
#
- name: "Debug: Start tmate"
uses: mxschmitt/action-tmate@v3
with:
limit-access-to-actor: true
if: ${{ github.ref == 'refs/heads/ci-debug' && failure() }}