summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <justus@gnupg.org>2016-10-05 13:34:26 +0200
committerJustus Winter <justus@gnupg.org>2017-09-12 10:41:35 +0200
commit8d5a124be53200c775b818e933603c1c8eeefbe5 (patch)
tree1709e8cc55ab742cea34fd5a574ee75df0cba7a1
parent1a75f7795e8d5e2b7cbc27e39eade1ee04668c19 (diff)
Fix active translator registration.
* libdiskfs/dir-lookup.c (diskfs_S_dir_lookup): Unconditionally register translators. Previously, we missed translators because 'transbox.active' is not in fact reset if the translator dies. * libnetfs/dir-lookup.c (netfs_S_dir_lookup): Likewise.
-rw-r--r--libdiskfs/dir-lookup.c66
-rw-r--r--libnetfs/dir-lookup.c74
2 files changed, 64 insertions, 76 deletions
diff --git a/libdiskfs/dir-lookup.c b/libdiskfs/dir-lookup.c
index 3c7198fb..63bba78e 100644
--- a/libdiskfs/dir-lookup.c
+++ b/libdiskfs/dir-lookup.c
@@ -249,13 +249,6 @@ diskfs_S_dir_lookup (struct protid *dircred,
if (np != dnp)
pthread_mutex_unlock (&dnp->lock);
- /* Check if an active translator is currently running. If
- not, fshelp_fetch_root will start one. In that case, we
- need to register it in the list of active
- translators. */
- boolean_t register_translator =
- np->transbox.active == MACH_PORT_NULL;
-
struct fshelp_stat_cookie2 cookie = {
.statp = &np->dn_stat,
.modep = &np->dn_stat.st_mode,
@@ -291,36 +284,37 @@ diskfs_S_dir_lookup (struct protid *dircred,
}
}
- if (register_translator)
- {
- char *translator_path = strdupa (relpath);
- char *complete_path;
- if (nextname != NULL)
- {
- /* This was not the last path component.
- NEXTNAME points to the next component, locate
- the end of the current component and use it
- to trim TRANSLATOR_PATH. */
- char *end = nextname;
- while (*end != 0)
- end--;
- translator_path[end - filename_start] = '\0';
- }
+ {
+ char *translator_path = strdupa (relpath);
+ char *complete_path;
+ if (nextname != NULL)
+ {
+ /* This was not the last path component.
+ NEXTNAME points to the next component, locate
+ the end of the current component and use it
+ to trim TRANSLATOR_PATH. */
+ char *end = nextname;
+ while (*end != 0)
+ end--;
+ translator_path[end - filename_start] = '\0';
+ }
- if (dircred->po->path == NULL || !strcmp (dircred->po->path,"."))
- /* dircred is the root directory. */
- complete_path = translator_path;
- else
- asprintf (&complete_path, "%s/%s", dircred->po->path, translator_path);
-
- err = fshelp_set_active_translator (&newpi->pi,
- complete_path,
- np->transbox.active);
- if (complete_path != translator_path)
- free(complete_path);
- if (err)
- goto out;
- }
+ if (dircred->po->path == NULL
+ || !strcmp (dircred->po->path,"."))
+ /* dircred is the root directory. */
+ complete_path = translator_path;
+ else
+ asprintf (&complete_path, "%s/%s", dircred->po->path,
+ translator_path);
+
+ err = fshelp_set_active_translator (&newpi->pi,
+ complete_path,
+ np->transbox.active);
+ if (complete_path != translator_path)
+ free(complete_path);
+ if (err)
+ goto out;
+ }
goto out;
}
diff --git a/libnetfs/dir-lookup.c b/libnetfs/dir-lookup.c
index c24a4989..321ee6e1 100644
--- a/libnetfs/dir-lookup.c
+++ b/libnetfs/dir-lookup.c
@@ -235,7 +235,6 @@ netfs_S_dir_lookup (struct protid *dircred,
}
}
- boolean_t register_translator = 0;
if (! err)
{
struct fshelp_stat_cookie2 cookie = {
@@ -246,12 +245,6 @@ netfs_S_dir_lookup (struct protid *dircred,
dirport = ports_get_send_right (newpi);
- /* Check if an active translator is currently running. If
- not, fshelp_fetch_root will start one. In that case, we
- need to register it in the list of active
- translators. */
- register_translator = np->transbox.active == MACH_PORT_NULL;
-
err = fshelp_fetch_root (&np->transbox,
&cookie,
dirport,
@@ -282,39 +275,40 @@ netfs_S_dir_lookup (struct protid *dircred,
}
}
- if (register_translator)
- {
- char *translator_path = strdupa (relpath);
- char *complete_path;
- if (nextname != NULL)
- {
- /* This was not the last path component.
- NEXTNAME points to the next component, locate
- the end of the current component and use it
- to trim TRANSLATOR_PATH. */
- char *end = nextname;
- while (*end != 0)
- end--;
- translator_path[end - filename_start] = '\0';
- }
-
- if (dircred->po->path == NULL || !strcmp (dircred->po->path,"."))
- /* dircred is the root directory. */
- complete_path = translator_path;
- else
- asprintf (&complete_path, "%s/%s", dircred->po->path, translator_path);
-
- err = fshelp_set_active_translator (&newpi->pi,
- complete_path,
- np->transbox.active);
- if (complete_path != translator_path)
- free(complete_path);
- if (err)
- {
- ports_port_deref (newpi);
- goto out;
- }
- }
+ {
+ char *translator_path = strdupa (relpath);
+ char *complete_path;
+ if (nextname != NULL)
+ {
+ /* This was not the last path component.
+ NEXTNAME points to the next component, locate
+ the end of the current component and use it
+ to trim TRANSLATOR_PATH. */
+ char *end = nextname;
+ while (*end != 0)
+ end--;
+ translator_path[end - filename_start] = '\0';
+ }
+
+ if (dircred->po->path == NULL
+ || !strcmp (dircred->po->path,"."))
+ /* dircred is the root directory. */
+ complete_path = translator_path;
+ else
+ asprintf (&complete_path, "%s/%s", dircred->po->path,
+ translator_path);
+
+ err = fshelp_set_active_translator (&newpi->pi,
+ complete_path,
+ np->transbox.active);
+ if (complete_path != translator_path)
+ free(complete_path);
+ if (err)
+ {
+ ports_port_deref (newpi);
+ goto out;
+ }
+ }
ports_port_deref (newpi);
goto out;