1 2 3 4 5 6 7 8 9 | ".config" file ... # # Security options # CONFIG_KEYS=y CONFIG_KEYS_DEBUG_PROC_KEYS=y CONFIG_SECURITY=y CONFIG_SECURITY_NETWORK=y CONFIG_SECURITY_CAPABILITIES=y |
1 2 3 4 5 6 7 | struct key_type new_key_type = { .name = "mykey", .instantiate = instantiate_key, .describe = key_desc, .destroy = key_destroy, .match = key_match, }; |
1 2 3 4 | [root@phoenix set.5]# keyctl show Session Keyring -3 --alswrv 0 0 keyring: _ses.1976 2 --alswrv 0 0 \_ keyring: _uid.0 |
1 2 3 | [root@phoenix set.5]# insmod ./kernel.land/newkey.ko Loading the module ... Registered "learning_key" |
1 2 3 4 5 6 7 8 9 | [root@phoenix set.5]# ./user.land/session In /var/log/message, you will see similar output Installing session keyring: keyring allocated successfully. keyring instantiated and linked successfully. New session keyring installed successfully. key of new type allocated successfully. New key type linked to current session. |
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 | [root@phoenix set.5]# keyctl show Session Keyring -3 --alswrv 0 0 keyring: session.2621 39044642 --alswrv 0 0 \_ mykey: New key type [root@phoenix set.5]# cat /proc/keys 00000001 I----- 1 perm 1f3f0000 0 0 keyring _uid_ses.0: 1/4 00000002 I----- 5 perm 1f3f0000 0 0 keyring _uid.0: empty 0253c622 I--Q-- 1 perm 3f3f0000 0 0 mykey New key type: 0 11a490da I--Q-- 2 perm 3f3f0000 0 0 keyring session.2621: 1/4 13670439 I--Q-- 2 perm 1f3f0000 0 0 keyring _ses.1977: 1/4 159d39b8 I--Q-- 5 perm 1f3f0000 0 0 keyring _ses.1976: 1/4 3a14f259 I--Q-- 3 perm 1f3f0000 0 0 keyring _ses.1978: 1/4 [root@phoenix set.5]# cat /proc/key-users 0: 8 7/7 5/100 136/10000 43: 2 2/2 2/100 56/10000 48: 2 2/2 2/100 56/10000 81: 2 2/2 2/100 56/10000 786: 4 4/4 4/100 113/10000 "keyctl describe <Key>" command gives the description of key. [root@phoenix set.5]# keyctl describe -3 -3: alswrvalswrv------------ 0 0 keyring: session.2621 [root@phoenix set.5]# keyctl describe 39044642 39044642: alswrvalswrv------------ 0 0 mykey: New key type [avinesh@phoenix set.5]$ keyctl search -3 mykey "New key type" 39044642 [root@phoenix set.5]# exit exit Now back to our previous state [root@phoenix set.5]# keyctl show Session Keyring -3 --alswrv 0 0 keyring: _ses.1976 2 --alswrv 0 0 \_ keyring: _uid.0 [root@phoenix set.5]# rmmod ./kernel.land/newkey.ko Unloading the module. Unregistered "learning_key" |
1 2 3 4 5 6 7 | [root@phoenix set.5]# cat /proc/keys 00000001 I----- 1 perm 1f3f0000 0 0 keyring _uid_ses.0 : 1/4 00000002 I----- 5 perm 1f3f0000 0 0 keyring _uid.0 : empty 13670439 I--Q-- 2 perm 1f3f0000 0 0 keyring _ses.1977 : 1/4 159d39b8 I--Q-- 6 perm 1f3f0000 0 0 keyring _ses.1976 : 1/4 3a14f259 I--Q-- 3 perm 1f3f0000 0 0 keyring _ses.1978 : 1/4 [Serial][Flags][Usage][Expiry][Permissions][UID][GID][TypeName][Description] :[Summary] |
1 2 3 4 5 6 | I Instantiated R Revoked D Dead Q Contributes to user's quota U Under construction by callback to user-space N Negative key |
1 2 3 4 5 6 | [root@phoenix set.5]# cat /proc/key-users 0: 6 5/5 3/100 90/10000 43: 2 2/2 2/100 56/10000 48: 2 2/2 2/100 56/10000 81: 2 2/2 2/100 56/10000 786: 4 4/4 4/100 113/10000 |
1 2 3 4 5 | <UID> User ID <usage> Usage count <inst>/<keys> Total number of keys and number instantiated <keys>/<max> Key count quota <bytes><max> Key size quota |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |