summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/patches/0001-term-improve-the-demuxer.patch60
-rw-r--r--debian/patches/0002-hurd-fix-receiver-lookup-in-termctty_open_terminal.patch199
-rw-r--r--debian/patches/0003-libdiskfs-add-permission-check-to-file_chflags.patch50
-rw-r--r--debian/patches/0004-utils-settrans-implement-settrans-start.patch98
-rw-r--r--debian/patches/series4
5 files changed, 411 insertions, 0 deletions
diff --git a/debian/patches/0001-term-improve-the-demuxer.patch b/debian/patches/0001-term-improve-the-demuxer.patch
new file mode 100644
index 00000000..b7b5d63e
--- /dev/null
+++ b/debian/patches/0001-term-improve-the-demuxer.patch
@@ -0,0 +1,60 @@
+From 7092a17e6c503c7843618e9f1118c55359c79f2e Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Tue, 10 Jun 2014 14:49:46 +0200
+Subject: [PATCH 1/4] term: improve the demuxer
+
+Handle multiple request types as recommended by the Mach Server
+Writer's Guide section 4, subsection "Handling Multiple Request
+Types". This avoids initializing the reply message in every X_server
+function.
+
+* term/main.c (demuxer): Improve the demuxer function.
+---
+ term/main.c | 24 ++++++++++++++++--------
+ 1 file changed, 16 insertions(+), 8 deletions(-)
+
+diff --git a/term/main.c b/term/main.c
+index 9cc32d4..be014e1 100644
+--- a/term/main.c
++++ b/term/main.c
+@@ -32,6 +32,10 @@
+
+ #include <version.h>
+
++#include "term_S.h"
++#include "tioctl_S.h"
++#include "device_reply_S.h"
++
+ const char *argp_program_version = STANDARD_HURD_VERSION (term);
+
+ int trivfs_fstype = FSTYPE_TERM;
+@@ -61,14 +65,18 @@ dev_t rdev;
+ int
+ demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp)
+ {
+- extern int term_server (mach_msg_header_t *, mach_msg_header_t *);
+- extern int tioctl_server (mach_msg_header_t *, mach_msg_header_t *);
+- extern int device_reply_server (mach_msg_header_t *, mach_msg_header_t *);
+-
+- return (trivfs_demuxer (inp, outp)
+- || term_server (inp, outp)
+- || tioctl_server (inp, outp)
+- || device_reply_server (inp, outp));
++ mig_routine_t routine;
++ if ((routine = NULL, trivfs_demuxer (inp, outp)) ||
++ (routine = term_server_routine (inp)) ||
++ (routine = tioctl_server_routine (inp)) ||
++ (routine = device_reply_server_routine (inp)))
++ {
++ if (routine)
++ (*routine) (inp, outp);
++ return TRUE;
++ }
++ else
++ return FALSE;
+ }
+
+ static struct argp_option options[] =
+--
+2.0.0
+
diff --git a/debian/patches/0002-hurd-fix-receiver-lookup-in-termctty_open_terminal.patch b/debian/patches/0002-hurd-fix-receiver-lookup-in-termctty_open_terminal.patch
new file mode 100644
index 00000000..f0781900
--- /dev/null
+++ b/debian/patches/0002-hurd-fix-receiver-lookup-in-termctty_open_terminal.patch
@@ -0,0 +1,199 @@
+From d080aa11f20e82c4a674df4fc92911828e271626 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Tue, 10 Jun 2014 16:20:37 +0200
+Subject: [PATCH 2/4] hurd: fix receiver lookup in termctty_open_terminal
+
+* hurd/hurd_types.h (ctty_t): New type definition.
+* hurd/term.defs (ctty_t): New type definition.
+* term/mig-decls.h: New file.
+* term/mig-mutate.h: Add mutators, includes.
+* term/term.h: Add include guards.
+* term/users.c (S_termctty_open_terminal): Fix receiver lookup.
+* boot/boot.c (S_termctty_open_terminal): Likewise.
+---
+ boot/boot.c | 2 +-
+ hurd/hurd_types.h | 1 +
+ hurd/term.defs | 14 +++++++++++++-
+ term/mig-decls.h | 42 ++++++++++++++++++++++++++++++++++++++++++
+ term/mig-mutate.h | 10 +++++++++-
+ term/term.h | 5 +++++
+ term/users.c | 4 +---
+ 7 files changed, 72 insertions(+), 6 deletions(-)
+ create mode 100644 term/mig-decls.h
+
+diff --git a/boot/boot.c b/boot/boot.c
+index ed29014..03617f5 100644
+--- a/boot/boot.c
++++ b/boot/boot.c
+@@ -1876,7 +1876,7 @@ S_io_revoke (mach_port_t obj,
+ support on the console device. */
+
+ kern_return_t
+-S_termctty_open_terminal (mach_port_t object,
++S_termctty_open_terminal (ctty_t object,
+ int flags,
+ mach_port_t *result,
+ mach_msg_type_name_t *restype)
+diff --git a/hurd/hurd_types.h b/hurd/hurd_types.h
+index 8eac206..4341177 100644
+--- a/hurd/hurd_types.h
++++ b/hurd/hurd_types.h
+@@ -49,6 +49,7 @@ typedef mach_port_t fs_notify_t;
+ typedef mach_port_t exec_startup_t;
+ typedef mach_port_t interrupt_t;
+ typedef mach_port_t proccoll_t;
++typedef mach_port_t ctty_t;
+
+ #include <errno.h> /* Defines `error_t'. */
+
+diff --git a/hurd/term.defs b/hurd/term.defs
+index 17ba4f3..45d825d 100644
+--- a/hurd/term.defs
++++ b/hurd/term.defs
+@@ -29,6 +29,18 @@ TERM_IMPORTS
+
+ INTR_INTERFACE
+
++type ctty_t = mach_port_copy_send_t
++#ifdef CTTY_INTRAN
++intran: CTTY_INTRAN
++#endif
++#ifdef CTTY_OUTTRAN
++outtran: CTTY_OUTTRAN
++#endif
++#ifdef CTTY_DESTRUCTOR
++destructor: CTTY_DESTRUCTOR
++#endif
++;
++
+ /* Find out what the controlling terminal ID port is. */
+ routine term_getctty (
+ terminal: io_t;
+@@ -109,7 +121,7 @@ routine term_on_pty (
+ not be made to terminal I/O ports. Return an unauthenticated I/O
+ port for the terminal opened as with flags FLAGS. */
+ routine termctty_open_terminal (
+- ctty: mach_port_t;
++ ctty: ctty_t;
+ flags: int;
+ out terminal: mach_port_send_t);
+
+diff --git a/term/mig-decls.h b/term/mig-decls.h
+new file mode 100644
+index 0000000..c91b133
+--- /dev/null
++++ b/term/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 __TERM_MIG_DECLS_H__
++#define __TERM_MIG_DECLS_H__
++
++#include <hurd/ports.h>
++
++#include "term.h"
++
++/* Called by server stub functions. */
++
++static inline struct port_info * __attribute__ ((unused))
++begin_using_ctty_port (mach_port_t port)
++{
++ return ports_lookup_port (term_bucket, port, cttyid_class);
++}
++
++static inline void __attribute__ ((unused))
++end_using_ctty (struct port_info *p)
++{
++ if (p)
++ ports_port_deref (p);
++}
++
++#endif /* __TERM_MIG_DECLS_H__ */
+diff --git a/term/mig-mutate.h b/term/mig-mutate.h
+index a6b99fe..1545719 100644
+--- a/term/mig-mutate.h
++++ b/term/mig-mutate.h
+@@ -21,5 +21,13 @@
+
+ #define IO_INTRAN trivfs_protid_t trivfs_begin_using_protid (io_t)
+ #define IO_DESTRUCTOR trivfs_end_using_protid (trivfs_protid_t)
++
++#define CTTY_INTRAN \
++ port_info_t begin_using_ctty_port (mach_port_t)
++#define CTTY_DESTRUCTOR \
++ end_using_ctty (port_info_t)
++
+ #define TIOCTL_IMPORTS import "../libtrivfs/mig-decls.h";
+-#define TERM_IMPORTS import "../libtrivfs/mig-decls.h";
++#define TERM_IMPORTS \
++ import "../libtrivfs/mig-decls.h"; \
++ import "mig-decls.h";
+diff --git a/term/term.h b/term/term.h
+index df82b6c..3067425 100644
+--- a/term/term.h
++++ b/term/term.h
+@@ -18,6 +18,9 @@
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
+
++#ifndef __HURD_TERM_H__
++#define __HURD_TERM_H__
++
+ #include <pthread.h>
+ #include <assert.h>
+ #include <errno.h>
+@@ -391,3 +394,5 @@ error_t pty_io_select (struct trivfs_protid *, mach_port_t,
+ error_t pty_open_hook (struct trivfs_control *, struct iouser *, int);
+ error_t pty_po_create_hook (struct trivfs_peropen *);
+ error_t pty_po_destroy_hook (struct trivfs_peropen *);
++
++#endif /* __HURD_TERM_H__ */
+diff --git a/term/users.c b/term/users.c
+index 9bd51d0..8151dc7 100644
+--- a/term/users.c
++++ b/term/users.c
+@@ -379,7 +379,7 @@ S_term_getctty (struct trivfs_protid *cred,
+
+ /* Implement termctty_open_terminal as described in <hurd/term.defs>. */
+ kern_return_t
+-S_termctty_open_terminal (mach_port_t arg,
++S_termctty_open_terminal (struct port_info *pi,
+ int flags,
+ mach_port_t *result,
+ mach_msg_type_name_t *resulttype)
+@@ -388,7 +388,6 @@ S_termctty_open_terminal (mach_port_t arg,
+ mach_port_t new_realnode;
+ struct iouser *user;
+ struct trivfs_protid *newcred;
+- struct port_info *pi = ports_lookup_port (term_bucket, arg, cttyid_class);
+ if (!pi)
+ return EOPNOTSUPP;
+
+@@ -409,7 +408,6 @@ S_termctty_open_terminal (mach_port_t arg,
+ }
+ }
+
+- ports_port_deref (pi);
+ return err;
+ }
+
+--
+2.0.0
+
diff --git a/debian/patches/0003-libdiskfs-add-permission-check-to-file_chflags.patch b/debian/patches/0003-libdiskfs-add-permission-check-to-file_chflags.patch
new file mode 100644
index 00000000..c78e37c1
--- /dev/null
+++ b/debian/patches/0003-libdiskfs-add-permission-check-to-file_chflags.patch
@@ -0,0 +1,50 @@
+From 55c78cf83a726c495b9f1b1c18d457e7080d3c2a Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Tue, 10 Jun 2014 14:22:31 +0200
+Subject: [PATCH 3/4] libdiskfs: add permission check to file_chflags
+
+Only root is allowed to change the high 16 bits. The TODO entry says
+otherwise, but that must be a mistake. For reference, see the glibc
+sources, sysdeps/mach/hurd/bits/stat.h.
+
+* libdiskfs/file-chflags.c (diskfs_S_file_chflags): Add permission
+check.
+* TODO (libdiskfs): Remove entry.
+---
+ TODO | 2 --
+ libdiskfs/file-chflags.c | 6 ++++++
+ 2 files changed, 6 insertions(+), 2 deletions(-)
+
+diff --git a/TODO b/TODO
+index d2500dc..0387e9f 100644
+--- a/TODO
++++ b/TODO
+@@ -108,8 +108,6 @@ See `tasks', the exported task list.
+ Rename the rest to libhurdutil or somesuch.
+
+ ** libdiskfs
+-*** file_chflags does not do proper permission checking (non-root isn't
+- supposed to be able to change the low bits)
+ *** Add the short-circuited-but-not-builtin translator startup code from
+ dir-lookup to fsys_getroot. Compare and match carefully these two
+ routines and then share common code.
+diff --git a/libdiskfs/file-chflags.c b/libdiskfs/file-chflags.c
+index 01dc495..9642c3c 100644
+--- a/libdiskfs/file-chflags.c
++++ b/libdiskfs/file-chflags.c
+@@ -25,6 +25,12 @@ diskfs_S_file_chflags (struct protid *cred,
+ {
+ CHANGE_NODE_FIELD (cred,
+ ({
++ if (flags & 0xffff0000
++ && ! idvec_contains (cred->user->uids, 0))
++ /* Only root is allowed to change the high 16
++ bits. */
++ return EPERM;
++
+ err = fshelp_isowner (&np->dn_stat, cred->user);
+ if (!err)
+ err = diskfs_validate_flags_change (np, flags);
+--
+2.0.0
+
diff --git a/debian/patches/0004-utils-settrans-implement-settrans-start.patch b/debian/patches/0004-utils-settrans-implement-settrans-start.patch
new file mode 100644
index 00000000..52f782b9
--- /dev/null
+++ b/debian/patches/0004-utils-settrans-implement-settrans-start.patch
@@ -0,0 +1,98 @@
+From 614fa4d44d734980b3f9651e9a2d5b66b8825dc8 Mon Sep 17 00:00:00 2001
+From: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Wed, 11 Jun 2014 11:54:18 +0200
+Subject: [PATCH 4/4] utils/settrans: implement settrans --start
+
+Start the translator specified by the NODE's passive translator record
+and set it as NODE's active translator. This is the equivalent of
+doing:
+
+% settrans --active /node $(showtrans /node)
+
+* utils/settrans.c (argp_option): Add --start.
+(parse_opt): Handle --start.
+(main): Retrieve the passive translator record if --start is given.
+---
+ utils/settrans.c | 32 +++++++++++++++++++++++++++++++-
+ 1 file changed, 31 insertions(+), 1 deletion(-)
+
+diff --git a/utils/settrans.c b/utils/settrans.c
+index ecc6d75..84b271a 100644
+--- a/utils/settrans.c
++++ b/utils/settrans.c
+@@ -1,6 +1,7 @@
+ /* Set a file's translator.
+
+- Copyright (C) 1995,96,97,98,2001,02,13 Free Software Foundation, Inc.
++ Copyright (C) 1995,96,97,98,2001,02,13,14
++ Free Software Foundation, Inc.
+ Written by Miles Bader <miles@gnu.org>
+
+ This program is free software; you can redistribute it and/or
+@@ -47,6 +48,7 @@ const char *argp_program_version = STANDARD_HURD_VERSION (settrans);
+ static struct argp_option options[] =
+ {
+ {"active", 'a', 0, 0, "Start TRANSLATOR and set it as NODE's active translator" },
++ {"start", 's', 0, 0, "Start the translator specified by the NODE's passive translator record and set it as NODE's active translator" },
+ {"passive", 'p', 0, 0, "Change NODE's passive translator record (default)" },
+ {"create", 'c', 0, 0, "Create NODE if it doesn't exist" },
+ {"dereference", 'L', 0, 0, "If a translator exists, put the new one on top"},
+@@ -107,6 +109,7 @@ main(int argc, char *argv[])
+ /* Various option flags. */
+ int passive = 0, active = 0, keep_active = 0, pause = 0, kill_active = 0,
+ orphan = 0;
++ int start = 0;
+ char *pid_file = NULL;
+ int excl = 0;
+ int timeout = DEFAULT_TIMEOUT * 1000; /* ms */
+@@ -122,6 +125,9 @@ main(int argc, char *argv[])
+ node_name = arg;
+ else /* command */
+ {
++ if (start)
++ argp_error (state, "both --start and TRANSLATOR given");
++
+ error_t err =
+ argz_create (state->argv + state->next - 1, &argz, &argz_len);
+ if (err)
+@@ -135,6 +141,10 @@ main(int argc, char *argv[])
+ return EINVAL;
+
+ case 'a': active = 1; break;
++ case 's':
++ start = 1;
++ active = 1; /* start implies active */
++ break;
+ case 'p': passive = 1; break;
+ case 'k': keep_active = 1; break;
+ case 'g': kill_active = 1; break;
+@@ -212,6 +222,26 @@ main(int argc, char *argv[])
+ active_flags = FS_TRANS_SET | FS_TRANS_EXCL;
+ }
+
++ if (start)
++ {
++ /* Retrieve the passive translator record in argz. */
++ mach_port_t node = file_name_lookup (node_name, lookup_flags, 0);
++ if (node == MACH_PORT_NULL)
++ error (4, errno, "%s", node_name);
++
++ char buf[1024];
++ argz = buf;
++ argz_len = sizeof (buf);
++
++ err = file_get_translator (node, &argz, &argz_len);
++ if (err == EINVAL)
++ error (4, 0, "%s: no passive translator record found", node_name);
++ if (err)
++ error (4, err, "%s", node_name);
++
++ mach_port_deallocate (mach_task_self (), node);
++ }
++
+ if ((active || chroot_command) && argz_len > 0)
+ {
+ /* Error during file lookup; we use this to avoid duplicating error
+--
+2.0.0
+
diff --git a/debian/patches/series b/debian/patches/series
index a7efa410..e7c93ee0 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -45,3 +45,7 @@ fix-net_rcv_msg.patch
#pp.patch
#pp-dde.patch
#pp-random.patch
+0001-term-improve-the-demuxer.patch
+0002-hurd-fix-receiver-lookup-in-termctty_open_terminal.patch
+0003-libdiskfs-add-permission-check-to-file_chflags.patch
+0004-utils-settrans-implement-settrans-start.patch