From 3fa43c34225e960d45f444ae4c86eace1b4259a4 Mon Sep 17 00:00:00 2001 From: Justus Winter <4winter@informatik.uni-hamburg.de> Date: Fri, 5 Sep 2014 10:45:08 +0200 Subject: forgot procfs --- ...d-proc_set_init_task-make-runsystem-pid-1.patch | 392 +++++++++++++++++++++ ...d-proc_set_init_task-make-runsystem-pid-1.patch | 342 ------------------ ...not-hard-code-the-default-argument-values.patch | 43 +++ debian/patches/series | 3 +- 4 files changed, 437 insertions(+), 343 deletions(-) create mode 100644 debian/patches/0001-Add-proc_set_init_task-make-runsystem-pid-1.patch delete mode 100644 debian/patches/0002-Add-proc_set_init_task-make-runsystem-pid-1.patch create mode 100644 debian/patches/0002-procfs-do-not-hard-code-the-default-argument-values.patch (limited to 'debian') diff --git a/debian/patches/0001-Add-proc_set_init_task-make-runsystem-pid-1.patch b/debian/patches/0001-Add-proc_set_init_task-make-runsystem-pid-1.patch new file mode 100644 index 00000000..e9d6f9d4 --- /dev/null +++ b/debian/patches/0001-Add-proc_set_init_task-make-runsystem-pid-1.patch @@ -0,0 +1,392 @@ +From 7814f2ef1f48d90b15c12c5521c9c1193fe80a7b Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Wed, 18 Sep 2013 15:59:31 +0200 +Subject: [PATCH 1/8] Add proc_set_init_task, make runsystem pid 1 + +* hurd/process.defs (proc_set_init_task): New procedure. +* hurd/process_reply.defs (proc_set_init_task): Likewise. +* hurd/process_request.defs (proc_set_init_task): Likewise. +* include/pids.h: Add HURD_PID_INIT as 1, adjust others accordingly. +* init/init.c (start_child): Register the child task. +* proc/proc.h (init_proc): New variable. +(create_startup_proc): Rename to create_init_proc. +* proc/main.c (main): Create placeholder proc object for pid 1. +* proc/mgt.c: Use init_proc instead of startup_proc, as the former is +the new root of the process tree. +(create_startup_proc): Rename to create_init_proc. +(S_proc_set_init_task): New function. +* doc/hurd.texi (Server Bootstrap): Update accordingly. +* procfs/main.c: Do not hard-code kernel pid, use pids.h instead. +--- + doc/hurd.texi | 2 +- + hurd/process.defs | 6 +++- + hurd/process_reply.defs | 2 +- + hurd/process_request.defs | 7 ++++- + include/pids.h | 7 +++-- + init/init.c | 2 +- + proc/main.c | 9 ++++-- + proc/mgt.c | 76 ++++++++++++++++++++++++++++++++++------------- + proc/proc.h | 8 +++-- + procfs/main.c | 9 ++++-- + 10 files changed, 93 insertions(+), 35 deletions(-) + +diff --git a/doc/hurd.texi b/doc/hurd.texi +index 8fa6da7..697cce7 100644 +--- a/doc/hurd.texi ++++ b/doc/hurd.texi +@@ -564,7 +564,7 @@ the root filesystem and the exec server. + + The @option{--multiboot-command-line} option tells the file system server that + it is a root filesystem, which triggers it to run @command{/hurd/init} as PID +-1. @command{/hurd/init} starts the @command{/hurd/proc} and ++2. @command{/hurd/init} starts the @command{/hurd/proc} and + @command{/hurd/auth} servers. After the servers are launched + @command{/hurd/init} starts the @command{/libexec/runsystem.sh} script to + finish booting. +diff --git a/hurd/process.defs b/hurd/process.defs +index bf90556..498faba 100644 +--- a/hurd/process.defs ++++ b/hurd/process.defs +@@ -373,7 +373,11 @@ routine proc_getnports ( + + /*** Routines related to early server bootstrapping ***/ + +-skip; /* Reserved for proc_set_init_task */ ++/* Set the task of process HURD_PID_INIT. Only the startup process ++ HURD_PID_STARTUP may use this interface. */ ++routine proc_set_init_task ( ++ process: process_t; ++ task: task_t); + + /* Inform the process server that the process is important. */ + routine proc_mark_important ( +diff --git a/hurd/process_reply.defs b/hurd/process_reply.defs +index ed46d55..80454a6 100644 +--- a/hurd/process_reply.defs ++++ b/hurd/process_reply.defs +@@ -177,7 +177,7 @@ simpleroutine proc_getnports_reply ( + + /*** Routines related to early server bootstrapping ***/ + +-skip; /* Reserved for proc_set_init_task */ ++skip; /* proc_set_init_task */ + skip; /* proc_mark_important */ + + simpleroutine proc_is_important_reply ( +diff --git a/hurd/process_request.defs b/hurd/process_request.defs +index 38e7146..7565f03 100644 +--- a/hurd/process_request.defs ++++ b/hurd/process_request.defs +@@ -374,7 +374,12 @@ simpleroutine proc_getnports_request ( + + /*** Routines related to early server bootstrapping ***/ + +-skip; /* Reserved for proc_set_init_task */ ++/* Set the task of process HURD_PID_INIT. Only the startup process ++ HURD_PID_STARTUP may use this interface. */ ++simpleroutine proc_set_init_task_request ( ++ process: process_t; ++ ureplyport reply: reply_port_t; ++ task: task_t); + + /* Inform the process server that the process is important. */ + simpleroutine proc_mark_important_request ( +diff --git a/include/pids.h b/include/pids.h +index 22415f4..dff7635 100644 +--- a/include/pids.h ++++ b/include/pids.h +@@ -22,8 +22,9 @@ + #ifndef _HURD_PROCESSES_H + #define _HURD_PROCESSES_H + +-#define HURD_PID_STARTUP 1 +-#define HURD_PID_KERNEL 2 +-#define HURD_PID_PROC 3 ++#define HURD_PID_INIT 1 ++#define HURD_PID_STARTUP 2 ++#define HURD_PID_KERNEL 3 ++#define HURD_PID_PROC 4 + + #endif /* _HURD_PROCESSES_H */ +diff --git a/init/init.c b/init/init.c +index b7b40bd..6bc6701 100644 +--- a/init/init.c ++++ b/init/init.c +@@ -1058,7 +1058,7 @@ start_child (const char *prog, char **progargs) + NULL, 0, /* OSF Mach */ + #endif + 0, &child_task); +- proc_child (procserver, child_task); ++ proc_set_init_task (procserver, child_task); + proc_task2pid (procserver, child_task, &child_pid); + proc_task2proc (procserver, child_task, &default_ports[INIT_PORT_PROC]); + +diff --git a/proc/main.c b/proc/main.c +index 73742ed..f1f4e1b 100644 +--- a/proc/main.c ++++ b/proc/main.c +@@ -1,5 +1,5 @@ + /* Initialization of the proc server +- Copyright (C) 1993,94,95,96,97,99,2000,01 Free Software Foundation, Inc. ++ Copyright (C) 1993,94,95,96,97,99,2000,01,13 Free Software Foundation, Inc. + + This file is part of the GNU Hurd. + +@@ -88,7 +88,12 @@ main (int argc, char **argv, char **envp) + generic_port = ports_get_right (genport); + + /* Create the initial proc object for init (PID 1). */ +- startup_proc = create_startup_proc (); ++ init_proc = create_init_proc (); ++ ++ /* Create the startup proc object for /hurd/init (PID 2). */ ++ startup_proc = allocate_proc (MACH_PORT_NULL); ++ startup_proc->p_deadmsg = 1; ++ complete_proc (startup_proc, HURD_PID_STARTUP); + + /* Create our own proc object. */ + self_proc = allocate_proc (mach_task_self ()); +diff --git a/proc/mgt.c b/proc/mgt.c +index b8aa0fc..02d69db 100644 +--- a/proc/mgt.c ++++ b/proc/mgt.c +@@ -1,5 +1,6 @@ + /* Process management +- Copyright (C) 1992,93,94,95,96,99,2000,01,02 Free Software Foundation, Inc. ++ Copyright (C) 1992,93,94,95,96,99,2000,01,02,13 ++ Free Software Foundation, Inc. + + This file is part of the GNU Hurd. + +@@ -184,7 +185,7 @@ S_proc_child (struct proc *parentp, + /* Process hierarchy. Remove from our current location + and place us under our new parent. Sanity check to make sure + parent is currently init. */ +- assert (childp->p_parent == startup_proc); ++ assert (childp->p_parent == init_proc); + if (childp->p_sib) + childp->p_sib->p_prevsib = childp->p_prevsib; + *childp->p_prevsib = childp->p_sib; +@@ -586,7 +587,7 @@ allocate_proc (task_t task) + /* Allocate and initialize the proc structure for init (PID 1), + the original parent of all other procs. */ + struct proc * +-create_startup_proc (void) ++create_init_proc (void) + { + static const uid_t zero; + struct proc *p; +@@ -595,7 +596,7 @@ create_startup_proc (void) + p = allocate_proc (MACH_PORT_NULL); + assert (p); + +- p->p_pid = HURD_PID_STARTUP; ++ p->p_pid = HURD_PID_INIT; + + p->p_parent = p; + p->p_sib = 0; +@@ -643,7 +644,7 @@ proc_death_notify (struct proc *p) + } + + /* Complete a new process that has been allocated but not entirely initialized. +- This gets called for every process except startup_proc (PID 1). */ ++ This gets called for every process except init_proc (PID 1). */ + void + complete_proc (struct proc *p, pid_t pid) + { +@@ -662,30 +663,47 @@ complete_proc (struct proc *p, pid_t pid) + + p->p_pid = pid; + +- ids_ref (&nullids); +- p->p_id = &nullids; ++ if (pid == HURD_PID_STARTUP) ++ { ++ /* Equip HURD_PID_STARTUP with the same credentials as ++ HURD_PID_INIT. */ ++ static const uid_t zero; ++ p->p_id = make_ids (&zero, 1); ++ assert (p->p_id); ++ } ++ else ++ { ++ ids_ref (&nullids); ++ p->p_id = &nullids; ++ } + + p->p_login = nulllogin; + p->p_login->l_refcnt++; + + /* Our parent is init for now. */ +- p->p_parent = startup_proc; ++ p->p_parent = init_proc; + +- p->p_sib = startup_proc->p_ochild; +- p->p_prevsib = &startup_proc->p_ochild; ++ p->p_sib = init_proc->p_ochild; ++ p->p_prevsib = &init_proc->p_ochild; + if (p->p_sib) + p->p_sib->p_prevsib = &p->p_sib; +- startup_proc->p_ochild = p; ++ init_proc->p_ochild = p; + p->p_loginleader = 0; + p->p_ochild = 0; + p->p_parentset = 0; + + p->p_noowner = 1; + +- p->p_pgrp = startup_proc->p_pgrp; ++ p->p_pgrp = init_proc->p_pgrp; + +- proc_death_notify (p); +- add_proc_to_hash (p); ++ /* At this point, we do not know the task of the startup process, ++ defer registering death notifications and adding it to the hash ++ tables. */ ++ if (pid != HURD_PID_STARTUP) ++ { ++ proc_death_notify (p); ++ add_proc_to_hash (p); ++ } + join_pgrp (p); + } + +@@ -747,7 +765,7 @@ process_has_exited (struct proc *p) + nowait_msg_proc_newids (tp->p_msgport, tp->p_task, + 1, tp->p_pgrp->pg_pgid, + !tp->p_pgrp->pg_orphcnt); +- tp->p_parent = startup_proc; ++ tp->p_parent = init_proc; + if (tp->p_dead) + isdead = 1; + } +@@ -755,17 +773,17 @@ process_has_exited (struct proc *p) + nowait_msg_proc_newids (tp->p_msgport, tp->p_task, + 1, tp->p_pgrp->pg_pgid, + !tp->p_pgrp->pg_orphcnt); +- tp->p_parent = startup_proc; ++ tp->p_parent = init_proc; + + /* And now append the lists. */ +- tp->p_sib = startup_proc->p_ochild; ++ tp->p_sib = init_proc->p_ochild; + if (tp->p_sib) + tp->p_sib->p_prevsib = &tp->p_sib; +- startup_proc->p_ochild = p->p_ochild; +- p->p_ochild->p_prevsib = &startup_proc->p_ochild; ++ init_proc->p_ochild = p->p_ochild; ++ p->p_ochild->p_prevsib = &init_proc->p_ochild; + + if (isdead) +- alert_parent (startup_proc); ++ alert_parent (init_proc); + } + + /* If an operation is in progress for this process, cause it +@@ -883,6 +901,24 @@ genpid () + return nextpid++; + } + ++/* Implement proc_set_init_task as described in . */ ++error_t ++S_proc_set_init_task(struct proc *callerp, ++ task_t task) ++{ ++ if (! callerp) ++ return EOPNOTSUPP; ++ ++ if (callerp != startup_proc) ++ return EPERM; ++ ++ init_proc->p_task = task; ++ proc_death_notify (init_proc); ++ add_proc_to_hash (init_proc); ++ ++ return 0; ++} ++ + /* Implement proc_mark_important as described in . */ + kern_return_t + S_proc_mark_important (struct proc *p) +diff --git a/proc/proc.h b/proc/proc.h +index a2e3c53..6196697 100644 +--- a/proc/proc.h ++++ b/proc/proc.h +@@ -1,5 +1,6 @@ + /* Process server definitions +- Copyright (C) 1992,93,94,95,96,99,2000,01 Free Software Foundation, Inc. ++ Copyright (C) 1992,93,94,95,96,99,2000,01,13 ++ Free Software Foundation, Inc. + + This file is part of the GNU Hurd. + +@@ -134,7 +135,8 @@ struct exc + + mach_port_t authserver; + struct proc *self_proc; /* process HURD_PID_PROC (us) */ +-struct proc *startup_proc; /* process 1 (init) */ ++struct proc *init_proc; /* process 1 (sysvinit) */ ++struct proc *startup_proc; /* process 2 (hurd/init) */ + + struct port_bucket *proc_bucket; + struct port_class *proc_class; +@@ -183,7 +185,7 @@ void exc_clean (void *); + struct proc *add_tasks (task_t); + int pidfree (pid_t); + +-struct proc *create_startup_proc (void); ++struct proc *create_init_proc (void); + struct proc *allocate_proc (task_t); + void proc_death_notify (struct proc *); + void complete_proc (struct proc *, pid_t); +diff --git a/procfs/main.c b/procfs/main.c +index 54e9682..f3067d9 100644 +--- a/procfs/main.c ++++ b/procfs/main.c +@@ -25,6 +25,7 @@ + #include + #include + #include ++#include + #include "procfs.h" + #include "proclist.h" + #include "rootdir.h" +@@ -42,7 +43,7 @@ uid_t opt_anon_owner; + #define OPT_CLK_TCK sysconf(_SC_CLK_TCK) + #define OPT_STAT_MODE 0400 + #define OPT_FAKE_SELF -1 +-#define OPT_KERNEL_PID 2 ++#define OPT_KERNEL_PID HURD_PID_KERNEL + #define OPT_ANON_OWNER 0 + + #define NODEV_KEY -1 /* <= 0, so no short option. */ +@@ -137,6 +138,8 @@ argp_parser (int key, char *arg, struct argp_state *state) + } + + struct argp_option common_options[] = { ++#define STR(X) XSTR (X) ++#define XSTR(X) #X + { "clk-tck", 'h', "HZ", 0, + "Unit used for the values expressed in system clock ticks " + "(default: sysconf(_SC_CLK_TCK))" }, +@@ -153,7 +156,7 @@ struct argp_option common_options[] = { + { "kernel-process", 'k', "PID", 0, + "Process identifier for the kernel, used to retreive its command " + "line, as well as the global up and idle times. " +- "(default: 2)" }, ++ "(default: " STR (OPT_KERNEL_PID) ")" }, + { "compatible", 'c', NULL, 0, + "Try to be compatible with the Linux procps utilities. " + "Currently equivalent to -h 100 -s 0444 -S 1." }, +@@ -169,6 +172,8 @@ struct argp_option common_options[] = { + { "nosuid", NOSUID_KEY, NULL, 0, + "Ignored for compatibility with Linux' procfs." }, + {} ++#undef XSTR ++#undef STR + }; + + struct argp argp = { +-- +2.1.0 + diff --git a/debian/patches/0002-Add-proc_set_init_task-make-runsystem-pid-1.patch b/debian/patches/0002-Add-proc_set_init_task-make-runsystem-pid-1.patch deleted file mode 100644 index dee6932d..00000000 --- a/debian/patches/0002-Add-proc_set_init_task-make-runsystem-pid-1.patch +++ /dev/null @@ -1,342 +0,0 @@ -From 34625240c68a6eeddc8d175bb355adfd1e33a71c Mon Sep 17 00:00:00 2001 -From: Justus Winter <4winter@informatik.uni-hamburg.de> -Date: Wed, 18 Sep 2013 15:59:31 +0200 -Subject: [PATCH 2/8] Add proc_set_init_task, make runsystem pid 1 - -* hurd/process.defs (proc_set_init_task): New procedure. -* hurd/process_reply.defs (proc_set_init_task): Likewise. -* hurd/process_request.defs (proc_set_init_task): Likewise. -* include/pids.h: Add HURD_PID_INIT as 1, adjust others accordingly. -* init/init.c (start_child): Register the child task. -* proc/proc.h (init_proc): New variable. -(create_startup_proc): Rename to create_init_proc. -* proc/main.c (main): Create placeholder proc object for pid 1. -* proc/mgt.c: Use init_proc instead of startup_proc, as the former is -the new root of the process tree. -(create_startup_proc): Rename to create_init_proc. -(S_proc_set_init_task): New function. -* doc/hurd.texi (Server Bootstrap): Update accordingly. ---- - doc/hurd.texi | 2 +- - hurd/process.defs | 6 +++- - hurd/process_reply.defs | 2 +- - hurd/process_request.defs | 7 ++++- - include/pids.h | 7 +++-- - init/init.c | 2 +- - proc/main.c | 9 ++++-- - proc/mgt.c | 76 ++++++++++++++++++++++++++++++++++------------- - proc/proc.h | 8 +++-- - 9 files changed, 86 insertions(+), 33 deletions(-) - -diff --git a/doc/hurd.texi b/doc/hurd.texi -index 8fa6da7..697cce7 100644 ---- a/doc/hurd.texi -+++ b/doc/hurd.texi -@@ -564,7 +564,7 @@ the root filesystem and the exec server. - - The @option{--multiboot-command-line} option tells the file system server that - it is a root filesystem, which triggers it to run @command{/hurd/init} as PID --1. @command{/hurd/init} starts the @command{/hurd/proc} and -+2. @command{/hurd/init} starts the @command{/hurd/proc} and - @command{/hurd/auth} servers. After the servers are launched - @command{/hurd/init} starts the @command{/libexec/runsystem.sh} script to - finish booting. -diff --git a/hurd/process.defs b/hurd/process.defs -index bf90556..498faba 100644 ---- a/hurd/process.defs -+++ b/hurd/process.defs -@@ -373,7 +373,11 @@ routine proc_getnports ( - - /*** Routines related to early server bootstrapping ***/ - --skip; /* Reserved for proc_set_init_task */ -+/* Set the task of process HURD_PID_INIT. Only the startup process -+ HURD_PID_STARTUP may use this interface. */ -+routine proc_set_init_task ( -+ process: process_t; -+ task: task_t); - - /* Inform the process server that the process is important. */ - routine proc_mark_important ( -diff --git a/hurd/process_reply.defs b/hurd/process_reply.defs -index ed46d55..80454a6 100644 ---- a/hurd/process_reply.defs -+++ b/hurd/process_reply.defs -@@ -177,7 +177,7 @@ simpleroutine proc_getnports_reply ( - - /*** Routines related to early server bootstrapping ***/ - --skip; /* Reserved for proc_set_init_task */ -+skip; /* proc_set_init_task */ - skip; /* proc_mark_important */ - - simpleroutine proc_is_important_reply ( -diff --git a/hurd/process_request.defs b/hurd/process_request.defs -index 38e7146..7565f03 100644 ---- a/hurd/process_request.defs -+++ b/hurd/process_request.defs -@@ -374,7 +374,12 @@ simpleroutine proc_getnports_request ( - - /*** Routines related to early server bootstrapping ***/ - --skip; /* Reserved for proc_set_init_task */ -+/* Set the task of process HURD_PID_INIT. Only the startup process -+ HURD_PID_STARTUP may use this interface. */ -+simpleroutine proc_set_init_task_request ( -+ process: process_t; -+ ureplyport reply: reply_port_t; -+ task: task_t); - - /* Inform the process server that the process is important. */ - simpleroutine proc_mark_important_request ( -diff --git a/include/pids.h b/include/pids.h -index 22415f4..dff7635 100644 ---- a/include/pids.h -+++ b/include/pids.h -@@ -22,8 +22,9 @@ - #ifndef _HURD_PROCESSES_H - #define _HURD_PROCESSES_H - --#define HURD_PID_STARTUP 1 --#define HURD_PID_KERNEL 2 --#define HURD_PID_PROC 3 -+#define HURD_PID_INIT 1 -+#define HURD_PID_STARTUP 2 -+#define HURD_PID_KERNEL 3 -+#define HURD_PID_PROC 4 - - #endif /* _HURD_PROCESSES_H */ -diff --git a/init/init.c b/init/init.c -index b7b40bd..6bc6701 100644 ---- a/init/init.c -+++ b/init/init.c -@@ -1058,7 +1058,7 @@ start_child (const char *prog, char **progargs) - NULL, 0, /* OSF Mach */ - #endif - 0, &child_task); -- proc_child (procserver, child_task); -+ proc_set_init_task (procserver, child_task); - proc_task2pid (procserver, child_task, &child_pid); - proc_task2proc (procserver, child_task, &default_ports[INIT_PORT_PROC]); - -diff --git a/proc/main.c b/proc/main.c -index 73742ed..f1f4e1b 100644 ---- a/proc/main.c -+++ b/proc/main.c -@@ -1,5 +1,5 @@ - /* Initialization of the proc server -- Copyright (C) 1993,94,95,96,97,99,2000,01 Free Software Foundation, Inc. -+ Copyright (C) 1993,94,95,96,97,99,2000,01,13 Free Software Foundation, Inc. - - This file is part of the GNU Hurd. - -@@ -88,7 +88,12 @@ main (int argc, char **argv, char **envp) - generic_port = ports_get_right (genport); - - /* Create the initial proc object for init (PID 1). */ -- startup_proc = create_startup_proc (); -+ init_proc = create_init_proc (); -+ -+ /* Create the startup proc object for /hurd/init (PID 2). */ -+ startup_proc = allocate_proc (MACH_PORT_NULL); -+ startup_proc->p_deadmsg = 1; -+ complete_proc (startup_proc, HURD_PID_STARTUP); - - /* Create our own proc object. */ - self_proc = allocate_proc (mach_task_self ()); -diff --git a/proc/mgt.c b/proc/mgt.c -index b8aa0fc..02d69db 100644 ---- a/proc/mgt.c -+++ b/proc/mgt.c -@@ -1,5 +1,6 @@ - /* Process management -- Copyright (C) 1992,93,94,95,96,99,2000,01,02 Free Software Foundation, Inc. -+ Copyright (C) 1992,93,94,95,96,99,2000,01,02,13 -+ Free Software Foundation, Inc. - - This file is part of the GNU Hurd. - -@@ -184,7 +185,7 @@ S_proc_child (struct proc *parentp, - /* Process hierarchy. Remove from our current location - and place us under our new parent. Sanity check to make sure - parent is currently init. */ -- assert (childp->p_parent == startup_proc); -+ assert (childp->p_parent == init_proc); - if (childp->p_sib) - childp->p_sib->p_prevsib = childp->p_prevsib; - *childp->p_prevsib = childp->p_sib; -@@ -586,7 +587,7 @@ allocate_proc (task_t task) - /* Allocate and initialize the proc structure for init (PID 1), - the original parent of all other procs. */ - struct proc * --create_startup_proc (void) -+create_init_proc (void) - { - static const uid_t zero; - struct proc *p; -@@ -595,7 +596,7 @@ create_startup_proc (void) - p = allocate_proc (MACH_PORT_NULL); - assert (p); - -- p->p_pid = HURD_PID_STARTUP; -+ p->p_pid = HURD_PID_INIT; - - p->p_parent = p; - p->p_sib = 0; -@@ -643,7 +644,7 @@ proc_death_notify (struct proc *p) - } - - /* Complete a new process that has been allocated but not entirely initialized. -- This gets called for every process except startup_proc (PID 1). */ -+ This gets called for every process except init_proc (PID 1). */ - void - complete_proc (struct proc *p, pid_t pid) - { -@@ -662,30 +663,47 @@ complete_proc (struct proc *p, pid_t pid) - - p->p_pid = pid; - -- ids_ref (&nullids); -- p->p_id = &nullids; -+ if (pid == HURD_PID_STARTUP) -+ { -+ /* Equip HURD_PID_STARTUP with the same credentials as -+ HURD_PID_INIT. */ -+ static const uid_t zero; -+ p->p_id = make_ids (&zero, 1); -+ assert (p->p_id); -+ } -+ else -+ { -+ ids_ref (&nullids); -+ p->p_id = &nullids; -+ } - - p->p_login = nulllogin; - p->p_login->l_refcnt++; - - /* Our parent is init for now. */ -- p->p_parent = startup_proc; -+ p->p_parent = init_proc; - -- p->p_sib = startup_proc->p_ochild; -- p->p_prevsib = &startup_proc->p_ochild; -+ p->p_sib = init_proc->p_ochild; -+ p->p_prevsib = &init_proc->p_ochild; - if (p->p_sib) - p->p_sib->p_prevsib = &p->p_sib; -- startup_proc->p_ochild = p; -+ init_proc->p_ochild = p; - p->p_loginleader = 0; - p->p_ochild = 0; - p->p_parentset = 0; - - p->p_noowner = 1; - -- p->p_pgrp = startup_proc->p_pgrp; -+ p->p_pgrp = init_proc->p_pgrp; - -- proc_death_notify (p); -- add_proc_to_hash (p); -+ /* At this point, we do not know the task of the startup process, -+ defer registering death notifications and adding it to the hash -+ tables. */ -+ if (pid != HURD_PID_STARTUP) -+ { -+ proc_death_notify (p); -+ add_proc_to_hash (p); -+ } - join_pgrp (p); - } - -@@ -747,7 +765,7 @@ process_has_exited (struct proc *p) - nowait_msg_proc_newids (tp->p_msgport, tp->p_task, - 1, tp->p_pgrp->pg_pgid, - !tp->p_pgrp->pg_orphcnt); -- tp->p_parent = startup_proc; -+ tp->p_parent = init_proc; - if (tp->p_dead) - isdead = 1; - } -@@ -755,17 +773,17 @@ process_has_exited (struct proc *p) - nowait_msg_proc_newids (tp->p_msgport, tp->p_task, - 1, tp->p_pgrp->pg_pgid, - !tp->p_pgrp->pg_orphcnt); -- tp->p_parent = startup_proc; -+ tp->p_parent = init_proc; - - /* And now append the lists. */ -- tp->p_sib = startup_proc->p_ochild; -+ tp->p_sib = init_proc->p_ochild; - if (tp->p_sib) - tp->p_sib->p_prevsib = &tp->p_sib; -- startup_proc->p_ochild = p->p_ochild; -- p->p_ochild->p_prevsib = &startup_proc->p_ochild; -+ init_proc->p_ochild = p->p_ochild; -+ p->p_ochild->p_prevsib = &init_proc->p_ochild; - - if (isdead) -- alert_parent (startup_proc); -+ alert_parent (init_proc); - } - - /* If an operation is in progress for this process, cause it -@@ -883,6 +901,24 @@ genpid () - return nextpid++; - } - -+/* Implement proc_set_init_task as described in . */ -+error_t -+S_proc_set_init_task(struct proc *callerp, -+ task_t task) -+{ -+ if (! callerp) -+ return EOPNOTSUPP; -+ -+ if (callerp != startup_proc) -+ return EPERM; -+ -+ init_proc->p_task = task; -+ proc_death_notify (init_proc); -+ add_proc_to_hash (init_proc); -+ -+ return 0; -+} -+ - /* Implement proc_mark_important as described in . */ - kern_return_t - S_proc_mark_important (struct proc *p) -diff --git a/proc/proc.h b/proc/proc.h -index a2e3c53..6196697 100644 ---- a/proc/proc.h -+++ b/proc/proc.h -@@ -1,5 +1,6 @@ - /* Process server definitions -- Copyright (C) 1992,93,94,95,96,99,2000,01 Free Software Foundation, Inc. -+ Copyright (C) 1992,93,94,95,96,99,2000,01,13 -+ Free Software Foundation, Inc. - - This file is part of the GNU Hurd. - -@@ -134,7 +135,8 @@ struct exc - - mach_port_t authserver; - struct proc *self_proc; /* process HURD_PID_PROC (us) */ --struct proc *startup_proc; /* process 1 (init) */ -+struct proc *init_proc; /* process 1 (sysvinit) */ -+struct proc *startup_proc; /* process 2 (hurd/init) */ - - struct port_bucket *proc_bucket; - struct port_class *proc_class; -@@ -183,7 +185,7 @@ void exc_clean (void *); - struct proc *add_tasks (task_t); - int pidfree (pid_t); - --struct proc *create_startup_proc (void); -+struct proc *create_init_proc (void); - struct proc *allocate_proc (task_t); - void proc_death_notify (struct proc *); - void complete_proc (struct proc *, pid_t); --- -2.1.0 - diff --git a/debian/patches/0002-procfs-do-not-hard-code-the-default-argument-values.patch b/debian/patches/0002-procfs-do-not-hard-code-the-default-argument-values.patch new file mode 100644 index 00000000..70b41c14 --- /dev/null +++ b/debian/patches/0002-procfs-do-not-hard-code-the-default-argument-values.patch @@ -0,0 +1,43 @@ +From 7a0bc7740d665cf8ea3442960fde67d28dda4ecf Mon Sep 17 00:00:00 2001 +From: Justus Winter <4winter@informatik.uni-hamburg.de> +Date: Fri, 5 Sep 2014 10:34:24 +0200 +Subject: [PATCH 2/8] procfs: do not hard-code the default argument values + +* procfs/main.c (common_options): If possible, do not hard-code the +default values. +--- + procfs/main.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/procfs/main.c b/procfs/main.c +index f3067d9..36a2d25 100644 +--- a/procfs/main.c ++++ b/procfs/main.c +@@ -142,13 +142,13 @@ struct argp_option common_options[] = { + #define XSTR(X) #X + { "clk-tck", 'h', "HZ", 0, + "Unit used for the values expressed in system clock ticks " +- "(default: sysconf(_SC_CLK_TCK))" }, ++ "(default: " STR (OPT_CLK_TCK) ")" }, + { "stat-mode", 's', "MODE", 0, + "The [pid]/stat file publishes information which on Hurd is only " + "available to the process owner. " + "You can use this option to override its mode to be more permissive " + "for compatibility purposes. " +- "(default: 0400)" }, ++ "(default: " STR (OPT_STAT_MODE) ")" }, + { "fake-self", 'S', "PID", OPTION_ARG_OPTIONAL, + "Provide a fake \"self\" symlink to the given PID, for compatibility " + "purposes. If PID is omitted, \"self\" will point to init. " +@@ -164,7 +164,7 @@ struct argp_option common_options[] = { + "Make USER the owner of files related to processes without one. " + "Be aware that USER will be granted access to the environment and " + "other sensitive information about the processes in question. " +- "(default: use uid 0)" }, ++ "(default: use uid " STR (OPT_ANON_OWNER) ")" }, + { "nodev", NODEV_KEY, NULL, 0, + "Ignored for compatibility with Linux' procfs." }, + { "noexec", NOEXEC_KEY, NULL, 0, +-- +2.1.0 + diff --git a/debian/patches/series b/debian/patches/series index 82b6286e..58c6c811 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -1,4 +1,5 @@ -0002-Add-proc_set_init_task-make-runsystem-pid-1.patch +0001-Add-proc_set_init_task-make-runsystem-pid-1.patch +0002-procfs-do-not-hard-code-the-default-argument-values.patch 0003-startup-rename-hurd-init-to-hurd-startup.patch 0004-init-add-a-minimalist-init-program.patch 0005-startup-do-not-pass-signals-on-to-the-child.patch -- cgit v1.2.3