gvfs-mount infinite loop if wrong password in stdin redirection



Hi all:

I have written a script to help me mount Windows shares. It is here:

https://github.com/rdiez/Tools/tree/master/MountWindowsShares

The script asks the user for the Windows password, and then runs gvfs-mount once for every network share to mount. I do not want to use the GNOME ring to store the passwords.

There is no other way to pass a password to gvfs-mount, so I am redirecting its stdin in order to feed it with the password, which seems to work well. However, if the user types the wrong password, gvfs-mount enters an infinite loop. I keeps asking for a password, apparently accepting one, and then it asks again for a password. And so on.

I think the problem is that routine prompt_for() in gvfs-mount is not checking for a possible error returned by fgets(), so it does not realise that stdin has reached the end of file (EOF) condition.

I guess gvfs-mount thinks that the user has typed an empty password and tries that empty password out against the remote server. When it fails, it asks again, causing an infinite loop. There does not seem to be a limit on the number of retries either.

Is there any chance that somebody could fix this?

By the way, error detection seems a little weak at some points. For example, g_print() has no way to signal that writing to stdout may have failed (I guess GNOME does not use C++ exceptions or setjmp/longjmp, right?). Errors writing to stdout can happen, and I have actually written about this myself:

  http://www.devtal.de/wiki/Benutzer:Rdiez/ErrorHandling
  See section "Check Errors from printf() too"

Calls to bindtextdomain() are not checked for errors either.

In order to find out whether a file descriptor is a terminal, one should probably call isatty() instead. tcgetattr() could return other error codes in the future.

Please copy me on any answers, as I am not subscribed to this mailing list.

Thanks,
  rdiez


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