From 9468d2eaa62344527901a2d7df55b21f8116722d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Sat, 18 May 2002 21:23:48 +0000 Subject: 2002-05-18 Roland McGrath * fakeroot.c (netfs_S_file_exec): Call check_openmodes and extract a ref to the send right with the node locked. --- trans/fakeroot.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'trans') 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; -- cgit v1.2.3