From 339278c5131eeac5a734c0d3407d4a0aae5c672b Mon Sep 17 00:00:00 2001 From: Valentin Vidic Date: Fri, 8 May 2009 17:03:50 +0200 Subject: [PATCH] Handle radiusd.conf upgrade. --- .../{radiusd.conf.expect => radiusd.conf.template} | 4 ++-- src/functions.sh | 20 +++++++++++++++++--- 2 files changed, 19 insertions(+), 5 deletions(-) rename files/etc/freeradius/{radiusd.conf.expect => radiusd.conf.template} (99%) diff --git a/files/etc/freeradius/radiusd.conf.expect b/files/etc/freeradius/radiusd.conf.template similarity index 99% rename from files/etc/freeradius/radiusd.conf.expect rename to files/etc/freeradius/radiusd.conf.template index 7906089..7586c66 100644 --- a/files/etc/freeradius/radiusd.conf.expect +++ b/files/etc/freeradius/radiusd.conf.template @@ -734,11 +734,11 @@ $INCLUDE ${confdir}/eap.conf # really can't emphasize this enough. # ldap { - server = "debian.local" + server = "#HOSTNAME#" # identity = "cn=admin,o=My Org,c=UA" # password = mypass port = 389 - basedn = "dc=local,dc=hr" + basedn = "#BASEDN#" filter = "(uid=%{Stripped-User-Name:-%{User-Name}})" # base_filter = "(objectclass=radiusprofile)" diff --git a/src/functions.sh b/src/functions.sh index cbb8be2..b29e43e 100644 --- a/src/functions.sh +++ b/src/functions.sh @@ -1039,7 +1039,7 @@ upgrade_amavis () { # handle freerdius config files upgrade upgrade_freeradius () { - local template config_new password realm + local template config_new password realm hostname basedn pkg freeradius-aai lt 2.1.3-0lenny0 || return 0 @@ -1047,10 +1047,24 @@ upgrade_freeradius () { restore_config freeradius-aai freeradius 2.1.3-0lenny0 \ /etc/freeradius/clients.conf \ /etc/freeradius/hints \ - /etc/freeradius/ldap.attrmap \ - /etc/freeradius/radiusd.conf + /etc/freeradius/ldap.attrmap # handle template based configs + template=/usr/share/carnet-upgrade/files/etc/freeradius/radiusd.conf.template + config_new=$(mktemp /var/lib/carnet-upgrade/radiusd.conf.XXXXXX) + basedn=$(sed -n '/^[[:space:]]*suffix[[:space:]]*/ { + s///; s/"//g; p; q }' /etc/ldap/slapd.conf) + hostname=$(hostname -f) + cp $template $config_new + sed -i "s/#HOSTNAME#/$hostname/" $config_new + sed -i "s/#BASEDN#/$basedn/" $config_new + if cmp -s $config_new /etc/freeradius/radiusd.conf >/dev/null; then + log "Restoring config file /etc/freeradius/radiusd.conf" + cp -v /usr/share/carnet-upgrade/files/etc/freeradius/radiusd.conf.restore \ + /etc/freeradius/radiusd.conf + fi + rm -f $config_new + template=/usr/share/carnet-upgrade/files/etc/freeradius/eap.conf.template config_new=$(mktemp /var/lib/carnet-upgrade/eap.conf.XXXXXX) password=$(grep -s '^[[:space:]]*private_key_password[[:space:]]*=' \ -- 1.7.10.4