Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensure that /usr/local/pf/conf/system_init_key is created #8571

Open
wants to merge 1 commit into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, this is the earliest place to put in, correct?
I recall that you said it needs to be as soon as possible.

/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