GNOME Bugzilla – Bug 742942
gvfs-mount should respond to EOF
Last modified: 2015-01-21 17:27:41 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
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.
Note that this patch applies on top of those from bug 742169.
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; + }
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.
Updated patch should fix the review issues.
Review of attachment 295072 [details] [review]: Thanks!
Pushed to master as 2ddbf4d973effd7402f53a4f14798e5f945855df. Thanks for the review!