diff options
author | Jelmer Vernooij <jelmer@jelmer.uk> | 2016-12-24 01:19:58 +0000 |
---|---|---|
committer | Jelmer Vernooij <jelmer@jelmer.uk> | 2016-12-24 01:22:40 +0000 |
commit | a69c15e021186221394c7f8f51fbbe1f6b5da653 (patch) | |
tree | d5498e7402b249fd9fb6a0be67b48a2013684e44 /debian | |
parent | 4fb1fb27a04ff10eb576d3ca4e4e035e1779d640 (diff) |
Cherry-pick change to fix check-iprop races. Thanks, Nico Williams.
Diffstat (limited to 'debian')
-rw-r--r-- | debian/changelog | 1 | ||||
-rw-r--r-- | debian/patches/check_iprop_races | 296 | ||||
-rw-r--r-- | debian/patches/series | 1 |
3 files changed, 298 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog index 63c825a94..368cb10d9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,7 @@ heimdal (7.1.0+dfsg-1) UNRELEASED; urgency=medium these contain jsquery copies without source and are autogenerated. * Revert accidental patch to de.po that removed translations for Debian package. + * Cherry-pick change to fix check-iprop races. Thanks, Nico Williams. -- Jelmer Vernooij <jelmer@debian.org> Fri, 16 Dec 2016 01:46:37 +0000 diff --git a/debian/patches/check_iprop_races b/debian/patches/check_iprop_races new file mode 100644 index 000000000..2ef34206a --- /dev/null +++ b/debian/patches/check_iprop_races @@ -0,0 +1,296 @@ +commit d237e8e4d94943315a1e7235f5b618b5acaef958 +Author: Nicolas Williams <nico@twosigma.com> +Date: Wed Dec 21 13:52:10 2016 -0600 + + Fix check-iprop races + +diff --git a/lib/kadm5/ipropd_slave.c b/lib/kadm5/ipropd_slave.c +index 72cadbcd3..463a75631 100644 +--- a/lib/kadm5/ipropd_slave.c ++++ b/lib/kadm5/ipropd_slave.c +@@ -596,15 +596,21 @@ slave_status(krb5_context context, + const char *file, + const char *fmt, ...) + { +- char *status = NULL; ++ char *status; ++ char *fmt2; + va_list args; + int len; + ++ if (asprintf(&fmt2, "%s\n", fmt) == -1 || fmt2 == NULL) { ++ (void) unlink(file); ++ return; ++ } + va_start(args, fmt); +- len = vasprintf(&status, fmt, args); ++ len = vasprintf(&status, fmt2, args); ++ free(fmt2); + va_end(args); + if (len < 0 || status == NULL) { +- unlink(file); ++ (void) unlink(file); + return; + } + krb5_warnx(context, "slave status change: %s", status); +diff --git a/tests/kdc/check-iprop.in b/tests/kdc/check-iprop.in +index fb7eba4b1..1cc397c93 100644 +--- a/tests/kdc/check-iprop.in ++++ b/tests/kdc/check-iprop.in +@@ -58,6 +58,74 @@ kdc="${kdc} --addresses=localhost -P $port" + kadmin="${kadmin} -r $R" + kinit="${kinit} -c $cache ${afs_no_afslog}" + ++slave_ver_from_master_old= ++slave_ver_from_master_new= ++slave_ver_old= ++slave_ver_new= ++get_iprop_ver () { ++ min_change=${1:-1} ++ slave_ver_from_master_new=`grep '^iprop/' iprop-stats | head -1 | awk '{print $3}'` ++ slave_ver_new=`grep 'up-to-date with version:' iprop-slave-status | awk '{print $4}'` ++ if [ -z "$slave_ver_from_master_new" -o -z "$slave_ver_new" ]; then ++ return 1 ++ fi ++ if [ x"$slave_ver_from_master_new" != x"$slave_ver_new" ]; then ++ return 1 ++ fi ++ if [ x"$slave_ver_from_master_old" != x ]; then ++ change=`expr "$slave_ver_from_master_new" - "$slave_ver_from_master_old"` ++ if [ "$change" -lt "$min_change" ]; then ++ return 1 ++ fi ++ fi ++ slave_ver_from_master_old=$slave_ver_from_master_new ++ slave_ver_old=$slave_ver_new ++ return 0 ++} ++ ++waitsec=65 ++sleeptime=2 ++wait_for () { ++ msg=$1 ++ shift ++ t=0 ++ while ! "$@"; do ++ sleep $sleeptime; ++ t=`expr $t + $sleeptime` ++ if [ $t -gt $waitsec ]; then ++ echo "Waited too long for $msg" ++ exit 1 ++ fi ++ done ++ return 0 ++} ++ ++check_pidfile_is_dead () { ++ if test ! -f lt-${1}.pid -a ! -f ${1}.pid; then ++ return 0 ++ fi ++ _pid=`cat lt-${1}.pid ${1}.pid 2>/dev/null` ++ if [ -z "$_pid" ]; then ++ return 0 ++ fi ++ if kill -0 $_pid 2>/dev/null; then ++ return 1 ++ fi ++ return 0 ++} ++ ++wait_for_slave () { ++ wait_for "iprop versions to change and/or slave to catch up" get_iprop_ver "$@" ++} ++ ++wait_for_master_down () { ++ wait_for "master to exit" check_pidfile_is_dead ipropd-master ++} ++ ++wait_for_slave_down () { ++ wait_for "slave to exit" check_pidfile_is_dead ipropd-slave ++} ++ + KRB5_CONFIG="${objdir}/krb5.conf" + export KRB5_CONFIG + +@@ -145,7 +213,7 @@ ${ipropd_slave} --hostname=slave.test.h5l.se -k ${keytab} --detach localhost || + { echo "ipropd-slave failed to start"; exit 1; } + ipds=`getpid ipropd-slave` + sh ${wait_kdc} ipropd-slave messages.log 'slave status change: up-to-date' || exit 1 +-sleep 1 ++get_iprop_ver || exit 1 + + echo "checking slave is up" + ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1 +@@ -155,7 +223,7 @@ ${EGREP} 'up-to-date with version' iprop-slave-status >/dev/null || { echo "slav + + echo "Add host" + ${kadmin} -l add --random-key --use-defaults host/foo@${R} || exit 1 +-sleep 2 ++wait_for_slave + KRB5_CONFIG="${objdir}/krb5-slave.conf" \ + ${kadmin} -l get host/foo@${R} > /dev/null || exit 1 + +@@ -163,7 +231,7 @@ echo "Rollover host keys" + ${kadmin} -l cpw -r --keepold host/foo@${R} || exit 1 + ${kadmin} -l cpw -r --keepold host/foo@${R} || exit 1 + ${kadmin} -l cpw -r --keepold host/foo@${R} || exit 1 +-sleep 2 ++wait_for_slave 3 + KRB5_CONFIG="${objdir}/krb5-slave.conf" \ + ${kadmin} -l get host/foo@${R} | \ + ${EGREP} Keytypes: | cut -d: -f2 | tr ' ' ' +@@ -172,7 +240,7 @@ ${kadmin} -l get host/foo@${R} | \ + + echo "Delete 3DES keys" + ${kadmin} -l del_enctype host/foo@${R} des3-cbc-sha1 +-sleep 2 ++wait_for_slave + KRB5_CONFIG="${objdir}/krb5-slave.conf" \ + ${kadmin} -l get host/foo@${R} | \ + ${EGREP} Keytypes: | cut -d: -f2 | tr ' ' ' +@@ -184,13 +252,13 @@ ${kadmin} -l get host/foo@${R} | \ + + echo "Change policy host" + ${kadmin} -l modify --policy=default host/foo@${R} || exit 1 +-sleep 2 ++wait_for_slave + KRB5_CONFIG="${objdir}/krb5-slave.conf" \ + ${kadmin} -l get host/foo@${R} > /dev/null 2>/dev/null || exit 1 + + echo "Rename host" + ${kadmin} -l rename host/foo@${R} host/bar@${R} || exit 1 +-sleep 2 ++wait_for_slave + KRB5_CONFIG="${objdir}/krb5-slave.conf" \ + ${kadmin} -l get host/foo@${R} > /dev/null 2>/dev/null && exit 1 + KRB5_CONFIG="${objdir}/krb5-slave.conf" \ +@@ -198,7 +266,7 @@ ${kadmin} -l get host/bar@${R} > /dev/null || exit 1 + + echo "Delete host" + ${kadmin} -l delete host/bar@${R} || exit 1 +-sleep 2 ++wait_for_slave + KRB5_CONFIG="${objdir}/krb5-slave.conf" \ + ${kadmin} -l get host/bar@${R} > /dev/null 2>/dev/null && exit 1 + +@@ -212,7 +280,7 @@ echo "kill slave and remove log and database" + sh ${leaks_kill} ipropd-slave $ipds || exit 1 + rm -f iprop-slave-status + +-sleep 2 ++wait_for_slave_down + ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Down' iprop-stats >/dev/null || exit 1 + + # ----------------- checking: slave is missing changes while down +@@ -235,11 +303,11 @@ KRB5_CONFIG="${objdir}/krb5-slave.conf" \ + ${ipropd_slave} --hostname=slave.test.h5l.se -k ${keytab} --detach localhost || + { echo "ipropd-slave failed to start"; exit 1; } + ipds=`getpid ipropd-slave` +-sh ${wait_kdc} ipropd-slave messages.log 'slave status change: up-to-date' || exit 1 +-sleep 1 + + echo "checking slave is up again" +-${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1 ++wait_for "slave to start and connect to master" \ ++ ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null ++wait_for_slave 2 + ${EGREP} 'up-to-date with version' iprop-slave-status >/dev/null || { echo "slave not up to date" ; cat iprop-slave-status ; exit 1; } + echo "checking for replay problems" + ${EGREP} 'Entry already exists in database' messages.log && exit 1 +@@ -252,7 +320,7 @@ cmp master-last.tmp slave-last.tmp || exit 1 + + echo "kill slave and remove log and database" + sh ${leaks_kill} ipropd-slave $ipds || exit 1 +-sleep 2 ++wait_for_slave_down + + rm current.slave.log current-db.slave* || exit 1 + > iprop-stats +@@ -263,11 +331,11 @@ KRB5_CONFIG="${objdir}/krb5-slave.conf" \ + ${ipropd_slave} --hostname=slave.test.h5l.se -k ${keytab} --detach localhost || + { echo "ipropd-slave failed to start"; exit 1; } + ipds=`getpid ipropd-slave` +-sh ${wait_kdc} ipropd-slave messages.log 'slave status change: up-to-date' || exit 1 +-sleep 1 ++wait_for_slave 0 + + echo "checking slave is up again" +-${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1 ++wait_for "slave to start and connect to master" \ ++ ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null + ${EGREP} 'up-to-date with version' iprop-slave-status >/dev/null || { echo "slave not up to date" ; cat iprop-slave-status ; exit 1; } + echo "checking for replay problems" + ${EGREP} 'Entry already exists in database' messages.log && exit 1 +@@ -275,11 +343,11 @@ ${EGREP} 'Entry already exists in database' messages.log && exit 1 + # ----------------- checking: checking live truncation of master log + + ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1 +-sleep 2 ++wait_for_slave + + echo "live truncate on master log" + ${iprop_log} truncate -K 5 || exit 1 +-sleep 2 ++wait_for_slave 0 + + echo "Killing master and slave" + sh ${leaks_kill} ipropd-master $ipdm || exit 1 +@@ -287,8 +355,8 @@ sh ${leaks_kill} ipropd-slave $ipds || exit 1 + + rm -f iprop-slave-status + +-#sleep 2 +-#${EGREP} "^master down at " iprop-stats > /dev/null || exit 1 ++wait_for_slave_down ++wait_for_master_down + + echo "compare versions on master and slave logs" + KRB5_CONFIG=${objdir}/krb5-slave.conf \ +@@ -316,25 +384,26 @@ KRB5_CONFIG="${objdir}/krb5-slave.conf" \ + ${ipropd_slave} --hostname=slave.test.h5l.se -k ${keytab} --detach localhost || + { echo "ipropd-slave failed to start"; exit 1; } + ipds=`getpid ipropd-slave` +-sh ${wait_kdc} ipropd-slave messages.log 'slave status change: up-to-date' || exit 1 +-sleep 1 ++wait_for_slave -1 + + echo "checking slave is up again" +-${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null || exit 1 ++wait_for "slave to start and connect to master" \ ++ ${EGREP} 'iprop/slave.test.h5l.se@TEST.H5L.SE.*Up' iprop-stats >/dev/null + ${EGREP} 'up-to-date with version' iprop-slave-status >/dev/null || { echo "slave to up to date" ; cat iprop-slave-status ; exit 1; } + echo "checking for replay problems" + ${EGREP} 'Entry already exists in database' messages.log && exit 1 + + echo "pushing one change" + ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1 +-sleep 2 ++wait_for_slave + + echo "Killing master" + sh ${leaks_kill} ipropd-master $ipdm || exit 1 + +-sleep 4 ++wait_for_master_down + +-${EGREP} 'disconnected' iprop-slave-status >/dev/null && { echo "slave still think its connected" ; cat iprop-slave-status ; exit 1; } ++wait_for "slave to disconnect" \ ++ ${EGREP} 'disconnected' iprop-slave-status >/dev/null + + if ! tail -30 messages.log | grep 'disconnected for server' > /dev/null; then + echo "client didnt disconnect" +@@ -356,13 +425,10 @@ ipdm=`getpid ipropd-master` + echo "probing for slave pid" + kill -0 ${ipds} || { echo "slave no longer there"; exit 1; } + +-sh ${wait_kdc} ipropd-slave messages.log "connection successful to master" || exit 1 +- +-sh ${wait_kdc} ipropd-slave messages.log "ipropd-slave started at version" || exit 1 + + echo "pushing one change" + ${kadmin} -l cpw --random-password user@${R} > /dev/null || exit 1 +-sleep 2 ++wait_for_slave + + echo "shutting down all services" + diff --git a/debian/patches/series b/debian/patches/series index b951b5926..8a44b0e91 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -11,3 +11,4 @@ installsh 047_link_gssapi 060_no_build_string parallel-build +check_iprop_races |