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: v0.94.7~3^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=94da46b6e31cac206cb32fc5bd3159209ee25e8c;p=ceph.git tests: make sure no segfault occurs when using some bad keyring Signed-off-by: Dunrong Huang (cherry picked from commit 2eb0bf32244fc174d56cc42e2298c67d8b5299ac) Signed-off-by: Brad Hubbard --- diff --git a/src/test/mon/misc.sh b/src/test/mon/misc.sh index 0351bd48a79a..24f6998d23fd 100755 --- a/src/test/mon/misc.sh +++ b/src/test/mon/misc.sh @@ -84,7 +84,28 @@ function TEST_osd_pool_get_set() { } -main misc +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: # compile-command: "cd ../.. ; make -j4 && test/mon/misc.sh"