summaryrefslogtreecommitdiff
path: root/request-key.c
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2010-02-22 15:46:17 +0000
committerDavid Howells <dhowells@redhat.com>2010-02-22 16:12:29 +0000
commit557f01ce1fdd3cc78be3aa74f281160a581c2777 (patch)
treeefa150193c5d049f6885d31d32169583b709e00e /request-key.c
parent53ad7681eedbe86ca729763ac2d75a90a451648a (diff)
downloadkeyutils-557f01ce1fdd3cc78be3aa74f281160a581c2777.tar.gz
keyutils historical version 1.0v1.0KEYUTILS_1.0KEYUTILS_0.3
- Add build dependency on glibc-kernheaders with key management syscall - Add data pipe-in facility for keyctl request2 - Rename library and header file "keyutil" -> "keyutils" for consistency - Fix shared library version naming to same way as glibc. - Add versioning for shared library symbols - Create new keyutils-libs package and install library and main symlink there - Install base library symlink in /usr/lib and place in devel package - Added a keyutils archive library - Shorten displayed key permissions list to just those we actually have - Add data pipe-in facilities for keyctl add, update and instantiate
Diffstat (limited to 'request-key.c')
-rw-r--r--request-key.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/request-key.c b/request-key.c
index 9b8863b..d58479e 100644
--- a/request-key.c
+++ b/request-key.c
@@ -29,7 +29,7 @@
#include <ctype.h>
#include <sys/select.h>
#include <sys/wait.h>
-#include "keyutil.h"
+#include "keyutils.h"
static int xdebug;
@@ -128,7 +128,7 @@ int main(int argc, char *argv[])
{
key_serial_t key;
char *ktype, *kdesc, *buf, *callout_info;
- int ret, ntype, dpos, dlen, fd;
+ int ret, ntype, dpos, n, fd;
signal(SIGSEGV, oops);
signal(SIGBUS, oops);
@@ -176,9 +176,11 @@ int main(int argc, char *argv[])
key = atoi(xkey);
- /* assume authority over the key */
+ /* assume authority over the key
+ * - older kernel doesn't support this function
+ */
ret = keyctl_assume_authority(key);
- if (ret < 0)
+ if (ret < 0 && !(argc == 9 || errno == EOPNOTSUPP))
error("Failed to assume authority over key %d (%m)\n", key);
/* ask the kernel to describe the key to us */
@@ -195,10 +197,9 @@ int main(int argc, char *argv[])
debug("Key descriptor: \"%s\"\n", buf);
ntype = -1;
dpos = -1;
- dlen = -1;
- sscanf(buf, "%*[^;]%n;%*d;%*d;%*x;%n%*[^;]%n", &ntype, &dpos, &dlen);
- if (dlen == -1)
+ n = sscanf(buf, "%*[^;]%n;%*d;%*d;%x;%n", &ntype, &n, &dpos);
+ if (n != 1)
error("Failed to parse key description\n");
ktype = buf;
@@ -708,7 +709,10 @@ static void pipe_to_program(char *op,
if (tmp < 0)
error("select failed: %m\n");
- debug("select -> %d r=%x w=%x\n", tmp, *(unsigned *) &rfds, *(unsigned *) &wfds);
+ debug("select -> %d r=%x w=%x\n",
+ tmp,
+ *(unsigned *) (void *) &rfds,
+ *(unsigned *) (void *) &wfds);
if (TOSTDIN != -1 && FD_ISSET(TOSTDIN, &wfds)) {
tmp = write(TOSTDIN, pc, ninfo);