From 9cd42e4576595fed873d7bb785638fbc71c16ed9 Mon Sep 17 00:00:00 2001 From: Dragan Dosen Date: Tue, 2 Sep 2008 20:27:27 +0200 Subject: [PATCH] debian/postinst: + validate php.ini configuration. (ticket #3938) + debconf-escape for error reporting. debian/control: + added a dependency on debconf (>= 1.4.72). --- debian/changelog | 16 ++++++++++++++++ debian/control | 2 +- debian/postinst | 30 ++++++++++++++++++++++++++++-- debian/templates | 14 ++++++++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 001d997..39377aa 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,19 @@ +php4-cn (4:4.4.4-6) stable; urgency=low + + * debian/postinst datoteka: + + provjera ispravnosti za postavke unutar php.ini + konfiguracijske datoteke - vrijednosti za postavke kao sto + su upload_max_filesize, post_max_size, memory_limit, ne + smiju zavrsavati sa 'B'; dozvoljene oznake su 'K' (kilo), + 'M' (mega) i 'G' (giga), npr. 16K, 32M, 1G. U protivnom, + kao mjerna jedinica koristit ce se 'byte' - korisnik je + informiran da provjeri konfiguraciju. (rijeseno: #3938) + + koristi se debconf-escape za ispis pogresno podesenih + postavki unutar php.ini datoteke. + * debian/control - ovisnost o debconf (>= 1.4.72). + + -- Dragan Dosen Tue, 2 Sep 2008 19:15:16 +0200 + php4-cn (4:4.4.4-5) stable; urgency=medium * dodana config skripta: diff --git a/debian/control b/debian/control index ac36990..27553db 100644 --- a/debian/control +++ b/debian/control @@ -8,7 +8,7 @@ Standards-Version: 3.6.1 Package: php4-cn Architecture: all -Depends: libapache2-mod-php4, php4-cli, php4-mysql, debconf, carnet-tools-cn (>= 2.4) +Depends: libapache2-mod-php4, php4-cli, php4-mysql, debconf (>= 1.4.72), carnet-tools-cn (>= 2.4) Conflicts: php5-cn Description: server-side, HTML-embedded scripting language (CARNet configuration) This package is a meta-package that, when installed, guarantees that you diff --git a/debian/postinst b/debian/postinst index d24ad5d..936c7aa 100755 --- a/debian/postinst +++ b/debian/postinst @@ -51,6 +51,20 @@ phpmemlimit () { echo $memlimit } +# phpinivalidate () +# +# Validate php.ini values. +# +phpinivalidate () { + + local ini_file + ini_file="$1" + + awk -F'[[:space:]]*=[[:space:]]*' \ + '/^[[:space:]]*[[:alpha:]_]+[[:space:]]*=[[:space:]]*[[:digit:]]+[MGK]B/ {print $1" = "$2}' \ + "$ini_file" +} + # Disable PHP5 module and enable Apache2 PHP4 module. # @@ -174,11 +188,10 @@ for SAPI in apache2 cli; do continue fi + ini_file="$PHP4DIR/$SAPI/php.ini" db_get php4-cn/${SAPI} || true if [ "$RET" = "true" ]; then - ini_file="$PHP4DIR/$SAPI/php.ini" - cp_echo "CN: Checking and enabling some specific parameters in file $ini_file" phplimit="$(phpmemlimit)M" @@ -222,6 +235,19 @@ for SAPI in apache2 cli; do rm -f "$ini_file_tmp" fi fi + + # Validate php.ini values. + if [ -f "$ini_file" ]; then + php4_inivalues="$(phpinivalidate "$ini_file")" + if [ -n "$php4_inivalues" ]; then + db_title php4-cn - konfiguracija za $(echo ${SAPI} | sed 's/a/A/;s/cli/CLI/') + db_subst php4-cn/inivalues php4_sapi $(echo ${SAPI} | sed 's/a/A/;s/cli/CLI/') + db_subst php4-cn/inivalues ini_file "$ini_file" + db_subst php4-cn/inivalues php4_inivalues "$(echo -n "$php4_inivalues" | debconf-escape -e)" + db_input critical php4-cn/inivalues || true + db_go || true + fi + fi done diff --git a/debian/templates b/debian/templates index f4889e4..471f93d 100644 --- a/debian/templates +++ b/debian/templates @@ -30,3 +30,17 @@ Description: Zelite li aktivirati preporucene PHP4 postavke za CLI? upload_max_filesize = 256M post_max_size = ${new_phplimit} memory_limit = ${new_phplimit} + +Template: php4-cn/inivalues +Type: note +Description: + Provjerom trenutne PHP4 konfiguracije za ${php4_sapi} (konfiguracijska + datoteka ${ini_file}), ustanovljeno je da sljedece postavke nisu ispravne: + . + ${php4_inivalues} + . + Vrijednosti za navedene postavke ne smiju zavrsavati sa 'B'. Dozvoljene + oznake su 'K' (kilo), 'M' (mega) i 'G' (giga), npr. 16K, 32M, 1G. U protivnom, + kao mjerna jedinica koristit ce se 'byte'. Molimo, svakako provjerite postavke + unutar navedene datoteke kako bi aplikacije (kao sto je Squirrelmail) mogle + normalno funkcionirati. -- 1.7.10.4