summaryrefslogtreecommitdiff
path: root/debian/patches/startup-0008-startup-bind-the-startup-server-to-servers-startup.patch
diff options
context:
space:
mode:
Diffstat (limited to 'debian/patches/startup-0008-startup-bind-the-startup-server-to-servers-startup.patch')
-rw-r--r--debian/patches/startup-0008-startup-bind-the-startup-server-to-servers-startup.patch344
1 files changed, 344 insertions, 0 deletions
diff --git a/debian/patches/startup-0008-startup-bind-the-startup-server-to-servers-startup.patch b/debian/patches/startup-0008-startup-bind-the-startup-server-to-servers-startup.patch
new file mode 100644
index 00000000..d3633eb0
--- /dev/null
+++ b/debian/patches/startup-0008-startup-bind-the-startup-server-to-servers-startup.patch
@@ -0,0 +1,344 @@
+From ccce2ecc7426fc65d05db387b5d8390644c17dc5 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Thu, 19 Sep 2013 09:15:02 +0200
+Subject: [PATCH 8/8] startup: bind the startup server to /servers/startup
+
+Previously, the Hurd (ab)used the fact that the startup server speaks
+all protocols on its message port. Any server that wished to register
+for shutdown notifications would use XXX to get a port to the startup
+server.
+
+This hardcodes the PID of /hurd/startup, and does not allow one to
+point a server to ones own startup server (e.g. using remap).
+
+Bind the startup server to /servers/startup instead. Use this to
+contact the startup server.
+
+* exec/main.c (S_exec_init): Use /servers/startup. Fall back to the
+old method so that the system still boots when the node
+/servers/startup is missing.
+* hurd/paths.h (_SERVERS_STARTUP): New macro.
+* libdiskfs/boot-start.c (diskfs_S_fsys_init): Use /servers/startup.
+* libdiskfs/init-startup.c (_diskfs_init_completed): Likewise.
+* pfinet/main.c (arrange_shutdown_notification): Likewise.
+* startup/Makefile (OBJS): Add fsysServer.o.
+* startup/startup.c (demuxer): Handle the fsys protocol.
+(main): Bind to /servers/startup.
+(S_fsys_getroot): Implement fsys_getroot. Stub out the rest.
+---
+ exec/main.c | 11 ++++-
+ hurd/paths.h | 1 +
+ libdiskfs/boot-start.c | 9 ++--
+ libdiskfs/init-startup.c | 13 ++++--
+ pfinet/main.c | 12 ++---
+ startup/Makefile | 2 +-
+ startup/startup.c | 119 +++++++++++++++++++++++++++++++++++++++++++++++
+ 7 files changed, 146 insertions(+), 21 deletions(-)
+
+diff --git a/exec/main.c b/exec/main.c
+index 78faebd..664f150 100644
+--- a/exec/main.c
++++ b/exec/main.c
+@@ -251,8 +251,15 @@ S_exec_init (struct trivfs_protid *protid,
+
+ proc_register_version (procserver, host_priv, "exec", "", HURD_VERSION);
+
+- err = proc_getmsgport (procserver, HURD_PID_STARTUP, &startup);
+- assert_perror (err);
++ startup = file_name_lookup (_SERVERS_STARTUP, 0, 0);
++ if (startup == MACH_PORT_NULL)
++ {
++ error (0, errno, "%s", _SERVERS_STARTUP);
++
++ /* Fall back to abusing the message port lookup. */
++ err = proc_getmsgport (procserver, HURD_PID_STARTUP, &startup);
++ assert_perror (err);
++ }
+ mach_port_deallocate (mach_task_self (), procserver);
+
+ /* Call startup_essential task last; init assumes we are ready to
+diff --git a/hurd/paths.h b/hurd/paths.h
+index 489da57..568e45f 100644
+--- a/hurd/paths.h
++++ b/hurd/paths.h
+@@ -26,6 +26,7 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ #define _SERVERS "/servers/"
+ #define _SERVERS_CRASH _SERVERS "crash"
+ #define _SERVERS_EXEC _SERVERS "exec"
++#define _SERVERS_STARTUP _SERVERS "startup"
+ #define _SERVERS_PROC _SERVERS "proc"
+ #define _SERVERS_PASSWORD _SERVERS "password"
+ #define _SERVERS_DEFPAGER _SERVERS "default-pager"
+diff --git a/libdiskfs/boot-start.c b/libdiskfs/boot-start.c
+index 42e991e..cfe2303 100644
+--- a/libdiskfs/boot-start.c
++++ b/libdiskfs/boot-start.c
+@@ -33,7 +33,6 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ #include <string.h>
+ #include <argz.h>
+ #include <error.h>
+-#include <pids.h>
+ #include "exec_S.h"
+ #include "exec_startup_S.h"
+ #include "fsys_S.h"
+@@ -602,9 +601,12 @@ diskfs_S_fsys_init (struct diskfs_control *pt,
+
+ proc_register_version (procserver, host, diskfs_server_name, "",
+ diskfs_server_version);
++ mach_port_deallocate (mach_task_self (), procserver);
+
+- err = proc_getmsgport (procserver, HURD_PID_STARTUP, &startup);
+- if (!err)
++ startup = file_name_lookup (_SERVERS_STARTUP, 0, 0);
++ if (startup == MACH_PORT_NULL)
++ error (0, errno, "%s", _SERVERS_STARTUP);
++ else
+ {
+ startup_essential_task (startup, mach_task_self (), MACH_PORT_NULL,
+ diskfs_server_name, host);
+@@ -612,7 +614,6 @@ diskfs_S_fsys_init (struct diskfs_control *pt,
+ }
+
+ mach_port_deallocate (mach_task_self (), host);
+- mach_port_deallocate (mach_task_self (), procserver);
+
+ _diskfs_init_completed ();
+
+diff --git a/libdiskfs/init-startup.c b/libdiskfs/init-startup.c
+index d10c964..3a588e1 100644
+--- a/libdiskfs/init-startup.c
++++ b/libdiskfs/init-startup.c
+@@ -25,8 +25,8 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
+ #include <fcntl.h>
+ #include <error.h>
+ #include <hurd/fsys.h>
++#include <hurd/paths.h>
+ #include <hurd/startup.h>
+-#include <pids.h>
+
+ #include "startup_S.h"
+
+@@ -195,15 +195,18 @@ _diskfs_init_completed ()
+
+ /* Mark us as important. */
+ err = proc_mark_important (proc);
++ mach_port_deallocate (mach_task_self (), proc);
+ /* This might fail due to permissions or because the old proc server
+ is still running, ignore any such errors. */
+ if (err && err != EPERM && err != EMIG_BAD_ID)
+ goto errout;
+
+- err = proc_getmsgport (proc, HURD_PID_STARTUP, &init);
+- mach_port_deallocate (mach_task_self (), proc);
+- if (err)
+- goto errout;
++ init = file_name_lookup (_SERVERS_STARTUP, 0, 0);
++ if (init == MACH_PORT_NULL)
++ {
++ err = errno;
++ goto errout;
++ }
+
+ notify = ports_get_send_right (pi);
+ ports_port_deref (pi);
+diff --git a/pfinet/main.c b/pfinet/main.c
+index 5b0262f..3cd5f13 100644
+--- a/pfinet/main.c
++++ b/pfinet/main.c
+@@ -24,11 +24,11 @@
+ #include <arpa/inet.h>
+ #include <error.h>
+ #include <argp.h>
++#include <hurd/paths.h>
+ #include <hurd/startup.h>
+ #include <string.h>
+ #include <fcntl.h>
+ #include <version.h>
+-#include <pids.h>
+
+ /* Include Hurd's errno.h file, but don't include glue-include/hurd/errno.h,
+ since it #undef's the errno macro. */
+@@ -154,7 +154,6 @@ arrange_shutdown_notification ()
+ {
+ error_t err;
+ mach_port_t initport, notify;
+- process_t procserver;
+ struct port_info *pi;
+
+ shutdown_notify_class = ports_create_class (0, 0);
+@@ -169,13 +168,8 @@ arrange_shutdown_notification ()
+ if (err)
+ return;
+
+- procserver = getproc ();
+- if (!procserver)
+- return;
+-
+- err = proc_getmsgport (procserver, HURD_PID_STARTUP, &initport);
+- mach_port_deallocate (mach_task_self (), procserver);
+- if (err)
++ initport = file_name_lookup (_SERVERS_STARTUP, 0, 0);
++ if (initport == MACH_PORT_NULL)
+ return;
+
+ notify = ports_get_send_right (pi);
+diff --git a/startup/Makefile b/startup/Makefile
+index 277fee4..23d35cb 100644
+--- a/startup/Makefile
++++ b/startup/Makefile
+@@ -21,7 +21,7 @@ makemode := server
+ SRCS = startup.c
+ OBJS = $(SRCS:.c=.o) \
+ startupServer.o notifyServer.o startup_replyUser.o msgServer.o \
+- startup_notifyUser.o
++ startup_notifyUser.o fsysServer.o
+ target = startup
+ HURDLIBS = shouldbeinlibc
+
+diff --git a/startup/startup.c b/startup/startup.c
+index fe8471d..ff58270 100644
+--- a/startup/startup.c
++++ b/startup/startup.c
+@@ -504,9 +504,11 @@ demuxer (mach_msg_header_t *inp,
+ 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));
+ }
+
+@@ -583,6 +585,18 @@ main (int argc, char **argv, char **envp)
+ /* Crash if the boot filesystem task dies. */
+ request_dead_name (fstask);
+
++ file_t node = file_name_lookup (_SERVERS_STARTUP, O_NOTRANS, 0);
++ if (node == MACH_PORT_NULL)
++ error (0, errno, "%s", _SERVERS_STARTUP);
++ else
++ {
++ file_set_translator (node,
++ 0, FS_TRANS_SET, 0,
++ NULL, 0,
++ startup, MACH_MSG_TYPE_COPY_SEND);
++ mach_port_deallocate (mach_task_self (), node);
++ }
++
+ /* Set up the set of ports we will pass to the programs we exec. */
+ for (i = 0; i < INIT_PORT_MAX; i++)
+ switch (i)
+@@ -1544,3 +1558,108 @@ S_msg_report_wait (mach_port_t process, thread_t thread,
+ *rpc = 0;
+ return 0;
+ }
++
++/* fsys */
++error_t
++S_fsys_getroot (mach_port_t fsys_t,
++ mach_port_t dotdotnode,
++ uid_t *uids, size_t nuids,
++ uid_t *gids, size_t ngids,
++ int flags,
++ retry_type *do_retry,
++ char *retry_name,
++ mach_port_t *ret,
++ mach_msg_type_name_t *rettype)
++{
++ int is_root = 0;
++ size_t i;
++
++ for (i = 0; i < nuids; i++)
++ if (uids[i] == 0)
++ {
++ is_root = 1;
++ break;
++ }
++
++ if (! is_root)
++ return EPERM;
++
++ *do_retry = FS_RETRY_NORMAL;
++ *retry_name = '\0';
++ *ret = startup;
++ *rettype = MACH_MSG_TYPE_COPY_SEND;
++ return 0;
++}
++
++error_t
++S_fsys_goaway (mach_port_t control, int flags)
++{
++ return EOPNOTSUPP;
++}
++
++error_t
++S_fsys_startup (mach_port_t bootstrap, int flags, mach_port_t control,
++ mach_port_t *real, mach_msg_type_name_t *realtype)
++{
++ return EOPNOTSUPP;
++}
++
++error_t
++S_fsys_syncfs (mach_port_t control,
++ int wait,
++ int recurse)
++{
++ return EOPNOTSUPP;
++}
++
++error_t
++S_fsys_set_options (mach_port_t control,
++ char *data, mach_msg_type_number_t len,
++ int do_children)
++{
++ return EOPNOTSUPP;
++}
++
++error_t
++S_fsys_get_options (mach_port_t control,
++ char **data, mach_msg_type_number_t *len)
++{
++ return EOPNOTSUPP;
++}
++
++error_t
++S_fsys_getfile (mach_port_t control,
++ uid_t *uids, size_t nuids,
++ uid_t *gids, size_t ngids,
++ char *handle, size_t handllen,
++ mach_port_t *pt,
++ mach_msg_type_name_t *pttype)
++{
++ return EOPNOTSUPP;
++}
++
++error_t
++S_fsys_getpriv (mach_port_t control,
++ mach_port_t *host_priv, mach_msg_type_name_t *host_priv_type,
++ mach_port_t *dev_master, mach_msg_type_name_t *dev_master_type,
++ task_t *fs_task, mach_msg_type_name_t *fs_task_type)
++{
++ return EOPNOTSUPP;
++}
++
++error_t
++S_fsys_init (mach_port_t control,
++ mach_port_t reply,
++ mach_msg_type_name_t replytype,
++ mach_port_t proc,
++ auth_t auth)
++{
++ return EOPNOTSUPP;
++}
++
++error_t
++S_fsys_forward (mach_port_t server, mach_port_t requestor,
++ char *argz, size_t argz_len)
++{
++ return EOPNOTSUPP;
++}
+--
+2.1.0
+