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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
|
diff --git a/auth/Makefile b/auth/Makefile
index 75910c7..b9eedda 100644
--- a/auth/Makefile
+++ b/auth/Makefile
@@ -25,6 +25,6 @@ target = auth
HURDLIBS = ports ihash shouldbeinlibc
OTHERLIBS = -lpthread
-MIGSFLAGS = -imacros $(srcdir)/authmutations.h
+MIGSFLAGS = -imacros $(srcdir)/mig-mutate.h
include ../Makeconf
diff --git a/auth/auth.c b/auth/auth.c
index e69c4f8..7d35bd3 100644
--- a/auth/auth.c
+++ b/auth/auth.c
@@ -35,6 +35,8 @@
#include "auth_S.h"
#include "auth_reply_U.h"
+#include "auth.h"
+
const char *argp_program_version = STANDARD_HURD_VERSION(auth);
@@ -72,14 +74,6 @@ destroy_authhandle (void *p)
idvec_free_contents (&h->auids);
idvec_free_contents (&h->agids);
}
-
-/* Called by server stub functions. */
-
-authhandle_t
-auth_port_to_handle (auth_t auth)
-{
- return ports_lookup_port (auth_bucket, auth, authhandle_portclass);
-}
/* id management. */
diff --git a/auth/auth.h b/auth/auth.h
new file mode 100644
index 0000000..0bc341d
--- /dev/null
+++ b/auth/auth.h
@@ -0,0 +1,28 @@
+/*
+ Copyright (C) 2014 Free Software Foundation, Inc.
+ Written by Justus Winter.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef __AUTH_H__
+#define __AUTH_H__
+
+#include <hurd/ports.h>
+
+extern struct port_bucket *auth_bucket;
+extern struct port_class *authhandle_portclass;
+
+#endif /* __AUTH_H__ */
diff --git a/auth/auth_mig.h b/auth/auth_mig.h
deleted file mode 100644
index d919c1b..0000000
--- a/auth/auth_mig.h
+++ /dev/null
@@ -1,5 +0,0 @@
-typedef struct authhandle *authhandle_t;
-
-authhandle_t auth_port_to_handle (auth_t);
-
-#include <hurd/ports.h>
diff --git a/auth/authmutations.h b/auth/authmutations.h
deleted file mode 100644
index 63b2f54..0000000
--- a/auth/authmutations.h
+++ /dev/null
@@ -1,6 +0,0 @@
-/* CPP definitions for MiG processing of auth.defs for auth server. */
-
-#define AUTH_INTRAN authhandle_t auth_port_to_handle (auth_t)
-#define AUTH_DESTRUCTOR ports_port_deref (authhandle_t)
-
-#define AUTH_IMPORTS import "auth_mig.h";
diff --git a/auth/mig-decls.h b/auth/mig-decls.h
new file mode 100644
index 0000000..09c7c70
--- /dev/null
+++ b/auth/mig-decls.h
@@ -0,0 +1,42 @@
+/*
+ Copyright (C) 2014 Free Software Foundation, Inc.
+ Written by Justus Winter.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
+
+#ifndef __AUTH_MIG_DECLS_H__
+#define __AUTH_MIG_DECLS_H__
+
+#include "auth.h"
+
+typedef struct authhandle *authhandle_t;
+
+/* Called by server stub functions. */
+
+static inline struct authhandle * __attribute__ ((unused))
+auth_port_to_handle (mach_port_t auth)
+{
+ return ports_lookup_port (auth_bucket, auth, authhandle_portclass);
+}
+
+static inline void __attribute__ ((unused))
+end_using_authhandle (struct authhandle *auth)
+{
+ if (auth)
+ ports_port_deref (auth);
+}
+
+#endif /* __AUTH_MIG_DECLS_H__ */
diff --git a/auth/mig-mutate.h b/auth/mig-mutate.h
new file mode 100644
index 0000000..ea40c70
--- /dev/null
+++ b/auth/mig-mutate.h
@@ -0,0 +1,24 @@
+/*
+ Copyright (C) 1991,93,94,2014 Free Software Foundation, Inc.
+ Written by Michael I. Bushnell.
+
+ This file is part of the GNU Hurd.
+
+ The GNU Hurd 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, or (at
+ your option) any later version.
+
+ The GNU Hurd is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with the GNU Hurd. If not, see <http://www.gnu.org/licenses/>. */
+
+/* CPP definitions for MiG processing of auth.defs for auth server. */
+
+#define AUTH_INTRAN authhandle_t auth_port_to_handle (auth_t)
+#define AUTH_DESTRUCTOR end_using_authhandle (authhandle_t)
+#define AUTH_IMPORTS import "mig-decls.h";
diff --git a/trans/Makefile b/trans/Makefile
index e74a869..a294282 100644
--- a/trans/Makefile
+++ b/trans/Makefile
@@ -37,6 +37,11 @@ password-MIGSFLAGS=\
"-DIO_DESTRUCTOR=trivfs_end_using_protid (trivfs_protid_t)" \
"-DPASSWORD_IMPORTS=import \"../libtrivfs/mig-decls.h\";"
+ifsock-MIGSFLAGS=\
+ "-DFILE_INTRAN=trivfs_protid_t trivfs_begin_using_protid (io_t)" \
+ "-DFILE_DESTRUCTOR=trivfs_end_using_protid (trivfs_protid_t)" \
+ "-DIFSOCK_IMPORTS=import \"../libtrivfs/mig-decls.h\";"
+
include ../Makeconf
vpath elfcore.c $(top_srcdir)/exec
diff --git a/trans/ifsock.c b/trans/ifsock.c
index 092bb40..4ed6589 100644
--- a/trans/ifsock.c
+++ b/trans/ifsock.c
@@ -131,15 +131,15 @@ trivfs_goaway (struct trivfs_control *fsys, int flags)
}
error_t
-S_ifsock_getsockaddr (file_t sockfile,
+S_ifsock_getsockaddr (struct trivfs_protid *cred,
mach_port_t *address)
{
- struct trivfs_protid *cred = ports_lookup_port (port_bucket, sockfile,
- node_class);
int perms;
error_t err;
- if (!cred)
+ if (!cred
+ || cred->pi.bucket != port_bucket
+ || cred->pi.class != node_class)
return EOPNOTSUPP;
err = file_check_access (cred->realnode, &perms);
@@ -148,6 +148,5 @@ S_ifsock_getsockaddr (file_t sockfile,
if (!err)
*address = address_port;
- ports_port_deref (cred);
return err;
}
diff --git a/utils/Makefile b/utils/Makefile
index 5ebb231..81fa293 100644
--- a/utils/Makefile
+++ b/utils/Makefile
@@ -73,7 +73,7 @@ rpctrace-CPPFLAGS = -DDATADIR=\"${datadir}\"
fakeauth: authServer.o auth_requestUser.o interruptServer.o \
../libports/libports.a ../libihash/libihash.a \
../libshouldbeinlibc/libshouldbeinlibc.a
-auth-MIGSFLAGS = -imacros $(srcdir)/../auth/authmutations.h
+auth-MIGSFLAGS = -imacros $(srcdir)/../auth/mig-mutate.h
fakeauth-CPPFLAGS = -I$(srcdir)/../auth
authServer-CPPFLAGS = -I$(srcdir)/../auth
auth_requestUser-CPPFLAGS = -I$(srcdir)/../auth
diff --git a/utils/fakeauth.c b/utils/fakeauth.c
index 660295f..590a421 100644
--- a/utils/fakeauth.c
+++ b/utils/fakeauth.c
@@ -30,6 +30,8 @@
#include "auth_request_U.h"
#include "interrupt_S.h"
+#include "../auth/auth.h"
+
/* Auth handles are server ports with sets of ids. */
struct authhandle
{
@@ -63,14 +65,6 @@ destroy_authhandle (void *p)
idvec_free_contents (&h->auids);
idvec_free_contents (&h->agids);
}
-
-/* Called by server stub functions. */
-
-authhandle_t
-auth_port_to_handle (auth_t auth)
-{
- return ports_lookup_port (auth_bucket, auth, authhandle_portclass);
-}
/* id management. */
|