From: Dunrong Huang Date: Mon, 7 Dec 2015 16:22:02 +0000 (+0800) Subject: tests: make sure no segfault occurs when using some bad keyring X-Git-Tag: v10.0.2~51^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F6698%2Fhead;p=ceph.git tests: make sure no segfault occurs when using some bad keyring Signed-off-by: Dunrong Huang --- diff --git a/src/test/mon/misc.sh b/src/test/mon/misc.sh index c11c0eb0d5d5..d280a67791d6 100755 --- a/src/test/mon/misc.sh +++ b/src/test/mon/misc.sh @@ -118,6 +118,27 @@ function TEST_mon_add_to_single_mon() { teardown $dir || return 1 } +function TEST_no_segfault_for_bad_keyring() { + local dir=$1 + setup $dir || return 1 + # create a client.admin key and add it to ceph.mon.keyring + ceph-authtool --create-keyring $dir/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *' + ceph-authtool --create-keyring $dir/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' + ceph-authtool $dir/ceph.mon.keyring --import-keyring $dir/ceph.client.admin.keyring + CEPH_ARGS_TMP="--fsid=$(uuidgen) --mon-host=127.0.0.1:7102 --auth-supported=cephx " + CEPH_ARGS_orig=$CEPH_ARGS + CEPH_ARGS="$CEPH_ARGS_TMP --keyring=$dir/ceph.mon.keyring " + run_mon $dir a + # create a bad keyring and make sure no segfault occurs when using the bad keyring + echo -e "[client.admin]\nkey = BQAUlgtWoFePIxAAQ9YLzJSVgJX5V1lh5gyctg==" > $dir/bad.keyring + CEPH_ARGS="$CEPH_ARGS_TMP --keyring=$dir/bad.keyring" + ceph osd dump 2> /dev/null + # 139(11|128) means segfault and core dumped + [ $? -eq 139 ] && return 1 + CEPH_ARGS=$CEPH_ARGS_orig + teardown $dir || return 1 +} + main misc "$@" # Local Variables: