summaryrefslogtreecommitdiff
path: root/tests/keyctl/padd/bad-args/runtest.sh
blob: fc82682c6d95541d1232bfb573e7246e5621fc88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash

. ../../../prepare.inc.sh
. ../../../toolbox.inc.sh


# ---- do the actual testing ----

result=PASS
echo "++++ BEGINNING TEST" >$OUTPUTFILE

# check that an empty key type fails correctly
marker "CHECK EMPTY KEY TYPE"
pcreate_key --fail stuff "" wibble @p
expect_error EINVAL

# check that an unsupported key type fails correctly
marker "CHECK UNSUPPORTED KEY TYPE"
pcreate_key --fail stuff lizardsgizzards wibble @p
expect_error ENODEV

# check that an invalid key type fails correctly
marker "CHECK INVALID KEY TYPE"
pcreate_key --fail stuff .user wibble @p
expect_error EPERM

# check that an maximum length invalid key type fails correctly
marker "CHECK MAXLEN KEY TYPE"
pcreate_key --fail stuff $maxtype wibble @p
expect_error ENODEV

# check that an overlong key type fails correctly
marker "CHECK OVERLONG KEY TYPE"
pcreate_key --fail stuff a$maxtype wibble @p
expect_error EINVAL

# check that creation of a keyring with non-empty payload fails correctly
marker "CHECK ADD KEYRING WITH PAYLOAD"
pcreate_key --fail stuff keyring wibble @p
expect_error EINVAL

# check that an max length key description works correctly
if [ $PAGE_SIZE -lt $maxsquota ]
then
    marker "CHECK MAXLEN DESC"
    pcreate_key stuff user $maxdesc @p
    expect_keyid keyid
else
    marker "CHECK MAXLEN DESC FAILS WITH EDQUOT"
    pcreate_key --fail stuff user $maxdesc @p
    expect_error EDQUOT
fi

# This doesn't work on MIPS earler than 3.19 because of a kernel bug
kver=`uname -r`
kmch=`uname -m`
if kernel_at_or_later_than 3.19 ||
	[ "$kmch" != "mips" -a "$kmch" != "mips64" ]
then
	# check that an overlong key description fails correctly (>4095 inc NUL)
	marker "CHECK OVERLONG DESC"
	pcreate_key --fail stuff user a$maxdesc @p
	expect_error EINVAL
fi

# check that a bad key ID fails correctly
marker "CHECK BAD KEY ID"
pcreate_key --fail stuff user wibble 0
expect_error EINVAL

echo "++++ FINISHED TEST: $result" >>$OUTPUTFILE

# --- then report the results in the database ---
toolbox_report_result $TEST $result