]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tests: make sure no segfault occurs when using some bad keyring
authorDunrong Huang <riegamaths@gmail.com>
Mon, 7 Dec 2015 16:22:02 +0000 (00:22 +0800)
committerBrad Hubbard <bhubbard@redhat.com>
Fri, 4 Mar 2016 02:06:43 +0000 (12:06 +1000)
Signed-off-by: Dunrong Huang <riegamaths@gmail.com>
(cherry picked from commit 2eb0bf32244fc174d56cc42e2298c67d8b5299ac)
Signed-off-by: Brad Hubbard <bhubbard@redhat.com>
src/test/mon/misc.sh

index 0351bd48a79a8427120b063c0d9bc97f18a5e312..24f6998d23fd25cbb7fd6c8300209f144ae634c2 100755 (executable)
@@ -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"