Bug 433510 - /usr/bin/krfb_httpd broken due to converted literal ^M chars
/usr/bin/krfb_httpd broken due to converted literal ^M chars
Product: Fedora
Classification: Fedora
Component: kdenetwork (Show other bugs)
All Linux
low Severity low
: ---
: ---
Assigned To: Lukáš Tinkl
Fedora Extras Quality Assurance
: Reopened
Depends On:
Blocks: 433511
  Show dependency treegraph
Reported: 2008-02-19 14:08 EST by Jeff Bastian
Modified: 2015-07-13 13:36 EDT (History)
4 users (show)

See Also:
Fixed In Version: 3.5.9-2
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2008-03-03 13:25:55 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
RHEL 5.1 krfb_httpd (93.22 KB, image/png)
2008-02-22 12:31 EST, Jeff Bastian
no flags Details
Fedora 8 krfb_httpd (99.91 KB, image/png)
2008-02-22 12:32 EST, Jeff Bastian
no flags Details
fixed Fedora 8 krfb_httpd (105.82 KB, image/png)
2008-02-22 12:32 EST, Jeff Bastian
no flags Details

External Trackers
Tracker ID Priority Status Summary Last Updated
KDE Software Compilation 135013 None None None Never

  None (edit)
Description Jeff Bastian 2008-02-19 14:08:59 EST
Description of problem:
Trying to connect to a krfb VNC session through a web browser hangs forever. 
This is because /usr/bin/krfb_httpd has some literal ^M characters converted
into actual newlines.

Looking at /usr/bin/krfb_httpd on older releases with vim (or any editor that
will show special control characters) will show (including line numbers):
      9 url="${url/^M/}"
     10 httptype="${httptype/^M/}"
     16         line="${line/^M/}"

Fedora 8's /usr/bin/krfb_httpd shows this instead:
      9 url="${url/
     10 /}"
     11 httptype="${httptype/
     12 /}"
     18         line="${line/
     19 /}"

As you can see, the literal ^M chars have been turned into newlines.

Unfortunately, diff seems to get confused by literal ^M chars so the output is

Version-Release number of selected component (if applicable):

How reproducible:
Every time

Steps to Reproduce:
1. Share your desktop with krfb
2. Connect to http://yourmachine:5800/ with a web browser on another machine

Actual results:
Web browser doesn't do anything

Expected results:
Java VNC viewer should launch

Additional info:
The <APPLET> tag is also wrong.  It should be:
  <APPLET CODE=vncviewer/VNCViewer.class ARCHIVE=vncviewer.jar ...>
I'll open a new BZ on this problem.
Comment 1 Jeff Bastian 2008-02-19 14:28:16 EST
See https://bugzilla.redhat.com/show_bug.cgi?id=433511#c4 for the fixed script.
Comment 2 Rex Dieter 2008-02-19 14:34:38 EST
> "Looking at /usr/bin/krfb_httpd on older releases" 

I assume you mean kdenetwork <= 3.5.7 here?
Comment 3 Jeff Bastian 2008-02-19 14:48:48 EST
I should have been more specific: I was actually looking at RHEL 4.6's
/usr/bin/krfb_httpd which is kdenetwork-3.3.1-2.3

The script actually hasn't changed all that much, though.  The only other
difference is 'head -1' to 'head -n 1' in line 23:
    size=`xdpyinfo .... |head -n 1|....`
Comment 4 Ngo Than 2008-02-22 08:30:27 EST
the Mac-style line breaks caused an problem and it's changed to unix line 
breaks. http://bugs.kde.org/135013

Are you sure that you won't see the problem with he Mac-style line breaks?
Comment 5 Jeff Bastian 2008-02-22 12:09:08 EST
The problem in http://bugs.kde.org/135013 is that the *entire script* is using
CRs (Mac-style).  If you open the RHEL 5.1 krfb_httpd script in vim, the script
is one long line, and vim notes [noeol] at the bottom.
#! /usr/bin/env bash^M^Mif [ "$1" = "--kinetd" ]; then^M        # redirect stdin
and stdout to the inetd socket.^M      exec <&$2 >&$2^Mfi^M^Mread request url
httptype || exit 0^Murl="${url/^M/}"^Mhttptype="${httptype/^M/}"^M^M......

In Fedora 8, the script was converted back to LFs (Unix-style), but it went a
little too far.  There were 3 CRs that should have remained literal CRs (see
original description).

Using the stock krfb_httpd program, when I try to connect to http://server:5800/
with Firefox, the icon in the upper right spins forever and the status bar says
"Waiting for server...".  If I change the 3 lines to use literal ^M chars, then
it launches the Java VNC viewer.
Comment 6 Jeff Bastian 2008-02-22 12:31:22 EST
Since 'diff' gets confused by the literal ^M chars, I've taken 3 screenshots of
vim to demonstrate the problem.

1. krfb_httpd-rhel51.png
   RHEL 5.1 kdenetwork-3.5.4-4.fc6 /usr/bin/krfb_httpd
   This is the problem described in http://bugs.kde.org/135013 -- the entire
   script is using Mac style CRs.  (See bug 433529 about this problem.)
2. krfb_httpd-f8.png
   Fedora 8 kdenetwork-3.5.8-9.fc8 /usr/bin/krfb_httpd
   This shows how the Mac-style CRs were converted to Unix-style LFs, but it
   went too far and converted 3 that should have remained CRs.  Annotated with
   Gimp to show where the CRs should be.
3. krfb_httpd-f8-fixed.png
   I've restored the three literal CRs and now krfb_httpd works as expected.
Comment 7 Jeff Bastian 2008-02-22 12:31:56 EST
Created attachment 295660 [details]
RHEL 5.1 krfb_httpd
Comment 8 Jeff Bastian 2008-02-22 12:32:29 EST
Created attachment 295661 [details]
Fedora 8 krfb_httpd
Comment 9 Jeff Bastian 2008-02-22 12:32:59 EST
Created attachment 295662 [details]
fixed Fedora 8 krfb_httpd
Comment 10 Kevin Kofler 2008-02-22 12:42:56 EST
Yuck, a file which automatically gets corrupted by the KatePart's line ending 
conversion (which is presumably how it got broken in the first place), fun... 
Thanks for tracking this down. I'm forwarding this to the upstream bug report.
Comment 11 Jeff Bastian 2008-02-22 13:06:38 EST
I think I see why the script is written this way: http requests end in a
DOS-style <CR><LF>.  The web browser sends a request like
   GET /index.html HTTP/1.1<CR><LF>
See http://www.faqs.org/rfcs/rfc2616.html section "5.1 Request-Line".

Since krfb_httpd is a Unix bash script, it reads a line and gets
   GET /index.html HTTP/1.1<CR>
as a value.  It uses a bash parameter expansion feature to strip the <CR> from
the text:
That searches for ^M and replaces it with nothing (since there's nothing between
/ and }).

After KatePart or whatever mangled the script, it became
which means it's no longer stripping the <CR> and it gets confused.

krfb_httpd really should be written in Perl or Python with a module that speaks
http properly...
Comment 12 Lukáš Tinkl 2008-02-26 08:37:43 EST
Fixed in 3.5.9-2
Comment 13 Kevin Kofler 2008-02-26 15:11:31 EST
As per http://fedoraproject.org/wiki/BugZappers/BugStatusWorkFlow , the bug 
should be in MODIFIED state, not RESOLVED, as long as the update has not been 
Comment 14 Fedora Update System 2008-02-28 16:37:09 EST
kdegames-3.5.9-1.fc7, kdesdk-3.5.9-1.fc7, kdeutils-3.5.9-1.fc7, kdeaccessibility-3.5.9-1.fc7, arts-1.5.9-1.fc7, kdeaddons-3.5.9-1.fc7, kdeartwork-3.5.9-1.fc7, kdebindings-3.5.9-1.fc7, kdegraphics-3.5.9-1.fc7, kdewebdev-3.5.9-1.fc7, kde-i18n-3.5.9-4.fc7, kdeadmin-3.5.9-1.fc7, kdeedu-3.5.9-1.fc7, kdemultimedia-3.5.9-1.fc7, kdenetwork-3.5.9-2.fc7, kdetoys-3.5.9-1.fc7, kdelibs-3.5.9-3.fc7, kdebase-3.5.9-1.fc7, kdepim-3.5.9-6.fc7, kdevelop-3.5.1-1.fc7 has been pushed to the Fedora 7 testing repository.  If problems still persist, please make note of it in this bug report.
 If you want to test the update, you can install it with 
 su -c 'yum --enablerepo=updates-testing update kdegames kdesdk kdeutils kdeaccessibility arts kdeaddons kdeartwork kdebindings kdegraphics kdewebdev kde-i18n kdeadmin kdeedu kdemultimedia kdenetwork kdetoys kdelibs kdebase kdepim kdevelop'.  You can provide feedback for this update here: http://admin.fedoraproject.org/updates/F7/FEDORA-2008-1892
Comment 15 Fedora Update System 2008-03-03 13:21:26 EST
kdevelop-3.5.1-3.fc7, arts-1.5.9-1.fc7, kdelibs-3.5.9-3.fc7, kdeaccessibility-3.5.9-1.fc7, kdeaddons-3.5.9-1.fc7, kdeadmin-3.5.9-1.fc7, kdeartwork-3.5.9-1.fc7, kdebase-3.5.9-3.fc7, kdebindings-3.5.9-1.fc7, kdeedu-3.5.9-1.fc7, kdegames-3.5.9-1.fc7, kdegraphics-3.5.9-1.fc7, kdemultimedia-3.5.9-1.fc7, kdepim-3.5.9-6.fc7, kdetoys-3.5.9-1.fc7, kdewebdev-3.5.9-1.fc7, kde-i18n-3.5.9-4.fc7, kdenetwork-3.5.9-2.fc7, kdesdk-3.5.9-1.fc7, kdeutils-3.5.9-1.fc7 has been pushed to the Fedora 7 stable repository.  If problems still persist, please make note of it in this bug report.
Comment 16 Fedora Update System 2008-03-03 13:25:46 EST
kdevelop-3.5.1-3.fc8, arts-1.5.9-1.fc8, kdelibs-3.5.9-3.fc8, kdeaccessibility-3.5.9-1.fc8, kdeaddons-3.5.9-1.fc8, kdeadmin-3.5.9-1.fc8, kdeartwork-3.5.9-1.fc8, kdebase-3.5.9-3.fc8, kdebindings-3.5.9-1.fc8, kdeedu-3.5.9-1.fc8, kdegames-3.5.9-1.fc8, kdegraphics-3.5.9-1.fc8, kde-i18n-3.5.9-4.fc8, kdemultimedia-3.5.9-1.fc8, kdenetwork-3.5.9-2.fc8, kdepim-3.5.9-6.fc8, kdesdk-3.5.9-1.fc8, kdetoys-3.5.9-1.fc8, kdeutils-3.5.9-1.fc8, kdewebdev-3.5.9-1.fc8 has been pushed to the Fedora 8 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.