aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2013-12-19 10:53:53 +0000
committerDavid Howells <dhowells@redhat.com>2013-12-19 10:53:53 +0000
commit097fd4c381b669b99687517c422396198e5b5121 (patch)
treefadaa98f41e3fed4aa7d142846717f1ccda2e109
parent67e435c3f1810bc0902698ea4ac4a85b4aef7e4f (diff)
downloadkeyutils-097fd4c381b669b99687517c422396198e5b5121.tar.gz
TEST: Check maximum size of payload to add_key()
Check maximum size of payload to add_key() using the keyctl padd function. Signed-off-by: David Howells <dhowells@redhat.com>
-rw-r--r--tests/keyctl/padd/useradd/runtest.sh38
-rw-r--r--tests/toolbox.inc.sh22
2 files changed, 58 insertions, 2 deletions
diff --git a/tests/keyctl/padd/useradd/runtest.sh b/tests/keyctl/padd/useradd/runtest.sh
index 8eb0973..00aec03 100644
--- a/tests/keyctl/padd/useradd/runtest.sh
+++ b/tests/keyctl/padd/useradd/runtest.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
. ../../../prepare.inc.sh
. ../../../toolbox.inc.sh
@@ -40,7 +40,41 @@ expect_payload payload "lizard"
marker "UNLINK KEY"
unlink_key $keyid @s
-keyctl show
+# add keys with huge payloads
+old_root_quota=`cat /proc/sys/kernel/keys/root_maxbytes`
+if [ $old_root_quota -lt 65536 ]
+then
+ marker "INCREASE QUOTA"
+ echo 65536 >/proc/sys/kernel/keys/root_maxbytes
+fi
+
+marker "ADD LARGE USER KEY"
+pcreate_key_by_size 32767 user large @s
+expect_keyid keyid
+md5sum_key $keyid
+expect_payload payload "f128f774ede3fe931e7c6745c4292f40"
+
+marker "ADD SMALL BIG KEY"
+pcreate_key_by_size 128 big_key small @s
+expect_keyid keyid
+md5sum_key $keyid
+expect_payload payload "f09f35a5637839458e462e6350ecbce4"
+
+marker "ADD HUGE BIG KEY"
+pcreate_key_by_size $((1024*1024-1)) big_key huge @s
+expect_keyid keyid
+md5sum_key $keyid
+expect_payload payload "e57598cd670284cf7d09e16ed9d4b2ac"
+
+marker "CLEAR KEYRING"
+clear_keyring @s
+
+if [ $old_root_quota -lt 65536 ]
+then
+ marker "RESET QUOTA"
+ echo $old_root_quota >/proc/sys/kernel/keys/root_maxbytes
+ sleep 1
+fi
echo "++++ FINISHED TEST: $result" >>$OUTPUTFILE
diff --git a/tests/toolbox.inc.sh b/tests/toolbox.inc.sh
index 2035003..16901a1 100644
--- a/tests/toolbox.inc.sh
+++ b/tests/toolbox.inc.sh
@@ -647,6 +647,28 @@ function pipe_key ()
###############################################################################
#
+# pipe a key's raw payload through md5sum
+#
+###############################################################################
+function md5sum_key ()
+{
+ my_exitval=0
+ if [ "x$1" = "x--fail" ]
+ then
+ my_exitval=1
+ shift
+ fi
+
+ echo keyctl pipe $1 \| md5sum \| cut -c1-32 >>$OUTPUTFILE
+ keyctl pipe $1 | md5sum | cut -c1-32 >>$OUTPUTFILE 2>&1
+ if [ $? != $my_exitval ]
+ then
+ failed
+ fi
+}
+
+###############################################################################
+#
# extract a printed payload from the log file
#
###############################################################################