OpenWrt Forum Archive

Topic: [OT] Needs help on telnetd

The content of this topic has been archived on 2 May 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

First, I would like to apologize if the contents in this post is a bit off topic.

I got myself a US Robotics USR5461 802.11g Wireless MAXg Router with a support for a USB v2.0 port for a printer server. US Robotics has released the firmware source code under GPL and made it available for download from here. A further look into the firmware source code reveals the firmware uses an older busybox-0.60 code that doesn't seem to have a support for a telnet session to login into the router. So, my first task is hack this firmware so that it will provide a telnet session to login into the router. The way I approached this was to replace the original busybox-0.60 with a newer busybox-1.1.0. Then, I configured the  new busybox to include supports for the telnetd + login modules. So far, the firmware compilation was successfull to yield a firmware about 1.87MB in size. And, my 5461 router doesn't seem to have any problem to accept and to run this newly compiled firmware. However, when I tried to issue a telnet session to the router, the router rejected the session with the following messages:

c:\>telnet 192.168.2.1 Connecting To 192.168.2.1... Could not open connection to the host, on port 23: Connect failed

It looks like I must have missed something here that I am not aware of. So, can anyone please help?

You don't mention how you have setup telnetd to run at boot?  Although the binary may be there and potentially working, what starts it running?

That's probably my problem. I did not see any /etc/passwd and /etc/init.d files and directory. I just incorporated telnetd through the /sbin/rc file. The firmware seems to have telnetd soft linked to /sbin/rc file. So, I thought this telnetd will get spawned when responds to port 23.

After messing with a hack called "door" for quite a while (see another thread ,http://forum.openwrt.org/viewtopic.php?id=3344) I finally decided to see how hard it would be to add utelnetd to the USR5461 firmware.  Not difficult at all:

1) I downloaded utelnetd-0.1.9.tar.gz from Penguintronics, and untarred it and mv'd the resulting directory to utelnetd in src/router;

2) I set up a simple Makefile, which configures the login program as /bin/true:
===
# cat release/src/router/utelnetd/Makefile
#include $(TOP)/.config

CFLAGS  += -I. -pipe -DSHELLPATH=\"$(LOGIN)\" -Wall
CFLAGS  += -s -O2
LDFLAGS +=

OBJS := utelnetd.o
LOGIN := /bin/true

all: utelnetd

clean:
        rm -f *.o *~ utelnetd

install: all
        install -D utelnetd $(INSTALLDIR)/usr/sbin/utelnetd
        $(STRIP) $(INSTALLDIR)/usr/sbin/utelnetd

utelnetd: $(OBJS)
        $(CC) -o $@ $^ $(LDFLAGS)
===
3) a line in src/router/Makefile compiles it:
===
]# cat release/src/router/Makefile |grep utelnetd
# enable utelnetd compilation
obj-y += utelnetd
===
and added lines in one of the start_ functions of services.c starts it:
===
# cat release/src/router/rc/services.c |grep utelnetd
/* start utelnetd */
        eval("/usr/sbin/utelnetd");
===
4) make the firmware and install it (AT YOUR OWN RISK), then telnet to the unit and enjoy:
===
# telnet 192.168.2.1
Trying 192.168.2.1...
Connected to 192.168.2.1 (192.168.2.1).
Escape character is '^]'.


BusyBox v0.60.0 (2006.06.23-22:37+0000) Built-in shell (msh)
Enter 'help' for a list of built-in commands.

# ps ef
  PID  Uid     Stat Command
    1 0         S    init noinitrd
    2 0         S    [keventd]
    3 0         S    [ksoftirqd_CPU0]
    4 0         S    [kswapd]
    5 0         S    [bdflush]
    6 0         S    [kupdated]
    7 0         S    [mtdblockd]
    8 0         S    [khubd]
   47 0         S    httpd
   51 0         S    dnsmasq -h -n -i br0 -r /tmp/resolv.conf
   53 0         R    /usr/sbin/utelnetd
   54 0         S    udhcpd /tmp/udhcpd.conf
  118 0         S    /bin/sh
  130 0         R    ps ef

=======
I am now messing around with p910nd, which I am going to install and test using wget and the telnet shell.  At the moment, trying to run this gives SIGSEGV, but it is very early days on this one.

A few month ago I bought a USR5461 as a cheap wireless printerserver for my home network. First everything worked fine but when I got my Macbook in november it refused to print to my Laserjet 1200 attached to the printserver. So I started to play with the USR5461's firmware source code and did a few modifcations. Here is a short list of the changes:

ippd
- removed ippd from the firmware image and replaced it with p910nd.

utelnetd
- added utelnetd.

p910nd
- added p910nd as a replacement for ippd.
- the printer now will be opened/closed individually for each job, so that it doesn't need to be online during system startup. If the printer isn't available when a client wants to send a job to it, p910nd immediately terminates the connection.
- added an option to select the printer's USB endpoint the printserver should connect to.

httpd
- added some function to maintain additional nvram variables.

dnsmasq
- dnsmasq now reads in the hosts file created by the startup routine from a variable stored in nvram.

user interface
- modified the status page so that it reports the correct printer-location.
- added an options page to edit the hosts file, the printserver's settings and to enable the telnet demon. Settings are stored in nvram.

Maybe my work is also interesting for somebody else or could serve as a starting point for further development. I posted a patch for the original source code, which can be downloaded at:

http://www-public.rz.uni-duesseldorf.de … 461.tar.gz

Merry Christmas!

I'm also interested in enhancing the USR5461 firmware. What I would like to have is support for a USB harddisc in addition to a printer, which I can access from Windows PCs over WLAN. I haven't look into the OS and source code of the USR5461 yet, but it seems to be Linux. So if there is enough memory available, it should be possible to add samba to the firmware. What do you think?

usr5461user wrote:

I'm also interested in enhancing the USR5461 firmware. What I would like to have is support for a USB harddisc in addition to a printer, which I can access from Windows PCs over WLAN. I haven't look into the OS and source code of the USR5461 yet, but it seems to be Linux. So if there is enough memory available, it should be possible to add samba to the firmware. What do you think?

Well, I don't think that this is a good idea.

The USR firmware is based on a Linux 2.4.20 kernel, and as far as I can see, it can be configured to support USB storage decices, but this feature is disabled in the standard configuration. Shouldn't be much work to reenable it.

But running Samba on the USR5461 nearly seems impossible to me because of it's limited amount of memory. With only 8MB RAM
and 2MB Flash you can't do much. Of course you can rip out some stuff you don't need from the standard firmware, so you can save some space in the root filesystem and in the Kernel, but there is usually less than 1 MB of free RAM available as you can see: 

# ps
  PID  Uid     Stat Command
    1 0         S    init noinitrd
    2 0         S    [keventd]
    3 0         R    [ksoftirqd_CPU0]
    4 0         S    [kswapd]
    5 0         S    [bdflush]
    6 0         S    [kupdated]
    7 0         S    [mtdblockd]
    8 0         S    [khubd]
   49 0         S    httpd
   50 0         S    dnsmasq -n -i br0 -r /tmp/resolv.conf
   51 0         S    p9100d -m 0 -b -f /dev/usb/lp0 0
   57 0         S    crond -L /dev/null -c /var/tmp -l 0
   58 0         S    utelnetd -d -l /bin/sh
   68 0         S    udhcpc -i eth1 -p /var/run/udhcpc0.pid -s /tmp/udhcpc -H M
  152 0         S    nas /tmp/nas.wan.conf /tmp/nas.wan.pid wan
  164 0         S    /bin/sh
  165 0         R    ps
# free
              total         used         free       shared      buffers
  Mem:         6412         5636          776            0          888
Swap:            0            0            0
Total:         6412         5636          776

I did some further changes to the firmware, so this shell output doesn't reflect the patched version you can download. The version I am running now uses a different WLAN-driver that also supports connecting to a WLAN in client mode. Besides I have have added crond to disable WLAN during the night and disabled the firewall completely.

The discussion might have continued from here.