summaryrefslogtreecommitdiff
path: root/trans/fakeroot.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2002-05-18 21:23:48 +0000
committerRoland McGrath <roland@gnu.org>2002-05-18 21:23:48 +0000
commit9468d2eaa62344527901a2d7df55b21f8116722d (patch)
tree00f97dc64e877ec7c8a2ae8b41eedf253f2a0768 /trans/fakeroot.c
parent20df0096095d99c7e8ff9d71046263127f610e6c (diff)
2002-05-18 Roland McGrath <roland@frob.com>
* fakeroot.c (netfs_S_file_exec): Call check_openmodes and extract a ref to the send right with the node locked.
Diffstat (limited to 'trans/fakeroot.c')
-rw-r--r--trans/fakeroot.c28
1 files changed, 21 insertions, 7 deletions
diff --git a/trans/fakeroot.c b/trans/fakeroot.c
index 967fb523..b688ce77 100644
--- a/trans/fakeroot.c
+++ b/trans/fakeroot.c
@@ -702,17 +702,31 @@ netfs_S_file_exec (struct protid *user,
size_t destroynameslen)
{
error_t err;
+ file_t file;
if (!user)
return EOPNOTSUPP;
- /* We cannot use MACH_MSG_TYPE_MOVE_SEND because we might need to
- retry an interrupted call that would have consumed the rights. */
- err = file_exec (user->po->np->nn->file, task, flags, argv, argvlen,
- envp, envplen, fds, MACH_MSG_TYPE_COPY_SEND, fdslen,
- portarray, MACH_MSG_TYPE_COPY_SEND, portarraylen,
- intarray, intarraylen, deallocnames, deallocnameslen,
- destroynames, destroynameslen);
+ mutex_lock (&user->po->np->lock);
+ err = check_openmodes (user->po->np->nn, O_EXEC, MACH_PORT_NULL);
+ file = user->po->np->nn->file;
+ if (!err)
+ err = mach_port_mod_refs (mach_task_self (),
+ file, MACH_PORT_RIGHT_SEND, 1);
+ mutex_unlock (&user->po->np->lock);
+
+ if (!err)
+ {
+ /* We cannot use MACH_MSG_TYPE_MOVE_SEND because we might need to
+ retry an interrupted call that would have consumed the rights. */
+ err = file_exec (user->po->np->nn->file, task, flags, argv, argvlen,
+ envp, envplen, fds, MACH_MSG_TYPE_COPY_SEND, fdslen,
+ portarray, MACH_MSG_TYPE_COPY_SEND, portarraylen,
+ intarray, intarraylen, deallocnames, deallocnameslen,
+ destroynames, destroynameslen);
+ mach_port_deallocate (mach_task_self (), file);
+ }
+
if (err == 0)
{
size_t i;