Re: g_file_read fails when running on a remote machine via ssh

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

 



On Wed, Feb 9, 2011 at 2:40 PM, Lex Trotman <elextr@xxxxxxxxx> wrote:
> On 10 February 2011 01:13, Jim George <jimgeorge@xxxxxxxxx> wrote:
>> On Tue, Feb 8, 2011 at 11:11 PM, Tristan Van Berkom <tvb@xxxxxxxxx> wrote:
>>> On Wed, Feb 9, 2011 at 4:19 AM, Jim George <jimgeorge@xxxxxxxxx> wrote:
>>>> Hi all,
>>>> In a larger GTK application that needs to do HTTP gets, I replaced use
>>>> of cURL and some helper functions called "glibcurl" with GIO calls. I
>>>> now face a strange problem that when the program runs locally,
>>>> everything is fine, but when run over an SSH tunnel with X forwarding,
>>>> the call to g_file_read fails, with a GError->message of "Operation
>>>> not supported".
>>>>
>>>> To investigate this further, I wrote a small test program pasted below:
>>>>
>>>> #include <glib.h>
>>>> #include <gio/gio.h>
>>>> #include <stdio.h>
>>>> #include <string.h>
>>>>
>>>> int main(int argc, char *argv[])
>>>> {
>>>> Â Â Â Âchar url[256] = "http://www.google.com";;
>>>> Â Â Â ÂGFile *file;
>>>> Â Â Â ÂGFileInputStream *istream;
>>>> Â Â Â ÂGError *err = NULL;
>>>>
>>>> Â Â Â Âif (argc > 1) {
>>>> Â Â Â Â Â Â Â Âstrncpy(url, argv[1], 256);
>>>> Â Â Â Â}
>>>>
>>>> Â Â Â Âprintf("Opening %s\n", url);
>>>> Â Â Â Âfile = g_file_new_for_uri(url);
>>>> Â Â Â Âistream = g_file_read(file, NULL, &err);
>>>>
>>>> Â Â Â Âif (err != NULL) {
>>>> Â Â Â Â Â Â Â Âg_error("Could not open %s for reading: %s\n", url, err->message);
>>>> Â Â Â Â Â Â Â Âg_error_free(err);
>>>> Â Â Â Â Â Â Â Âreturn 1;
>>>> Â Â Â Â}
>>>>
>>>> Â Â Â Âg_input_stream_close(G_INPUT_STREAM(istream), NULL, &err);
>>>> Â Â Â Âg_object_unref(file);
>>>>
>>>> Â Â Â Âreturn 0;
>>>> }
>>>>
>>>> I compiled this using: gcc -g -O0 `pkg-config --cflags --libs gio-2.0
>>>> gtk+-2.0` -o test test.c
>>>>
>>>> Running ./test locally gives me the "Opening http://www.google.com";
>>>> message, and a normal exit.
>>>> When I run the program on a different machine, to which I have opened
>>>> an ssh connection, I get this:
>>>>
>>>> Opening http://www.google.com
>>>>
>>>> ** ERROR **: Could not open http://www.google.com for reading:
>>>> Operation not supported
>>>>
>>>> aborting...
>>>> Aborted (core dumped)
>>>>
>>>> This matches the behavior on my main gtk program. As a test, the
>>>> behavior of the test program is identical when trying to access a text
>>>> file on one of our local web servers.
>>>>
>>>> I couldn't find much documentation on gfile and gio by way of a
>>>> tutorial, so I'm pretty much feeling my way around right now. What am
>>>> I doing wrong?
>>>
>>> I'm the wrong person to answer you directly about GIO, but I did
>>> hear that the tls support is only very recently added to GIO.
>>>
>>> Check that you are indeed using the unstable and unreleased new
>>> glib package that includes this support.
>>>
>>> Cheers,
>>> Â Â Â Â -Tristan
>>>
>>
>> Hi Tristan,
>> Sorry, I forgot to mention, first system (where I did the build and
>> initial test that succeeded) is running Fedora 14, with gtk2 package
>> version of 2.22.0, the second one from where I did the "ssh" runs
>> Fedora 13, with gtk2 package version 2.20.1.
>>
>> I believe these versions do support http via GIO, what stumps me is
>> why things should behave differently when I'm running my program
>> remotely (over a pts), as opposed to running it locally (from tty).
>> The connection to the webserver is still plain http, and should not be
>> using TLS in both cases.
>>
>> Sequence of operations: log in locally on my F13 box, use ssh to
>> connect to the F14 box and run the test program included in the
>> previous email. In this case, I get an error message ("Operation not
>> supported"). If I log in locally at the F14 box and run the same
>> program, it works fine.
>
> I know it is a bit obvious but are you sure you are running the ssh
> command as the same user as when logged in. Âie you login to a shell
> as you and then run the command, not just have the sshd run it for
> you?
>
> Cheers
> Lex

Yes, I have a shell on the remote machine, and run my program from
bash. Just to be sure, I tried it the other way (having ssh execute
the test program without creating a shell) and it has the same result.
-Jim
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list



[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux