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 742942 - gvfs-mount should respond to EOF
gvfs-mount should respond to EOF
Status: RESOLVED FIXED
Product: gvfs
Classification: Core
Component: general
1.23.x
Other Linux
: Normal normal
: ---
Assigned To: gvfs-maint
gvfs-maint
Depends on:
Blocks:
 
 
Reported: 2015-01-14 23:00 UTC by Ross Lagerwall
Modified: 2015-01-21 17:27 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
gvfs-mount: Abort login if EOF is received (2.14 KB, patch)
2015-01-14 23:09 UTC, Ross Lagerwall
needs-work Details | Review
gvfs-mount: Abort login if EOF is received (3.48 KB, patch)
2015-01-21 07:51 UTC, Ross Lagerwall
committed Details | Review

Description Ross Lagerwall 2015-01-14 23:00:53 UTC
A user on the ml requested that gvfs-mount aborts the mounting process on EOF to ease scripting. This seems like a reasonable request.

https://mail.gnome.org/archives/gvfs-list/2014-October/msg00001.html
Comment 1 Ross Lagerwall 2015-01-14 23:09:19 UTC
Created attachment 294561 [details] [review]
gvfs-mount: Abort login if EOF is received

When reading a username, password or domain from the user, abort the
login process if EOF is received. This eases scripting gvfs-mount
and prevents an infinite loop with some backends.
Comment 2 Ross Lagerwall 2015-01-14 23:09:49 UTC
Note that this patch applies on top of those from bug 742169.
Comment 3 Ondrej Holy 2015-01-15 08:18:49 UTC
Review of attachment 294561 [details] [review]:

Looks good, although I don't like adding new goto's...

Would be good to do same handling also for ask_question_cd:
@@ -220,2 +223,5 @@ ask_question_cb (GMountOperation *op,
   s = prompt_for ("Choice", NULL, TRUE);
+  if (!s)
+    goto error;
+
   choice = atoi (s);
@@ -227,2 +233,7 @@ ask_question_cb (GMountOperation *op,
   g_free (s);
+
+  return;
+
+error:
+  g_mount_operation_reply (op, G_MOUNT_OPERATION_ABORTED);
 }

And I don't think it is necessary to print this error:
@@ -245,3 +256,3 @@ mount_mountable_done_cb (GObject *object,
         g_printerr (_("Error mounting location: Anonymous access denied\n"));
-      else
+      else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED))
         g_printerr (_("Error mounting location: %s\n"), error->message);
@@ -273,3 +284,3 @@ mount_done_cb (GObject *object,
         g_printerr (_("Error mounting location: Anonymous access denied\n"));
-      else
+      else if (!g_error_matches (error, G_IO_ERROR, G_IO_ERROR_FAILED_HANDLED))
         g_printerr (_("Error mounting location: %s\n"), error->message);

::: programs/gvfs-mount.c
@@ +124,3 @@
   len = strlen (data);
+  if (len == 0)
+    return NULL;

Maybe would be good to print newline to be handy if user press ^D...
-    return NULL;
+    {
+      g_print ("\n");
+      return NULL;
+    }
Comment 4 Ross Lagerwall 2015-01-21 07:51:01 UTC
Created attachment 295072 [details] [review]
gvfs-mount: Abort login if EOF is received

When reading a username, password or domain from the user, abort the
login process if EOF is received. This eases scripting gvfs-mount
and prevents an infinite loop with some backends.
Comment 5 Ross Lagerwall 2015-01-21 07:52:29 UTC
Updated patch should fix the review issues.
Comment 6 Ondrej Holy 2015-01-21 08:11:33 UTC
Review of attachment 295072 [details] [review]:

Thanks!
Comment 7 Ross Lagerwall 2015-01-21 17:27:41 UTC
Pushed to master as 2ddbf4d973effd7402f53a4f14798e5f945855df. Thanks for the review!