summaryrefslogtreecommitdiff
path: root/debian/patches/exec_filename_exec.patch
blob: 632c94a79de21bb2beabefc3c5025e2f5816947a (plain)
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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
From 011df9d35eb68132cdb14a0f55e2435375e2cfce Mon Sep 17 00:00:00 2001
From: Emilio Pozuelo Monfort <pochu27@gmail.com>
Date: Wed, 26 May 2010 00:15:37 +0200
Subject: [PATCH 1/3] Add a new exec_exec_file_name RPC

* hurd/exec.defs (exec_exec_file_name): New RPC.
(exec_exec): Label as deprecated.
* doc/hurd.texi: Updated.
* exec/exec.c (S_exec_exec_file_name): New function.
(S_exec_exec): Label as deprecated.
(do_exec): Add argument.
* exec/hashexec.c (check_hashbang): Add argument.
Don't guess the file name if file_name_exec is set.
* exec/priv.h (check_hashbang): Add argument.
---
 doc/hurd.texi   |    8 ++++----
 exec/exec.c     |   50 +++++++++++++++++++++++++++++++++++++++++++++-----
 exec/hashexec.c |   18 ++++++++++++------
 exec/priv.h     |    4 +++-
 hurd/exec.defs  |   19 +++++++++++++++++--
 5 files changed, 81 insertions(+), 18 deletions(-)

Index: hurd-debian/doc/hurd.texi
===================================================================
--- hurd-debian.orig/doc/hurd.texi	2014-02-03 22:48:45.000000000 +0000
+++ hurd-debian/doc/hurd.texi	2014-02-03 23:45:08.000000000 +0000
@@ -102,7 +102,7 @@
 documentation was last updated for version @value{VERSION} of the Hurd.
 
 Copyright @copyright{} 1994, 1996, 1998, 1999, 2000, 2001, 2002, 2003,
-2004, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
+2004, 2005, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to make and distribute verbatim copies of
@@ -2766,14 +2766,14 @@
 authentication handle that was not previously present (as opposed to
 merely reordering them), then the @code{EXEC_SECURE} and
 @code{EXEC_NEWTASK} flags should both be added in the call to
-@code{exec_exec}.
+@code{exec_exec_file_name}.
 
 The server then needs to open a new port onto the executed file which
 will not share any file pointers with the port the user passed in,
 opened with @code{O_READ}.  Finally, all the information (mutated
 appropriately for setuid/setgid) should be sent to the execserver with
-@code{exec_exec}.  Whatever error code @code{exec_exec} returns should
-returned to the caller of @code{file_exec}.
+@code{exec_exec_file_name}.  Whatever error code @code{exec_exec_file_name}
+returns should be returned to the caller of @code{file_exec}.
 
 @node File Locking
 @subsection File Locking
Index: hurd-debian/exec/exec.c
===================================================================
--- hurd-debian.orig/exec/exec.c	2014-02-03 22:48:45.000000000 +0000
+++ hurd-debian/exec/exec.c	2014-02-03 22:48:44.000000000 +0000
@@ -1,6 +1,6 @@
 /* GNU Hurd standard exec server.
-   Copyright (C) 1992,93,94,95,96,98,99,2000,01,02,04
-   	Free Software Foundation, Inc.
+   Copyright (C) 1992 ,1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+   2002, 2004, 2010 Free Software Foundation, Inc.
    Written by Roland McGrath.
 
    Can exec ELF format directly.
@@ -738,6 +738,7 @@
 do_exec (file_t file,
 	 task_t oldtask,
 	 int flags,
+	 char *filename,
 	 char *argv, mach_msg_type_number_t argvlen, boolean_t argv_copy,
 	 char *envp, mach_msg_type_number_t envplen, boolean_t envp_copy,
 	 mach_port_t *dtable, mach_msg_type_number_t dtablesize,
@@ -796,7 +797,7 @@
     {
       /* Check for a #! executable file.  */
       check_hashbang (&e,
-		      file, oldtask, flags,
+		      file, oldtask, flags, filename,
 		      argv, argvlen, argv_copy,
 		      envp, envplen, envp_copy,
 		      dtable, dtablesize, dtable_copy,
@@ -1356,6 +1357,7 @@
   return e.error;
 }
 
+/* Deprecated.  */
 kern_return_t
 S_exec_exec (struct trivfs_protid *protid,
 	     file_t file,
@@ -1372,13 +1374,51 @@
 	     mach_port_t *deallocnames, mach_msg_type_number_t ndeallocnames,
 	     mach_port_t *destroynames, mach_msg_type_number_t ndestroynames)
 {
+  return S_exec_exec_file_name (protid,
+				file,
+				oldtask,
+				flags,
+				"",
+				argv, argvlen, argv_copy,
+				envp, envplen, envp_copy,
+				dtable, dtablesize,
+				dtable_copy,
+				portarray, nports,
+				portarray_copy,
+				intarray, nints,
+				intarray_copy,
+				deallocnames, ndeallocnames,
+				destroynames, ndestroynames);
+}
+
+kern_return_t
+S_exec_exec_file_name (struct trivfs_protid *protid,
+		       file_t file,
+		       task_t oldtask,
+		       int flags,
+		       char *filename,
+		       char *argv, mach_msg_type_number_t argvlen,
+		       boolean_t argv_copy,
+		       char *envp, mach_msg_type_number_t envplen,
+		       boolean_t envp_copy,
+		       mach_port_t *dtable, mach_msg_type_number_t dtablesize,
+		       boolean_t dtable_copy,
+		       mach_port_t *portarray, mach_msg_type_number_t nports,
+		       boolean_t portarray_copy,
+		       int *intarray, mach_msg_type_number_t nints,
+		       boolean_t intarray_copy,
+		       mach_port_t *deallocnames,
+		       mach_msg_type_number_t ndeallocnames,
+		       mach_port_t *destroynames,
+		       mach_msg_type_number_t ndestroynames)
+{
   if (! protid)
     return EOPNOTSUPP;
 
   /* There were no user-specified exec servers,
      or none of them could be found.  */
 
-  return do_exec (file, oldtask, flags,
+  return do_exec (file, oldtask, flags, filename,
 		  argv, argvlen, argv_copy,
 		  envp, envplen, envp_copy,
 		  dtable, dtablesize, dtable_copy,
Index: hurd-debian/exec/hashexec.c
===================================================================
--- hurd-debian.orig/exec/hashexec.c	2014-02-03 22:48:45.000000000 +0000
+++ hurd-debian/exec/hashexec.c	2014-02-03 23:45:08.000000000 +0000
@@ -1,5 +1,6 @@
 /* GNU Hurd standard exec server, #! script execution support.
-   Copyright (C) 1995,96,97,98,99,2000,02 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2002, 2010
+   Free Software Foundation, Inc.
    Written by Roland McGrath.
 
    This file is part of the GNU Hurd.
@@ -35,6 +36,7 @@
 		file_t file,
 		task_t oldtask,
 		int flags,
+		char *file_name_exec,
 		char *argv, u_int argvlen, boolean_t argv_copy,
 		char *envp, u_int envplen, boolean_t envp_copy,
 		mach_port_t *dtable, u_int dtablesize, boolean_t dtable_copy,
@@ -225,10 +227,12 @@
 	    file_name = NULL;
 	  else if (! (flags & EXEC_SECURE))
 	    {
-	      /* Try to figure out the file's name.  We guess that if ARGV[0]
-		 contains a slash, it might be the name of the file; and that
-		 if it contains no slash, looking for files named by ARGV[0] in
-		 the `PATH' environment variable might find it.  */
+	      /* Try to figure out the file's name.  If FILE_NAME_EXEC
+		 is not NULL, then it's the file's name.  Otherwise we
+		 guess that if ARGV[0] contains a slash, it might be
+		 the name of the file; and that if it contains no slash,
+		 looking for files named by ARGV[0] in the `PATH'
+		 environment variable might find it.  */
 
 	      error_t error;
 	      char *name;
@@ -278,7 +282,9 @@
 	      else
 		name = argv;
 
-	      if (strchr (name, '/') != NULL)
+	      if (file_name_exec && file_name_exec[0] != '\0')
+		error = lookup (name = file_name_exec, 0, &name_file);
+	      else if (strchr (name, '/') != NULL)
 		error = lookup (name, 0, &name_file);
 	      else if ((error = hurd_catch_signal
 			(sigmask (SIGBUS) | sigmask (SIGSEGV),
Index: hurd-debian/exec/priv.h
===================================================================
--- hurd-debian.orig/exec/priv.h	2014-02-03 22:48:45.000000000 +0000
+++ hurd-debian/exec/priv.h	2014-02-03 22:48:44.000000000 +0000
@@ -1,5 +1,6 @@
 /* GNU Hurd standard exec server, private declarations.
-   Copyright (C) 1992,93,94,95,96,99,2000,02, 04 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1999, 2000, 2002, 2004,
+   2010 Free Software Foundation, Inc.
    Written by Roland McGrath.
 
 This file is part of the GNU Hurd.
@@ -32,6 +33,7 @@
 #include <link.h>		/* This gives us the ElfW macro.  */
 #include <fcntl.h>
 #include "exec_S.h"
+#include "exec_experimental_S.h"
 
 
 #ifndef exec_priv_h
@@ -134,6 +136,7 @@
 		     file_t file,
 		     task_t oldtask,
 		     int flags,
+		     char *filename,
 		     char *argv, u_int argvlen, boolean_t argv_copy,
 		     char *envp, u_int envplen, boolean_t envp_copy,
 		     mach_port_t *dtable, u_int dtablesize,
Index: hurd-debian/hurd/exec.defs
===================================================================
--- hurd-debian.orig/hurd/exec.defs	2014-02-03 22:48:45.000000000 +0000
+++ hurd-debian/hurd/exec.defs	2014-02-03 22:48:44.000000000 +0000
@@ -1,5 +1,6 @@
 /* Interface definitions for the exec servers.
-   Copyright (C) 1991,92,93,94,95,2001 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1992, 1993, 1994, 1995, 2001, 2010
+   Free Software Foundation, Inc.
 
 This file is part of the GNU Hurd.
 
@@ -29,6 +30,7 @@
 
 INTR_INTERFACE
 
+/* Deprecated: use exec_exec_file_name instead.  */
 routine exec_exec (
 	execserver: file_t;
 	file: mach_port_send_t;
Index: hurd-debian/hurd/exec_experimental.defs
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ hurd-debian/hurd/exec_experimental.defs	2014-02-03 22:48:44.000000000 +0000
@@ -0,0 +1,46 @@
+/* Interface definitions for the exec servers.
+   Copyright (C) 1991, 1992, 1993, 1994, 1995, 2001, 2010, 2012
+   Free Software Foundation, Inc.
+
+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; see the file COPYING.  If not, write to
+the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+/* Written by Michael I. Bushnell and Roland McGrath.  */
+
+subsystem exec_experimental 434242;
+
+#include <hurd/hurd_types.defs>
+
+#ifdef EXEC_IMPORTS
+EXEC_IMPORTS
+#endif
+
+INTR_INTERFACE
+
+routine exec_exec_file_name (
+	execserver: file_t;
+	file: mach_port_send_t;
+	oldtask: task_t;
+	flags: int;
+	filename: string_t;
+	argv: data_t SCP;
+	envp: data_t SCP;
+	dtable: portarray_t SCP;
+	portarray: portarray_t SCP;
+	intarray: intarray_t SCP;
+	deallocnames: mach_port_name_array_t;
+	destroynames: mach_port_name_array_t);
+
Index: hurd-debian/exec/Makefile
===================================================================
--- hurd-debian.orig/exec/Makefile	2014-02-03 22:48:45.000000000 +0000
+++ hurd-debian/exec/Makefile	2014-02-03 22:48:44.000000000 +0000
@@ -22,7 +22,7 @@
 
 SRCS = exec.c main.c hashexec.c hostarch.c
 OBJS = main.o hostarch.o exec.o hashexec.o \
-       execServer.o exec_startupServer.o
+       execServer.o exec_startupServer.o exec_experimentalServer.o
 
 target = exec
 #targets = exec exec.static
@@ -30,6 +30,7 @@
 
 exec-MIGSFLAGS = -imacros $(srcdir)/execmutations.h
 exec_startup-MIGSFLAGS = -imacros $(srcdir)/execmutations.h
+exec_experimental-MIGSFLAGS = -imacros $(srcdir)/execmutations.h
 
 include ../Makeconf
 
Index: hurd-debian/exec/main.c
===================================================================
--- hurd-debian.orig/exec/main.c	2014-02-03 22:48:45.000000000 +0000
+++ hurd-debian/exec/main.c	2014-02-03 23:45:19.000000000 +0000
@@ -47,6 +47,7 @@
 
 
 #include "exec_S.h"
+#include "exec_experimental_S.h"
 #include "exec_startup_S.h"
 
 static int
@@ -54,6 +55,7 @@
 {
   mig_routine_t routine;
   if ((routine = exec_server_routine (inp)) ||
+      (routine = exec_experimental_server_routine (inp)) ||
       (routine = NULL, trivfs_demuxer (inp, outp)) ||
       (routine = exec_startup_server_routine (inp)))
     {