bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3] Test reverse authenticating ioctl-handler protocol


From: Carl Fredrik Hammar
Subject: [PATCH 3/3] Test reverse authenticating ioctl-handler protocol
Date: Wed, 26 Aug 2009 16:55:58 +0200

* Makefile (ioctl_handler_MIGSFLAGS): New variable.
* ioctl-tests/qioctl.c (S_ioctl_handler_get): Remove deprecated routine.
(S_ioctl_handler_request): New funtction.
---
 ioctl-tests/Makefile |    1 +
 ioctl-tests/qioctl.c |   29 ++++++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/ioctl-tests/Makefile b/ioctl-tests/Makefile
index a8333a7..a5df1d5 100644
--- a/ioctl-tests/Makefile
+++ b/ioctl-tests/Makefile
@@ -28,6 +28,7 @@ SRCS = qioctl.c qioctl-handler.c #test.c
 OBJS = qioctl.o qioctl-handler.o qioctlServer.o ioctl_handlerServer.o #test.o
 target = qioctl #test
 HURDLIBS = trivfs fshelp
+ioctl_handler-MIGSFLAGS = -DREPLY_PORTS
 
 include ../Makeconf
 
diff --git a/ioctl-tests/qioctl.c b/ioctl-tests/qioctl.c
index cd6389c..5967bf9 100644
--- a/ioctl-tests/qioctl.c
+++ b/ioctl-tests/qioctl.c
@@ -29,6 +29,7 @@
 
 #include "qioctl_S.h"
 #include "ioctl_handler_S.h"
+#include "ioctl_handler_reply_U.h"
 
 
 const char *argp_program_version = STANDARD_HURD_VERSION (qioctl);
@@ -93,23 +94,41 @@ S_qnormal (io_t io)
 /* Open and return HANDLER_FILE_NAME as described in
    <hurd/ioctl_handler.defs>.  */
 error_t
-S_ioctl_handler_get (io_t io, io_t *handler)
+S_ioctl_handler_request (io_t io,
+                        mach_port_t request_reply_port,
+                        mach_msg_type_name_t request_reply_port_type,
+                        mach_port_t rendezvous)
 {
-  file_t handler_authed;
+  auth_t auth;
+  mach_port_t reply_port;
+  file_t handler_authed, handler;
   error_t err;
 
-  err = 0;
+  err = ioctl_handler_acknowledge (request_reply_port,
+                                  request_reply_port_type, 0);
+  if (err)
+    return MIG_NO_REPLY;
+
+  auth = getauth ();
+  err = auth_user_authenticate (auth, rendezvous, MACH_MSG_TYPE_COPY_SEND,
+                                &reply_port);
+  mach_port_deallocate (mach_task_self (), auth);
+  mach_port_deallocate (mach_task_self (), rendezvous);
+  if (err)
+    return MIG_NO_REPLY;
+
   handler_authed = file_name_lookup (handler_file_name, 0, 0);
   if (handler_authed == MACH_PORT_NULL)
     err = errno;
 
   if (!err)
     {
-      err = io_restrict_auth (handler_authed, handler, 0, 0, 0, 0);
+      err = io_restrict_auth (handler_authed, &handler, 0, 0, 0, 0);
       mach_port_deallocate (mach_task_self (), handler_authed);
     }
 
-  return err;
+  ioctl_handler_reply (reply_port, err, handler, MACH_MSG_TYPE_MOVE_SEND);
+  return MIG_NO_REPLY;
 }
 
 static int
-- 
1.6.3.3





reply via email to

[Prev in Thread] Current Thread [Next in Thread]