Remote shell problems.

Jonathan Andrews jon at jonshouse.co.uk
Thu Feb 2 07:27:10 UTC 2012


On Thu, 2012-02-02 at 02:15 +0100, Denys Vlasenko wrote: 
> On Wednesday 01 February 2012 12:56, Jonathan Andrews wrote:
> > To help me develop a few things on a arm board i'm tring to get a remote
> > shell working.
> > 
> > Firstly I tried to set the arm board up for telnet
> > 
> > The kernel config has this
> > CONFIG_UNIX98_PTYS=y
> > CONFIG_DEVPTS_MULTIPLE_INSTANCES=y
> > 
> > Kernel 2.6.36.4
> > 
> > Busybox 1.19.2
> > config has this :
> > CONFIG_FEATURE_DEVPTS=y
> > 
> > 
> > The arm board itself after boot and laughably small rc script.
> > # mount
> > rootfs on / type rootfs (rw)
> > /dev/root on / type ext2 (rw,relatime,errors=continue)
> > /proc on /proc type proc (rw,relatime)
> > none on /sys type sysfs (rw,relatime)
> > none on /dev/pts type devpts (rw,relatime,mode=600,ptmxmode=000)
> 
> Mine is just "none on /dev/pts type devpts (rw,relatime,mode=600)".
> Are you sure "ptmxmode=000" is a good idea?
I cribbed this from an example I googled, I know very little about psudo
terminals and linux pty stuff. I will read up when time allows.

I have this in the boards startup script
mount -t devpts none /dev/pts

What does mode=600 signify ?

> 
> 
> > # telnetd -l /bin/bash -F
> > telnetd: can't find free pty
> > 
> > Oh dear ... Can anyone help here.
> 
> Sure. Lets see what working telnetd does:
> 
> # strace telnetd -l /bin/bash -F
> execve("/bin/telnetd", ["telnetd", "-l", "/bin/bash", "-F"], [/* 33 vars */]) = 0
> ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
> ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
> getuid32()                              = 0
> socket(PF_INET6, SOCK_STREAM, IPPROTO_IP) = 3
> brk(0)                                  = 0x811d000
> brk(0x811e000)                          = 0x811e000
> setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
> bind(3, {sa_family=AF_INET6, sin6_port=htons(23), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
> listen(3, 1)                            = 0
> fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
> rt_sigaction(SIGPIPE, {SIG_IGN}, {SIG_DFL}, 8) = 0
> rt_sigaction(SIGCHLD, {SIG_IGN}, {SIG_DFL}, 8) = 0
> select(4, [3], [], NULL, NULL
> 
> ....here I connect to it...
> 
> )          = 1 (in [3])
> accept(3, 0, NULL)                      = 4
> fcntl64(4, F_SETFD, FD_CLOEXEC)         = 0
> brk(0x811f000)                          = 0x811f000
> open("/dev/ptmx", O_RDWR|O_LARGEFILE)   = 5
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> here is what you need to have, and probably don't.

That was it :-) Many thanks :-D

I had the mknod for the device in script generating the initrd but for
some reason it was missing from the dev directory on the target machine.

I built strace for the board and tried it, that was going to be my next
step but I guess I needed it much sooner than I thought!

netcat for a remote console is still broken, its expanding "\r" both
with the busybox "nc" and netcat0.7.1 I built from source to compare?
Maybe im cross compiling something in the wrong way, possibly something
thinks its running DOS text but I cant tell what ?

Thanks,
Jon



************************** stuff
>From Linux PC end, telnet to arm board

[root at jonspc arm-many-voices]# rpm -qa |grep 'telnet'
telnet-0.17-45.fc12.i686
[root at jonspc arm-many-voices]# uname -a
Linux jonspc 2.6.32.26-175.fc12.i686 #1 SMP Wed Dec 1 21:52:04 UTC 2010
i686 athlon i386 GNU/Linux

[root at jonspc sources]# telnet 10.10.10.111 2222
Trying 10.10.10.111...
Connected to 10.10.10.111.
Escape character is '^]'.

/bin/bash: line 1: $'\r': command not found
ls
/bin/bash: line 2: $'ls\r': command not found



strace from arm board itself

rcS-4.2# strace nc -l -p 2222 -e /bin/bash
execve("/sbin/nc", ["nc", "-l", "-p", "2222", "-e", "/bin/bash"], [/* 9 vars */]) = 0
uname({sys="Linux", node="(none)", ...}) = 0
brk(0)                                  = 0x2010000
brk(0x2010cb2)                          = 0x2010cb2
set_tls(0x2010450, 0x183018, 0, 0x1, 0x2010450) = 0
brk(0x2031cb2)                          = 0x2031cb2
brk(0x2032000)                          = 0x2032000
getuid32()                              = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 3
setsockopt(3, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
bind(3, {sa_family=AF_INET, sin_port=htons(2222), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
listen(3, 1)                            = 0
fcntl64(3, F_SETFD, FD_CLOEXEC)         = 0
accept(3, 0, NULL)                      = 4
dup2(4, 0)                              = 0
close(4)                                = 0
dup2(0, 1)                              = 1
dup2(0, 2)                              = 2
execve("/bin/bash", ["/bin/bash"], [/* 9 vars */]) = 0
uname({sys="Linux", node="(none)", ...}) = 0
brk(0)                                  = 0x542000
brk(0x542c9c)                           = 0x542c9c
set_tls(0x542450, 0x145408, 0, 0x1, 0x542450) = 0
brk(0x563c9c)                           = 0x563c9c
brk(0x564000)                           = 0x564000
open("/dev/tty", O_RDWR|O_NONBLOCK|O_LARGEFILE) = -1 ENXIO (No such device or address)
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0xbefebc8c) = -1 EINVAL (Invalid      argument)
getuid32()                              = 0
getgid32()                              = 0
geteuid32()                             = 0
getegid32()                             = 0
time(NULL)                              = 4390
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, 0xbefebd88) = -1 EINVAL (Invalid      argument)
open("/proc/meminfo", O_RDONLY)         = 3
fstat64(3, {st_mode=S_IFREG|0444, st_size=0, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x40040000
read(3, "MemTotal:          60544 kB\nMemF"..., 1024) = 924
close(3)                                = 0
munmap(0x40040000, 4096)                = 0
rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTART|0x4000000}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGCHLD, {SIG_DFL, [], SA_RESTART|0x4000000}, {SIG_DFL, [], SA_RESTART|0x4000000}, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0x4000000 /* SA_??? */}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], 0x4000000 /* SA_??? */}, {SIG_DFL, [], 0x4000000 /* SA_??? */}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, [], 0x4000000 /* SA_??? */}, {SIG_DFL, [], 0}, 8) = 0
rt_sigaction(SIGQUIT, {SIG_DFL, [], 0x4000000 /* SA_??? */}, {SIG_DFL, [], 0x4000000 /* SA_??? */}, 8) = 0
rt_sigprocmask(SIG_BLOCK, NULL, [], 8)  = 0
rt_sigaction(SIGQUIT, {SIG_IGN, [], 0x4000000 /* SA_??? */}, {SIG_DFL, [], 0x4000000 /* SA_??? */}, 8) = 0
rt_sigaction(SIGINT, {0x3c504, [], 0x4000000 /* SA_??? */}, {SIG_DFL, [], 0x4000000 /* SA_??? */}, 8) = 0
uname({sys="Linux", node="(none)", ...}) = 0
stat64("/dev", {st_mode=S_IFDIR|0755, st_size=69632, ...}) = 0
stat64(".", {st_mode=S_IFDIR|0755, st_size=69632, ...}) = 0
getpid()                                = 407
getppid()                               = 406
gettimeofday({4390, 350898}, NULL)      = 0
fcntl64(0, F_GETFL)                     = 0x2 (flags O_RDWR)
fstat64(0, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
_llseek(0, 0, 0xbefebd54, SEEK_CUR)     = -1 ESPIPE (Illegal seek)
wait4(-1, 0xbefebcd4, WNOHANG, NULL)    = -1 ECHILD (No child processes)
read(0, "\r", 1)                        = 1
read(0, "\n", 1)                        = 1
stat64(".", {st_mode=S_IFDIR|0755, st_size=69632, ...}) = 0
stat64("/sbin/\r", 0xbefebbd0)          = -1 ENOENT (No such file or directory)
stat64("/usr/sbin/\r", 0xbefebbd0)      = -1 ENOENT (No such file or directory)
stat64("/bin/\r", 0xbefebbd0)           = -1 ENOENT (No such file or directory)
stat64("/usr/bin/\r", 0xbefebbd0)       = -1 ENOENT (No such file or directory)
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x542048) = 408
rt_sigaction(SIGINT, {0x29ed0, [], 0x4000000 /* SA_??? */}, {0x3c504, [], 0x4000000 /* SA_??? */}, 8) = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 127}], 0, NULL) = 408
--- {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=408, si_status=127, si_utime=0, si_stime=0} (Child exite     d) ---
wait4(-1, 0xbefebd30, WNOHANG, NULL)    = -1 ECHILD (No child processes)
rt_sigaction(SIGINT, {0x3c504, [], 0x4000000 /* SA_??? */}, {0x29ed0, [], 0x4000000 /* SA_??? */}, 8) = 0
wait4(-1, 0xbefebcd4, WNOHANG, NULL)    = -1 ECHILD (No child processes)
read(0, "l", 1)                         = 1
read(0, "s", 1)                         = 1
read(0, "\r", 1)                        = 1
read(0, "\n", 1)                        = 1
stat64(".", {st_mode=S_IFDIR|0755, st_size=69632, ...}) = 0
stat64("/sbin/ls\r", 0xbefebbd0)        = -1 ENOENT (No such file or directory)
stat64("/usr/sbin/ls\r", 0xbefebbd0)    = -1 ENOENT (No such file or directory)
stat64("/bin/ls\r", 0xbefebbd0)         = -1 ENOENT (No such file or directory)
stat64("/usr/bin/ls\r", 0xbefebbd0)     = -1 ENOENT (No such file or directory)
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x542048) = 409
--- {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=409, si_status=127, si_utime=0, si_stime=0} (Child exite     d) ---
rt_sigaction(SIGINT, {0x29ed0, [], 0x4000000 /* SA_??? */}, {0x3c504, [], 0x4000000 /* SA_??? */}, 8) = 0
wait4(-1, [{WIFEXITED(s) && WEXITSTATUS(s) == 127}], 0, NULL) = 409
wait4(-1, 0xbefebd30, WNOHANG, NULL)    = -1 ECHILD (No child processes)
rt_sigaction(SIGINT, {0x3c504, [], 0x4000000 /* SA_??? */}, {0x29ed0, [], 0x4000000 /* SA_??? */}, 8) = 0
wait4(-1, 0xbefebcd4, WNOHANG, NULL)    = -1 ECHILD (No child processes)
read(0,





More information about the busybox mailing list