550 lines
11 KiB
HTML
550 lines
11 KiB
HTML
<HTML
|
|
><HEAD
|
|
><TITLE
|
|
>Serial Devices and the login: Prompt</TITLE
|
|
><META
|
|
NAME="GENERATOR"
|
|
CONTENT="Modular DocBook HTML Stylesheet Version 1.57"><LINK
|
|
REL="HOME"
|
|
TITLE="Linux Network Administrators Guide"
|
|
HREF="index.html"><LINK
|
|
REL="UP"
|
|
TITLE="Configuring the Serial Hardware"
|
|
HREF="x-087-2-serial.html"><LINK
|
|
REL="PREVIOUS"
|
|
TITLE="Using the Configuration Utilities"
|
|
HREF="x-087-2-serial-configuration.html"><LINK
|
|
REL="NEXT"
|
|
TITLE="Configuring TCP/IP Networking"
|
|
HREF="x-087-2-iface.html"></HEAD
|
|
><BODY
|
|
CLASS="SECT1"
|
|
BGCOLOR="#FFFFFF"
|
|
TEXT="#000000"
|
|
LINK="#0000FF"
|
|
VLINK="#840084"
|
|
ALINK="#0000FF"
|
|
><DIV
|
|
CLASS="NAVHEADER"
|
|
><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TH
|
|
COLSPAN="3"
|
|
ALIGN="center"
|
|
>Linux Network Administrators Guide</TH
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="left"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x-087-2-serial-configuration.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="80%"
|
|
ALIGN="center"
|
|
VALIGN="bottom"
|
|
>Chapter 4. Configuring the Serial Hardware</TD
|
|
><TD
|
|
WIDTH="10%"
|
|
ALIGN="right"
|
|
VALIGN="bottom"
|
|
><A
|
|
HREF="x-087-2-iface.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"></DIV
|
|
><DIV
|
|
CLASS="SECT1"
|
|
><H1
|
|
CLASS="SECT1"
|
|
><A
|
|
NAME="X-087-2-SERIAL.GETTY"
|
|
>4.6. Serial Devices and the login: Prompt</A
|
|
></H1
|
|
><P
|
|
>It was once very common that a Unix installation involved one server
|
|
machine and many “dumb” character mode terminals or
|
|
dial-up modems. Today that sort of installation is less common, which
|
|
is good news for many people interested in operating this way, because
|
|
the “dumb” terminals are now very cheap to
|
|
acquire. Dial-up modem configurations are no less common, but these
|
|
days they would probably be used to support a SLIP or PPP login
|
|
(discussed in <A
|
|
HREF="x-087-2-slip.html"
|
|
>Chapter 7</A
|
|
> and <A
|
|
HREF="x-087-2-ppp.html"
|
|
>Chapter 8</A
|
|
> ) than to be used for a simple login.
|
|
Nevertheless, each of these configurations can make use of a simple
|
|
program called a <B
|
|
CLASS="COMMAND"
|
|
>getty</B
|
|
> program.</P
|
|
><P
|
|
>The term <B
|
|
CLASS="COMMAND"
|
|
>getty</B
|
|
> is probably a contraction of
|
|
“get tty.” A <B
|
|
CLASS="COMMAND"
|
|
>getty</B
|
|
> program opens a
|
|
serial device, configures it appropriately, optionally configures a
|
|
modem, and waits for a connection to be made. An active connection on
|
|
a serial device is usually indicated by the Data Carrier Detect (DCD)
|
|
pin on the serial device being raised. When a connection is detected,
|
|
the <B
|
|
CLASS="COMMAND"
|
|
>getty</B
|
|
> program issues a
|
|
<TT
|
|
CLASS="LITERAL"
|
|
>login:</TT
|
|
> prompt, and then invokes the
|
|
<B
|
|
CLASS="COMMAND"
|
|
>login</B
|
|
> program to handle the actual system
|
|
login. Each of the virtual terminals (e.g.,
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/dev/tty1</TT
|
|
>) in Linux has a
|
|
<B
|
|
CLASS="COMMAND"
|
|
>getty</B
|
|
> running against it.</P
|
|
><P
|
|
>There are a number of different <B
|
|
CLASS="COMMAND"
|
|
>getty</B
|
|
>
|
|
implementations, each designed to suit some configurations better than
|
|
others. The <B
|
|
CLASS="COMMAND"
|
|
>getty</B
|
|
> that we'll describe here is
|
|
called <B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
>. It is quite popular because it has
|
|
all sorts of features that make it especially modem-friendly,
|
|
including support for automatic fax programs and voice modems. We'll
|
|
concentrate on configuring <B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> to answer
|
|
conventional data calls and leave the rest for you to explore at your
|
|
convenience.</P
|
|
><DIV
|
|
CLASS="SECT2"
|
|
><H2
|
|
CLASS="SECT2"
|
|
><A
|
|
NAME="X-087-2-SERIAL.GETTY.MGETTY"
|
|
>4.6.1. Configuring the mgetty Daemon</A
|
|
></H2
|
|
><P
|
|
>The <B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> daemon is available in source form from
|
|
<SPAN
|
|
CLASS="SYSTEMITEM"
|
|
>ftp://alpha.greenie.net/pub/mgetty/source/</SPAN
|
|
>,
|
|
and is available in just about all Linux distributions in prepackaged
|
|
form. The <B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> daemon differs from most other
|
|
<B
|
|
CLASS="COMMAND"
|
|
>getty</B
|
|
> implementations in that it has been designed
|
|
specifically for Hayes-compatible modems. It still supports direct
|
|
terminal connections, but is best suited for dialup
|
|
applications. Rather than using the DCD line to detect an incoming
|
|
call, it listens for the <TT
|
|
CLASS="LITERAL"
|
|
>RING</TT
|
|
> message generated by
|
|
modern modems when they detect an incoming call and are not configured
|
|
for auto-answer.</P
|
|
><P
|
|
>The main executable program is called
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/usr/sbin/mgetty</TT
|
|
>, and its main configuration file
|
|
is called <TT
|
|
CLASS="FILENAME"
|
|
>/etc/mgetty/mgetty.config</TT
|
|
>. There are a
|
|
number of other binary programs and configuration files that cover
|
|
other <B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> features.</P
|
|
><P
|
|
>For most installations, configuration is a matter of editing the
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/etc/mgetty/ mgetty.config</TT
|
|
> file and adding
|
|
appropriate entries to the <TT
|
|
CLASS="FILENAME"
|
|
>/etc/inittab</TT
|
|
> file to
|
|
execute <B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> automatically.</P
|
|
><P
|
|
><A
|
|
HREF="x-087-2-serial.getty.html#X-087-2-SERIAL.MGETTY.CONF"
|
|
>Example 4-6</A
|
|
> shows a very simple
|
|
<B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> configuration file. This example configures
|
|
two serial devices. The first, <TT
|
|
CLASS="FILENAME"
|
|
>/dev/ttyS0</TT
|
|
>,
|
|
supports a Hayes-compatible modem at 38,400 bps. The second,
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/dev/ttyS0</TT
|
|
>, supports a directly connected VT100
|
|
terminal at 19,200 bps.</P
|
|
><P
|
|
><DIV
|
|
CLASS="EXAMPLE"
|
|
><A
|
|
NAME="X-087-2-SERIAL.MGETTY.CONF"
|
|
></A
|
|
><P
|
|
><B
|
|
>Example 4-6. Sample /etc/mgetty/mgetty.config File</B
|
|
></P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
>#
|
|
# mgetty configuration file
|
|
#
|
|
# this is a sample configuration file, see mgetty.info for details
|
|
#
|
|
# comment lines start with a "#", empty lines are ignored
|
|
#
|
|
# ----- global section -----
|
|
#
|
|
# In this section, you put the global defaults, per-port stuff is below
|
|
#
|
|
# access the modem(s) with 38400 bps
|
|
speed 38400
|
|
#
|
|
# set the global debug level to "4" (default from policy.h)
|
|
debug 4
|
|
#
|
|
|
|
# ----- port specific section -----
|
|
#
|
|
# Here you can put things that are valid only for one line, not the others
|
|
#
|
|
#
|
|
# Hayes modem connected to ttyS0: don't do fax, less logging
|
|
#
|
|
port ttyS0
|
|
debug 3
|
|
data-only y
|
|
#
|
|
# direct connection of a VT100 terminal which doesn't like DTR drops
|
|
#
|
|
port ttyS1
|
|
direct y
|
|
speed 19200
|
|
toggle-dtr n
|
|
#</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></P
|
|
><P
|
|
>The configuration file supports global and port-specific options.
|
|
In our example we used a global option to set the speed to 38,400 bps. This
|
|
value is inherited by the <TT
|
|
CLASS="FILENAME"
|
|
>ttyS0</TT
|
|
> port. Ports we apply
|
|
<B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> to use this speed setting unless it is
|
|
overwritten by a port-specific speed setting, as we have done in the
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>ttyS1</TT
|
|
> configuration.</P
|
|
><P
|
|
>The <TT
|
|
CLASS="LITERAL"
|
|
>debug</TT
|
|
> keyword controls the verbosity of
|
|
<B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> logging. The <TT
|
|
CLASS="LITERAL"
|
|
>data-only</TT
|
|
>
|
|
keyword in the <TT
|
|
CLASS="FILENAME"
|
|
>ttyS0</TT
|
|
> configuration causes
|
|
<B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> to ignore any modem fax features, to operate
|
|
just as a data modem. The <TT
|
|
CLASS="LITERAL"
|
|
>direct</TT
|
|
> keyword in the
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>ttyS1</TT
|
|
> configuration instructs
|
|
<B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> not to attempt any modem initialization on
|
|
the port. Finally, the <TT
|
|
CLASS="LITERAL"
|
|
>toggle-dtr</TT
|
|
> keyword instructs
|
|
<B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> not to attempt to hang up the line by
|
|
dropping the DTR (Data Terminal Ready) pin on the serial interface;
|
|
some terminals don't like this to happen.</P
|
|
><P
|
|
>You can also choose to leave the <TT
|
|
CLASS="FILENAME"
|
|
>mgetty.config</TT
|
|
>
|
|
file empty and use command-line arguments to specify most of the same
|
|
parameters. The documentation accompanying the application includes a
|
|
complete description of the <B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> configuration
|
|
file parameters and command-line arguments. See the following example.</P
|
|
><P
|
|
>We need to add two entries to the <TT
|
|
CLASS="FILENAME"
|
|
>/etc/inittab</TT
|
|
>
|
|
file to activate this configuration. The <TT
|
|
CLASS="FILENAME"
|
|
>inittab</TT
|
|
>
|
|
file is the configuration file of the Unix System V
|
|
<B
|
|
CLASS="COMMAND"
|
|
>init</B
|
|
> command. The <B
|
|
CLASS="COMMAND"
|
|
>init</B
|
|
> command
|
|
is responsible for system initialization; it provides a means of
|
|
automatically executing programs at boot time and re-executing them
|
|
when they terminate. This is ideal for the goals of running a
|
|
<B
|
|
CLASS="COMMAND"
|
|
>getty</B
|
|
> program.</P
|
|
><P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
>T0:23:respawn:/sbin/mgetty ttyS0
|
|
T1:23:respawn:/sbin/mgetty ttyS1</PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></P
|
|
><P
|
|
>Each line of the <TT
|
|
CLASS="FILENAME"
|
|
>/etc/inittab</TT
|
|
> file contains four
|
|
fields, separated by colons. The first field is an identifier that
|
|
uniquely labels an entry in the file; traditionally it is two
|
|
characters, but modern versions allow four. The second field is the
|
|
list of run levels at which this entry should be active. A run level
|
|
is a means of providing alternate machine configurations and is
|
|
implemented using trees of startup scripts stored in directories
|
|
called <TT
|
|
CLASS="FILENAME"
|
|
>/etc/rc1.d</TT
|
|
>,
|
|
<TT
|
|
CLASS="FILENAME"
|
|
>/etc/rc2.d</TT
|
|
>, etc. This feature is typically
|
|
implemented very simply, and you should model your entries on others
|
|
in the file or refer to your system documentation for more
|
|
information. The third field describes when to take action. For the
|
|
purposes of running a <B
|
|
CLASS="COMMAND"
|
|
>getty</B
|
|
> program, this field
|
|
should be set to <TT
|
|
CLASS="LITERAL"
|
|
>respawn</TT
|
|
>, meaning that the command
|
|
should be re-executed automatically when it dies. There are several
|
|
other options, as well, but they are not useful for our purposes
|
|
here. The fourth field is the actual command to execute; this is where
|
|
we specify the <B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> command and any arguments we
|
|
wish to pass it. In our simple example we're starting and restarting
|
|
<B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
> whenever the system is operating at either
|
|
of run levels two or three, and are supplying as an argument just the
|
|
name of the device we wish it to use. The <B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
>
|
|
command assumes the <TT
|
|
CLASS="FILENAME"
|
|
>/dev/</TT
|
|
>, so we don't need to
|
|
supply it.</P
|
|
><P
|
|
>This chapter was a quick introduction to <B
|
|
CLASS="COMMAND"
|
|
>mgetty</B
|
|
>
|
|
and how to offer login prompts to serial devices. You can find more
|
|
extensive information in the Serial-HOWTO.</P
|
|
><P
|
|
>After you've edited the configuration files, you need to reload
|
|
<B
|
|
CLASS="COMMAND"
|
|
>init</B
|
|
> to make the changes take effect. Simply send a
|
|
hangup signal to the <B
|
|
CLASS="COMMAND"
|
|
>init</B
|
|
> process; it always has a
|
|
process ID of one, so you can use the following command safely:</P
|
|
><TABLE
|
|
BORDER="0"
|
|
BGCOLOR="#E0E0E0"
|
|
WIDTH="100%"
|
|
><TR
|
|
><TD
|
|
><PRE
|
|
CLASS="SCREEN"
|
|
># <TT
|
|
CLASS="USERINPUT"
|
|
><B
|
|
>kill -HUP 1</B
|
|
></TT
|
|
></PRE
|
|
></TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></DIV
|
|
><DIV
|
|
CLASS="NAVFOOTER"
|
|
><HR
|
|
ALIGN="LEFT"
|
|
WIDTH="100%"><TABLE
|
|
WIDTH="100%"
|
|
BORDER="0"
|
|
CELLPADDING="0"
|
|
CELLSPACING="0"
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x-087-2-serial-configuration.html"
|
|
>Prev</A
|
|
></TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="index.html"
|
|
>Home</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x-087-2-iface.html"
|
|
>Next</A
|
|
></TD
|
|
></TR
|
|
><TR
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="left"
|
|
VALIGN="top"
|
|
>Using the Configuration Utilities</TD
|
|
><TD
|
|
WIDTH="34%"
|
|
ALIGN="center"
|
|
VALIGN="top"
|
|
><A
|
|
HREF="x-087-2-serial.html"
|
|
>Up</A
|
|
></TD
|
|
><TD
|
|
WIDTH="33%"
|
|
ALIGN="right"
|
|
VALIGN="top"
|
|
>Configuring TCP/IP Networking</TD
|
|
></TR
|
|
></TABLE
|
|
></DIV
|
|
></BODY
|
|
></HTML
|
|
> |