Back to index

glibc  2.9
Functions | Variables
ports-set.c File Reference
#include <hurd.h>

Go to the source code of this file.

Functions

static error_t setbootstrap (mach_port_t newport)
error_t _hurd_setauth (auth_t)
error_t _hurd_setproc (process_t)
error_t _hurd_setcttyid (mach_port_t)
error_t _hurd_ports_set (unsigned int which, mach_port_t newport)

Variables

error_t(* _hurd_ports_setters [INIT_PORT_MAX])(mach_port_t newport)

Function Documentation

error_t _hurd_ports_set ( unsigned int  which,
mach_port_t  newport 
)

Definition at line 43 of file ports-set.c.

{
  error_t err;
  if (which >= _hurd_nports)
    return EINVAL;
  if (err = __mach_port_mod_refs (__mach_task_self (), newport,
                              MACH_PORT_RIGHT_SEND, 1))
    return err;
  if (which >= INIT_PORT_MAX || _hurd_ports_setters[which] == NULL)
    {
      _hurd_port_set (&_hurd_ports[which], newport);
      return 0;
    }
  return (*_hurd_ports_setters[which]) (newport);
}

Here is the call graph for this function:

Here is the caller graph for this function:

error_t _hurd_setauth ( auth_t  )

Definition at line 34 of file setauth.c.

{
  error_t err;
  unsigned int d;
  mach_port_t newport, ref;

  /* Give the new send right a user reference.
     This is a good way to check that it is valid.  */
  if (err = __mach_port_mod_refs (__mach_task_self (), new,
                              MACH_PORT_RIGHT_SEND, 1))
    return err;

  HURD_CRITICAL_BEGIN;

  /* We lock against another thread doing setauth.  Anyone who sets
     _hurd_ports[INIT_PORT_AUTH] some other way is asking to lose.  */
  __mutex_lock (&reauth_lock);

  /* Install the new port in the cell.  */
  __mutex_lock (&_hurd_id.lock);
  _hurd_port_set (&_hurd_ports[INIT_PORT_AUTH], new);
  _hurd_id.valid = 0;
  if (_hurd_id.rid_auth)
    {
      __mach_port_deallocate (__mach_task_self (), _hurd_id.rid_auth);
      _hurd_id.rid_auth = MACH_PORT_NULL;
    }
  __mutex_unlock (&_hurd_id.lock);

  if (_hurd_init_dtable != NULL)
    /* We just have the simple table we got at startup.
       Otherwise, a reauth_hook in dtable.c takes care of this.  */
    for (d = 0; d < _hurd_init_dtablesize; ++d)
      if (_hurd_init_dtable[d] != MACH_PORT_NULL)
       {
         mach_port_t new;
         ref = __mach_reply_port ();
         if (! __io_reauthenticate (_hurd_init_dtable[d],
                                 ref, MACH_MSG_TYPE_MAKE_SEND) &&
             ! HURD_PORT_USE (&_hurd_ports[INIT_PORT_AUTH],
                            __auth_user_authenticate
                            (port,
                            ref, MACH_MSG_TYPE_MAKE_SEND,
                            &new)))
           {
             __mach_port_deallocate (__mach_task_self (),
                                  _hurd_init_dtable[d]);
             _hurd_init_dtable[d] = new;
           }
         __mach_port_destroy (__mach_task_self (), ref);
       }

  ref = __mach_reply_port ();
  if (__USEPORT (CRDIR,
               ! __io_reauthenticate (port,
                                   ref, MACH_MSG_TYPE_MAKE_SEND) &&
               ! __auth_user_authenticate (new,
                                        ref, MACH_MSG_TYPE_MAKE_SEND,
                                        &newport)))
    _hurd_port_set (&_hurd_ports[INIT_PORT_CRDIR], newport);
  __mach_port_destroy (__mach_task_self (), ref);

  ref = __mach_reply_port ();
  if (__USEPORT (CWDIR,
               ! __io_reauthenticate (port,
                                   ref, MACH_MSG_TYPE_MAKE_SEND) &&
               ! __auth_user_authenticate (new,
                                        ref, MACH_MSG_TYPE_MAKE_SEND,
                                        &newport)))
    _hurd_port_set (&_hurd_ports[INIT_PORT_CWDIR], newport);
  __mach_port_destroy (__mach_task_self (), ref);

  /* Run things which want to do reauthorization stuff.  */
  RUN_HOOK (_hurd_reauth_hook, (new));

  __mutex_unlock (&reauth_lock);

  HURD_CRITICAL_END;

  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

error_t _hurd_setcttyid ( mach_port_t  )

Definition at line 226 of file hurdioctl.c.

{
  error_t err;

  if (cttyid != MACH_PORT_NULL)
    {
      /* Give the new send right a user reference.
        This is a good way to check that it is valid.  */
      if (err = __mach_port_mod_refs (__mach_task_self (), cttyid,
                                  MACH_PORT_RIGHT_SEND, 1))
       return err;
    }

  /* Install the port, consuming the reference we just created.  */
  install_ctty (cttyid);

  return 0;
}

Here is the call graph for this function:

error_t _hurd_setproc ( process_t  )

Definition at line 188 of file hurdinit.c.

{
  error_t err;
  mach_port_t oldmsg;

  /* Give the proc server our message port.  */
  if (err = __proc_setmsgport (procserver, _hurd_msgport, &oldmsg))
    return err;
  if (oldmsg != MACH_PORT_NULL)
    /* Deallocate the old msg port we replaced.  */
    __mach_port_deallocate (__mach_task_self (), oldmsg);

  /* Tell the proc server where our args and environment are.  */
  if (err = __proc_set_arg_locations (procserver,
                                  _hide_arguments ? 0 :
                                  (vm_address_t) __libc_argv,
                                  _hide_environment ? 0 :
                                  (vm_address_t) __environ))
    return err;

  /* Those calls worked, so the port looks good.  */
  _hurd_port_set (&_hurd_ports[INIT_PORT_PROC], procserver);

  {
    pid_t oldpgrp = _hurd_pgrp;

    /* Call these functions again so they can fetch the
       new information from the new proc server.  */
    RUN_HOOK (_hurd_proc_subinit, ());

    if (_hurd_pgrp != oldpgrp)
      {
       /* Run things that want notification of a pgrp change.  */
       DECLARE_HOOK (_hurd_pgrp_changed_hook, (pid_t));
       RUN_HOOK (_hurd_pgrp_changed_hook, (_hurd_pgrp));
      }
  }

  return 0;
}

Here is the call graph for this function:

static error_t setbootstrap ( mach_port_t  newport) [static]

Definition at line 22 of file ports-set.c.

{
  return __task_set_special_port (__mach_task_self (),
                              TASK_BOOTSTRAP_PORT,
                              newport);
}

Here is the call graph for this function:


Variable Documentation

error_t(* _hurd_ports_setters[INIT_PORT_MAX])(mach_port_t newport)
Initial value:
  {
    [INIT_PORT_BOOTSTRAP] = setbootstrap,
    [INIT_PORT_AUTH] = _hurd_setauth,
    [INIT_PORT_PROC] = _hurd_setproc,
    [INIT_PORT_CTTYID] = _hurd_setcttyid,
  }

Definition at line 33 of file ports-set.c.