mirror of
https://sourceware.org/git/glibc.git
synced 2025-07-28 00:21:52 +03:00
Mon Oct 16 03:22:37 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
* sysdeps/mach/hurd/getcwd.c: Use __file_name_lookup_under. * sysdeps/mach/hurd/bind.c: Likewise. * sysdeps/mach/hurd/access.c: Use new __hurd_file_name_lookup calling convention. * hurd/hurdexec.c: Undo last change (10 Oct 95).
This commit is contained in:
@ -1,3 +1,12 @@
|
|||||||
|
Mon Oct 16 03:22:37 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
||||||
|
|
||||||
|
* sysdeps/mach/hurd/getcwd.c: Use __file_name_lookup_under.
|
||||||
|
* sysdeps/mach/hurd/bind.c: Likewise.
|
||||||
|
* sysdeps/mach/hurd/access.c: Use new __hurd_file_name_lookup
|
||||||
|
calling convention.
|
||||||
|
|
||||||
|
* hurd/hurdexec.c: Undo last change (10 Oct 95).
|
||||||
|
|
||||||
Sun Oct 15 21:04:13 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
Sun Oct 15 21:04:13 1995 Roland McGrath <roland@churchy.gnu.ai.mit.edu>
|
||||||
|
|
||||||
* hurd/hurd/lookup.h: New file.
|
* hurd/hurd/lookup.h: New file.
|
||||||
|
@ -20,6 +20,7 @@ Cambridge, MA 02139, USA. */
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <hurd.h>
|
#include <hurd.h>
|
||||||
#include <hurd/fd.h>
|
#include <hurd/fd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
/* Change the current root directory to FD. */
|
/* Change the current root directory to FD. */
|
||||||
int
|
int
|
||||||
|
@ -217,14 +217,14 @@ _hurd_exec (task_t task, file_t file,
|
|||||||
*pdp++ = dtable[i];
|
*pdp++ = dtable[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
err = __file_exec (file, task, MACH_MSG_TYPE_COPY_SEND,
|
err = __file_exec (file, task,
|
||||||
_hurd_exec_flags & EXEC_INHERITED,
|
_hurd_exec_flags & EXEC_INHERITED,
|
||||||
args, argslen, 0, env, envlen, 0,
|
args, argslen, env, envlen,
|
||||||
dtable, MACH_MSG_TYPE_COPY_SEND, dtablesize, 0,
|
dtable, MACH_MSG_TYPE_COPY_SEND, dtablesize,
|
||||||
ports, MACH_MSG_TYPE_COPY_SEND, _hurd_nports, 0,
|
ports, MACH_MSG_TYPE_COPY_SEND, _hurd_nports,
|
||||||
ints, INIT_INT_MAX, 0,
|
ints, INIT_INT_MAX,
|
||||||
please_dealloc, pdp - please_dealloc, 0,
|
please_dealloc, pdp - please_dealloc,
|
||||||
NULL, 0, 0);
|
NULL, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release references to the standard ports. */
|
/* Release references to the standard ports. */
|
||||||
|
@ -174,7 +174,6 @@ void _mp_default_free ();
|
|||||||
else \
|
else \
|
||||||
____mpn_sqr_n (prodp, up, size, tspace); \
|
____mpn_sqr_n (prodp, up, size, tspace); \
|
||||||
} while (0);
|
} while (0);
|
||||||
#define assert(trueval) do {if (!(trueval)) abort ();} while (0)
|
|
||||||
|
|
||||||
/* Structure for conversion between internal binary format and
|
/* Structure for conversion between internal binary format and
|
||||||
strings in base 2..36. */
|
strings in base 2..36. */
|
||||||
|
@ -21,6 +21,7 @@ Cambridge, MA 02139, USA. */
|
|||||||
#include <hurd.h>
|
#include <hurd.h>
|
||||||
#include <hurd/port.h>
|
#include <hurd/port.h>
|
||||||
#include <hurd/id.h>
|
#include <hurd/id.h>
|
||||||
|
#include <hurd/lookup.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
/* Test for access to FILE by our real user and group IDs. */
|
/* Test for access to FILE by our real user and group IDs. */
|
||||||
@ -28,10 +29,48 @@ int
|
|||||||
DEFUN(__access, (file, type), CONST char *file AND int type)
|
DEFUN(__access, (file, type), CONST char *file AND int type)
|
||||||
{
|
{
|
||||||
error_t err;
|
error_t err;
|
||||||
file_t crdir, cwdir, rcrdir, rcwdir, io;
|
file_t rcrdir, rcwdir, io;
|
||||||
struct hurd_userlink crdir_ulink, cwdir_ulink;
|
|
||||||
int flags, allowed;
|
int flags, allowed;
|
||||||
mach_port_t ref;
|
|
||||||
|
error_t reauthenticate (int which, file_t *result)
|
||||||
|
{
|
||||||
|
/* Get a port to our root directory, authenticated with the real IDs. */
|
||||||
|
error_t err;
|
||||||
|
mach_port_t ref;
|
||||||
|
ref = __mach_reply_port ();
|
||||||
|
err = HURD_PORT_USE
|
||||||
|
(&_hurd_ports[which],
|
||||||
|
({
|
||||||
|
err = __io_reauthenticate (port, ref, MACH_MSG_TYPE_MAKE_SEND);
|
||||||
|
if (!err)
|
||||||
|
err = __auth_user_authenticate (_hurd_id.rid_auth,
|
||||||
|
port,
|
||||||
|
ref, MACH_MSG_TYPE_MAKE_SEND,
|
||||||
|
result);
|
||||||
|
err;
|
||||||
|
}));
|
||||||
|
__mach_port_destroy (__mach_task_self (), ref);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
error_t init_port (int which, error_t (*operate) (mach_port_t))
|
||||||
|
{
|
||||||
|
switch (which)
|
||||||
|
{
|
||||||
|
case INIT_PORT_AUTH:
|
||||||
|
return (*operate) (_hurd_id.rid_auth);
|
||||||
|
case INIT_PORT_CRDIR:
|
||||||
|
return (reauthenticate (INIT_PORT_CRDIR, &rcrdir) ?:
|
||||||
|
(*operate) (rcrdir));
|
||||||
|
case INIT_PORT_CWDIR:
|
||||||
|
return (reauthenticate (INIT_PORT_CWDIR, &rcwdir) ?:
|
||||||
|
(*operate) (rcwdir));
|
||||||
|
default:
|
||||||
|
return _hurd_ports_use (which, operate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
rcrdir = rcwdir = MACH_PORT_NULL;
|
||||||
|
|
||||||
HURD_CRITICAL_BEGIN;
|
HURD_CRITICAL_BEGIN;
|
||||||
|
|
||||||
@ -67,34 +106,11 @@ DEFUN(__access, (file, type), CONST char *file AND int type)
|
|||||||
&_hurd_id.rid_auth)))
|
&_hurd_id.rid_auth)))
|
||||||
goto lose;
|
goto lose;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get a port to our root directory, authenticated with the real IDs. */
|
|
||||||
crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink);
|
|
||||||
ref = __mach_reply_port ();
|
|
||||||
err = __io_reauthenticate (crdir, ref, MACH_MSG_TYPE_MAKE_SEND);
|
|
||||||
if (!err)
|
if (!err)
|
||||||
err = __auth_user_authenticate (_hurd_id.rid_auth,
|
/* Look up the file name using the modified init ports. */
|
||||||
crdir,
|
err = __hurd_file_name_lookup (&init_port, &__getdport,
|
||||||
ref, MACH_MSG_TYPE_MAKE_SEND,
|
file, 0, 0, &io);
|
||||||
&rcrdir);
|
|
||||||
_hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir);
|
|
||||||
__mach_port_destroy (__mach_task_self (), ref);
|
|
||||||
|
|
||||||
if (!err)
|
|
||||||
{
|
|
||||||
/* Get a port to our current working directory, authenticated with
|
|
||||||
the real IDs. */
|
|
||||||
cwdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink);
|
|
||||||
ref = __mach_reply_port ();
|
|
||||||
err = __io_reauthenticate (cwdir, ref, MACH_MSG_TYPE_MAKE_SEND);
|
|
||||||
if (!err)
|
|
||||||
err = __auth_user_authenticate (_hurd_id.rid_auth,
|
|
||||||
cwdir,
|
|
||||||
ref, MACH_MSG_TYPE_MAKE_SEND,
|
|
||||||
&rcwdir);
|
|
||||||
_hurd_port_free (&_hurd_ports[INIT_PORT_CWDIR], &cwdir_ulink, cwdir);
|
|
||||||
__mach_port_destroy (__mach_task_self (), ref);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* We are done with _hurd_id.rid_auth now. */
|
/* We are done with _hurd_id.rid_auth now. */
|
||||||
lose:
|
lose:
|
||||||
@ -102,15 +118,10 @@ DEFUN(__access, (file, type), CONST char *file AND int type)
|
|||||||
|
|
||||||
HURD_CRITICAL_END;
|
HURD_CRITICAL_END;
|
||||||
|
|
||||||
if (err)
|
if (rcrdir != MACH_PORT_NULL)
|
||||||
return __hurd_fail (err);
|
__mach_port_deallocate (__mach_task_self (), rcrdir);
|
||||||
|
if (rcwdir != MACH_PORT_NULL)
|
||||||
/* Now do a path lookup on FILE, using the crdir and cwdir
|
__mach_port_deallocate (__mach_task_self (), rcwdir);
|
||||||
reauthenticated with _hurd_id.rid_auth. */
|
|
||||||
|
|
||||||
err = __hurd_file_name_lookup (rcrdir, rcwdir, file, 0, 0, &io);
|
|
||||||
__mach_port_deallocate (__mach_task_self (), rcrdir);
|
|
||||||
__mach_port_deallocate (__mach_task_self (), rcwdir);
|
|
||||||
if (err)
|
if (err)
|
||||||
return __hurd_fail (err);
|
return __hurd_fail (err);
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 1992, 1994 Free Software Foundation, Inc.
|
/* Copyright (C) 1992, 1994, 1995 Free Software Foundation, Inc.
|
||||||
This file is part of the GNU C Library.
|
This file is part of the GNU C Library.
|
||||||
|
|
||||||
The GNU C Library is free software; you can redistribute it and/or
|
The GNU C Library is free software; you can redistribute it and/or
|
||||||
@ -65,40 +65,22 @@ DEFUN(bind, (fd, addr, len),
|
|||||||
if (! err)
|
if (! err)
|
||||||
/* Link the node, now a socket, into the target directory. */
|
/* Link the node, now a socket, into the target directory. */
|
||||||
err = __dir_link (node, dir, n);
|
err = __dir_link (node, dir, n);
|
||||||
|
__mach_port_deallocate (__mach_task_self (), node);
|
||||||
if (! err)
|
if (! err)
|
||||||
/* Get a port to the ifsock translator. */
|
|
||||||
{
|
{
|
||||||
retry_type retry;
|
/* Get a port to the ifsock translator. */
|
||||||
string_t retry_name;
|
ifsock = __file_name_lookup_under (dir, n, 0, 0);
|
||||||
|
if (ifsock == MACH_PORT_NULL)
|
||||||
err = __dir_lookup (dir, n, 0, 0, &retry, retry_name, &ifsock);
|
|
||||||
|
|
||||||
if (! err && (retry != FS_RETRY_NORMAL || retry_name[0]))
|
|
||||||
/* Either someone has fucked with our new node, or the ifsock
|
|
||||||
translator is acting very oddly. */
|
|
||||||
{
|
{
|
||||||
struct hurd_userlink crdir_ulink;
|
err = errno;
|
||||||
file_t crdir =
|
/* If we failed, get rid of the node we created. */
|
||||||
_hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR],
|
__dir_unlink (dir, n);
|
||||||
&crdir_ulink);
|
|
||||||
|
|
||||||
err = __hurd_file_name_lookup_retry (crdir,
|
|
||||||
retry, retry_name, 0, 0,
|
|
||||||
&ifsock);
|
|
||||||
|
|
||||||
_hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR],
|
|
||||||
&crdir_ulink, crdir);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err)
|
|
||||||
/* If we failed, get rid of the node we created. */
|
|
||||||
__dir_unlink (dir, n);
|
|
||||||
}
|
}
|
||||||
if (! err)
|
if (! err)
|
||||||
/* Get the address port. */
|
/* Get the address port. */
|
||||||
err = __ifsock_getsockaddr (ifsock, &aport);
|
err = __ifsock_getsockaddr (ifsock, &aport);
|
||||||
__mach_port_deallocate (__mach_task_self (), ifsock);
|
__mach_port_deallocate (__mach_task_self (), ifsock);
|
||||||
__mach_port_deallocate (__mach_task_self (), node);
|
|
||||||
}
|
}
|
||||||
__mach_port_deallocate (__mach_task_self (), dir);
|
__mach_port_deallocate (__mach_task_self (), dir);
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ Cambridge, MA 02139, USA. */
|
|||||||
#include <hurd.h>
|
#include <hurd.h>
|
||||||
#include <hurd/port.h>
|
#include <hurd/port.h>
|
||||||
#include <hurd/fd.h>
|
#include <hurd/fd.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
/* Change the current directory to FD. */
|
/* Change the current directory to FD. */
|
||||||
int
|
int
|
||||||
|
@ -47,12 +47,9 @@ __getcwd (char *buf, size_t size)
|
|||||||
file_t parent;
|
file_t parent;
|
||||||
char *dirbuf = NULL;
|
char *dirbuf = NULL;
|
||||||
unsigned int dirbufsize = 0;
|
unsigned int dirbufsize = 0;
|
||||||
file_t crdir;
|
|
||||||
struct hurd_userlink crdir_ulink;
|
|
||||||
|
|
||||||
inline void cleanup (void)
|
inline void cleanup (void)
|
||||||
{
|
{
|
||||||
_hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir);
|
|
||||||
__mach_port_deallocate (__mach_task_self (), parent);
|
__mach_port_deallocate (__mach_task_self (), parent);
|
||||||
|
|
||||||
if (dirbuf != NULL)
|
if (dirbuf != NULL)
|
||||||
@ -86,12 +83,8 @@ __getcwd (char *buf, size_t size)
|
|||||||
|
|
||||||
/* Get a port to our root directory and stat it. */
|
/* Get a port to our root directory and stat it. */
|
||||||
|
|
||||||
crdir = _hurd_port_get (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink);
|
if (err = __USEPORT (CRDIR, __io_stat (port, &st)))
|
||||||
if (err = __io_stat (crdir, &st))
|
return __hurd_fail (err), NULL;
|
||||||
{
|
|
||||||
_hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir);
|
|
||||||
return __hurd_fail (err), NULL;
|
|
||||||
}
|
|
||||||
rootdev = st.st_dev;
|
rootdev = st.st_dev;
|
||||||
rootino = st.st_ino;
|
rootino = st.st_ino;
|
||||||
|
|
||||||
@ -101,10 +94,7 @@ __getcwd (char *buf, size_t size)
|
|||||||
(parent = port),
|
(parent = port),
|
||||||
MACH_PORT_RIGHT_SEND,
|
MACH_PORT_RIGHT_SEND,
|
||||||
1)))
|
1)))
|
||||||
{
|
return __hurd_fail (err), NULL;
|
||||||
_hurd_port_free (&_hurd_ports[INIT_PORT_CRDIR], &crdir_ulink, crdir);
|
|
||||||
return __hurd_fail (err), NULL;
|
|
||||||
}
|
|
||||||
if (err = __io_stat (parent, &st))
|
if (err = __io_stat (parent, &st))
|
||||||
{
|
{
|
||||||
cleanup ();
|
cleanup ();
|
||||||
@ -130,14 +120,15 @@ __getcwd (char *buf, size_t size)
|
|||||||
int direntry, nentries;
|
int direntry, nentries;
|
||||||
|
|
||||||
/* Look at the parent directory. */
|
/* Look at the parent directory. */
|
||||||
if (err = __hurd_file_name_lookup (crdir, parent, "..", O_READ, 0, &newp))
|
newp = __file_name_lookup_under (parent, "..", O_READ, 0);
|
||||||
|
if (newp == MACH_PORT_NULL)
|
||||||
goto lose;
|
goto lose;
|
||||||
__mach_port_deallocate (__mach_task_self (), parent);
|
__mach_port_deallocate (__mach_task_self (), parent);
|
||||||
parent = newp;
|
parent = newp;
|
||||||
|
|
||||||
/* Figure out if this directory is a mount point. */
|
/* Figure out if this directory is a mount point. */
|
||||||
if (err = __io_stat (parent, &st))
|
if (err = __io_stat (parent, &st))
|
||||||
goto lose;
|
goto errlose;
|
||||||
dotdev = st.st_dev;
|
dotdev = st.st_dev;
|
||||||
dotino = st.st_ino;
|
dotino = st.st_ino;
|
||||||
mount_point = dotdev != thisdev;
|
mount_point = dotdev != thisdev;
|
||||||
@ -184,14 +175,14 @@ __getcwd (char *buf, size_t size)
|
|||||||
|
|
||||||
if (mount_point || d->d_ino == thisino)
|
if (mount_point || d->d_ino == thisino)
|
||||||
{
|
{
|
||||||
file_t try;
|
file_t try = __file_name_lookup_under (parent, d->d_name,
|
||||||
if (err = __hurd_file_name_lookup (crdir, parent, d->d_name,
|
O_NOLINK, 0);
|
||||||
O_NOLINK, 0, &try))
|
if (try == MACH_PORT_NULL)
|
||||||
goto lose;
|
goto lose;
|
||||||
err = __io_stat (try, &st);
|
err = __io_stat (try, &st);
|
||||||
__mach_port_deallocate (__mach_task_self (), try);
|
__mach_port_deallocate (__mach_task_self (), try);
|
||||||
if (err)
|
if (err)
|
||||||
goto lose;
|
goto errlose;
|
||||||
if (st.st_dev == thisdev && st.st_ino == thisino)
|
if (st.st_dev == thisdev && st.st_ino == thisino)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -199,7 +190,7 @@ __getcwd (char *buf, size_t size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (err)
|
if (err)
|
||||||
goto lose;
|
goto errlose;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Prepend the directory name just discovered. */
|
/* Prepend the directory name just discovered. */
|
||||||
@ -244,6 +235,9 @@ __getcwd (char *buf, size_t size)
|
|||||||
cleanup ();
|
cleanup ();
|
||||||
return file_name;
|
return file_name;
|
||||||
|
|
||||||
|
errlose:
|
||||||
|
/* Set errno. */
|
||||||
|
(void) __hurd_fail (err);
|
||||||
lose:
|
lose:
|
||||||
cleanup ();
|
cleanup ();
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Reference in New Issue
Block a user