Skip to content

Commit

Permalink
ensure that /usr/local/pf/conf/system_init_key is created
Browse files Browse the repository at this point in the history
  • Loading branch information
jrouzierinverse committed Feb 26, 2025
1 parent 3be0b6d commit d3bca92
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
11 changes: 7 additions & 4 deletions debian/packetfence-config.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ set -e

DIST=$(lsb_release -c -s)

setup_system_init_key() {
if [ ! -f /usr/local/pf/conf/system_init_key ]; then
hexdump -e '/1 "%x"' < /dev/urandom | head -c 32 > /usr/local/pf/conf/system_init_key
fi
}

case "$1" in
configure)
if [ ! -f /usr/local/pf/conf/pfconfig.conf ]; then
Expand All @@ -29,10 +35,7 @@ case "$1" in
echo "pfconfig.conf already exists, won't touch it!"
fi

if [ ! -f /usr/local/pf/conf/system_init_key ]; then
hexdump -e '/1 "%x"' < /dev/urandom | head -c 32 > /usr/local/pf/conf/system_init_key
fi

setup_system_init_key
/sbin/ldconfig
if [ ${DIST} = "jessie" ] || [ ${DIST} = "stretch" ] || [ ${DIST} = "bullseye" ] || [ ${DIST} = "bookworm" ]; then
systemctl enable packetfence-config
Expand Down
7 changes: 7 additions & 0 deletions debian/packetfence-config.preinst
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ stop_service_if_exists() {
fi
}

setup_system_init_key() {
if [ ! -f /usr/local/pf/conf/system_init_key ]; then
hexdump -e '/1 "%x"' < /dev/urandom | head -c 32 > /usr/local/pf/conf/system_init_key
fi
}

case "$1" in
install)
setup_system_init_key
if grep -E "^pf:" /etc/passwd > /dev/null ; then
echo "pf user already exist"
else
Expand All @@ -37,6 +43,7 @@ case "$1" in
exit 0
;;
upgrade)
setup_system_init_key
stop_service_if_exists packetfence-config
set +e
/usr/sbin/update-rc.d -f packetfence-config remove
Expand Down
7 changes: 7 additions & 0 deletions debian/packetfence.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,15 @@ export LC_CTYPE

DIST=$(lsb_release -c -s)

setup_system_init_key() {
if [ ! -f /usr/local/pf/conf/system_init_key ]; then
hexdump -e '/1 "%x"' < /dev/urandom | head -c 32 > /usr/local/pf/conf/system_init_key
fi
}

case "$1" in
configure)
setup_system_init_key
export PACKETFENCE=/usr/local/pf
export PERL5LIB=/usr/local/pf/lib
find $PACKETFENCE/conf -type f -exec chmod 664 '{}' \;
Expand Down
8 changes: 8 additions & 0 deletions debian/packetfence.preinst
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,15 @@ rm_conffile() {
fi
}

setup_system_init_key() {
if [ ! -f /usr/local/pf/conf/system_init_key ]; then
hexdump -e '/1 "%x"' < /dev/urandom | head -c 32 > /usr/local/pf/conf/system_init_key
fi
}

case "$1" in
install)
setup_system_init_key
stop_service_if_exists packetfence
if [ -z "$(getent passwd pf)" ]; then
if ! /usr/bin/id -g pf &>/dev/null; then
Expand Down Expand Up @@ -85,6 +92,7 @@ case "$1" in
;;

upgrade)
setup_system_init_key
# mv the old raddb dir if upgrading from FreeRADIUS 2
echo "Upgrading from $2"
if dpkg --compare-versions "$2" lt "6"; then
Expand Down

0 comments on commit d3bca92

Please sign in to comment.