bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 2/4] sutils: fix file_name_lookup_carefully


From: Justus Winter
Subject: [PATCH 2/4] sutils: fix file_name_lookup_carefully
Date: Fri, 28 Jun 2013 18:46:04 +0200

file_name_lookup_carefully is like file_name_lookup but tries hard to
avoid starting any passive translators while doing the lookup. The
callback contains code to get a new handle to the root if it
encounters a translator, but this code was not being executed if the
node had no record of an passive translator, just an active one.

Fix the callback by dropping the test for a passive translator. AIUI
the current check for a passive translator makes no sense, as the code
is supposed to fail on encountering a passive translator.

This fixes lookups inside translators that have no passive
translator. For example if /run is a tmpfs started only as active
translator, touch /run/lock && mount tmpfs -t tmpfs /run/lock -o
size=5M would fail.

* sutils/clookup.c (lookup): Drop the test for an passive translator.
---
 sutils/clookup.c |   50 ++++++++++++++++++--------------------------------
 1 file changed, 18 insertions(+), 32 deletions(-)

diff --git a/sutils/clookup.c b/sutils/clookup.c
index 0107799..0232b63 100644
--- a/sutils/clookup.c
+++ b/sutils/clookup.c
@@ -83,43 +83,29 @@ file_name_lookup_carefully (const char *name, int flags, 
mode_t mode)
           is), we have to simulate the above lookup being done without
           O_NOTRANS.  Do this being careful not to start any translators.  */
        {
-         char _ptrans[1024], *ptrans = _ptrans;
-         size_t ptrans_len = sizeof _ptrans;
+         /* See if there's an active translator.  */
+         fsys_t fsys;  /* Active translator control port.  */
 
-         err = file_get_translator (*node, &ptrans, &ptrans_len);
+         err = file_get_translator_cntl (*node, &fsys);
          if (! err)
-           /* Has a passive translator, see if there's an active one too.  */
+           /* There is!  Get its root node to use as the actual file.  */
            {
-             fsys_t fsys;      /* Active translator control port.  */
-
-             if (ptrans != _ptrans)
-               /* Deallocate out-of-line memory from file_get_translator.  */
-               munmap (ptrans, ptrans_len);
-
-             err = file_get_translator_cntl (*node, &fsys);
+             file_t unauth_dir; /* DIR unauthenticated.  */
+             err = io_restrict_auth (dir, &unauth_dir, 0, 0, 0, 0);
              if (! err)
-               /* There is!  Get its root node to use as the actual file.  */
-               {
-                 file_t unauth_dir; /* DIR unauthenticated.  */
-                 err = io_restrict_auth (dir, &unauth_dir, 0, 0, 0, 0);
-                 if (! err)
-                   {
-                     file_t old_node = *node;
-                     err = fsys_getroot (fsys,
-                                         unauth_dir, MACH_MSG_TYPE_COPY_SEND,
-                                         uids, num_uids, gids, num_gids,
-                                         flags & ~O_NOTRANS, retry,
-                                         retry_name, node);
-                     mach_port_deallocate (mach_task_self (), unauth_dir);
-                     if (! err)
-                       mach_port_deallocate (mach_task_self (), old_node);
-                   }
-                 mach_port_deallocate (mach_task_self (), fsys);
-               }
+               {
+                 file_t old_node = *node;
+                 err = fsys_getroot (fsys,
+                                 unauth_dir, MACH_MSG_TYPE_COPY_SEND,
+                                 uids, num_uids, gids, num_gids,
+                                 flags & ~O_NOTRANS, retry,
+                                 retry_name, node);
+                 mach_port_deallocate (mach_task_self (), unauth_dir);
+                 if (! err)
+               mach_port_deallocate (mach_task_self (), old_node);
+               }
+             mach_port_deallocate (mach_task_self (), fsys);
            }
-         else if (err == EINVAL)
-           /* No passive translator.  */
-           err = 0;
 
          if (!err && tail)
            /* Append TAIL to RETRY_NAME.  */
-- 
1.7.10.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]