2010年(49)
分类: 嵌入式
2010-09-07 15:44:48
Busybox集成了telnetd功能,有两种选择:第一,使用inetd管理telnetd的启动,当有telnet连接时由inetd启动;第二,直接打开telnetd守护进程,监听telnet连接。本文选择的是直接打开telnetd守护进程,那么在编译busybox时必须做如下选择。
[*] telnetd [*] Support standalone telnetd (not inetd only) |
telnet是一种非常老的远程登录技术,linux内核配置时默认并不支持。要想内核支持telnet,必须选择两项功能。
(1)Unix 98 PTY;
(2)dev/pts file system for Unix98 PTYs
根据对linux
Device Drivers ---> Character devices ---> [*] Unix98 PTY support |
在系统运行是,通过cat /proc/filesystems命令可以看到devpts文件系统是否被支持。
首先应该确保在根文件系统目录下存在/dev/pts目录;其次,在/etc/fstab文件中添加如下挂载语句。
devpts /dev/pts devpts gid=5,mode=620 0 0 |
这样在系统启动后,会根据fstab文件挂载devpts文件系统的目录。
或者,可以选择系统启动后手动挂载。
mount -t devpts devpts /dev/pts |
首先看这样一段话,说明了ptmx文件的作用。
A pseudo terminal (PTY) is a software device consisting of two halves: a master and a slave. The slave device behaves identical to a physical terminal; the master device is used by a process to read data from and write data to the slave, thereby emulating a terminal. Typical programs for the master side are telnet servers and xterms. Linux has traditionally used the BSD-like names /dev/ptyxx for masters and /dev/ttyxx for slaves of pseudo terminals. This scheme has a number of problems. The GNU C library glibc 2.1 and later, however, supports the Unix98 naming standard: in order to acquire a pseudo terminal, a process opens /dev/ptmx; the number of the pseudo terminal is then made available to the process and the pseudo terminal slave can be accessed as /dev/pts/. What was traditionally /dev/ttyp2 will then be /dev/pts/2, for example. |
其次,应该在/dev下建立ptmx设备节点。
mknod -m 666 ptmx c 5 2 |
/sbin/telnetd -l /sbin/vt100 |