Jump to content

Guidelines and HOWTOs/Debugging/Debugging IOSlaves/Debugging kio fish: Difference between revisions

From KDE Community Wiki
*>Tstaerk
this file is not needed
Ochurlaud (talk | contribs)
m 27 revisions imported
 
(15 intermediate revisions by one other user not shown)
Line 1: Line 1:
This page is a starting point for debugging kio_fish. Please also read [[Guidelines_and_HOWTOs/Debugging/Debugging_IOSlaves|how to debug IO slaves generically]].
This page is a starting point for debugging kio_fish. Please also read [[Guidelines_and_HOWTOs/Debugging/Debugging_IOSlaves|how to debug IO slaves generically]].
= Overview =
When you point your konqueror to fish://''user''@''target'', [http://websvn.kde.org/trunk/KDE/kdebase/runtime/kioslave/fish/fish.cpp?view=log the fish kioslave] opens a process that calls the executable ssh. If a password is needed, this question is passed on to you (search for "password" in fish.cpp). Then a [http://websvn.kde.org/trunk/KDE/kdebase/runtime/kioslave/fish/fish.pl?view=log perl script] is copied over to the target host and executed there. On the target host, the file is named .fishsrv.pl. This perl script is compiled into your binary kio_fish.o. If you want to change it sustainably, you will have to change fish.pl in your source dir and then compile and install the directory [http://websvn.kde.org/trunk/KDE/kdebase/runtime/kioslave/fish/ kioslave/fish].
The perl script, running on the target computer, is (t)here to execute fish commands like LIST, STAT, WRITE and APPEND. They are sent from fish.cpp running on the source computer.


= Bugs =
= Bugs =
Line 6: Line 11:
* [http://bugs.kde.org/show_bug.cgi?id=145123 fish protocol dies unexpectedly]
* [http://bugs.kde.org/show_bug.cgi?id=145123 fish protocol dies unexpectedly]


= Overview =
= Test case =
When you point your konqueror to fish://''user''@''target'', [http://websvn.kde.org/trunk/KDE/kdebase/runtime/kioslave/fish/fish.cpp?view=log the fish kioslave] opens a process that calls the executable ssh. If a password is needed, this question is passed on to you (search for "password" in fish.cpp). Then a [http://websvn.kde.org/trunk/KDE/kdebase/runtime/kioslave/fish/fish.pl?view=log perl script] is copied over to the target host and executed there. On the target host, the file is named .fishsrv.pl. This perl script is compiled into your binary kio_fish.o. If you want to change it sustainably, you will have to change fish.pl in your source dir and then compile and install the directory [http://websvn.kde.org/trunk/KDE/kdebase/runtime/kioslave/fish/ kioslave/fish].
If you want a test case to get some debugging output from kio_fish, get a fresh checkout of kdebase. There you find a test case in runtime/kioslave/fish/tests. [[User:Tstaerk|I]] had the problem that the STOR commands from the fish kioslave were not logged as long as I had localhost as target computer. When I changed it to my local address (192.168.0.7), it worked.
 
= Logging =
You may want to switch on logging for fish.cpp and for fish.pl.
 
In this example, we want to log the output of fish.cpp to /tmp/debugfish. As described at [[Guidelines_and_HOWTOs/Debugging/Debugging_IOSlaves|Debugging_IOSlaves]], change your kdebugrc, e.g. like that:
cat >> $(kde4-config --path config | sed "s/.*://")kdebugrc << EOF
[7127]
InfoOutput=0
InfoFilename=/tmp/debugfish
EOF


The perl script, running on the target computer, is (t)here to execute fish commands like LIST, STAT, WRITE and APPEND. They are sent from fish.cpp running on the source computer.
In this example, we want to log the output of fish.pl to /tmp/kio_fish.debug.log so we change the 14th line of fish.pl to
open(DEBUG,">>/tmp/kio_fish.debug.log");
and uncomment all the lines containing DEBUG.


= Manually testing fish =
= Manually testing fish =
To test fish manually, call ~/.fishsrv.pl. The fish server will ask you in friendly words (it says ### 100) to transmit its own code, followed by a line __END__. Transmit it. Then the fish server is ready to talk with you (it says ### 200). You can have a conversation like this:
To test fish manually, call ~/.fishsrv.pl. The fish server will ask you in friendly words (it says ### 100) to transmit its own code, followed by a line __END__. Transmit it. Then the fish server is ready to talk with you (it says ### 200). You can have a conversation like this:
itchy:~ # (echo __END__; cat)| cat .fishsrv.pl -  | perl .fishsrv.pl
### 100 transfer fish server
  ### 200
  ### 200
  #VER
  #VER
  VER 0.0.3 copy lscount lslinks lsmime exec stat
  VER 0.0.3 copy lscount lslinks lsmime exec stat
  ### 200
  ### 200
#WRITE 0 6 /tmp/file1


So here is how you can have a sensible communication with a fish server:
### 100
  (echo __END__; cat)| cat .fishsrv.pl - | perl .fishsrv.pl
123456
### 200
  itchy:~ # cat /tmp/file1
  123456itchy:~ #


== The WRITE command ==
Example:
#WRITE 0 6 /tmp/file1
Syntax:
#WRITE ''start'' ''end'' ''file''
Reads the ''end''-''start'' bytes from STDIN and writes them into file ''file'' starting at position ''start'' ending at position ''end''.


== Write to a file ==
== The EXEC command ==
  itchy:~/kdebase/runtime/kioslave/fish # cat fish.pl - | perl fish.pl
The EXEC command executes an sh command on the computer where the fish perl service is running.
 
Example:
  itchy:~/kdebase/runtime/kioslave/fish # (echo __END__; cat)| cat fish.pl - | perl fish.pl
  ### 100 transfer fish server
  ### 100 transfer fish server
  ### 200
  ### 200
  #WRITE 0 6 /t
  #EXEC ls blah
123456
### 100
132345
  ### 200
  ### 200
  itchy:~/kdebase/runtime/kioslave/fish # ll /t
  itchy:~/kdebase/runtime/kioslave/fish # cat blah
  -rw-r--r-- 1 root root 6 Feb 28 08:17 /t
AUTHORS
CMakeFiles
CMakeLists.txt
[...]
 
= Passwordless login =
For your work you may want to setup passwordless logins on localhost. This saves you from typing the password again and again. Here is an example how you can do it.
itchy:~ # '''ssh-keygen -t dsa'''
Generating public/private dsa key pair.
'''Enter file in which to save the key (/root/.ssh/id_dsa):'''
'''Enter passphrase (empty for no passphrase):'''
'''Enter same passphrase again:'''
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
9c:a3:7e:f8:50:c4:85:2e:97:e5:2f:f7:1e:91:b2:06 root@itchy
The key's randomart image is:
+--[ DSA 1024]----+
|        ..      |
|      ....      |
|      .o+      |
|      .o+..    . |
|      oS E.. o  |
|      o ...oo . |
|      o.  oo..  |
|    ....  .  .. |
|      .o.    ..  |
  +-----------------+
itchy:~ # '''cat .ssh/id_dsa.pub >> .ssh/authorized_keys'''
itchy:~ # ssh root@localhost
Last login: Sat Feb 28 17:05:39 2009 from localhost
Have a lot of fun...
itchy:~ #
 
= See also =
* [http://websvn.kde.org/trunk/KDE/kdebase/runtime/kioslave/fish/README?view=markup README for kio_fish]
* [http://perldoc.perl.org/index-functions.html Perl functions A-Z]
* [http://en.wikibooks.org/wiki/Perl_Programming WikiBook on Perl]

Latest revision as of 12:31, 11 March 2016

This page is a starting point for debugging kio_fish. Please also read how to debug IO slaves generically.

Overview

When you point your konqueror to fish://user@target, the fish kioslave opens a process that calls the executable ssh. If a password is needed, this question is passed on to you (search for "password" in fish.cpp). Then a perl script is copied over to the target host and executed there. On the target host, the file is named .fishsrv.pl. This perl script is compiled into your binary kio_fish.o. If you want to change it sustainably, you will have to change fish.pl in your source dir and then compile and install the directory kioslave/fish.

The perl script, running on the target computer, is (t)here to execute fish commands like LIST, STAT, WRITE and APPEND. They are sent from fish.cpp running on the source computer.

Bugs

Interesting bugs to get into the topic

Test case

If you want a test case to get some debugging output from kio_fish, get a fresh checkout of kdebase. There you find a test case in runtime/kioslave/fish/tests. I had the problem that the STOR commands from the fish kioslave were not logged as long as I had localhost as target computer. When I changed it to my local address (192.168.0.7), it worked.

Logging

You may want to switch on logging for fish.cpp and for fish.pl.

In this example, we want to log the output of fish.cpp to /tmp/debugfish. As described at Debugging_IOSlaves, change your kdebugrc, e.g. like that:

cat >> $(kde4-config --path config | sed "s/.*://")kdebugrc << EOF
[7127]
InfoOutput=0
InfoFilename=/tmp/debugfish
EOF

In this example, we want to log the output of fish.pl to /tmp/kio_fish.debug.log so we change the 14th line of fish.pl to

open(DEBUG,">>/tmp/kio_fish.debug.log");

and uncomment all the lines containing DEBUG.

Manually testing fish

To test fish manually, call ~/.fishsrv.pl. The fish server will ask you in friendly words (it says ### 100) to transmit its own code, followed by a line __END__. Transmit it. Then the fish server is ready to talk with you (it says ### 200). You can have a conversation like this:

itchy:~ # (echo __END__; cat)| cat .fishsrv.pl -  | perl .fishsrv.pl
### 100 transfer fish server
### 200
#VER
VER 0.0.3 copy lscount lslinks lsmime exec stat
### 200
#WRITE 0 6 /tmp/file1
### 100
123456
### 200
itchy:~ # cat /tmp/file1
123456itchy:~ #

The WRITE command

Example:

#WRITE 0 6 /tmp/file1

Syntax:

#WRITE start end file

Reads the end-start bytes from STDIN and writes them into file file starting at position start ending at position end.

The EXEC command

The EXEC command executes an sh command on the computer where the fish perl service is running.

Example:

itchy:~/kdebase/runtime/kioslave/fish # (echo __END__; cat)| cat fish.pl -  | perl fish.pl
### 100 transfer fish server
### 200
#EXEC ls blah
### 200
itchy:~/kdebase/runtime/kioslave/fish # cat blah
AUTHORS
CMakeFiles
CMakeLists.txt
[...]

Passwordless login

For your work you may want to setup passwordless logins on localhost. This saves you from typing the password again and again. Here is an example how you can do it.

itchy:~ # ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/root/.ssh/id_dsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
9c:a3:7e:f8:50:c4:85:2e:97:e5:2f:f7:1e:91:b2:06 root@itchy
The key's randomart image is:
+--[ DSA 1024]----+
|         ..      |
|       ....      |
|       .o+       |
|      .o+..    . |
|       oS E.. o  |
|       o ...oo . |
|      o.   oo..  |
|     ....  .  .. |
|      .o.    ..  |
+-----------------+
itchy:~ # cat .ssh/id_dsa.pub >> .ssh/authorized_keys
itchy:~ # ssh root@localhost
Last login: Sat Feb 28 17:05:39 2009 from localhost
Have a lot of fun...
itchy:~ #

See also