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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
From eadbc8748478f8cb2551e5d362330ab8be35c568 Mon Sep 17 00:00:00 2001
From: Justus Winter <justus@gnupg.org>
Date: Sat, 23 Apr 2016 17:52:33 +0200
Subject: [PATCH hurd 1/3] startup: implement bits of the fs and io protocols
* startup/Makefile: Build fs and io server with default
implementations.
(mung_msg_S.h): Tune regexp only to match the include guard.
* startup/startup.c (demuxer): Add new protocols. Nicer implementation.
(S_file_check_access): New function.
(S_io_restrict_auth): Likewise.
---
startup/Makefile | 6 ++++--
startup/startup.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++---------
2 files changed, 50 insertions(+), 11 deletions(-)
diff --git a/startup/Makefile b/startup/Makefile
index ee2ecdd5..db062ad 100644
--- a/startup/Makefile
+++ b/startup/Makefile
@@ -21,15 +21,17 @@ makemode := server
SRCS = startup.c
OBJS = $(SRCS:.c=.o) \
startupServer.o notifyServer.o startup_replyUser.o msgServer.o \
- startup_notifyUser.o fsysServer.o
+ startup_notifyUser.o fsysServer.o fsServer.o ioServer.o
target = startup
HURDLIBS = shouldbeinlibc
# startup does not use libports. Disable the default payload to port
# conversion.
MIGSFLAGS="-DHURD_DEFAULT_PAYLOAD_TO_PORT=1"
+fsServer-CFLAGS="-DMIG_EOPNOTSUPP=EOPNOTSUPP"
+ioServer-CFLAGS="-DMIG_EOPNOTSUPP=EOPNOTSUPP"
include ../Makeconf
mung_msg_S.h: msg_S.h
- sed 's/msg_server/mung_msg_server/' < $< > $@
+ sed 's/_msg_server/_mung_msg_server/' < $< > $@
diff --git a/startup/startup.c b/startup/startup.c
index 9c45f4b..172857b 100644
--- a/startup/startup.c
+++ b/startup/startup.c
@@ -51,12 +51,16 @@
#include <version.h>
#include <argp.h>
#include <pids.h>
+#include <idvec.h>
#include "startup_notify_U.h"
#include "startup_reply_U.h"
#include "startup_S.h"
#include "notify_S.h"
#include "mung_msg_S.h"
+#include "fsys_S.h"
+#include "fs_S.h"
+#include "io_S.h"
/* host_reboot flags for when we crash. */
static int crash_flags = RB_AUTOBOOT;
@@ -502,15 +506,19 @@ static int
demuxer (mach_msg_header_t *inp,
mach_msg_header_t *outp)
{
- extern int notify_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int startup_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int msg_server (mach_msg_header_t *, mach_msg_header_t *);
- extern int fsys_server (mach_msg_header_t *, mach_msg_header_t *);
-
- return (notify_server (inp, outp) ||
- msg_server (inp, outp) ||
- fsys_server (inp, outp) ||
- startup_server (inp, outp));
+ mig_routine_t routine;
+ if ((routine = notify_server_routine (inp)) ||
+ (routine = msg_server_routine (inp)) ||
+ (routine = fsys_server_routine (inp)) ||
+ (routine = fs_server_routine (inp)) ||
+ (routine = io_server_routine (inp)) ||
+ (routine = startup_server_routine (inp)))
+ {
+ (*routine) (inp, outp);
+ return TRUE;
+ }
+ else
+ return FALSE;
}
error_t
@@ -1703,3 +1711,32 @@ S_fsys_forward (mach_port_t server, mach_port_t requestor,
{
return EOPNOTSUPP;
}
+
+error_t
+S_file_check_access (mach_port_t server,
+ int *allowed)
+{
+ if (server != startup)
+ return EOPNOTSUPP;
+ *allowed = 0;
+}
+
+error_t
+S_io_restrict_auth (mach_port_t server,
+ mach_port_t *newport,
+ mach_msg_type_name_t *newporttype,
+ uid_t *uids, size_t nuids,
+ uid_t *gids, size_t ngids)
+{
+ struct idvec user = { uids, (unsigned) nuids, (unsigned) nuids };
+
+ if (server != startup)
+ return EOPNOTSUPP;
+
+ if (! idvec_contains (&user, 0))
+ return EPERM;
+
+ *newport = server;
+ *newporttype = MACH_MSG_TYPE_COPY_SEND;
+ return 0;
+}
--
2.1.4
|