Skip to content

Commit

Permalink
add more traps
Browse files Browse the repository at this point in the history
  • Loading branch information
nazunalika committed Nov 29, 2023
1 parent e495571 commit 81cf38e
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
13 changes: 8 additions & 5 deletions func/core/pkg_freeradius/10-test-freeradius.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
#!/bin/bash
r_log "freeradius" "Test basic freeradius functionality"
function cleanup() {
cp /etc/raddb/users.backup /etc/raddb/users
rm -rf /etc/raddb/users.backup
systemctl stop radiusd.service
}

r_log "freeradius" "Test basic freeradius functionality"
r_log "freeradius" "Configure freeradius"
trap cleanup EXIT

cp /etc/raddb/users /etc/raddb/users.backup
cat >> /etc/raddb/users << EOF
rocky Cleartext-Password := "rocky"
Expand All @@ -13,7 +20,3 @@ systemctl start radiusd.service
sleep 1
echo "User-Name=rocky,User-Password=rocky " | radclient -x localhost:1812 auth testing123 | grep -q 'Access-Accept'
r_checkExitStatus $?

cp /etc/raddb/users.backup /etc/raddb/users
rm -rf /etc/raddb/users.backup
systemctl stop radiusd.service
1 change: 1 addition & 0 deletions func/core/pkg_git/11-test-clone-log.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
r_log "git" "Test basic git clones"
trap 'rm -rf $TMPREPO' EXIT

WORKDIR=$(pwd)
TMPREPO=/var/tmp/repo
Expand Down
4 changes: 1 addition & 3 deletions func/core/pkg_httpd/30-test-basic-auth.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash
r_log "httpd" "Test basic authentication functionality"
trap "rm /etc/httpd/conf.d/test-basic-auth.conf ; m_serviceCycler httpd reload" EXIT

cat > /etc/httpd/conf.d/test-basic-auth.conf <<EOF
## Core basic auth test
Expand All @@ -18,6 +19,3 @@ echo "Basic Auth Test" > /var/www/html/basic_auth/index.html
m_serviceCycler httpd cycle
curl -s -u tester:tester http://localhost/basic_auth/ | grep -q 'Basic Auth Test' > /dev/null 2>&1
r_checkExitStatus $?

rm /etc/httpd/conf.d/test-basic-auth.conf
m_serviceCycler httpd reload
11 changes: 7 additions & 4 deletions func/core/pkg_httpd/40-test-basic-vhost.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
#!/bin/bash
function cleanup() {
rm /etc/httpd/conf.d/vhost.conf
sed -i '/127.0.0.1 coretest/d' /etc/hosts
m_serviceCycler httpd reload
}

r_log "httpd" "Test basic vhost functionality"
trap cleanup EXIT

echo "127.0.0.1 coretest" >> /etc/hosts
cat > /etc/httpd/conf.d/vhost.conf << EOF
Expand All @@ -19,7 +26,3 @@ m_serviceCycler httpd cycle
curl -s http://coretest/ | grep -q 'core vhost test page' > /dev/null 2>&1

r_checkExitStatus $?

rm /etc/httpd/conf.d/vhost.conf
sed -i '/127.0.0.1 coretest/d' /etc/hosts
m_serviceCycler httpd reload
9 changes: 8 additions & 1 deletion func/core/pkg_shadow-utils/40-pw.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
#!/bin/bash
function cleanup() {
pwconv
rm -rf /var/tmp/pwunconv /var/tmp/pwconv
}

trap cleanup EXIT

r_log "shadow" "Check that pwck can use correct files"
pwck -rq ./common/files/correct-passwd ./common/files/correct-shadow
r_checkExitStatus $?
Expand All @@ -10,7 +17,7 @@ if [ "$ret_val" -eq 0 ]; then
r_log "shadow" "They're correct."
exit 1
fi
r_checkExitStatus 0
r_checkExitStatus $ret_val

r_log "shadow" "Check that pwconv is functional"
mkdir -p /var/tmp/pwconv
Expand Down

0 comments on commit 81cf38e

Please sign in to comment.