After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 764099 - Misc house arrest bug fixes
Misc house arrest bug fixes
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: afc backend and volume monitor
unspecified
Other All
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2016-03-23 18:45 UTC by Bastien Nocera
Modified: 2016-06-09 10:00 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
afc: Fix handling of new HouseArrest paths (8.41 KB, patch)
2016-03-23 18:45 UTC, Bastien Nocera
none Details | Review
afc: Add guards against the operation mode not being set (2.19 KB, patch)
2016-03-23 18:45 UTC, Bastien Nocera
committed Details | Review
afc: Fix handling of new HouseArrest paths (8.37 KB, patch)
2016-06-06 16:38 UTC, Bastien Nocera
none Details | Review
afc: Fix handling of new HouseArrest paths (8.52 KB, patch)
2016-06-08 10:12 UTC, Bastien Nocera
committed Details | Review

Description Bastien Nocera 2016-03-23 18:45:32 UTC
The first one, we'll need to land into stable releases.
Comment 1 Bastien Nocera 2016-03-23 18:45:37 UTC
Created attachment 324611 [details] [review]
afc: Fix handling of new HouseArrest paths

In b8ad223, we re-rooted the HouseArrest paths to always include
Documents/ as anything closed to the root isn't accessible. This caused
2 problems:
- first, it meant that checking for the new path being "/" wasn't
  correct, as the path would always include at least a "Documents" path
  component
- secondly, it meant that the display name for the root directory for an
  application was incorrect as it was always "Documents" instead of the
  app name.
Comment 2 Bastien Nocera 2016-03-23 18:45:43 UTC
Created attachment 324612 [details] [review]
afc: Add guards against the operation mode not being set

We usually did:
if mode == AFC; <foo> else <bar>

To guard against the mode not actually being HouseArrest in the else
branch, change this to:
if mode == AFC; <foo> else if mode == HOUSE_ARREST ; <bar> ; else ; <baz>
Comment 3 Ondrej Holy 2016-03-24 15:05:17 UTC
Review of attachment 324611 [details] [review]:

::: daemon/gvfsbackendafc.c
@@ +878,3 @@
+    *is_doc_root = TRUE;
+  else if (is_doc_root)
+    *is_doc_root = FALSE;

It would be good to check is_doc_root first (just a nitpick), e.g.:
if (is_doc_root)
  *is_doc_root = (comps[0] != NULL && comps[1] == NULL);

@@ +885,3 @@
   comps[0] = g_strdup ("Documents");
+  *new_path = g_strjoinv ("/", comps);
+  if (is_doc_root)

is_doc_root is not a boolean, it is a pointer in this case, is this really what you want?

@@ +924,3 @@
         goto is_dir_bail;
 
+      if (is_doc_root)

It would be good to merge this with previous if statement as it is in other cases (just a nitpick)...
Comment 4 Ondrej Holy 2016-03-24 15:06:13 UTC
Review of attachment 324612 [details] [review]:

May this really happen? Shouldn't we return some meaningful error instead of asserts?
Comment 5 Bastien Nocera 2016-03-24 15:07:50 UTC
(In reply to Ondrej Holy from comment #4)
> Review of attachment 324612 [details] [review] [review]:
> 
> May this really happen? Shouldn't we return some meaningful error instead of
> asserts?

It can't happen, that's why it's an assertion. That would mean we forgot to adapt the code if we ever added a new operation "mode".
Comment 6 Ondrej Holy 2016-03-29 09:15:55 UTC
Asking just for sure, it is ok then :-)
Comment 7 Bastien Nocera 2016-06-06 16:23:52 UTC
(In reply to Ondrej Holy from comment #3)
> Review of attachment 324611 [details] [review] [review]:
> 
> ::: daemon/gvfsbackendafc.c
> @@ +878,3 @@
> +    *is_doc_root = TRUE;
> +  else if (is_doc_root)
> +    *is_doc_root = FALSE;
> 
> It would be good to check is_doc_root first (just a nitpick), e.g.:
> if (is_doc_root)
>   *is_doc_root = (comps[0] != NULL && comps[1] == NULL);

Fixed.

> @@ +885,3 @@
>    comps[0] = g_strdup ("Documents");
> +  *new_path = g_strjoinv ("/", comps);
> +  if (is_doc_root)
> 
> is_doc_root is not a boolean, it is a pointer in this case, is this really
> what you want?

should be if (*is_doc_root) indeed, fixed.

> @@ +924,3 @@
>          goto is_dir_bail;
>  
> +      if (is_doc_root)
> 
> It would be good to merge this with previous if statement as it is in other
> cases (just a nitpick)...

Fixed.
Comment 8 Bastien Nocera 2016-06-06 16:38:29 UTC
Created attachment 329207 [details] [review]
afc: Fix handling of new HouseArrest paths

In b8ad223, we re-rooted the HouseArrest paths to always include
Documents/ as anything closed to the root isn't accessible. This caused
2 problems:
- first, it meant that checking for the new path being "/" wasn't
  correct, as the path would always include at least a "Documents" path
  component
- secondly, it meant that the display name for the root directory for an
  application was incorrect as it was always "Documents" instead of the
  app name.
Comment 9 Ondrej Holy 2016-06-07 11:05:48 UTC
Review of attachment 329207 [details] [review]:

::: daemon/gvfsbackendafc.c
@@ +883,3 @@
   comps[0] = g_strdup ("Documents");
+  *new_path = g_strjoinv ("/", comps);
+  if (*is_doc_root)

This is still probably wrong, because is_doc_root may be NULL...
Comment 10 Bastien Nocera 2016-06-08 10:12:16 UTC
Created attachment 329369 [details] [review]
afc: Fix handling of new HouseArrest paths

In b8ad223, we re-rooted the HouseArrest paths to always include
Documents/ as anything closed to the root isn't accessible. This caused
2 problems:
- first, it meant that checking for the new path being "/" wasn't
  correct, as the path would always include at least a "Documents" path
  component
- secondly, it meant that the display name for the root directory for an
  application was incorrect as it was always "Documents" instead of the
  app name.
Comment 11 Ondrej Holy 2016-06-08 10:36:58 UTC
Review of attachment 329369 [details] [review]:

Looks good to me now, thanks, but please test it properly before pushing, I haven't got a chance to test...
Comment 12 Bastien Nocera 2016-06-09 09:59:51 UTC
Attachment 324612 [details] pushed as 828d6ae - afc: Add guards against the operation mode not being set
Attachment 329369 [details] pushed as 5471b77 - afc: Fix handling of new HouseArrest paths