-/* Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
-This file is part of the GNU C Library.
+/* Copyright (C) 1992-2017 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
-The GNU C Library is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public License as
-published by the Free Software Foundation; either version 2 of the
-License, or (at your option) any later version.
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
-The GNU C Library 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
-Library General Public License for more details.
+ The GNU C Library 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
+ Lesser General Public License for more details.
-You should have received a copy of the GNU Library General Public
-License along with the GNU C Library; see the file COPYING.LIB. If
-not, write to the Free Software Foundation, Inc., 675 Mass Ave,
-Cambridge, MA 02139, USA. */
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <http://www.gnu.org/licenses/>. */
#include <hurd.h>
#include <hurd/msg_server.h>
#include <unistd.h>
#include <limits.h>
#include <string.h>
+#include <argz.h>
#define AUTHCHECK \
/* Snarfing and frobbing the init ports. */
kern_return_t
-_S_msg_get_init_port (mach_port_t msgport, mach_port_t auth, int which,
- mach_port_t *result, mach_msg_type_name_t *result_type)
+ _S_msg_get_init_port (mach_port_t msgport, mach_port_t auth, int which,
+ mach_port_t *result, mach_msg_type_name_t *result_type)
{
AUTHCHECK;
*result_type = MACH_MSG_TYPE_MOVE_SEND;
kern_return_t
_S_msg_set_init_port (mach_port_t msgport, mach_port_t auth,
- int which, mach_port_t port)
+ int which, mach_port_t port)
{
error_t err;
kern_return_t
_S_msg_get_init_ports (mach_port_t msgport, mach_port_t auth,
- mach_port_t **ports,
- mach_msg_type_name_t *ports_type,
- mach_msg_type_number_t *nports)
+ mach_port_t **ports,
+ mach_msg_type_name_t *ports_type,
+ mach_msg_type_number_t *nports)
{
mach_msg_type_number_t i;
error_t err;
kern_return_t
_S_msg_set_init_ports (mach_port_t msgport, mach_port_t auth,
- mach_port_t *ports, mach_msg_type_number_t nports)
+ mach_port_t *ports, mach_msg_type_number_t nports)
{
mach_msg_type_number_t i;
error_t err;
kern_return_t
_S_msg_get_init_int (mach_port_t msgport, mach_port_t auth,
- int which, int *value)
+ int which, int *value)
{
AUTHCHECK;
kern_return_t
_S_msg_get_init_ints (mach_port_t msgport, mach_port_t auth,
- int **values, mach_msg_type_number_t *nvalues)
+ int **values, mach_msg_type_number_t *nvalues)
{
error_t err;
mach_msg_type_number_t i;
}
__spin_unlock (&ss->lock);
return 0;
+
+ case INIT_TRACEMASK:
+ _hurdsig_traced = value;
+ return 0;
}
default:
return EINVAL;
kern_return_t
_S_msg_set_init_int (mach_port_t msgport, mach_port_t auth,
- int which, int value)
+ int which, int value)
{
AUTHCHECK;
kern_return_t
_S_msg_set_init_ints (mach_port_t msgport, mach_port_t auth,
- int *values, mach_msg_type_number_t nvalues)
+ int *values, mach_msg_type_number_t nvalues)
{
error_t err;
mach_msg_type_number_t i;
\f
kern_return_t
-_S_msg_get_fd (mach_port_t msgport, mach_port_t auth,
- int which, mach_port_t *result, mach_msg_type_name_t *result_type)
+_S_msg_get_fd (mach_port_t msgport, mach_port_t auth, int which,
+ mach_port_t *result, mach_msg_type_name_t *result_type)
{
AUTHCHECK;
kern_return_t
_S_msg_set_fd (mach_port_t msgport, mach_port_t auth,
- int which, mach_port_t port)
+ int which, mach_port_t port)
{
AUTHCHECK;
kern_return_t
_S_msg_get_env_variable (mach_port_t msgport,
- char *variable,
- char **data, mach_msg_type_number_t *datalen)
+ char *variable,
+ char **data, mach_msg_type_number_t *datalen)
{
+ error_t err;
+ mach_msg_type_number_t valuelen;
const char *value = getenv (variable);
if (value == NULL)
return ENOENT;
- /* XXX this pointer might become invalid */
- *data = value;
- *datalen = strlen (value);
+ valuelen = strlen (value);
+ if (valuelen > *datalen)
+ {
+ if (err = __vm_allocate (__mach_task_self (),
+ (vm_address_t *) data, valuelen, 1))
+ return err;
+ }
+
+ memcpy (*data, value, valuelen);
+ *datalen = valuelen;
+
return 0;
}
kern_return_t
_S_msg_set_env_variable (mach_port_t msgport, mach_port_t auth,
- char *variable,
- char *value,
- int replace)
+ char *variable,
+ char *value,
+ int replace)
{
AUTHCHECK;
kern_return_t
_S_msg_get_environment (mach_port_t msgport,
- char **data, mach_msg_type_number_t *datalen)
+ char **data, mach_msg_type_number_t *datalen)
{
/* Pack the environment into an array with nulls separating elements. */
if (__environ != NULL)
kern_return_t
_S_msg_set_environment (mach_port_t msgport, mach_port_t auth,
- char *data, mach_msg_type_number_t datalen)
+ char *data, mach_msg_type_number_t datalen)
{
int _hurd_split_args (char *, mach_msg_type_number_t, char **);
int envc;
AUTHCHECK;
- envc = _hurd_split_args (data, datalen, NULL);
+ envc = __argz_count (data, datalen);
envp = malloc ((envc + 1) * sizeof (char *));
if (envp == NULL)
return errno;
- _hurd_split_args (data, datalen, envp);
+ __argz_extract (data, datalen, envp);
__environ = envp; /* XXX cooperate with loadenv et al */
return 0;
}
\f
-/* Get and frob the exec flags. */
-
-kern_return_t
-_S_msg_get_exec_flags (mach_port_t process, mach_port_t auth,
- int *flags)
-{
- AUTHCHECK;
-
- *flags = _hurd_exec_flags;
- return 0;
-}
-
-kern_return_t
-_S_msg_set_all_exec_flags (mach_port_t process, mach_port_t auth,
- int flags)
-{
- AUTHCHECK;
-
- _hurd_exec_flags = flags;
- return 0;
-}
-
-kern_return_t
-_S_msg_set_some_exec_flags (mach_port_t process, mach_port_t auth,
- int flags)
-{
- AUTHCHECK;
-
- _hurd_exec_flags |= flags;
- return 0;
-}
-
-kern_return_t
-_S_msg_clear_some_exec_flags (mach_port_t process, mach_port_t auth,
- int flags)
-{
- AUTHCHECK;
-
- _hurd_exec_flags &= ~flags;
- return 0;
-}
-\f
/* XXX */
kern_return_t
_S_msg_get_dtable (mach_port_t process,
- mach_port_t refport,
- portarray_t *dtable,
- mach_msg_type_name_t *dtablePoly,
- mach_msg_type_number_t *dtableCnt)
+ mach_port_t refport,
+ portarray_t *dtable,
+ mach_msg_type_name_t *dtablePoly,
+ mach_msg_type_number_t *dtableCnt)
{ return EOPNOTSUPP; }
kern_return_t
_S_msg_set_dtable (mach_port_t process,
- mach_port_t refport,
- portarray_t dtable,
- mach_msg_type_number_t dtableCnt)
-{ return EOPNOTSUPP; }
-
-kern_return_t
-_S_msg_startup_dosync (mach_port_t process)
+ mach_port_t refport,
+ portarray_t dtable,
+ mach_msg_type_number_t dtableCnt)
{ return EOPNOTSUPP; }