diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2014-01-28 23:43:09 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2014-01-28 23:43:09 +0100 |
commit | e24381784b0a56896542d1a5828a77ad0e1c40ec (patch) | |
tree | 493e0d6ad811f563142c5de72a8b80bb5d142b93 | |
parent | 613f84a0fcd46f2143b046b57c6c6444eafa4d4d (diff) | |
parent | b8c728ec51696c5d17ef09a00b3b193b70a487da (diff) |
Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd
-rw-r--r-- | auth/auth.c | 10 | ||||
-rw-r--r-- | exec/main.c | 6 | ||||
-rw-r--r-- | libdiskfs/demuxer.c | 18 | ||||
-rw-r--r-- | libdiskfs/dir-link.c | 26 | ||||
-rw-r--r-- | libdiskfs/dir-unlink.c | 20 | ||||
-rw-r--r-- | libdiskfs/file-get-trans.c | 26 | ||||
-rw-r--r-- | libdiskfs/file-get-transcntl.c | 16 | ||||
-rw-r--r-- | libdiskfs/file-set-trans.c | 60 | ||||
-rw-r--r-- | libdiskfs/fsys-getroot.c | 56 | ||||
-rw-r--r-- | libnetfs/demuxer.c | 14 | ||||
-rw-r--r-- | libnetfs/release-peropen.c | 5 | ||||
-rw-r--r-- | libshouldbeinlibc/wire.c | 12 | ||||
-rw-r--r-- | libtrivfs/demuxer.c | 13 | ||||
-rw-r--r-- | pfinet/main.c | 11 | ||||
-rw-r--r-- | pflocal/pflocal.c | 3 | ||||
-rw-r--r-- | pflocal/sserver.c | 10 | ||||
-rw-r--r-- | proc/main.c | 10 | ||||
-rw-r--r-- | proc/mgt.c | 7 | ||||
-rw-r--r-- | proc/mig-decls.h | 42 | ||||
-rw-r--r-- | proc/proc_exc.defs | 8 | ||||
-rw-r--r-- | trans/Makefile | 6 | ||||
-rw-r--r-- | trans/password.c | 30 | ||||
-rw-r--r-- | utils/fakeauth.c | 6 |
23 files changed, 235 insertions, 180 deletions
diff --git a/auth/auth.c b/auth/auth.c index a395e79d..e69c4f86 100644 --- a/auth/auth.c +++ b/auth/auth.c @@ -464,18 +464,16 @@ S_auth_server_authenticate (struct authhandle *serverauth, } +#include "../libports/notify_S.h" +#include "../libports/interrupt_S.h" static int auth_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) { - mig_routine_t auth_server_routine (mach_msg_header_t *); - mig_routine_t ports_notify_server_routine (mach_msg_header_t *); - mig_routine_t ports_interrupt_server_routine (mach_msg_header_t *); - mig_routine_t routine; if ((routine = auth_server_routine (inp)) || - (routine = ports_notify_server_routine (inp)) || - (routine = ports_interrupt_server_routine (inp))) + (routine = ports_interrupt_server_routine (inp)) || + (routine = ports_notify_server_routine (inp))) { (*routine) (inp, outp); return TRUE; diff --git a/exec/main.c b/exec/main.c index 41b1db49..c1f347cf 100644 --- a/exec/main.c +++ b/exec/main.c @@ -46,12 +46,12 @@ struct trivfs_control *fsys; char **save_argv; +#include "exec_S.h" +#include "exec_startup_S.h" + static int exec_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) { - mig_routine_t exec_server_routine (mach_msg_header_t *); - mig_routine_t exec_startup_server_routine (mach_msg_header_t *); - mig_routine_t routine; if ((routine = exec_server_routine (inp)) || (routine = NULL, trivfs_demuxer (inp, outp)) || diff --git a/libdiskfs/demuxer.c b/libdiskfs/demuxer.c index 5412f26c..4a1c4fb4 100644 --- a/libdiskfs/demuxer.c +++ b/libdiskfs/demuxer.c @@ -17,19 +17,19 @@ #include "priv.h" +#include "io_S.h" +#include "fs_S.h" +#include "../libports/notify_S.h" +#include "fsys_S.h" +#include "../libports/interrupt_S.h" +#include "ifsock_S.h" +#include "startup_notify_S.h" +#include "exec_startup_S.h" + int diskfs_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) { - mig_routine_t diskfs_io_server_routine (mach_msg_header_t *); - mig_routine_t diskfs_fs_server_routine (mach_msg_header_t *); - mig_routine_t ports_notify_server_routine (mach_msg_header_t *); - mig_routine_t diskfs_fsys_server_routine (mach_msg_header_t *); - mig_routine_t ports_interrupt_server_routine (mach_msg_header_t *); - mig_routine_t diskfs_ifsock_server_routine (mach_msg_header_t *); - mig_routine_t diskfs_exec_startup_server_routine (mach_msg_header_t *); - mig_routine_t diskfs_startup_notify_server_routine (mach_msg_header_t *); - mig_routine_t routine; if ((routine = diskfs_io_server_routine (inp)) || (routine = diskfs_fs_server_routine (inp)) || diff --git a/libdiskfs/dir-link.c b/libdiskfs/dir-link.c index 45d88948..ca5dd561 100644 --- a/libdiskfs/dir-link.c +++ b/libdiskfs/dir-link.c @@ -29,7 +29,7 @@ diskfs_S_dir_link (struct protid *dircred, struct node *tnp; /* node being deleted implicitly */ struct node *dnp; /* directory of new entry */ struct dirstat *ds = alloca (diskfs_dirstat_size); - error_t error; + error_t err; if (!dircred) return EOPNOTSUPP; @@ -53,19 +53,19 @@ diskfs_S_dir_link (struct protid *dircred, pthread_mutex_lock (&dnp->lock); /* Lookup new location */ - error = diskfs_lookup (dnp, name, RENAME, &tnp, ds, dircred); - if (!error && excl) + err = diskfs_lookup (dnp, name, RENAME, &tnp, ds, dircred); + if (!err && excl) { - error = EEXIST; + err = EEXIST; diskfs_nput (tnp); } - if (error && error != ENOENT) + if (err && err != ENOENT) { - if (error == EAGAIN) - error = EINVAL; + if (err == EAGAIN) + err = EINVAL; diskfs_drop_dirstat (dnp, ds); pthread_mutex_unlock (&dnp->lock); - return error; + return err; } if (np == tnp) @@ -107,8 +107,8 @@ diskfs_S_dir_link (struct protid *dircred, if (tnp) { assert (!excl); - error = diskfs_dirrewrite (dnp, tnp, np, name, ds); - if (!error) + err = diskfs_dirrewrite (dnp, tnp, np, name, ds); + if (!err) { /* Deallocate link on TNP */ tnp->dn_stat.st_nlink--; @@ -119,15 +119,15 @@ diskfs_S_dir_link (struct protid *dircred, diskfs_nput (tnp); } else - error = diskfs_direnter (dnp, name, np, ds, dircred); + err = diskfs_direnter (dnp, name, np, ds, dircred); if (diskfs_synchronous) diskfs_node_update (dnp, 1); pthread_mutex_unlock (&dnp->lock); pthread_mutex_unlock (&np->lock); - if (!error) + if (!err) /* MiG won't do this for us, which it ought to. */ mach_port_deallocate (mach_task_self (), filecred->pi.port_right); - return error; + return err; } diff --git a/libdiskfs/dir-unlink.c b/libdiskfs/dir-unlink.c index f687a16e..cf02c227 100644 --- a/libdiskfs/dir-unlink.c +++ b/libdiskfs/dir-unlink.c @@ -27,7 +27,7 @@ diskfs_S_dir_unlink (struct protid *dircred, struct node *dnp; struct node *np; struct dirstat *ds = alloca (diskfs_dirstat_size); - error_t error; + error_t err; mach_port_t control = MACH_PORT_NULL; if (!dircred) @@ -39,14 +39,14 @@ diskfs_S_dir_unlink (struct protid *dircred, pthread_mutex_lock (&dnp->lock); - error = diskfs_lookup (dnp, name, REMOVE, &np, ds, dircred); - if (error == EAGAIN) - error = EPERM; /* 1003.1-1996 5.5.1.4 */ - if (error) + err = diskfs_lookup (dnp, name, REMOVE, &np, ds, dircred); + if (err == EAGAIN) + err = EPERM; /* 1003.1-1996 5.5.1.4 */ + if (err) { diskfs_drop_dirstat (dnp, ds); pthread_mutex_unlock (&dnp->lock); - return error; + return err; } /* This isn't the BSD behavior, but it is Posix compliant and saves @@ -62,14 +62,14 @@ diskfs_S_dir_unlink (struct protid *dircred, return EPERM; /* 1003.1-1996 5.5.1.4 */ } - error = diskfs_dirremove (dnp, np, name, ds); + err = diskfs_dirremove (dnp, np, name, ds); if (diskfs_synchronous) diskfs_node_update (dnp, 1); - if (error) + if (err) { diskfs_nput (np); pthread_mutex_unlock (&dnp->lock); - return error; + return err; } np->dn_stat.st_nlink--; @@ -94,5 +94,5 @@ diskfs_S_dir_unlink (struct protid *dircred, mach_port_deallocate (mach_task_self (), control); } - return error; + return err; } diff --git a/libdiskfs/file-get-trans.c b/libdiskfs/file-get-trans.c index 11ed439e..db5bbdad 100644 --- a/libdiskfs/file-get-trans.c +++ b/libdiskfs/file-get-trans.c @@ -28,7 +28,7 @@ diskfs_S_file_get_translator (struct protid *cred, size_t *translen) { struct node *np; - error_t error = 0; + error_t err = 0; if (!cred) return EOPNOTSUPP; @@ -48,16 +48,16 @@ diskfs_S_file_get_translator (struct protid *cred, bcopy (_HURD_SYMLINK, *trans, sizeof _HURD_SYMLINK); if (diskfs_read_symlink_hook) - error = (*diskfs_read_symlink_hook) (np, + err = (*diskfs_read_symlink_hook) (np, *trans + sizeof _HURD_SYMLINK); - if (!diskfs_read_symlink_hook || error == EINVAL) + if (!diskfs_read_symlink_hook || err == EINVAL) { - error = diskfs_node_rdwr (np, *trans + sizeof _HURD_SYMLINK, + err = diskfs_node_rdwr (np, *trans + sizeof _HURD_SYMLINK, 0, np->dn_stat.st_size, 0, cred, &amt); - if (!error) + if (!err) assert (amt == np->dn_stat.st_size); } - if (!error) + if (!err) { (*trans)[sizeof _HURD_SYMLINK + np->dn_stat.st_size] = '\0'; *translen = len; @@ -88,7 +88,7 @@ diskfs_S_file_get_translator (struct protid *cred, bcopy (buf, *trans, buflen); free (buf); *translen = buflen; - error = 0; + err = 0; } else if (S_ISFIFO (np->dn_stat.st_mode)) { @@ -99,7 +99,7 @@ diskfs_S_file_get_translator (struct protid *cred, *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); bcopy (_HURD_FIFO, *trans, sizeof _HURD_FIFO); *translen = len; - error = 0; + err = 0; } else if (S_ISSOCK (np->dn_stat.st_mode)) { @@ -110,18 +110,18 @@ diskfs_S_file_get_translator (struct protid *cred, *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); bcopy (_HURD_IFSOCK, *trans, sizeof _HURD_IFSOCK); *translen = len; - error = 0; + err = 0; } else { if (! (np->dn_stat.st_mode & S_IPTRANS)) - error = EINVAL; + err = EINVAL; else { char *string; u_int len; - error = diskfs_get_translator (np, &string, &len); - if (!error) + err = diskfs_get_translator (np, &string, &len); + if (!err) { if (len > *translen) *trans = mmap (0, len, PROT_READ|PROT_WRITE, MAP_ANON, 0, 0); @@ -134,5 +134,5 @@ diskfs_S_file_get_translator (struct protid *cred, pthread_mutex_unlock (&np->lock); - return error; + return err; } diff --git a/libdiskfs/file-get-transcntl.c b/libdiskfs/file-get-transcntl.c index c7fad91a..311d23ef 100644 --- a/libdiskfs/file-get-transcntl.c +++ b/libdiskfs/file-get-transcntl.c @@ -25,7 +25,7 @@ diskfs_S_file_get_translator_cntl (struct protid *cred, mach_msg_type_name_t *ctltype) { struct node *np; - error_t error; + error_t err; if (!cred) return EOPNOTSUPP; @@ -34,15 +34,15 @@ diskfs_S_file_get_translator_cntl (struct protid *cred, pthread_mutex_lock (&np->lock); - error = fshelp_isowner (&np->dn_stat, cred->user); - if (!error) - error = fshelp_fetch_control (&np->transbox, ctl); - if (!error && *ctl == MACH_PORT_NULL) - error = ENXIO; - if (!error) + err = fshelp_isowner (&np->dn_stat, cred->user); + if (!err) + err = fshelp_fetch_control (&np->transbox, ctl); + if (!err && *ctl == MACH_PORT_NULL) + err = ENXIO; + if (!err) *ctltype = MACH_MSG_TYPE_MOVE_SEND; pthread_mutex_unlock (&np->lock); - return error; + return err; } diff --git a/libdiskfs/file-set-trans.c b/libdiskfs/file-set-trans.c index 58f62550..6e1a61d2 100644 --- a/libdiskfs/file-set-trans.c +++ b/libdiskfs/file-set-trans.c @@ -32,7 +32,7 @@ diskfs_S_file_set_translator (struct protid *cred, fsys_t active) { struct node *np; - error_t error; + error_t err; mach_port_t control = MACH_PORT_NULL; if (!cred) @@ -51,32 +51,32 @@ diskfs_S_file_set_translator (struct protid *cred, pthread_mutex_lock (&np->lock); - error = fshelp_isowner (&np->dn_stat, cred->user); - if (error) + err = fshelp_isowner (&np->dn_stat, cred->user); + if (err) { pthread_mutex_unlock (&np->lock); - return error; + return err; } if ((active_flags & FS_TRANS_SET) && ! (active_flags & FS_TRANS_ORPHAN)) { - error = fshelp_fetch_control (&np->transbox, &control); - if (error) + err = fshelp_fetch_control (&np->transbox, &control); + if (err) { pthread_mutex_unlock (&np->lock); - return error; + return err; } if ((control != MACH_PORT_NULL) && ((active_flags & FS_TRANS_EXCL) == 0)) { pthread_mutex_unlock (&np->lock); - error = fsys_goaway (control, killtrans_flags); + err = fsys_goaway (control, killtrans_flags); mach_port_deallocate (mach_task_self (), control); - if (error && (error != MIG_SERVER_DIED) - && (error != MACH_SEND_INVALID_DEST)) - return error; - error = 0; + if (err && (err != MIG_SERVER_DIED) + && (err != MACH_SEND_INVALID_DEST)) + return err; + err = 0; pthread_mutex_lock (&np->lock); } else if (control != MACH_PORT_NULL) @@ -94,12 +94,12 @@ diskfs_S_file_set_translator (struct protid *cred, if (active_flags & FS_TRANS_SET) { - error = fshelp_set_active (&np->transbox, active, + err = fshelp_set_active (&np->transbox, active, active_flags & FS_TRANS_EXCL); - if (error) + if (err) { pthread_mutex_unlock (&np->lock); - return error; + return err; } } @@ -158,12 +158,12 @@ diskfs_S_file_set_translator (struct protid *cred, } minor = strtol (arg, 0, 0); - error = diskfs_validate_rdev_change (np, + err = diskfs_validate_rdev_change (np, makedev (major, minor)); - if (error) + if (err) { pthread_mutex_unlock (&np->lock); - return error; + return err; } np->dn_stat.st_rdev = makedev (major, minor); } @@ -180,36 +180,36 @@ diskfs_S_file_set_translator (struct protid *cred, } if (diskfs_create_symlink_hook) - error = (*diskfs_create_symlink_hook)(np, arg); - if (!diskfs_create_symlink_hook || error == EINVAL) + err = (*diskfs_create_symlink_hook)(np, arg); + if (!diskfs_create_symlink_hook || err == EINVAL) /* Store the argument in the file as the target of the link */ - error = diskfs_node_rdwr (np, arg, 0, strlen (arg), + err = diskfs_node_rdwr (np, arg, 0, strlen (arg), 1, cred, 0); - if (error) + if (err) { pthread_mutex_unlock (&np->lock); - return error; + return err; } } newmode = (np->dn_stat.st_mode & ~S_IFMT) | newmode; - error = diskfs_validate_mode_change (np, newmode); - if (!error) + err = diskfs_validate_mode_change (np, newmode); + if (!err) { np->dn_stat.st_mode = newmode; diskfs_node_update (np, diskfs_synchronous); } pthread_mutex_unlock (&np->lock); - return error; + return err; } } - error = diskfs_set_translator (np, passive, passivelen, cred); + err = diskfs_set_translator (np, passive, passivelen, cred); } pthread_mutex_unlock (&np->lock); - if (! error && cred->po->path && active_flags & FS_TRANS_SET) - error = fshelp_set_active_translator (&cred->pi, cred->po->path, active); + if (! err && cred->po->path && active_flags & FS_TRANS_SET) + err = fshelp_set_active_translator (&cred->pi, cred->po->path, active); - return error; + return err; } diff --git a/libdiskfs/fsys-getroot.c b/libdiskfs/fsys-getroot.c index 39973a80..85e11671 100644 --- a/libdiskfs/fsys-getroot.c +++ b/libdiskfs/fsys-getroot.c @@ -42,7 +42,7 @@ diskfs_S_fsys_getroot (fsys_t controlport, { struct port_info *pt = ports_lookup_port (diskfs_port_bucket, controlport, diskfs_control_class); - error_t error = 0; + error_t err = 0; mode_t type; struct protid *newpi; struct peropen *newpo; @@ -79,23 +79,23 @@ diskfs_S_fsys_getroot (fsys_t controlport, || fshelp_translated (&diskfs_root_node->transbox)) && !(flags & O_NOTRANS)) { - error = fshelp_fetch_root (&diskfs_root_node->transbox, + err = fshelp_fetch_root (&diskfs_root_node->transbox, &peropen_context, dotdot, &user, flags, _diskfs_translator_callback1, _diskfs_translator_callback2, retry, retryname, returned_port); - if (error != ENOENT) + if (err != ENOENT) { pthread_mutex_unlock (&diskfs_root_node->lock); pthread_rwlock_unlock (&diskfs_fsys_lock); drop_idvec (); - if (!error) + if (!err) *returned_port_poly = MACH_MSG_TYPE_MOVE_SEND; - return error; + return err; } /* ENOENT means the translator was removed in the interim. */ - error = 0; + err = 0; } if (type == S_IFLNK && !(flags & (O_NOLINK | O_NOTRANS))) @@ -105,19 +105,19 @@ diskfs_S_fsys_getroot (fsys_t controlport, size_t amt; if (diskfs_read_symlink_hook) - error = (*diskfs_read_symlink_hook) (diskfs_root_node, pathbuf); - if (!diskfs_read_symlink_hook || error == EINVAL) - error = diskfs_node_rdwr (diskfs_root_node, pathbuf, 0, + err = (*diskfs_read_symlink_hook) (diskfs_root_node, pathbuf); + if (!diskfs_read_symlink_hook || err == EINVAL) + err = diskfs_node_rdwr (diskfs_root_node, pathbuf, 0, diskfs_root_node->dn_stat.st_size, 0, 0, &amt); pathbuf[amt] = '\0'; pthread_mutex_unlock (&diskfs_root_node->lock); pthread_rwlock_unlock (&diskfs_fsys_lock); - if (error) + if (err) { drop_idvec (); - return error; + return err; } if (pathbuf[0] == '/') @@ -144,31 +144,31 @@ diskfs_S_fsys_getroot (fsys_t controlport, if ((type == S_IFSOCK || type == S_IFBLK || type == S_IFCHR || type == S_IFIFO) && (flags & (O_READ|O_WRITE|O_EXEC))) - error = EOPNOTSUPP; + err = EOPNOTSUPP; - if (!error && (flags & O_READ)) - error = fshelp_access (&diskfs_root_node->dn_stat, S_IREAD, &user); + if (!err && (flags & O_READ)) + err = fshelp_access (&diskfs_root_node->dn_stat, S_IREAD, &user); - if (!error && (flags & O_EXEC)) - error = fshelp_access (&diskfs_root_node->dn_stat, S_IEXEC, &user); + if (!err && (flags & O_EXEC)) + err = fshelp_access (&diskfs_root_node->dn_stat, S_IEXEC, &user); - if (!error && (flags & (O_WRITE))) + if (!err && (flags & (O_WRITE))) { if (type == S_IFDIR) - error = EISDIR; + err = EISDIR; else if (diskfs_check_readonly ()) - error = EROFS; + err = EROFS; else - error = fshelp_access (&diskfs_root_node->dn_stat, + err = fshelp_access (&diskfs_root_node->dn_stat, S_IWRITE, &user); } - if (error) + if (err) { pthread_mutex_unlock (&diskfs_root_node->lock); pthread_rwlock_unlock (&diskfs_fsys_lock); drop_idvec (); - return error; + return err; } if ((flags & O_NOATIME) @@ -178,16 +178,16 @@ diskfs_S_fsys_getroot (fsys_t controlport, flags &= ~OPENONLY_STATE_MODES; - error = diskfs_make_peropen (diskfs_root_node, flags, + err = diskfs_make_peropen (diskfs_root_node, flags, &peropen_context, &newpo); - if (! error) + if (! err) { - error = diskfs_create_protid (newpo, &user, &newpi); - if (error) + err = diskfs_create_protid (newpo, &user, &newpi); + if (err) diskfs_release_peropen (newpo); } - if (! error) + if (! err) { mach_port_deallocate (mach_task_self (), dotdot); *retry = FS_RETRY_NORMAL; @@ -204,5 +204,5 @@ diskfs_S_fsys_getroot (fsys_t controlport, drop_idvec (); - return error; + return err; } diff --git a/libnetfs/demuxer.c b/libnetfs/demuxer.c index 8ef4d86b..4c20ab62 100644 --- a/libnetfs/demuxer.c +++ b/libnetfs/demuxer.c @@ -20,17 +20,17 @@ #include "netfs.h" +#include "io_S.h" +#include "fs_S.h" +#include "../libports/notify_S.h" +#include "fsys_S.h" +#include "../libports/interrupt_S.h" +#include "ifsock_S.h" + int netfs_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) { - mig_routine_t netfs_io_server_routine (mach_msg_header_t *); - mig_routine_t netfs_fs_server_routine (mach_msg_header_t *); - mig_routine_t ports_notify_server_routine (mach_msg_header_t *); - mig_routine_t netfs_fsys_server_routine (mach_msg_header_t *); - mig_routine_t ports_interrupt_server_routine (mach_msg_header_t *); - mig_routine_t netfs_ifsock_server_routine (mach_msg_header_t *); - mig_routine_t routine; if ((routine = netfs_io_server_routine (inp)) || (routine = netfs_fs_server_routine (inp)) || diff --git a/libnetfs/release-peropen.c b/libnetfs/release-peropen.c index d4d3574c..c206b438 100644 --- a/libnetfs/release-peropen.c +++ b/libnetfs/release-peropen.c @@ -18,6 +18,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ +#include <sys/file.h> #include "netfs.h" void @@ -39,6 +40,10 @@ netfs_release_peropen (struct peropen *po) if (po->shadow_root_parent) mach_port_deallocate (mach_task_self (), po->shadow_root_parent); + if (po->lock_status != LOCK_UN) + fshelp_acquire_lock (&po->np->userlock, &po->lock_status, + &po->np->lock, LOCK_UN); + netfs_nput (po->np); free (po->path); diff --git a/libshouldbeinlibc/wire.c b/libshouldbeinlibc/wire.c index b9540955..ca5d32b1 100644 --- a/libshouldbeinlibc/wire.c +++ b/libshouldbeinlibc/wire.c @@ -139,10 +139,10 @@ wire_segment (vm_address_t start, vm_size_t len) { mach_port_t host, device; - error_t error; + error_t err; - error = get_privileged_ports (&host, &device); - if (!error) + err = get_privileged_ports (&host, &device); + if (!err) { wire_segment_internal (start, len, host); mach_port_deallocate (mach_task_self (), host); @@ -158,11 +158,11 @@ wire_task_self () { struct link_map *map; mach_port_t host, device; - error_t error; + error_t err; extern char _edata, _etext, __data_start; - error = get_privileged_ports (&host, &device); - if (error) + err = get_privileged_ports (&host, &device); + if (err) return; map = loaded (); diff --git a/libtrivfs/demuxer.c b/libtrivfs/demuxer.c index 411699fe..306cd115 100644 --- a/libtrivfs/demuxer.c +++ b/libtrivfs/demuxer.c @@ -21,17 +21,16 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "priv.h" +#include "trivfs_io_S.h" +#include "trivfs_fs_S.h" +#include "../libports/notify_S.h" +#include "trivfs_fsys_S.h" +#include "../libports/interrupt_S.h" + int trivfs_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) { - mig_routine_t trivfs_io_server_routine (mach_msg_header_t *); - mig_routine_t trivfs_fs_server_routine (mach_msg_header_t *); - mig_routine_t ports_notify_server_routine (mach_msg_header_t *); - mig_routine_t trivfs_fsys_server_routine (mach_msg_header_t *); - mig_routine_t ports_interrupt_server_routine (mach_msg_header_t *); - mig_routine_t trivfs_ifsock_server_routine (mach_msg_header_t *); - mig_routine_t routine; if ((routine = trivfs_io_server_routine (inp)) || (routine = trivfs_fs_server_routine (inp)) || diff --git a/pfinet/main.c b/pfinet/main.c index dce16005..a596e18b 100644 --- a/pfinet/main.c +++ b/pfinet/main.c @@ -72,16 +72,17 @@ const char *argp_program_version = STANDARD_HURD_VERSION (pfinet); /* Option parser. */ extern struct argp pfinet_argp; +#include "io_S.h" +#include "socket_S.h" +#include "pfinet_S.h" +#include "iioctl_S.h" +#include "startup_notify_S.h" + int pfinet_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) { struct port_info *pi; - mig_routine_t io_server_routine (mach_msg_header_t *); - mig_routine_t socket_server_routine (mach_msg_header_t *); - mig_routine_t pfinet_server_routine (mach_msg_header_t *); - mig_routine_t iioctl_server_routine (mach_msg_header_t *); - mig_routine_t startup_notify_server_routine (mach_msg_header_t *); /* We have several classes in one bucket, which need to be demuxed differently. */ diff --git a/pflocal/pflocal.c b/pflocal/pflocal.c index d51f721e..fcb62d1d 100644 --- a/pflocal/pflocal.c +++ b/pflocal/pflocal.c @@ -46,13 +46,12 @@ int trivfs_protid_nportclasses = 1; int trivfs_cntl_nportclasses = 1; /* ---------------------------------------------------------------- */ +#include "socket_S.h" /* A demuxer to separate out pf-level operations on our node. */ static int pf_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) { - mig_routine_t socket_server_routine (mach_msg_header_t *); - mig_routine_t routine; if ((routine = socket_server_routine (inp)) || (routine = NULL, trivfs_demuxer (inp, outp))) diff --git a/pflocal/sserver.c b/pflocal/sserver.c index 4ce26b13..7df69a41 100644 --- a/pflocal/sserver.c +++ b/pflocal/sserver.c @@ -32,15 +32,15 @@ struct port_bucket *sock_port_bucket; static int sock_server_active = 0; static pthread_spinlock_t sock_server_active_lock = PTHREAD_SPINLOCK_INITIALIZER; +#include "io_S.h" +#include "socket_S.h" +#include "../libports/interrupt_S.h" +#include "../libports/notify_S.h" + /* A demuxer for socket operations. */ static int sock_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) { - mig_routine_t io_server_routine (mach_msg_header_t *); - mig_routine_t socket_server_routine (mach_msg_header_t *); - mig_routine_t ports_interrupt_server_routine (mach_msg_header_t *); - mig_routine_t ports_notify_server_routine (mach_msg_header_t *); - mig_routine_t routine; if ((routine = io_server_routine (inp)) || (routine = socket_server_routine (inp)) || diff --git a/proc/main.c b/proc/main.c index 5d6dc212..73742edd 100644 --- a/proc/main.c +++ b/proc/main.c @@ -34,15 +34,15 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ const char *argp_program_version = STANDARD_HURD_VERSION (proc); +#include "process_S.h" +#include "notify_S.h" +#include "../libports/interrupt_S.h" +#include "proc_exc_S.h" + int message_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) { - mig_routine_t process_server_routine (mach_msg_header_t *); - mig_routine_t notify_server_routine (mach_msg_header_t *); - mig_routine_t ports_interrupt_server_routine (mach_msg_header_t *); - mig_routine_t proc_exc_server_routine (mach_msg_header_t *); - mig_routine_t routine; if ((routine = process_server_routine (inp)) || (routine = notify_server_routine (inp)) || @@ -417,7 +417,7 @@ S_proc_handle_exceptions (struct proc *p, the thread_set_state requested by proc_handle_exceptions and then send an exception_raise message as requested. */ kern_return_t -S_proc_exception_raise (mach_port_t excport, +S_proc_exception_raise (struct exc *e, mach_port_t reply, mach_msg_type_name_t reply_type, mach_port_t thread, @@ -428,8 +428,7 @@ S_proc_exception_raise (mach_port_t excport, { error_t err; struct proc *p; - struct exc *e = ports_lookup_port (proc_bucket, excport, exc_class); - if (!e) + if (!e || e->pi.bucket != proc_bucket || e->pi.class != exc_class) return EOPNOTSUPP; p = task_find (task); @@ -455,7 +454,6 @@ S_proc_exception_raise (mach_port_t excport, the faulting thread's state to run its recovery code, which should dequeue that message. */ err = thread_set_state (thread, e->flavor, e->thread_state, e->statecnt); - ports_port_deref (e); mach_port_deallocate (mach_task_self (), thread); mach_port_deallocate (mach_task_self (), task); if (err) @@ -484,7 +482,6 @@ S_proc_exception_raise (mach_port_t excport, /* Nuke the task; we will get a notification message and report that it died with SIGNO. */ task_terminate (task); - ports_port_deref (e); /* In the MACH_SEND_NOTIFY_IN_PROGRESS case, the kernel did a pseudo-receive of the RPC request message that may have added user diff --git a/proc/mig-decls.h b/proc/mig-decls.h new file mode 100644 index 00000000..0d5bd4df --- /dev/null +++ b/proc/mig-decls.h @@ -0,0 +1,42 @@ +/* Translation functions for mig. + + Copyright (C) 2013 Free Software Foundation, Inc. + + Written by Justus Winter <4winter@informatik.uni-hamburg.de> + + 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 __MIG_DECLS_H__ +#define __MIG_DECLS_H__ + +#include "proc.h" + +typedef struct exc* exc_t; + +static inline exc_t __attribute__ ((unused)) +begin_using_exc_port (mach_port_t port) +{ + return ports_lookup_port (NULL, port, exc_class); +} + +static inline void __attribute__ ((unused)) +end_using_exc (exc_t exc) +{ + if (exc != NULL) + ports_port_deref (exc); +} + +#endif diff --git a/proc/proc_exc.defs b/proc/proc_exc.defs index e9c58f1c..c9108246 100644 --- a/proc/proc_exc.defs +++ b/proc/proc_exc.defs @@ -33,9 +33,15 @@ subsystem proc_exc 2400; #include <mach/std_types.defs> ServerPrefix S_; +import "mig-decls.h"; + +type exception_t = mach_port_copy_send_t + cusertype: mach_port_t + intran: exc_t begin_using_exc_port (exception_t) + destructor: end_using_exc (exc_t); routine proc_exception_raise ( - exception_port: mach_port_t; + exception_port: exception_t; replyport reply: mach_port_poly_t; msgoption flags: integer_t; thread: mach_port_t; diff --git a/trans/Makefile b/trans/Makefile index 291df2f3..c0386d08 100644 --- a/trans/Makefile +++ b/trans/Makefile @@ -1,6 +1,6 @@ # # Copyright (C) 1994, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2006, 2007, -# 2008 Free Software Foundation, Inc. +# 2008, 2013 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -32,6 +32,10 @@ OBJS = $(SRCS:.c=.o) fsysServer.o ifsockServer.o passwordServer.o \ HURDLIBS = ports netfs trivfs iohelp fshelp pipe ihash shouldbeinlibc LDLIBS += -lpthread password-LDLIBS = $(LIBCRYPT) +password-MIGSFLAGS=\ + "-DIO_INTRAN=trivfs_protid_t trivfs_begin_using_protid (io_t)" \ + "-DIO_DESTRUCTOR=trivfs_end_using_protid (trivfs_protid_t)" \ + "-DPASSWORD_IMPORTS=import <hurd/trivfs.h>;" include ../Makeconf diff --git a/trans/password.c b/trans/password.c index 6f15a9e8..344b78ba 100644 --- a/trans/password.c +++ b/trans/password.c @@ -1,5 +1,5 @@ /* Hurd standard password server. - Copyright (C) 1999 Free Software Foundation + Copyright (C) 1999, 2013 Free Software Foundation Written by Mark Kettenis. The GNU Hurd is free software; you can redistribute it and/or @@ -135,10 +135,9 @@ trivfs_goaway (struct trivfs_control *fsys, int flags) /* Implement password_check_user as described in <hurd/password.defs>. */ kern_return_t -S_password_check_user (io_t server, uid_t user, char *pw, +S_password_check_user (struct trivfs_protid *cred, uid_t user, char *pw, mach_port_t *port, mach_msg_type_name_t *port_type) { - struct trivfs_protid *cred; struct ugids ugids = UGIDS_INIT; auth_t auth; error_t err; @@ -150,10 +149,16 @@ S_password_check_user (io_t server, uid_t user, char *pw, return strdup (pw); } - cred = ports_lookup_port (port_bucket, server, trivfs_protid_portclasses[0]); if (! cred) return EOPNOTSUPP; + if (cred->pi.bucket != port_bucket || + cred->pi.class != trivfs_protid_portclasses[0]) + { + ports_port_deref (cred); + return EOPNOTSUPP; + } + /* Verify password. */ err = ugids_add_user (&ugids, user, 1); if (!err) @@ -173,17 +178,14 @@ S_password_check_user (io_t server, uid_t user, char *pw, } ugids_fini (&ugids); - - ports_port_deref (cred); return err; } /* Implement password_check_group as described in <hurd/password.defs>. */ kern_return_t -S_password_check_group (io_t server, uid_t group, char *pw, +S_password_check_group (struct trivfs_protid *cred, uid_t group, char *pw, mach_port_t *port, mach_msg_type_name_t *port_type) { - struct trivfs_protid *cred; struct ugids ugids = UGIDS_INIT; auth_t auth; error_t err; @@ -195,10 +197,16 @@ S_password_check_group (io_t server, uid_t group, char *pw, return strdup (pw); } - cred = ports_lookup_port (port_bucket, server, trivfs_protid_portclasses[0]); if (! cred) return EOPNOTSUPP; - + + if (cred->pi.bucket != port_bucket || + cred->pi.class != trivfs_protid_portclasses[0]) + { + ports_port_deref (cred); + return EOPNOTSUPP; + } + /* Verify password. */ err = ugids_add_gid (&ugids, group, 1); if (!err) @@ -218,7 +226,5 @@ S_password_check_group (io_t server, uid_t group, char *pw, } ugids_fini (&ugids); - - ports_port_deref (cred); return err; } diff --git a/utils/fakeauth.c b/utils/fakeauth.c index 2c72c894..660295f9 100644 --- a/utils/fakeauth.c +++ b/utils/fakeauth.c @@ -299,13 +299,11 @@ S_interrupt_operation (mach_port_t port, mach_port_seqno_t seqno) return interrupt_operation (real_auth_port, 0); } +#include "../libports/notify_S.h" + static int auth_demuxer (mach_msg_header_t *inp, mach_msg_header_t *outp) { - mig_routine_t auth_server_routine (mach_msg_header_t *); - mig_routine_t interrupt_server_routine (mach_msg_header_t *); - mig_routine_t ports_notify_server_routine (mach_msg_header_t *); - mig_routine_t routine; if ((routine = auth_server_routine (inp)) || (routine = interrupt_server_routine (inp)) || |