From 20945739309a1ea4ce10d029ff4a6ef787f83403 Mon Sep 17 00:00:00 2001
From: "Dmitry V. Levin" <ldv@altlinux.org>
Date: Thu, 19 Feb 2015 21:42:31 +0000
Subject: [PATCH] Remove linux/keyctl.h

* linux/keyctl.h: Remove.
* Makefile.am (EXTRA_DIST): Remove it.
* keyctl.c: Do not include <linux/keyctl.h>.
* xlat/key_perms.in: Add default values.
* xlat/key_reqkeys.in: Likewise.
* xlat/key_spec.in: Likewise.
* xlat/keyctl_commands.in: Likewise.
---
 Makefile.am             |  1 -
 keyctl.c                | 30 --------------------
 linux/keyctl.h          | 61 -----------------------------------------
 xlat/key_perms.in       | 56 ++++++++++++++++++-------------------
 xlat/key_reqkeys.in     | 18 ++++++------
 xlat/key_spec.in        | 16 +++++------
 xlat/keyctl_commands.in | 46 +++++++++++++++----------------
 7 files changed, 68 insertions(+), 160 deletions(-)
 delete mode 100644 linux/keyctl.h

diff --git a/Makefile.am b/Makefile.am
index 80dddfe5..ddd2d0b0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -219,7 +219,6 @@ EXTRA_DIST =				\
 	linux/ia64/syscallent.h		\
 	linux/ia64/userent.h		\
 	linux/inet_diag.h		\
-	linux/keyctl.h			\
 	linux/m68k/ioctls_arch0.h	\
 	linux/m68k/ioctls_inc0.h	\
 	linux/m68k/syscallent.h		\
diff --git a/keyctl.c b/keyctl.c
index a12bd54c..e77557e9 100644
--- a/keyctl.c
+++ b/keyctl.c
@@ -1,5 +1,4 @@
 #include "defs.h"
-#include <linux/keyctl.h>
 
 typedef int32_t key_serial_t;
 
@@ -236,35 +235,6 @@ keyctl_get_persistent(struct tcb *tcp, int uid, key_serial_t id)
 	return 0;
 }
 
-#define KEY_POS_VIEW	0x01000000
-#define KEY_POS_READ	0x02000000
-#define KEY_POS_WRITE	0x04000000
-#define KEY_POS_SEARCH	0x08000000
-#define KEY_POS_LINK	0x10000000
-#define KEY_POS_SETATTR	0x20000000
-#define KEY_POS_ALL	0x3f000000
-#define KEY_USR_VIEW	0x00010000
-#define KEY_USR_READ	0x00020000
-#define KEY_USR_WRITE	0x00040000
-#define KEY_USR_SEARCH	0x00080000
-#define KEY_USR_LINK	0x00100000
-#define KEY_USR_SETATTR	0x00200000
-#define KEY_USR_ALL	0x003f0000
-#define KEY_GRP_VIEW	0x00000100
-#define KEY_GRP_READ	0x00000200
-#define KEY_GRP_WRITE	0x00000400
-#define KEY_GRP_SEARCH	0x00000800
-#define KEY_GRP_LINK	0x00001000
-#define KEY_GRP_SETATTR	0x00002000
-#define KEY_GRP_ALL	0x00003f00
-#define KEY_OTH_VIEW	0x00000001
-#define KEY_OTH_READ	0x00000002
-#define KEY_OTH_WRITE	0x00000004
-#define KEY_OTH_SEARCH	0x00000008
-#define KEY_OTH_LINK	0x00000010
-#define KEY_OTH_SETATTR	0x00000020
-#define KEY_OTH_ALL	0x0000003f
-
 #include "xlat/key_perms.h"
 
 static int
diff --git a/linux/keyctl.h b/linux/keyctl.h
deleted file mode 100644
index 840cb990..00000000
--- a/linux/keyctl.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* keyctl.h: keyctl command IDs
- *
- * Copyright (C) 2004, 2008 Red Hat, Inc. All Rights Reserved.
- * Written by David Howells (dhowells@redhat.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-
-#ifndef _LINUX_KEYCTL_H
-#define _LINUX_KEYCTL_H
-
-/* special process keyring shortcut IDs */
-#define KEY_SPEC_THREAD_KEYRING		-1	/* - key ID for thread-specific keyring */
-#define KEY_SPEC_PROCESS_KEYRING	-2	/* - key ID for process-specific keyring */
-#define KEY_SPEC_SESSION_KEYRING	-3	/* - key ID for session-specific keyring */
-#define KEY_SPEC_USER_KEYRING		-4	/* - key ID for UID-specific keyring */
-#define KEY_SPEC_USER_SESSION_KEYRING	-5	/* - key ID for UID-session keyring */
-#define KEY_SPEC_GROUP_KEYRING		-6	/* - key ID for GID-specific keyring */
-#define KEY_SPEC_REQKEY_AUTH_KEY	-7	/* - key ID for assumed request_key auth key */
-#define KEY_SPEC_REQUESTOR_KEYRING	-8	/* - key ID for request_key() dest keyring */
-
-/* request-key default keyrings */
-#define KEY_REQKEY_DEFL_NO_CHANGE		-1
-#define KEY_REQKEY_DEFL_DEFAULT			0
-#define KEY_REQKEY_DEFL_THREAD_KEYRING		1
-#define KEY_REQKEY_DEFL_PROCESS_KEYRING		2
-#define KEY_REQKEY_DEFL_SESSION_KEYRING		3
-#define KEY_REQKEY_DEFL_USER_KEYRING		4
-#define KEY_REQKEY_DEFL_USER_SESSION_KEYRING	5
-#define KEY_REQKEY_DEFL_GROUP_KEYRING		6
-#define KEY_REQKEY_DEFL_REQUESTOR_KEYRING	7
-
-/* keyctl commands */
-#define KEYCTL_GET_KEYRING_ID		0	/* ask for a keyring's ID */
-#define KEYCTL_JOIN_SESSION_KEYRING	1	/* join or start named session keyring */
-#define KEYCTL_UPDATE			2	/* update a key */
-#define KEYCTL_REVOKE			3	/* revoke a key */
-#define KEYCTL_CHOWN			4	/* set ownership of a key */
-#define KEYCTL_SETPERM			5	/* set perms on a key */
-#define KEYCTL_DESCRIBE			6	/* describe a key */
-#define KEYCTL_CLEAR			7	/* clear contents of a keyring */
-#define KEYCTL_LINK			8	/* link a key into a keyring */
-#define KEYCTL_UNLINK			9	/* unlink a key from a keyring */
-#define KEYCTL_SEARCH			10	/* search for a key in a keyring */
-#define KEYCTL_READ			11	/* read a key or keyring's contents */
-#define KEYCTL_INSTANTIATE		12	/* instantiate a partially constructed key */
-#define KEYCTL_NEGATE			13	/* negate a partially constructed key */
-#define KEYCTL_SET_REQKEY_KEYRING	14	/* set default request-key keyring */
-#define KEYCTL_SET_TIMEOUT		15	/* set key timeout */
-#define KEYCTL_ASSUME_AUTHORITY		16	/* assume request_key() authorisation */
-#define KEYCTL_GET_SECURITY		17	/* get key security label */
-#define KEYCTL_SESSION_TO_PARENT	18	/* apply session keyring to parent process */
-#define KEYCTL_REJECT			19	/* reject a partially constructed key */
-#define KEYCTL_INSTANTIATE_IOV		20	/* instantiate a partially constructed key */
-#define KEYCTL_INVALIDATE		21	/* invalidate a key */
-#define KEYCTL_GET_PERSISTENT		22	/* get a user's persistent keyring */
-
-#endif /*  _LINUX_KEYCTL_H */
diff --git a/xlat/key_perms.in b/xlat/key_perms.in
index f7e8edba..c96a9ed9 100644
--- a/xlat/key_perms.in
+++ b/xlat/key_perms.in
@@ -1,28 +1,28 @@
-KEY_POS_VIEW
-KEY_POS_READ
-KEY_POS_WRITE
-KEY_POS_SEARCH
-KEY_POS_LINK
-KEY_POS_SETATTR
-KEY_POS_ALL
-KEY_USR_VIEW
-KEY_USR_READ
-KEY_USR_WRITE
-KEY_USR_SEARCH
-KEY_USR_LINK
-KEY_USR_SETATTR
-KEY_USR_ALL
-KEY_GRP_VIEW
-KEY_GRP_READ
-KEY_GRP_WRITE
-KEY_GRP_SEARCH
-KEY_GRP_LINK
-KEY_GRP_SETATTR
-KEY_GRP_ALL
-KEY_OTH_VIEW
-KEY_OTH_READ
-KEY_OTH_WRITE
-KEY_OTH_SEARCH
-KEY_OTH_LINK
-KEY_OTH_SETATTR
-KEY_OTH_ALL
+KEY_POS_VIEW	0x01000000
+KEY_POS_READ	0x02000000
+KEY_POS_WRITE	0x04000000
+KEY_POS_SEARCH	0x08000000
+KEY_POS_LINK	0x10000000
+KEY_POS_SETATTR	0x20000000
+KEY_POS_ALL	0x3f000000
+KEY_USR_VIEW	0x00010000
+KEY_USR_READ	0x00020000
+KEY_USR_WRITE	0x00040000
+KEY_USR_SEARCH	0x00080000
+KEY_USR_LINK	0x00100000
+KEY_USR_SETATTR	0x00200000
+KEY_USR_ALL	0x003f0000
+KEY_GRP_VIEW	0x00000100
+KEY_GRP_READ	0x00000200
+KEY_GRP_WRITE	0x00000400
+KEY_GRP_SEARCH	0x00000800
+KEY_GRP_LINK	0x00001000
+KEY_GRP_SETATTR	0x00002000
+KEY_GRP_ALL	0x00003f00
+KEY_OTH_VIEW	0x00000001
+KEY_OTH_READ	0x00000002
+KEY_OTH_WRITE	0x00000004
+KEY_OTH_SEARCH	0x00000008
+KEY_OTH_LINK	0x00000010
+KEY_OTH_SETATTR	0x00000020
+KEY_OTH_ALL	0x0000003f
diff --git a/xlat/key_reqkeys.in b/xlat/key_reqkeys.in
index 6da0ff7d..747e440b 100644
--- a/xlat/key_reqkeys.in
+++ b/xlat/key_reqkeys.in
@@ -1,9 +1,9 @@
-KEY_REQKEY_DEFL_NO_CHANGE
-KEY_REQKEY_DEFL_DEFAULT
-KEY_REQKEY_DEFL_THREAD_KEYRING
-KEY_REQKEY_DEFL_PROCESS_KEYRING
-KEY_REQKEY_DEFL_SESSION_KEYRING
-KEY_REQKEY_DEFL_USER_KEYRING
-KEY_REQKEY_DEFL_USER_SESSION_KEYRING
-KEY_REQKEY_DEFL_GROUP_KEYRING
-KEY_REQKEY_DEFL_REQUESTOR_KEYRING
+KEY_REQKEY_DEFL_NO_CHANGE -1
+KEY_REQKEY_DEFL_DEFAULT 0
+KEY_REQKEY_DEFL_THREAD_KEYRING 1
+KEY_REQKEY_DEFL_PROCESS_KEYRING 2
+KEY_REQKEY_DEFL_SESSION_KEYRING 3
+KEY_REQKEY_DEFL_USER_KEYRING 4
+KEY_REQKEY_DEFL_USER_SESSION_KEYRING 5
+KEY_REQKEY_DEFL_GROUP_KEYRING 6
+KEY_REQKEY_DEFL_REQUESTOR_KEYRING 7
diff --git a/xlat/key_spec.in b/xlat/key_spec.in
index 942b7efe..3e879544 100644
--- a/xlat/key_spec.in
+++ b/xlat/key_spec.in
@@ -1,8 +1,8 @@
-KEY_SPEC_THREAD_KEYRING
-KEY_SPEC_PROCESS_KEYRING
-KEY_SPEC_SESSION_KEYRING
-KEY_SPEC_USER_KEYRING
-KEY_SPEC_USER_SESSION_KEYRING
-KEY_SPEC_GROUP_KEYRING
-KEY_SPEC_REQKEY_AUTH_KEY
-KEY_SPEC_REQUESTOR_KEYRING
+KEY_SPEC_THREAD_KEYRING -1
+KEY_SPEC_PROCESS_KEYRING -2
+KEY_SPEC_SESSION_KEYRING -3
+KEY_SPEC_USER_KEYRING -4
+KEY_SPEC_USER_SESSION_KEYRING -5
+KEY_SPEC_GROUP_KEYRING -6
+KEY_SPEC_REQKEY_AUTH_KEY -7
+KEY_SPEC_REQUESTOR_KEYRING -8
diff --git a/xlat/keyctl_commands.in b/xlat/keyctl_commands.in
index 33daf51d..beb3b1dd 100644
--- a/xlat/keyctl_commands.in
+++ b/xlat/keyctl_commands.in
@@ -1,23 +1,23 @@
-KEYCTL_GET_KEYRING_ID
-KEYCTL_JOIN_SESSION_KEYRING
-KEYCTL_UPDATE
-KEYCTL_REVOKE
-KEYCTL_CHOWN
-KEYCTL_SETPERM
-KEYCTL_DESCRIBE
-KEYCTL_CLEAR
-KEYCTL_LINK
-KEYCTL_UNLINK
-KEYCTL_SEARCH
-KEYCTL_READ
-KEYCTL_INSTANTIATE
-KEYCTL_NEGATE
-KEYCTL_SET_REQKEY_KEYRING
-KEYCTL_SET_TIMEOUT
-KEYCTL_ASSUME_AUTHORITY
-KEYCTL_GET_SECURITY
-KEYCTL_SESSION_TO_PARENT
-KEYCTL_REJECT
-KEYCTL_INSTANTIATE_IOV
-KEYCTL_INVALIDATE
-KEYCTL_GET_PERSISTENT
+KEYCTL_GET_KEYRING_ID 0
+KEYCTL_JOIN_SESSION_KEYRING 1
+KEYCTL_UPDATE 2
+KEYCTL_REVOKE 3
+KEYCTL_CHOWN 4
+KEYCTL_SETPERM 5
+KEYCTL_DESCRIBE 6
+KEYCTL_CLEAR 7
+KEYCTL_LINK 8
+KEYCTL_UNLINK 9
+KEYCTL_SEARCH 10
+KEYCTL_READ 11
+KEYCTL_INSTANTIATE 12
+KEYCTL_NEGATE 13
+KEYCTL_SET_REQKEY_KEYRING 14
+KEYCTL_SET_TIMEOUT 15
+KEYCTL_ASSUME_AUTHORITY 16
+KEYCTL_GET_SECURITY 17
+KEYCTL_SESSION_TO_PARENT 18
+KEYCTL_REJECT 19
+KEYCTL_INSTANTIATE_IOV 20
+KEYCTL_INVALIDATE 21
+KEYCTL_GET_PERSISTENT 22