Compare commits

...

16 Commits

57 changed files with 11459 additions and 4679 deletions

224
CHANGES
View File

@ -1,6 +1,228 @@
CHANGES CHANGES
======= =======
version 8.1.15 (Dec 31, 2006):
- protection again telnet option negotation loops - patch by
Robby Griffin <rmg@yakshavers.com>
- console now prints the attach/detach sequences when suspended
- added --with-cycladests configure option to allow
cross-compiling on a cyclades ts - patch by Matt Johnson
<mwj@doc.ic.ac.uk>
- added master conserver host to 'console -x' output for
'device' consoles - patch by Matt Johnson <mwj@doc.ic.ac.uk>
- fixed parsing error when dealing with encapsulated
client/server options
version 8.1.14 (Apr 9, 2006):
- fixed rpm conserver.spec file - based on patch by Martin Evans
<m.d.t.evans@qmul.ac.uk>
- added 'uds' console type for unix domain socket connections -
based on patch by DJ Gregor <dj@gregor.com>
- probing of interfaces under cygwin (and possibly others?) now
skips unconfigured interfaces (even if flagged as up!) -
reported by Chris Riddoch <chrisr@digeo.com>
- added the '!login' console option to prevent clients from
connecting to a console - suggested by Greg Tillman
<gregtillman@comcast.net>
- added a 'noop' console type for consoles you'd like to name,
but have no connection to - suggested by Greg Tillman
<gregtillman@comcast.net>
- deprecated escape commands removed from the code
- added '^EcP' and '^EcR' sequences to set the playback and
replay line lengths
- new console config options 'playback' and 'replay' to let the
client set prefered output lengths (with a special feature for
a size of zero)
- prefer strlcpy() over strcpy() - based on patch by Peter
Valchev <pvalchev@openbsd.org>
- fixed bug where '^Eco' by user on an 'exec' console with an
'initcmd' causes input by user to be ignored (could be other
console types as well) - reported by Mark Wedel
<Mark.Wedel@sun.com>
- made POSIX termios code in autologin a requirement (since
conserver requires it) and cleaned up a few other issues -
based on reports by Arthur Clune <ajc22@york.ac.uk>
version 8.1.13 (Jan 15, 2006):
- use SIOCGIFNUM for interface count (if available) and catch
EINVAL on Solaris - patch by Peter Jeremy
<peter.jeremy@alcatel.com.au>
- console output now resets idle timer - suggested by Peter
Saunders <pajs@fodder.org.uk>
- bug fix for conserver process running out of control and using
up cpu - debugged with Alexandra N. Kossovsky
<Alexandra.Kossovsky@oktetlabs.ru>
version 8.1.12 (Sep 5, 2005):
- printf() fix for autologin - patch by Menno Duursma
<druiloor@zonnet.nl>
- newly spawned (from SIGHUP) processes didn't properly close
primary socket
- SSL certificates now work again (anonymous ciphers are not
allowed if a certificate is used)
- client options -x, -u, -w, and -i can now take a console name
to restrict output - suggested by Evan McClure
<emcclure@internap.com>
- convert program now installed in $libdir/conserver - patch by
Petter Reinholdtsen <pere@hungry.com>
- we now ignore SIGXFSZ, if it exists
- added 'limited' access option to remove certain functionality
from users - suggested by Sven Michels <sven@darkman.de>
- added client option -z/-Z for sending commands to servers
(reload, quit, etc) - based on suggestion by Joshua Pincus
<Joshua.Pincus@Sun.COM>
- added 'execrunas' and 'initrunas' console options to allow
'exec' and 'initcmd' execution as another user and/or group -
based on patch by Gary Mills <mills@cc.umanitoba.ca>
- the east coast mirror had to shut down (for now, at least)
- crash from bad pointer manipulation during log replay - reported by
Ryan Kirkpatrick <linux@rkirkpat.net>
version 8.1.11 (Nov 9, 2004):
- fixed array bounds and stack tromping - reported by Emmett
Hogan <hogan@bigcityit.com>
- most recent client to ask for read-write now gets it (used to
be first client to connect)
- client read-write mode now separate from console up/down state
- 'make autologin.install' now compiles autologin - reported by
Graham Merrill <teddgram@sbcglobal.net>
- new 'autocomplete' option for controlling shortest-prefix
console name matching (which has always been on)
- client now blocks on ^Eco, waiting for status of connection
- added 'a' and 'A' for upper and lowercase alphanumeric
(0-9a-z) conversions to the *subst config items - based on
patch by Jonathan Chen <jon+conserver@spock.org>
version 8.1.10 (Sep 21, 2004):
- fix "forwarding level too deep" issue with '^Ec;' - reported
by Han Pilmeyer <han.pilmeyer@hp.com>
version 8.1.9 (Jul 14, 2004):
- fixed bug processing access lists when duplicates exist in the
list - reported by Phil Dibowitz <phil@usc.edu>
- fixed bug where 'idletimeout' was not recognized in default
blocks - reported by John Cagle <jcagle@gmail.com>
- added an 'autocomplete' config option to set the console name
autocompletion behavior - suggested by John Stoffel
<stoffel@lucent.com>
version 8.1.8 (Jun 9, 2004):
- added 'initspinmax' and 'initspintimer' console options to
help calm console initialization "spinning"
- fixed setsockopt() error on 64bit solaris - reported by Trond
Hagen <trond@basefarm.no>
version 8.1.7 (May 28, 2004):
- cleaned up the manpages a bit to make things clearer and more
standard - reported by Dave Stuit <djs@tellme.com>
- added an east coast mirror! http://conserver.syr.edu/ -
thanks to Christopher T. Beers <ctbeers@syr.edu>
- primary group of users not included in '@group' syntax -
reported by Phil Dibowitz <phil@usc.edu>
- changed '@group' behavior such that groups are checked when
needed, instead of cached at startup, which is more logical
- missing variables when building convert with tcp_wrappers -
reported by Nikolaos Papavassiliou
<Nikolaos.Papavassiliou@reuters.com>
- added --with-rpath option - suggested by Phil Dibowitz
<phil@usc.edu>
version 8.1.6 (May 25, 2004):
- added ability to configure client via system-wide console.cf
file and per-user .consolerc - suggested (independently) by
Erik Sjolund <erik.sjolund@sbc.su.se> and Trevor Fiatal
<trevor@fiatal.net>
- fixed bug where break strings were not properly sent -
reported by Tim Small <tim@buttersideup.com>
- fixed bug in config file 'protocol' value handling - reported
by Kees Cook <kees@osdl.org>
- conserver no longer uses the local domain name in the default
access list (the default list is only created if no access
list is specified in the configuration file) - inspired by
William P LePera <lepera@us.ibm.com>
- added a 'terminal' console configuration block for printing
strings when attaching and detaching from consoles - suggested
by Richard Threadgill <richardt@tellme.com>
version 8.1.5 (May 7, 2004):
- changed remaining O_NDELAY flags to O_NONBLOCK
- added PROTOCOLS file to describe the client/server protocol
- added '#include' capability to conserver.cf file
- added '@group' syntax to conserver.cf file to support use of
system groups
- added -U client option to allow client to ask for encryption
but fall back to non-encrypted connections otherwise -
suggested by Mike Hendon <mike.hendon@uk.nomura.com>
- fixed bug where socket not properly deleted on exit - reported
by William P LePera <lepera@us.ibm.com>
- added 'initdelay' option for throttling startup of consoles -
suggested by Jay McCanta <mccantaj@amgen.com>
version 8.1.4 (Apr 13, 2004):
- fixed macro use in manpages to hopefully be more compatible
- removed extra newline of --MARK-- range output
- fixed bug where server -b option wasn't working - reported by
Nathan R. Hruby <nhruby@uga.edu>
- fixed client segfault when using -R, -t, -d, and -b options
- added a --with-uds configure option to have all client/server
communication happen via unix domain sockets - suggested by
William P LePera <lepera@us.ibm.com>
version 8.1.3 (Mar 22, 2004):
- fixed small memory and file descriptor leak in client when
using '^Ec;'
- '^Ec;' now only disconnects from the previous console only
after a successfully move to a new console, allowing you to
abort the move - suggested by Christopher T. Beers
<ctbeers@syr.edu>
version 8.1.2 (Mar 11, 2004):
- better handling of client command (^Ec|) when user is bumped,
conserver is reconfigured, etc
- added 'initsubst' option for 'initcmd' substitutions like
'devicesubst' and 'execsubst' - based on patch by Bill
Sommerfeld <sommerfeld@east.sun.com>
- modified and added to *subst (initsubst, etc) syntax to allow
for flexibility and future enhancement
- changed 'port' and 'portinc' minimums from 1 to 0 - it allows
more flexibility and helps with 0-based counting
- removed unportable sys/cdefs.h from contrib/chat/chat.c -
patch by Bill Sommerfeld <sommerfeld@east.sun.com>
- added --with-extmsgs configure switch to enable entertaining
messages
- marked various undocumented client commands as deprecated so
that they can be removed in a future version
- added ability to "move" to a new console via '^Ec;' -
suggested by Christopher T. Beers <ctbeers@syr.edu>
- added a dump of console information when -S is used twice -
suggested by Todd Stansell <todd@stansell.org>
version 8.1.1 (Feb 10, 2004):
- fixed mistake in Makefiles where rpmbuild fails - reported by
Martin Evans <m.d.t.evans@qmul.ac.uk>
- fixed a couple typos - reported by Matt Selsky
<selsky@columbia.edu>
version 8.1.0 (Jan 18, 2004):
- fixes for HP-UX compilation - patch by Petter Reinholdtsen
<pere@hungry.com>
- fixes for compilation under various operating systems -
patch by Albert Chin <conserver-users@mlists.thewrittenword.com>
- added a 'protocol' option for either 'telnet' or 'raw' socket
communication - also reflected in -i output
- changed the client/server protocol to use 0xff as a command
character for sending control commands - similiar to the
telnet protocol - improves the ^Ec| interaction
- client -E option now disables ssl encryption attempts, useful
for broken SSL environents - suggested by Graydon Dodson
<grdodson@lexmark.com>
- bad error message connecting non-ssl client with ssl-required
server - reported by Graydon Dodson <grdodson@lexmark.com>
- added note about pam configuration to conserver.passwd.man -
suggested by Erik Sjolund <erik.sjolund@sbc.su.se>
- improved telnet protocol option handling such that connections
to standard telnet ports should work properly
version 8.0.9 (Dec 10, 2003): version 8.0.9 (Dec 10, 2003):
- fixed major bug in connect() handling which causes most - fixed major bug in connect() handling which causes most
socket-based consoles to timeout after 10 seconds - reported socket-based consoles to timeout after 10 seconds - reported
@ -643,5 +865,5 @@ before version 6.05:
and enhancements of various types were applied. and enhancements of various types were applied.
# #
# $Id: CHANGES,v 1.141 2003/12/10 18:33:40 bryan Exp $ # $Id: CHANGES,v 1.217 2006/12/31 02:04:11 bryan Exp $
# #

41
INSTALL
View File

@ -10,6 +10,25 @@ Upgrading?
new features added to the client if you're considering *not* new features added to the client if you're considering *not*
upgrading. upgrading.
Version 8.1.3
- The '^Ec;' sequence won't work correctly with 8.1.2 (where it
was introduced).
Version 8.1.2
- The 'devicesubst' and 'execsubst' formats have changed from
8.1.1. It's fairly simple to update your config file to the
new format...just check the conserver.cf manpage. Sorry for
having to change things, but it's for a good reason (I should
have though ahead when designing the original format).
Version 8.1.0
- The client/server protocol has changed to better protect 8-bit
data and to allow programs invoked with '^Ec|' not have to
worry about accidentally sending the escape sequence to the
server. Though it will look like things are mostly
backward-compatible, don't count on it and just upgrade.
Version 8.0.2 Version 8.0.2
- I've added a '^Ec;' sequence to allow the client to signal the - I've added a '^Ec;' sequence to allow the client to signal the
@ -146,6 +165,9 @@ Detailed Instructions
--with-maxmemb=MAXMEMB Specify maximum consoles per process [16] --with-maxmemb=MAXMEMB Specify maximum consoles per process [16]
--with-timeout=TIMEOUT Specify connect() timeout in seconds [10] --with-timeout=TIMEOUT Specify connect() timeout in seconds [10]
--with-trustrevdns Trust reverse DNS information --with-trustrevdns Trust reverse DNS information
--with-extmsgs Produce extended messages
--with-uds[=DIR] Use Unix domain sockets for client/server
communication [/tmp/conserver]
--with-libwrap[=PATH] Compile in libwrap (tcp_wrappers) support --with-libwrap[=PATH] Compile in libwrap (tcp_wrappers) support
--with-openssl[=PATH] Compile in OpenSSL support --with-openssl[=PATH] Compile in OpenSSL support
--with-dmalloc[=PATH] Compile in dmalloc support --with-dmalloc[=PATH] Compile in dmalloc support
@ -163,10 +185,11 @@ Detailed Instructions
A couple of notes. First, --with-libwrap will add tcp_wrappers A couple of notes. First, --with-libwrap will add tcp_wrappers
lookups to all socket connections in the server. --with-openssl lookups to all socket connections in the server. --with-openssl
will add encryption between the client and server when you connect will add encryption between the client and server when you connect
to a console. things such as 'console -q', 'console -w', etc. are to a console. --with-uds will cause the client and server to use
still unencrypted, as well as connections from conserver to any unix domain sockets for their communication, eliminating the
terminal servers. --with-dmalloc should only be used to do memory tcp communication they normally do (which means --with-master and
allocation debugging and not used in production. --with-port are not used). --with-dmalloc should only be used to
do memory allocation debugging and not used in production.
- Run './configure'. This will detect system specific - Run './configure'. This will detect system specific
information. The --prefix option will redirect where things are information. The --prefix option will redirect where things are
@ -205,10 +228,10 @@ Detailed Instructions
step. step.
+ Next, make sure conserver runs during boot. The init script we + Next, make sure conserver runs during boot. The init script we
use under Solaris is installed in <PREFIX>/etc/conserver.rc. use under Solaris is installed in
Use that or some form of it for your own /etc/init.d script or <DATADIR>/examples/conserver/conserver.rc. Use that or some
an entry in startup files (/etc/rc, /etc/rc.local, or form of it for your own /etc/init.d script or an entry in
whatever). startup files (/etc/rc, /etc/rc.local, or whatever).
+ Now for the fun stuff. You need to create a conserver.cf and + Now for the fun stuff. You need to create a conserver.cf and
conserver.passwd file. Those are defined with the conserver.passwd file. Those are defined with the
@ -255,5 +278,5 @@ Other Information And Gotchas
# #
# $Id: INSTALL,v 1.34 2003/10/03 17:52:31 bryan Exp $ # $Id: INSTALL,v 1.39 2005/05/21 13:47:16 bryan Exp $
# #

306
PROTOCOL Normal file
View File

@ -0,0 +1,306 @@
Conserver Protocol
==================
What Is This?
-------------
The following is an attempt to describe the client/server protocol used
between the server (conserver) and the client (console). This document
bases it's information on conserver version 8.1.4, as it's the release
currently available. If there are changes to the client/server
protocol, the INSTALL file should reference them and, ideally, this
document will be updated.
The information is looked at from the point of the server, since it's
the server that controls all information and triggers actions on the
client (like a suspend). The client's perspective should be obvious
from this information.
SSL
---
The client and server can negotiate an SSL connection. As far as the
code is concerned, the SSL "layer" is transparent. Data is sent and
received just as if it was unencrypted. Therefore, aside bringing up
the SSL connection, the SSL bits are unimportant from a protocol
standpoint. The client and server still send and receive the same
information - it just happens to be encrypted to everyone else.
"On-The-Wire" Data
------------------
The low-level, "on-the-wire" data is encapsulated similar to the telnet
protocol. All data is sent "as-is" with the exception of 0xFF. 0xFF is
used as a "command character" and both the client and server expect to
see a predefined option after it. The possible options are: 0xFF, 'E',
'G', 'Z', and '.'.
The 0xFF option says to use the literal character 0xFF. So, if there is
a 0xFF character in the data stream to be sent, the code will send two
0xFF characters (it's similar to using '\\' in C strings to embed a
'\').
The other options are used in various contexts, which will be described
in detail below.
Life As A Server
----------------
There are three different interfaces presented to clients by the server.
I'm going to name the three modes "master", "group", and "console". The
first two are line-based, and the third is character-based.
To understand the differences, I must outline how conserver manages
consoles. When conserver starts, it reads the configuration file,
listens on the master socket, and, for each group of consoles it must
manage (where the group size is set by -m), it forks off a copy of
itself. Those child processes are what actually connect to the consoles
and they each listen on a new socket for client connections. So, you
end up with a parent process (that knows about all consoles) that
manages the child processes (that know only about consoles it manages),
and everyone is listening on an individual socket for connections from
clients.
The parent process interacts with clients in "master" mode. That mode
expects line-based commands and responds similarly. Because it's the
master, it understands a certain set of commands that are different than
in "group" mode.
The child processes interact with clients in "group" mode first, and
negotiate a change to "console" mode when a client requests a connection
to a specific console.
"master" Mode
-------------
When parent process gets a connection from a client, it either sends an
"ok" string to signal it's ready or an error message (like "access from
your host is refused") and the connection is dropped. At this point,
there are a small number of commands recognized by the server, since
most are restricted to "logged in" clients. Here's the list of
available commands:
exit disconnect
help this help message
login log in
ssl start ssl session
An "exit" is sent a "goodbye" response and the connection is dropped. A
"help" is sent the list above. A "ssl" is sent an "ok" response and
then the server expects the client to negotiate an ssl connection. A
"login" requires one argument (the username) and is either sent an "ok",
meaning the client is logged in, or a "passwd?" followed by the local
hostname, asking for the user's password, which it expects next. If the
client sends a valid password, an "ok" is sent, otherwise an error
message and the connection is dropped.
Upon successful login, the commands available are:
call provide port for given console
exit disconnect
groups provide ports for group leaders
help this help message
master provide a list of master servers
newlogs* close and open all logfiles (SIGUSR2)
pid provide pid of master process
quit* terminate conserver (SIGTERM)
restart* restart conserver (SIGHUP) - deprecated
reconfig* reread config file (SIGHUP)
version provide version info for server
up* bring up all downed consoles (SIGUSR1)
* = requires admin privileges
"exit" and "help" are the same as before the client logged login.
The "call" command expects one argument, the console name to connect to.
The server will respond with either a port number (if it's a locally
managed console), an "@hostname" where hostname is the name of the
remote conserver host managing the console (if it's a remotely managed
console), or an error message (possibly multi-line). The client is not
disconnected, whatever the response.
The "groups" command responds with a colon-separated list of port
numbers, which correspond to each of the child processes running on the
local host. The client is not disconnected.
The "master" command responds with a colon-separated list of "@hostname"
names. The list includes any hosts (including the possibility of the
local host) which have locally managed consoles. The client is not
disconnected.
The "newlogs" command reopens all logfiles used by conserver, assuming
the user has administrative access. It responds with a message starting
with "ok" if successful and an error message otherwise (like
"unauthorized command"). The client is disconnected if it's successful.
The "pid" command responds with the pid of the master process (in this
case, the one the client is talking to). The client is not
disconnected.
The "quit" command will shut down conserver, assuming the user has
administrative access. It responds with a message starting with "ok" if
successful and an error message otherwise (like "unauthorized command").
The client is disconnected if it's successful.
The "restart" command has been deprecated. You should use "reconfig".
The "reconfig" command will cause conserver to reread the configuration
file and apply any changes, assuming the user has administrative access.
It responds with a message starting with "ok" if successful and an error
message otherwise (like "unauthorized command"). The client is not
disconnected.
The "version" command responds with the version string. The client is
not disconnected.
The "up" command tries to "bring up" all disconnected consoles, assuming
the user has administrative access. It responds with a message starting
with "ok" if successful and an error message otherwise (like
"unauthorized command"). The client is disconnected if it's successful.
"group" Mode
------------
When a child process gets a connection from a client, it either sends an
"ok" string to signal it's ready or an error message (like "access from
your host is refused") and the connection is dropped. At this point,
"group" mode acts just like "master" mode. Once the client successfully
logs in, however, "group" mode has the recognizes the following
commands:
broadcast send broadcast message
call connect to given console
disconnect* disconnect the given user(s)
examine examine port and baud rates
exit disconnect
group show users in this group
help this help message
hosts show host status and user
info show console information
textmsg send a text message
* = requires admin privileges
The "exit" and "help" commands are like the others documented above.
The "broadcast" command expects a text string of the message to be sent
to all users connected to this process. An "ok" is sent as a response.
The "call" command expects one argument, the console name to connect to,
just like in "master" mode. The difference here is that this requests
the server to attach the client to the console and go into "console"
mode. If the attachment is successful, the response will begin with a
'[' character. If not, an error message is returned. The success
responses are:
[console is read-only] - console is read only
[read-only -- initializing] - console is initializing, and
read-only for the time being
[line to console is down] - console is down
[attached] - attached read-write
[spy] - attached read-only
The "disconnect" command expects an argument of the form "user@console"
where either the "user" or "@console" part may be omitted. Upon
success, a response of the form "ok -- disconnected X users" is sent,
where X is the number of users disconnected. If a user is unauthorized
or some other problem occurs, an error message (like "unauthorized
command") is sent.
The "examine" command returns a list of console information of the form
that 'console -x' shows.
The "group" command returns a list of console information of the form
that 'console -w' shows.
The "hosts" command returns a list of console information of the form
that 'console -u' shows.
The "info" command returns a list of console information of the form
that 'console -i' shows.
The "textmsg" command expects two arguments, the first being the
recipient of the message in the form "user@console" (again, where the
"user" or "@console" portion may be omitted) and the second being the
string, like the "broadcast" command. The server returns "ok".
"console" Mode
--------------
As mentioned above, "console" mode is obtained by using the "call"
command when connected to a child processes operating in "group" mode.
"console" mode should look very familiar to a user of conserver, as it's
what the user interacts with when connected to a console. There's
really nothings special here. Each character received from the client
is compared to the escape sequence, and if it matches, an action occurs
on the server side. If it doesn't match the escape sequence, the data
is sent on to the console. All data received from the console is sent
to the client(s). Of course, there are certain exceptions to these
rules, based on the state of the console and the state of the client.
And, certain escape sequences cause special behaviors to occur.
Most escape sequences cause the server to send information back to the
user. Stuff like "^Ecw", "^Eci", and "^Ecu" are examples. The escape
sequence is absorbed by the server, the server sends the client a
variety of information, and things continue as before.
The more "interesting" escape sequences are the following.
"^Ec;" The server sends a 0xFF,'G' command sequence to the client, to
signal a wish to move to a new console. The client then gets
put into the same state as the "^Ecz" sequence (paused), which
gives the client a chance to either resume the connection or
disconnect.
"^Ec|" The server sends a 0xFF,'E' command sequence to the client, to
signal a wish to have the client program interact with a
program, as opposed to the user. The server discards all data
until it receives one of the following command sequences from
the client:
0xFF,'E' Signals successful redirection of interaction to
a program. The server then responds with "[rw]"
or "[ro]" to tell the client whether or not they
have read-write access. If not, the client
should abort the program and send the abort
command sequence below, as other data received by
the server will just get dropped.
0xFF,'.' Abort the operation. The server assumes the
redirection didn't happen and returns the client
to it's normal mode.
The server keeps the client in the "redirected" state until it
receives a 0xFF,'.' command sequence from the client (which
usually occurs when the client command terminates).
If the client is "bumped" from read-write to read-only by
another user, the server will send the client a 0xFF,'.' command
sequence to tell it to abort the redirection and return control
back to the user.
"^Ecz" The server sends a 0xFF,'Z' command sequence to the client, to
signal a wish to suspend to client process. The client is then
put into a "paused" state where it receives no more data from
the server. When the client is ready to resume receiving data,
it sends a character of data to the server, at which point the
server discards the character and sends back a status message of
the form " -- MSG]". The current set of possible messages are:
" -- line down]"
" -- read-only]"
" -- attached (nologging)]"
" -- attached]"
" -- spy mode]"
#
# $Id: PROTOCOL,v 1.2 2005/09/05 21:54:03 bryan Exp $
#

15
README
View File

@ -16,6 +16,14 @@ Documentation
Downloading Downloading
The latest version can be found at http://www.conserver.com/ The latest version can be found at http://www.conserver.com/
(US-West).
Mirrors of the site are at:
Australia http://planetmirror.com/pub/conserver/
Ireland http://conserver.oss-mirror.org/
Germany http://conserver.linux-mirror.org/
Russia http://conserver.rinet.ru/
Systems Tested Systems Tested
@ -29,7 +37,9 @@ Systems Tested
Cygwin (w2k),gcc 2.95.3 Cygwin (w2k),gcc 2.95.3
DEC Tru64 4.0, gcc DEC Tru64 4.0, gcc
DEC Tru64 4.0/5.1, native cc DEC Tru64 4.0/5.1, native cc
FreeBSD 4.2/4.8/5.1 (x86), gcc FreeBSD 4.x (i386) gcc
FreeBSD 5.x (i386/amd64/sparc64) gcc
FreeBSD 6.x/7.x (i386/amd64/sparc64/ia64) gcc
HP-UX 10.20, gcc HP-UX 10.20, gcc
HP-UX 11.10 parisc and ia64, native cc HP-UX 11.10 parisc and ia64, native cc
Irix 6.15, native cc Irix 6.15, native cc
@ -40,6 +50,7 @@ Systems Tested
MacOS X, native gcc MacOS X, native gcc
Solaris 2.5.1 thru 9 (sparc/x86), gcc Solaris 2.5.1 thru 9 (sparc/x86), gcc
Solaris 7/8, native cc Solaris 7/8, native cc
Solaris 10 and Solaris Express (build 33) (x86), gcc and native cc
Contributions Contributions
@ -55,5 +66,5 @@ Contributions
http://www.columbia.edu/acis/sy/unixdev/zinc http://www.columbia.edu/acis/sy/unixdev/zinc
# #
# $Id: README,v 1.22 2003/08/23 19:34:24 bryan Exp $ # $Id: README,v 1.26 2006/04/16 17:45:08 bryan Exp $
# #

46
TODO
View File

@ -11,13 +11,10 @@ Bryan Stansell
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
- Telnet protocol should be improved - Telnet protocol should be improved
- Not even RFC 854 compliant - Not even RFC 854 compliant...or maybe it is (as of 8.1.0)
- Option negotiation ignored - should we negotiate anything? - Option negotiation semi-ignored - should we negotiate anything more?
- Others? - Others?
- better shadow file support
- what does this mean? i've forgotten.
- syslog? - syslog?
Daniel E. Singer <des@cs.duke.edu> would like to see it - especially Daniel E. Singer <des@cs.duke.edu> would like to see it - especially
in regards to --use-libwrap code in regards to --use-libwrap code
@ -27,6 +24,7 @@ Bryan Stansell
- hpux has bigcrypt() also, which we support, so maybe we're covered - hpux has bigcrypt() also, which we support, so maybe we're covered
- config file examples for various configurations - config file examples for various configurations
- sample conserver.cf has some...but it's not explained well
- per-line timestamps - per-line timestamps
- only when not connected? - only when not connected?
@ -34,8 +32,12 @@ Bryan Stansell
- pipe input/output (console <-> program) via 'console' - pipe input/output (console <-> program) via 'console'
- some apps (net-ups thing, gdb) might need to talk to user - some apps (net-ups thing, gdb) might need to talk to user
- ^Ec| does this, but the interact with user bits might not work - ^Ec| does this, but the interact with user bits might not work
- actually, ^Ec| does work right with 8.1.0...one change that might
be nice is the ability to NOT watch the i/o pass to the local
command - try sending a big file to the local host with xmodem.
- autologout? setting per console? gack, would have to interpret data. - autologout? setting per console? gack, would have to interpret data.
- this will never happen...i don't want to interpret data
- "listen" capability (watch all/multiple consoles) - "listen" capability (watch all/multiple consoles)
@ -48,17 +50,17 @@ Bryan Stansell
- passphrase...hmmm..could really use some sort of send/expect - passphrase...hmmm..could really use some sort of send/expect
thing here. you could write a wrapper script of sorts, but it thing here. you could write a wrapper script of sorts, but it
really would be nice to have a raw socket and do the right thing. really would be nice to have a raw socket and do the right thing.
- this does work, using the 'initcmd' option, so, all done?
- cyclades ts1000/2000 port : "Moses, Joel" <jmoses@deloitte.com> - cyclades ts1000/2000 port : "Moses, Joel" <jmoses@deloitte.com>
- config file for client (list of masters, for example)
- strftime() idea for logfile names : Lars Kellogg-Stedman <lars@larsshack.org> - strftime() idea for logfile names : Lars Kellogg-Stedman <lars@larsshack.org>
- 9600baud log replay? - 9600baud log replay?
- server -M flag should accept multiple addresses (comma separated) - server -M flag should accept multiple addresses (comma separated)
- should client as well? - should client as well?
- this may never happen...does anyone really need it?
- automatic log rotation in general : Egan Ford <egan@us.ibm.com> - automatic log rotation in general : Egan Ford <egan@us.ibm.com>
@ -69,6 +71,7 @@ Bryan Stansell
- suggestions by Trevor Fiatal <trevor@seven.com> - suggestions by Trevor Fiatal <trevor@seven.com>
- include server hostname on 'console -x' output - include server hostname on 'console -x' output
- i think the -i output covers it, but maybe not
- ability to configure strings to be sent to a console periodically : - ability to configure strings to be sent to a console periodically :
Greg A. Woods <woods@planix.com> Greg A. Woods <woods@planix.com>
@ -78,13 +81,32 @@ Bryan Stansell
- redefine client escape sequence in conserver.cf : Toby Gerhart - redefine client escape sequence in conserver.cf : Toby Gerhart
<toby.gerhart@eds.com> <toby.gerhart@eds.com>
- not even sure if this is possible w/o confusing the client,
but maybe with the new 8.1.0 client-server protocol, we can!
- send a string when connected to a console, so you can set the - log rotation by date : Tom Pachla <tom.pachla@nlc-bnc.ca>
xterm title, for example : Richard Threadgill <richardt@tellme.com>
- allow for very long replays (hundres of lines) : John Stoffel - strict file permission checks on conserver.passwd/conserver.cf : Erik
<stoffel@lucent.com> Sjolund <erik.sjolund@sbc.su.se>
- netgroup support? : Nikolaos Papavassiliou
<Nikolaos.Papavassiliou@reuters.com> and Phil Dibowitz <phil@usc.edu>
- send sequences to console on client connect? (to repaint screen,
for example) : John Cagle <jcagle@gmail.com>
- uucp locks : Sebastian Zagrodzki <sebek@heron.net.icm.edu.pl>
- support more than 9 break sequences : Danish Mirza <Danish@lehman.com>
thought it was easy, but adding more than could break things with
current encoding. doable, will have to think harder about it.
- reintroduce console grouping : Martin Turba
<martin.turba@igd.fraunhofer.de>
- quick-recheck of down consoles (for uds) and possibly only log state
changes (instead of each try) : DJ Gregor <dj@gregor.com>
# #
# $Id: TODO,v 1.44 2003/11/29 14:10:47 bryan Exp $ # $Id: TODO,v 1.56 2006/04/03 22:20:34 bryan Exp $
# #

View File

@ -45,7 +45,7 @@ clean:
distclean: clean distclean: clean
rm -f Makefile rm -f Makefile
install: install: autologin
$(MKDIR) $(DESTDIR)$(bindir) $(MKDIR) $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) autologin $(DESTDIR)$(bindir) $(INSTALL_PROGRAM) autologin $(DESTDIR)$(bindir)

View File

@ -69,7 +69,7 @@
*/ */
#ifndef lint #ifndef lint
char *rcsid = "$Id: autologin.c,v 1.23 2002/09/21 06:29:39 bryan Exp $"; char *rcsid = "$Id: autologin.c,v 1.25 2006/04/10 01:50:16 bryan Exp $";
#endif /* not lint */ #endif /* not lint */
extern char *progname; extern char *progname;
gid_t awGrps[NGROUPS_MAX]; gid_t awGrps[NGROUPS_MAX];
@ -88,37 +88,18 @@ void usage();
int int
Process() Process()
{ {
register int c;
int iErrs = 0; int iErrs = 0;
int i, iNewGrp; int i, iNewGrp;
gid_t wGid; gid_t wGid;
uid_t wUid; uid_t wUid;
char *pcCmd = (char *)0, char *pcCmd = (char *)0,
*pcDevTty = (char *)0; *pcDevTty = (char *)0;
char *pcTmp;
#ifdef HAVE_GETUSERATTR #ifdef HAVE_GETUSERATTR
char *pcGrps; char *pcGrps;
#endif #endif
struct passwd *pwd; struct passwd *pwd;
struct stat st; struct stat st;
#ifdef HAVE_TERMIOS_H
struct termios n_tio; struct termios n_tio;
#else
# ifdef TIOCNOTTY
# ifdef O_CBREAK
auto struct tc n_tchars;
# else
auto struct tchars n_tchars;
# endif
# ifdef TIOCGLTC
auto struct ltchars n_ltchars;
# endif
# else
# ifdef TIOCGETP
auto struct sgttyb n_sty;
# endif
# endif
#endif
#if defined(HAVE_BSM_AUDIT_H) && defined(HAVE_LIBBSM) #if defined(HAVE_BSM_AUDIT_H) && defined(HAVE_LIBBSM)
char my_hostname[MAXHOSTNAMELEN]; char my_hostname[MAXHOSTNAMELEN];
#endif #endif
@ -126,7 +107,7 @@ Process()
#if defined(HAVE_BSM_AUDIT_H) && defined(HAVE_LIBBSM) #if defined(HAVE_BSM_AUDIT_H) && defined(HAVE_LIBBSM)
if (0 != gethostname(my_hostname, sizeof(my_hostname))) { if (0 != gethostname(my_hostname, sizeof(my_hostname))) {
(void) fprintf(stderr, "%s: gethostname: %s\n", strerror(errno)); (void) fprintf(stderr, "%s: gethostname: %s\n", progname, strerror(errno));
exit(1); exit(1);
/* NOTREACHED */ /* NOTREACHED */
} }
@ -320,7 +301,7 @@ Process()
# endif # endif
(void)au_write(iAuditFile, ptAuditToken); (void)au_write(iAuditFile, ptAuditToken);
if(0 > au_close(iAuditFile, AU_TO_WRITE, AUE_autologin)) { if(0 > au_close(iAuditFile, AU_TO_WRITE, AUE_autologin)) {
fprintf(stderr, "%s: audit write failed", fprintf(stderr, "%s: audit write failed: %s",
progname, progname,
strerror(errno)); strerror(errno));
} }
@ -372,54 +353,6 @@ Process()
/* put the tty in the correct mode /* put the tty in the correct mode
*/ */
#ifndef HAVE_TERMIOS_H
if (0 != ioctl(0, TIOCGETP, (char *)&n_sty)) {
fprintf(stderr, "%s: iotcl: getp: %s\n", progname, strerror(errno));
exit(10);
}
#ifdef O_CBREAK
n_sty.sg_flags &= ~(O_CBREAK);
n_sty.sg_flags |= (O_CRMOD|O_ECHO);
#else
n_sty.sg_flags &= ~(CBREAK);
n_sty.sg_flags |= (CRMOD|ECHO);
#endif
n_sty.sg_kill = '\025'; /* ^U */
n_sty.sg_erase = '\010'; /* ^H */
if (0 != ioctl(0, TIOCSETP, (char *)&n_sty)) {
fprintf(stderr, "%s: iotcl: setp: %s\n", progname, strerror(errno));
exit(10);
}
/* stty undef all tty chars
*/
#if 0
if (-1 == ioctl(0, TIOCGETC, (char *)&n_tchars)) {
fprintf(stderr, "%s: ioctl: getc: %s\n", progname, strerror(errno));
return;
}
n_tchars.t_intrc = -1;
n_tchars.t_quitc = -1;
if (-1 == ioctl(0, TIOCSETC, (char *)&n_tchars)) {
fprintf(stderr, "%s: ioctl: setc: %s\n", progname, strerror(errno));
return;
}
#endif
#ifdef TIOCGLTC
if (-1 == ioctl(0, TIOCGLTC, (char *)&n_ltchars)) {
fprintf(stderr, "%s: ioctl: gltc: %s\n", progname, strerror(errno));
return;
}
n_ltchars.t_suspc = -1;
n_ltchars.t_dsuspc = -1;
n_ltchars.t_flushc = -1;
n_ltchars.t_lnextc = -1;
if (-1 == ioctl(0, TIOCSLTC, (char *)&n_ltchars)) {
fprintf(stderr, "%s: ioctl: sltc: %s\n", progname, strerror(errno));
return;
}
#endif
#else /* not using ioctl, using POSIX or sun stuff */
#ifdef HAVE_TCGETATTR #ifdef HAVE_TCGETATTR
if (0 != tcgetattr(0, &n_tio)) { if (0 != tcgetattr(0, &n_tio)) {
(void) fprintf(stderr, "%s: tcgetattr: %s\n", progname, strerror(errno)); (void) fprintf(stderr, "%s: tcgetattr: %s\n", progname, strerror(errno));
@ -455,16 +388,7 @@ Process()
exit(1); exit(1);
/* NOTREACHED */ /* NOTREACHED */
} }
#else
#ifndef HAVE_TERMIOS_H
if (0 != ioctl(0, TCSETS, &n_tio)) {
(void) fprintf(stderr, "%s: ioctl: TCSETS: %s\n", progname, strerror(errno));
exit(1);
/* NOTREACHED */
}
#endif #endif
#endif
#endif /* setup tty */
if (fMakeUtmp) { if (fMakeUtmp) {
extern char *ttyname(); extern char *ttyname();
@ -532,7 +456,7 @@ char *pctty;
register int fdUtmp; register int fdUtmp;
register char *pcDev; register char *pcDev;
register struct utmp *up; register struct utmp *up;
auto struct utmp outmp, utmp; auto struct utmp utmp;
if ((char *)0 == pctty) { if ((char *)0 == pctty) {

View File

@ -1,4 +1,4 @@
.\" $Id: autologin.man,v 1.1 2003/11/04 02:36:24 bryan Exp $ .\" $Id: autologin.man,v 1.2 2004/03/23 18:32:06 bryan Exp $
.TH AUTOLOGIN 8L PUCC .TH AUTOLOGIN 8L PUCC
.SH NAME .SH NAME
autologin \- create an automatic login session from /etc/inittab autologin \- create an automatic login session from /etc/inittab
@ -112,12 +112,21 @@ environment variable set to
ss10:2:respawn:/usr/local/etc/autologin \-e TERM=reg20 \-t/dev/tty10 \-lssinfo ss10:2:respawn:/usr/local/etc/autologin \-e TERM=reg20 \-t/dev/tty10 \-lssinfo
.ad .ad
.PP .PP
Adding the following line to \fI/etc/ttytab\fP on a Sun 4.1.\fIx\fP Adding the following line to
.I /etc/ttytab
on a Sun
.RI 4.1. x
machine establishes a root login on the console device: machine establishes a root login on the console device:
.br
.na .na
console "/usr/local/etc/autologin \-lroot \-t" xterm on local secure console "/usr/local/etc/autologin \-lroot \-t" xterm on local secure
.ad .ad
Note that \fIinit\fP provides the \fItty\fP argument on the end of the command. .PP
Note that
.I init
provides the
.I tty
argument on the end of the command.
.SH FILES .SH FILES
/bin/su /bin/su
.br .br

View File

@ -8,6 +8,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/un.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netdb.h> #include <netdb.h>
#include <ctype.h> #include <ctype.h>
@ -34,6 +35,17 @@
# define DEFESC 'c' # define DEFESC 'c'
#endif #endif
/* set the default length of the replay functions
* DEFREPLAY for 'r'
* DEFPLAYBACK for 'p'
*/
#if !defined(DEFREPLAY)
# define DEFREPLAY 20
#endif
#if !defined(PLAYBACK)
# define DEFPLAYBACK 60
#endif
/* For legacy compile-time setting of the port... /* For legacy compile-time setting of the port...
*/ */
#if ! defined(DEFPORT) #if ! defined(DEFPORT)
@ -91,6 +103,18 @@ typedef long fd_set;
#include <termios.h> #include <termios.h>
#ifndef TAB3
# ifdef OXTABS
# define TAB3 OXTABS
# else
# ifdef XTABS
# define TAB3 XTABS
# else
# define TAB3 0
# endif
# endif
#endif
#ifdef HAVE_STROPTS_H #ifdef HAVE_STROPTS_H
# include <stropts.h> # include <stropts.h>
#endif #endif

660
config.guess vendored

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,8 @@
/* config.h.in. Generated from configure.in by autoheader. */ /* config.h.in. Generated from configure.in by autoheader. */
/* Client config file path */
#undef CLIENTCONFIGFILE
/* Config file path */ /* Config file path */
#undef CONFIGFILE #undef CONFIGFILE
@ -15,6 +18,9 @@
/* Socket used to communicate */ /* Socket used to communicate */
#undef DEFPORT #undef DEFPORT
/* Defined if building for a Cyclades TS */
#undef FOR_CYCLADES_TS
/* Define to 1 if you have the `bigcrypt' function. */ /* Define to 1 if you have the `bigcrypt' function. */
#undef HAVE_BIGCRYPT #undef HAVE_BIGCRYPT
@ -57,6 +63,9 @@
/* Define to 1 if you have the `getspnam' function. */ /* Define to 1 if you have the `getspnam' function. */
#undef HAVE_GETSPNAM #undef HAVE_GETSPNAM
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
/* Define to 1 if you have the `getuserattr' function. */ /* Define to 1 if you have the `getuserattr' function. */
#undef HAVE_GETUSERATTR #undef HAVE_GETUSERATTR
@ -189,6 +198,9 @@
/* Define to 1 if you have the <string.h> header file. */ /* Define to 1 if you have the <string.h> header file. */
#undef HAVE_STRING_H #undef HAVE_STRING_H
/* Define to 1 if you have the `strlcpy' function. */
#undef HAVE_STRLCPY
/* Define to 1 if you have the <stropts.h> header file. */ /* Define to 1 if you have the <stropts.h> header file. */
#undef HAVE_STROPTS_H #undef HAVE_STROPTS_H
@ -237,6 +249,9 @@
/* Define to 1 if you have the <sys/uio.h> header file. */ /* Define to 1 if you have the <sys/uio.h> header file. */
#undef HAVE_SYS_UIO_H #undef HAVE_SYS_UIO_H
/* Define to 1 if you have the <sys/un.h> header file. */
#undef HAVE_SYS_UN_H
/* Define to 1 if you have the <sys/vlimit.h> header file. */ /* Define to 1 if you have the <sys/vlimit.h> header file. */
#undef HAVE_SYS_VLIMIT_H #undef HAVE_SYS_VLIMIT_H
@ -312,7 +327,7 @@
/* Define as the return type of signal handlers (`int' or `void'). */ /* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE #undef RETSIGTYPE
/* Define to 1 if the `setpgrp' function takes no argument. */ /* Define if setpgrp is POSIX */
#undef SETPGRP_VOID #undef SETPGRP_VOID
/* Define to 1 if you have the ANSI C header files. */ /* Define to 1 if you have the ANSI C header files. */
@ -324,9 +339,18 @@
/* Defined if we trust reverse DNS */ /* Defined if we trust reverse DNS */
#undef TRUST_REVERSE_DNS #undef TRUST_REVERSE_DNS
/* Directory for Unix domain sockets */
#undef UDSDIR
/* Defined if we produce extended messages */
#undef USE_EXTENDED_MESSAGES
/* use tcp_wrappers libwrap */ /* use tcp_wrappers libwrap */
#undef USE_LIBWRAP #undef USE_LIBWRAP
/* Defined if we use Unix domain sockets */
#undef USE_UNIX_DOMAIN_SOCKETS
/* Define to 1 if on AIX 3. /* Define to 1 if on AIX 3.
System headers sometimes define this. System headers sometimes define this.
We just want to avoid a redefinition error message. */ We just want to avoid a redefinition error message. */
@ -340,6 +364,9 @@
/* Define to empty if `const' does not conform to ANSI C. */ /* Define to empty if `const' does not conform to ANSI C. */
#undef const #undef const
/* Define to `int' if <sys/types.h> doesn't define. */
#undef gid_t
/* Define to `int' if <sys/types.h> does not define. */ /* Define to `int' if <sys/types.h> does not define. */
#undef mode_t #undef mode_t
@ -348,3 +375,9 @@
/* Define if <signal.h> does not define sig_atomic_t */ /* Define if <signal.h> does not define sig_atomic_t */
#undef sig_atomic_t #undef sig_atomic_t
/* Define to `unsigned' if <sys/types.h> does not define. */
#undef size_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t

199
config.sub vendored
View File

@ -1,9 +1,10 @@
#! /bin/sh #! /bin/sh
# Configuration validation subroutine script. # Configuration validation subroutine script.
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
# Inc.
timestamp='2003-11-20' timestamp='2006-12-08'
# This file is (in principle) common to ALL GNU software. # This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software # The presence of a machine in this file suggests that SOME GNU software
@ -21,14 +22,15 @@ timestamp='2003-11-20'
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
# Boston, MA 02111-1307, USA. # 02110-1301, USA.
#
# As a special exception to the GNU General Public License, if you # As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a # distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under # configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program. # the same distribution terms that you use for the rest of that program.
# Please send patches to <config-patches@gnu.org>. Submit a context # Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted ChangeLog entry. # diff and a properly formatted ChangeLog entry.
# #
@ -70,7 +72,7 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\ version="\
GNU config.sub ($timestamp) GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
Free Software Foundation, Inc. Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO This is free software; see the source for copying conditions. There is NO
@ -83,11 +85,11 @@ Try \`$me --help' for more information."
while test $# -gt 0 ; do while test $# -gt 0 ; do
case $1 in case $1 in
--time-stamp | --time* | -t ) --time-stamp | --time* | -t )
echo "$timestamp" ; exit 0 ;; echo "$timestamp" ; exit ;;
--version | -v ) --version | -v )
echo "$version" ; exit 0 ;; echo "$version" ; exit ;;
--help | --h* | -h ) --help | --h* | -h )
echo "$usage"; exit 0 ;; echo "$usage"; exit ;;
-- ) # Stop option processing -- ) # Stop option processing
shift; break ;; shift; break ;;
- ) # Use stdin as input. - ) # Use stdin as input.
@ -99,7 +101,7 @@ while test $# -gt 0 ; do
*local*) *local*)
# First pass through any local machine types. # First pass through any local machine types.
echo $1 echo $1
exit 0;; exit ;;
* ) * )
break ;; break ;;
@ -118,8 +120,9 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations. # Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*) uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;; ;;
@ -145,7 +148,7 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis) -apple | -axis | -knuth | -cray)
os= os=
basic_machine=$1 basic_machine=$1
;; ;;
@ -170,6 +173,10 @@ case $os in
-hiux*) -hiux*)
os=-hiuxwe2 os=-hiuxwe2
;; ;;
-sco6)
os=-sco5v6
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5) -sco5)
os=-sco3.2v5 os=-sco3.2v5
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@ -186,6 +193,10 @@ case $os in
# Don't forget version if it is 3.2v4 or newer. # Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;; ;;
-sco5v6*)
# Don't forget version if it is 3.2v4 or newer.
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco*) -sco*)
os=-sco3.2v2 os=-sco3.2v2
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
@ -230,14 +241,16 @@ case $basic_machine in
| alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| am33_2.0 \ | am33_2.0 \
| arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \ | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr | avr32 \
| bfin \
| c4x | clipper \ | c4x | clipper \
| d10v | d30v | dlx | dsp16xx \ | d10v | d30v | dlx | dsp16xx \
| fr30 | frv \ | fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \ | i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \ | ip2k | iq2000 \
| m32r | m68000 | m68k | m88k | mcore \ | m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore \
| mips | mipsbe | mipseb | mipsel | mipsle \ | mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \ | mips16 \
| mips64 | mips64el \ | mips64 | mips64el \
@ -246,6 +259,7 @@ case $basic_machine in
| mips64vr4100 | mips64vr4100el \ | mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \ | mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \ | mips64vr5000 | mips64vr5000el \
| mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \ | mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \ | mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \ | mipsisa64 | mipsisa64el \
@ -254,20 +268,24 @@ case $basic_machine in
| mipsisa64sr71k | mipsisa64sr71kel \ | mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \ | mipstx39 | mipstx39el \
| mn10200 | mn10300 \ | mn10200 | mn10300 \
| mt \
| msp430 \ | msp430 \
| nios | nios2 \
| ns16k | ns32k \ | ns16k | ns32k \
| openrisc | or32 \ | or32 \
| pdp10 | pdp11 | pj | pjl \ | pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \ | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| pyramid \ | pyramid \
| sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | score \
| sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
| sh64 | sh64le \ | sh64 | sh64le \
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| strongarm \ | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \ | tahoe | thumb | tic4x | tic80 | tron \
| v850 | v850e \ | v850 | v850e \
| we32k \ | we32k \
| x86 | xscale | xstormy16 | xtensa \ | x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| z8k) | z8k)
basic_machine=$basic_machine-unknown basic_machine=$basic_machine-unknown
;; ;;
@ -278,6 +296,9 @@ case $basic_machine in
;; ;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;; ;;
ms1)
basic_machine=mt-unknown
;;
# We use `pc' rather than `unknown' # We use `pc' rather than `unknown'
# because (1) that's what they normally are, and # because (1) that's what they normally are, and
@ -297,20 +318,20 @@ case $basic_machine in
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \ | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \ | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \ | arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* \ | avr-* | avr32-* \
| bs2000-* \ | bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
| clipper-* | cydra-* \ | clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \ | d10v-* | d30v-* | dlx-* \
| elxsi-* \ | elxsi-* \
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \ | h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \ | i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \ | ip2k-* | iq2000-* \
| m32r-* \ | m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | mcore-* \ | m88110-* | m88k-* | maxq-* | mcore-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \ | mips16-* \
| mips64-* | mips64el-* \ | mips64-* | mips64el-* \
@ -319,6 +340,7 @@ case $basic_machine in
| mips64vr4100-* | mips64vr4100el-* \ | mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \ | mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \ | mips64vr5000-* | mips64vr5000el-* \
| mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \ | mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \ | mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \ | mipsisa64-* | mipsisa64el-* \
@ -326,24 +348,28 @@ case $basic_machine in
| mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39-* | mipstx39el-* \ | mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \ | msp430-* \
| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ | nios-* | nios2-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| orion-* \ | orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \ | pyramid-* \
| romp-* | rs6000-* \ | romp-* | rs6000-* \
| sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
| shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \ | tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tron-* \ | tron-* \
| v850-* | v850e-* | vax-* \ | v850-* | v850e-* | vax-* \
| we32k-* \ | we32k-* \
| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \ | x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
| xtensa-* \ | xstormy16-* | xtensa-* \
| ymp-* \ | ymp-* \
| z8k-*) | z8k-*)
;; ;;
@ -363,6 +389,9 @@ case $basic_machine in
basic_machine=a29k-amd basic_machine=a29k-amd
os=-udi os=-udi
;; ;;
abacus)
basic_machine=abacus-unknown
;;
adobe68k) adobe68k)
basic_machine=m68010-adobe basic_machine=m68010-adobe
os=-scout os=-scout
@ -380,6 +409,9 @@ case $basic_machine in
amd64) amd64)
basic_machine=x86_64-pc basic_machine=x86_64-pc
;; ;;
amd64-*)
basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
amdahl) amdahl)
basic_machine=580-amdahl basic_machine=580-amdahl
os=-sysv os=-sysv
@ -439,12 +471,27 @@ case $basic_machine in
basic_machine=j90-cray basic_machine=j90-cray
os=-unicos os=-unicos
;; ;;
craynv)
basic_machine=craynv-cray
os=-unicosmp
;;
cr16c)
basic_machine=cr16c-unknown
os=-elf
;;
crds | unos) crds | unos)
basic_machine=m68k-crds basic_machine=m68k-crds
;; ;;
crisv32 | crisv32-* | etraxfs*)
basic_machine=crisv32-axis
;;
cris | cris-* | etrax*) cris | cris-* | etrax*)
basic_machine=cris-axis basic_machine=cris-axis
;; ;;
crx)
basic_machine=crx-unknown
os=-elf
;;
da30 | da30-*) da30 | da30-*)
basic_machine=m68k-da30 basic_machine=m68k-da30
;; ;;
@ -467,6 +514,10 @@ case $basic_machine in
basic_machine=m88k-motorola basic_machine=m88k-motorola
os=-sysv3 os=-sysv3
;; ;;
djgpp)
basic_machine=i586-pc
os=-msdosdjgpp
;;
dpx20 | dpx20-*) dpx20 | dpx20-*)
basic_machine=rs6000-bull basic_machine=rs6000-bull
os=-bosx os=-bosx
@ -645,10 +696,6 @@ case $basic_machine in
mips3*) mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;; ;;
mmix*)
basic_machine=mmix-knuth
os=-mmixware
;;
monitor) monitor)
basic_machine=m68k-rom68k basic_machine=m68k-rom68k
os=-coff os=-coff
@ -661,6 +708,9 @@ case $basic_machine in
basic_machine=i386-pc basic_machine=i386-pc
os=-msdos os=-msdos
;; ;;
ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
mvs) mvs)
basic_machine=i370-ibm basic_machine=i370-ibm
os=-mvs os=-mvs
@ -729,10 +779,6 @@ case $basic_machine in
np1) np1)
basic_machine=np1-gould basic_machine=np1-gould
;; ;;
nv1)
basic_machine=nv1-cray
os=-unicosmp
;;
nsr-tandem) nsr-tandem)
basic_machine=nsr-tandem basic_machine=nsr-tandem
;; ;;
@ -740,9 +786,8 @@ case $basic_machine in
basic_machine=hppa1.1-oki basic_machine=hppa1.1-oki
os=-proelf os=-proelf
;; ;;
or32 | or32-*) openrisc | openrisc-*)
basic_machine=or32-unknown basic_machine=or32-unknown
os=-coff
;; ;;
os400) os400)
basic_machine=powerpc-ibm basic_machine=powerpc-ibm
@ -773,6 +818,12 @@ case $basic_machine in
pc532 | pc532-*) pc532 | pc532-*)
basic_machine=ns32k-pc532 basic_machine=ns32k-pc532
;; ;;
pc98)
basic_machine=i386-pc
;;
pc98-*)
basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentium | p5 | k5 | k6 | nexgen | viac3) pentium | p5 | k5 | k6 | nexgen | viac3)
basic_machine=i586-pc basic_machine=i586-pc
;; ;;
@ -829,6 +880,10 @@ case $basic_machine in
basic_machine=i586-unknown basic_machine=i586-unknown
os=-pw32 os=-pw32
;; ;;
rdos)
basic_machine=i386-pc
os=-rdos
;;
rom68k) rom68k)
basic_machine=m68k-rom68k basic_machine=m68k-rom68k
os=-coff os=-coff
@ -855,6 +910,10 @@ case $basic_machine in
sb1el) sb1el)
basic_machine=mipsisa64sb1el-unknown basic_machine=mipsisa64sb1el-unknown
;; ;;
sde)
basic_machine=mipsisa32-sde
os=-elf
;;
sei) sei)
basic_machine=mips-sei basic_machine=mips-sei
os=-seiux os=-seiux
@ -866,6 +925,9 @@ case $basic_machine in
basic_machine=sh-hitachi basic_machine=sh-hitachi
os=-hms os=-hms
;; ;;
sh5el)
basic_machine=sh5le-unknown
;;
sh64) sh64)
basic_machine=sh64-unknown basic_machine=sh64-unknown
;; ;;
@ -1015,6 +1077,10 @@ case $basic_machine in
basic_machine=hppa1.1-winbond basic_machine=hppa1.1-winbond
os=-proelf os=-proelf
;; ;;
xbox)
basic_machine=i686-pc
os=-mingw32
;;
xps | xps100) xps | xps100)
basic_machine=xps100-honeywell basic_machine=xps100-honeywell
;; ;;
@ -1045,6 +1111,9 @@ case $basic_machine in
romp) romp)
basic_machine=romp-ibm basic_machine=romp-ibm
;; ;;
mmix)
basic_machine=mmix-knuth
;;
rs6000) rs6000)
basic_machine=rs6000-ibm basic_machine=rs6000-ibm
;; ;;
@ -1061,13 +1130,10 @@ case $basic_machine in
we32k) we32k)
basic_machine=we32k-att basic_machine=we32k-att
;; ;;
sh3 | sh4 | sh[34]eb | sh[1234]le | sh[23]ele) sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
basic_machine=sh-unknown basic_machine=sh-unknown
;; ;;
sh64) sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
basic_machine=sh64-unknown
;;
sparc | sparcv9 | sparcv9b)
basic_machine=sparc-sun basic_machine=sparc-sun
;; ;;
cydra) cydra)
@ -1140,19 +1206,23 @@ case $os in
| -aos* \ | -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \ | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* \ | -chorusos* | -chorusrdb* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \ | -mingw32* | -linux-gnu* | -linux-newlib* | -linux-uclibc* \
| -uxpv* | -beos* | -mpeix* | -udk* \
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \ | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \ | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \ | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \ | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \ | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*) | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers*)
# Remember, each alternative MUST END IN *, to match a version number. # Remember, each alternative MUST END IN *, to match a version number.
;; ;;
-qnx*) -qnx*)
@ -1170,7 +1240,7 @@ case $os in
os=`echo $os | sed -e 's|nto|nto-qnx|'` os=`echo $os | sed -e 's|nto|nto-qnx|'`
;; ;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \ -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* \ | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
| -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*) | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;; ;;
-mac*) -mac*)
@ -1279,6 +1349,9 @@ case $os in
-kaos*) -kaos*)
os=-kaos os=-kaos
;; ;;
-zvmoe)
os=-zvmoe
;;
-none) -none)
;; ;;
*) *)
@ -1301,6 +1374,12 @@ else
# system, and we'll never get to this point. # system, and we'll never get to this point.
case $basic_machine in case $basic_machine in
score-*)
os=-elf
;;
spu-*)
os=-elf
;;
*-acorn) *-acorn)
os=-riscix1.2 os=-riscix1.2
;; ;;
@ -1310,9 +1389,9 @@ case $basic_machine in
arm*-semi) arm*-semi)
os=-aout os=-aout
;; ;;
c4x-* | tic4x-*) c4x-* | tic4x-*)
os=-coff os=-coff
;; ;;
# This must come before the *-dec entry. # This must come before the *-dec entry.
pdp10-*) pdp10-*)
os=-tops20 os=-tops20
@ -1356,9 +1435,15 @@ case $basic_machine in
*-be) *-be)
os=-beos os=-beos
;; ;;
*-haiku)
os=-haiku
;;
*-ibm) *-ibm)
os=-aix os=-aix
;; ;;
*-knuth)
os=-mmixware
;;
*-wec) *-wec)
os=-proelf os=-proelf
;; ;;
@ -1524,7 +1609,7 @@ case $basic_machine in
esac esac
echo $basic_machine$os echo $basic_machine$os
exit 0 exit
# Local variables: # Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp) # eval: (add-hook 'write-file-hooks 'time-stamp)

2065
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -4,6 +4,7 @@ AH_TEMPLATE([DEFPORT], [Socket used to communicate])
AH_TEMPLATE([DEFBASEPORT], [Base socket used for secondary channel]) AH_TEMPLATE([DEFBASEPORT], [Base socket used for secondary channel])
AH_TEMPLATE([MASTERHOST], [Hostname of console server]) AH_TEMPLATE([MASTERHOST], [Hostname of console server])
AH_TEMPLATE([CONFIGFILE], [Config file path]) AH_TEMPLATE([CONFIGFILE], [Config file path])
AH_TEMPLATE([CLIENTCONFIGFILE], [Client config file path])
AH_TEMPLATE([PASSWDFILE], [Password file path]) AH_TEMPLATE([PASSWDFILE], [Password file path])
AH_TEMPLATE([LOGFILEPATH], [Logfile path]) AH_TEMPLATE([LOGFILEPATH], [Logfile path])
AH_TEMPLATE([MAXMEMB], [Number of consoles per child process]) AH_TEMPLATE([MAXMEMB], [Number of consoles per child process])
@ -16,9 +17,14 @@ AH_TEMPLATE([HAVE_OPENSSL], [have openssl support])
AH_TEMPLATE([HAVE_DMALLOC], [have dmalloc support]) AH_TEMPLATE([HAVE_DMALLOC], [have dmalloc support])
AH_TEMPLATE([HAVE_SA_LEN],[Defined if sa_len member exists in struct sockaddr]) AH_TEMPLATE([HAVE_SA_LEN],[Defined if sa_len member exists in struct sockaddr])
AH_TEMPLATE([TRUST_REVERSE_DNS],[Defined if we trust reverse DNS]) AH_TEMPLATE([TRUST_REVERSE_DNS],[Defined if we trust reverse DNS])
AH_TEMPLATE([USE_EXTENDED_MESSAGES],[Defined if we produce extended messages])
AH_TEMPLATE([USE_UNIX_DOMAIN_SOCKETS],[Defined if we use Unix domain sockets])
AH_TEMPLATE([UDSDIR], [Directory for Unix domain sockets])
AH_TEMPLATE([FOR_CYCLADES_TS], [Defined if building for a Cyclades TS])
dnl ### Normal initialization. ###################################### dnl ### Normal initialization. ######################################
AC_INIT AC_INIT
AC_PREREQ(2.59)
AC_CONFIG_SRCDIR([conserver/main.c]) AC_CONFIG_SRCDIR([conserver/main.c])
AC_CONFIG_HEADER(config.h) AC_CONFIG_HEADER(config.h)
@ -48,7 +54,7 @@ dnl AC_MSG_RESULT($with_64bit)
AC_MSG_CHECKING(for port number specification) AC_MSG_CHECKING(for port number specification)
AC_ARG_WITH(port, AC_ARG_WITH(port,
AC_HELP_STRING([--with-port=PORT],[Specify port number @<:@conserver@:>@]), AS_HELP_STRING([--with-port=PORT],[Specify port number @<:@conserver@:>@]),
[case "$withval" in [case "$withval" in
yes|no) yes|no)
AC_DEFINE_UNQUOTED(DEFPORT, "conserver") AC_DEFINE_UNQUOTED(DEFPORT, "conserver")
@ -64,7 +70,7 @@ AC_ARG_WITH(port,
AC_MSG_CHECKING(for secondary channel base port) AC_MSG_CHECKING(for secondary channel base port)
AC_ARG_WITH(base, AC_ARG_WITH(base,
AC_HELP_STRING([--with-base=PORT], [Base port for secondary channel @<:@0@:>@]), AS_HELP_STRING([--with-base=PORT], [Base port for secondary channel @<:@0@:>@]),
[case "$withval" in [case "$withval" in
yes|no) yes|no)
AC_DEFINE_UNQUOTED(DEFBASEPORT, "0") AC_DEFINE_UNQUOTED(DEFBASEPORT, "0")
@ -80,7 +86,7 @@ AC_ARG_WITH(base,
AC_MSG_CHECKING(for master conserver hostname) AC_MSG_CHECKING(for master conserver hostname)
AC_ARG_WITH(master, AC_ARG_WITH(master,
AC_HELP_STRING([--with-master=MASTER],[Specify master server hostname @<:@console@:>@]), AS_HELP_STRING([--with-master=MASTER],[Specify master server hostname @<:@console@:>@]),
[case "$withval" in [case "$withval" in
yes|no) yes|no)
AC_DEFINE_UNQUOTED(MASTERHOST, "console") AC_DEFINE_UNQUOTED(MASTERHOST, "console")
@ -94,9 +100,29 @@ AC_ARG_WITH(master,
[AC_DEFINE_UNQUOTED(MASTERHOST, "console") [AC_DEFINE_UNQUOTED(MASTERHOST, "console")
AC_MSG_RESULT('console')]) AC_MSG_RESULT('console')])
AC_MSG_CHECKING(for client configuration filename)
AC_ARG_WITH(ccffile,
AS_HELP_STRING([--with-ccffile=CFFILE],[Specify client config filename @<:@SYSCONFDIR/console.cf@:>@]),
[case "$withval" in
yes|no)
AC_DEFINE_UNQUOTED(CLIENTCONFIGFILE, [SYSCONFDIR "/console.cf"])
AC_MSG_RESULT('$sysconfdir/console.cf')
;;
[[\\/]]* | ?:[[\\/]]* )
AC_DEFINE_UNQUOTED(CLIENTCONFIGFILE, ["$withval"])
AC_MSG_RESULT('$withval')
;;
*)
AC_DEFINE_UNQUOTED(CLIENTCONFIGFILE, [SYSCONFDIR "/$withval"])
AC_MSG_RESULT('$sysconfdir/$withval')
;;
esac],
[AC_DEFINE_UNQUOTED(CLIENTCONFIGFILE, [SYSCONFDIR "/console.cf"])
AC_MSG_RESULT('$sysconfdir/console.cf')])
AC_MSG_CHECKING(for configuration filename) AC_MSG_CHECKING(for configuration filename)
AC_ARG_WITH(cffile, AC_ARG_WITH(cffile,
AC_HELP_STRING([--with-cffile=CFFILE],[Specify config filename @<:@SYSCONFDIR/conserver.cf@:>@]), AS_HELP_STRING([--with-cffile=CFFILE],[Specify config filename @<:@SYSCONFDIR/conserver.cf@:>@]),
[case "$withval" in [case "$withval" in
yes|no) yes|no)
AC_DEFINE_UNQUOTED(CONFIGFILE, [SYSCONFDIR "/conserver.cf"]) AC_DEFINE_UNQUOTED(CONFIGFILE, [SYSCONFDIR "/conserver.cf"])
@ -116,7 +142,7 @@ AC_ARG_WITH(cffile,
AC_MSG_CHECKING(for password filename) AC_MSG_CHECKING(for password filename)
AC_ARG_WITH(pwdfile, AC_ARG_WITH(pwdfile,
AC_HELP_STRING([--with-pwdfile=PWDFILE],[Specify password filename @<:@SYSCONFDIR/conserver.passwd@:>@]), AS_HELP_STRING([--with-pwdfile=PWDFILE],[Specify password filename @<:@SYSCONFDIR/conserver.passwd@:>@]),
[case "$withval" in [case "$withval" in
yes|no) yes|no)
AC_DEFINE_UNQUOTED(PASSWDFILE, [SYSCONFDIR "/conserver.passwd"]) AC_DEFINE_UNQUOTED(PASSWDFILE, [SYSCONFDIR "/conserver.passwd"])
@ -136,7 +162,7 @@ AC_ARG_WITH(pwdfile,
AC_MSG_CHECKING(for log filename) AC_MSG_CHECKING(for log filename)
AC_ARG_WITH(logfile, AC_ARG_WITH(logfile,
AC_HELP_STRING([--with-logfile=LOGFILE],[Specify log filename @<:@/var/log/conserver@:>@]), AS_HELP_STRING([--with-logfile=LOGFILE],[Specify log filename @<:@/var/log/conserver@:>@]),
[case "$withval" in [case "$withval" in
yes|no) yes|no)
AC_DEFINE_UNQUOTED(LOGFILEPATH, "/var/log/conserver") AC_DEFINE_UNQUOTED(LOGFILEPATH, "/var/log/conserver")
@ -153,7 +179,7 @@ AC_ARG_WITH(logfile,
AC_SUBST(PIDFILE) AC_SUBST(PIDFILE)
AC_MSG_CHECKING(for PID filename) AC_MSG_CHECKING(for PID filename)
AC_ARG_WITH(pidfile, AC_ARG_WITH(pidfile,
AC_HELP_STRING([--with-pidfile=PIDFILE],[Specify PID filepath @<:@/var/run/conserver.pid@:>@]), AS_HELP_STRING([--with-pidfile=PIDFILE],[Specify PID filepath @<:@/var/run/conserver.pid@:>@]),
[case "$withval" in [case "$withval" in
yes|no) yes|no)
PIDFILE="/var/run/conserver.pid" PIDFILE="/var/run/conserver.pid"
@ -168,7 +194,7 @@ AC_MSG_RESULT('$PIDFILE')
AC_MSG_CHECKING(for MAXMEMB setting) AC_MSG_CHECKING(for MAXMEMB setting)
AC_ARG_WITH(maxmemb, AC_ARG_WITH(maxmemb,
AC_HELP_STRING([--with-maxmemb=MAXMEMB],[Specify maximum consoles per process @<:@16@:>@]), AS_HELP_STRING([--with-maxmemb=MAXMEMB],[Specify maximum consoles per process @<:@16@:>@]),
[case "$withval" in [case "$withval" in
yes|no) yes|no)
AC_DEFINE_UNQUOTED(MAXMEMB, 16) AC_DEFINE_UNQUOTED(MAXMEMB, 16)
@ -190,7 +216,7 @@ AC_ARG_WITH(maxmemb,
AC_MSG_CHECKING(for connect() timeout) AC_MSG_CHECKING(for connect() timeout)
AC_ARG_WITH(timeout, AC_ARG_WITH(timeout,
AC_HELP_STRING([--with-timeout=TIMEOUT],[Specify connect() timeout in seconds @<:@10@:>@]), AS_HELP_STRING([--with-timeout=TIMEOUT],[Specify connect() timeout in seconds @<:@10@:>@]),
[if expr "$withval" : '[[0-9]]*$' >/dev/null 2>&1 && [if expr "$withval" : '[[0-9]]*$' >/dev/null 2>&1 &&
test "$withval" -gt 0 -a "$withval" -lt 300; then test "$withval" -gt 0 -a "$withval" -lt 300; then
AC_DEFINE_UNQUOTED(CONNECTTIMEOUT, $withval) AC_DEFINE_UNQUOTED(CONNECTTIMEOUT, $withval)
@ -204,7 +230,7 @@ AC_ARG_WITH(timeout,
AC_MSG_CHECKING(whether to trust reverse DNS) AC_MSG_CHECKING(whether to trust reverse DNS)
AC_ARG_WITH(trustrevdns, AC_ARG_WITH(trustrevdns,
AC_HELP_STRING([--with-trustrevdns],[Trust reverse DNS information]), AS_HELP_STRING([--with-trustrevdns],[Trust reverse DNS information]),
[case "$withval" in [case "$withval" in
yes) yes)
AC_DEFINE(TRUST_REVERSE_DNS) AC_DEFINE(TRUST_REVERSE_DNS)
@ -215,6 +241,77 @@ AC_ARG_WITH(trustrevdns,
;; ;;
esac],[AC_MSG_RESULT(no)]) esac],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(whether to display extended messages)
AC_ARG_WITH(extmsgs,
AS_HELP_STRING([--with-extmsgs],[Produce extended messages]),
[case "$withval" in
yes)
AC_DEFINE(USE_EXTENDED_MESSAGES)
AC_MSG_RESULT(yes)
;;
*)
AC_MSG_RESULT(no)
;;
esac],[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(whether to use Unix domain sockets)
cons_with_uds="NO"
AC_ARG_WITH(uds,
AS_HELP_STRING([--with-uds@<:@=DIR@:>@ ],
[Use Unix domain sockets for client/server communication @<:@/tmp/conserver@:>@]),
[case "$withval" in
yes)
AC_DEFINE_UNQUOTED(UDSDIR, "/tmp/conserver")
AC_DEFINE(USE_UNIX_DOMAIN_SOCKETS)
AC_MSG_RESULT([/tmp/conserver])
cons_with_uds="YES"
;;
no)
AC_MSG_RESULT(no)
;;
*)
AC_DEFINE_UNQUOTED(UDSDIR, "$withval")
AC_DEFINE(USE_UNIX_DOMAIN_SOCKETS)
AC_MSG_RESULT('$withval')
cons_with_uds="YES"
if expr "$withval" : '/' >/dev/null 2>&1; then
:
else
echo "*** WARNING *** you may have better success using a fully-qualified path"
echo "*** WARNING *** instead of '$withval'"
fi
;;
esac],[AC_MSG_RESULT(no)])
use_dash_r=no
AC_MSG_CHECKING(whether to use -R paths as well as -L)
AC_ARG_WITH(rpath,
AS_HELP_STRING([--with-rpath],[Use -R as well as -L for libraries]),
[case "$withval" in
yes|no)
AC_MSG_RESULT($withval)
use_dash_r=$withval
;;
*)
AC_MSG_RESULT(no)
;;
esac],
[AC_MSG_RESULT(no)])
AC_MSG_CHECKING(whether we are building for a Cyclades TS)
AC_ARG_WITH(cycladests,
AS_HELP_STRING([--with-cycladests],[Build for a Cyclades TS]),
[case "$withval" in
yes)
AC_DEFINE(FOR_CYCLADES_TS)
AC_MSG_RESULT(yes)
;;
*)
AC_MSG_RESULT(no)
;;
esac],[AC_MSG_RESULT(no)])
dnl ### Check for compiler et al. ################################### dnl ### Check for compiler et al. ###################################
AC_PROG_CC AC_PROG_CC
AC_PROG_INSTALL AC_PROG_INSTALL
@ -244,7 +341,7 @@ if test "$ac_cv_sys_posix_termios" != "yes"; then
AC_MSG_ERROR([POSIX termios interface required]) AC_MSG_ERROR([POSIX termios interface required])
fi fi
AC_CHECK_HEADERS(unistd.h getopt.h sys/vlimit.h sys/resource.h ttyent.h sys/ttold.h sys/uio.h sys/ioctl_compat.h usersec.h sys/select.h stropts.h sys/audit.h shadow.h sys/time.h crypt.h sysexits.h types.h sys/sockio.h sys/param.h) AC_CHECK_HEADERS(unistd.h getopt.h sys/vlimit.h sys/resource.h ttyent.h sys/ttold.h sys/uio.h sys/ioctl_compat.h usersec.h sys/select.h stropts.h sys/audit.h shadow.h sys/time.h crypt.h sysexits.h types.h sys/sockio.h sys/param.h sys/un.h)
dnl sys/proc.h needs sys/param.h on openbsd, apparently dnl sys/proc.h needs sys/param.h on openbsd, apparently
AC_CHECK_HEADERS(sys/proc.h, [], [], AC_CHECK_HEADERS(sys/proc.h, [], [],
[#if HAVE_SYS_PARAM_H [#if HAVE_SYS_PARAM_H
@ -256,6 +353,8 @@ AC_HEADER_SYS_WAIT
AC_TYPE_MODE_T AC_TYPE_MODE_T
AC_TYPE_SIGNAL AC_TYPE_SIGNAL
AC_TYPE_PID_T AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_CHECK_TYPE([sig_atomic_t],, AC_CHECK_TYPE([sig_atomic_t],,
AC_DEFINE(sig_atomic_t, volatile int, AC_DEFINE(sig_atomic_t, volatile int,
@ -299,13 +398,18 @@ AC_SEARCH_LIBS(crypt,crypt)
AC_SUBST(CONSLIBS) AC_SUBST(CONSLIBS)
AC_SUBST(CONSCPPFLAGS) AC_SUBST(CONSCPPFLAGS)
AC_SUBST(CONSLDFLAGS) AC_SUBST(CONSLDFLAGS)
cons_with_libwrap="NO"
AC_ARG_WITH(libwrap, AC_ARG_WITH(libwrap,
AC_HELP_STRING([--with-libwrap@<:@=PATH@:>@], AS_HELP_STRING([--with-libwrap@<:@=PATH@:>@],
[Compile in libwrap (tcp_wrappers) support]), [Compile in libwrap (tcp_wrappers) support]),
[if test "$withval" != "no"; then [if test "$withval" != "no"; then
if test "$withval" != "yes"; then if test "$withval" != "yes"; then
WRAPCPPFLAGS="-I$withval/include" WRAPCPPFLAGS="-I$withval/include"
WRAPLDFLAGS="-L$withval/lib" if test "$use_dash_r" != "yes"; then
WRAPLDFLAGS="-L$withval/lib"
else
WRAPLDFLAGS="-L$withval/lib -R$withval/lib"
fi
else else
WRAPCPPFLAGS="" WRAPCPPFLAGS=""
WRAPLDFLAGS="" WRAPLDFLAGS=""
@ -326,6 +430,7 @@ AC_ARG_WITH(libwrap,
int deny_severity = 0; int deny_severity = 0;
],[hosts_access((void *)0)], ],[hosts_access((void *)0)],
[AC_MSG_RESULT(yes) [AC_MSG_RESULT(yes)
cons_with_libwrap="YES"
AC_DEFINE(USE_LIBWRAP) AC_DEFINE(USE_LIBWRAP)
CONSLIBS="$CONSLIBS -lwrap" CONSLIBS="$CONSLIBS -lwrap"
CONSLDFLAGS="$CONSLDFLAGS $WRAPLDFLAGS" CONSLDFLAGS="$CONSLDFLAGS $WRAPLDFLAGS"
@ -338,6 +443,7 @@ AC_ARG_WITH(libwrap,
int deny_severity = 0; int deny_severity = 0;
],[hosts_access((void *)0)], ],[hosts_access((void *)0)],
[AC_MSG_RESULT(yes) [AC_MSG_RESULT(yes)
cons_with_libwrap="YES"
AC_DEFINE(USE_LIBWRAP) AC_DEFINE(USE_LIBWRAP)
CONSLIBS="$CONSLIBS -lwrap -lnsl" CONSLIBS="$CONSLIBS -lwrap -lnsl"
CONSLDFLAGS="$CONSLDFLAGS $WRAPLDFLAGS" CONSLDFLAGS="$CONSLDFLAGS $WRAPLDFLAGS"
@ -349,13 +455,18 @@ AC_ARG_WITH(libwrap,
fi] fi]
) )
cons_with_openssl="NO"
AC_ARG_WITH(openssl, AC_ARG_WITH(openssl,
AC_HELP_STRING([--with-openssl@<:@=PATH@:>@], AS_HELP_STRING([--with-openssl@<:@=PATH@:>@],
[Compile in OpenSSL support]), [Compile in OpenSSL support]),
[if test "$withval" != "no"; then [if test "$withval" != "no"; then
if test "$withval" != "yes"; then if test "$withval" != "yes"; then
OPENSSLCPPFLAGS="-I$withval/include" OPENSSLCPPFLAGS="-I$withval/include"
OPENSSLLDFLAGS="-L$withval/lib" if test "$use_dash_r" != "yes"; then
OPENSSLLDFLAGS="-L$withval/lib"
else
OPENSSLLDFLAGS="-L$withval/lib -R$withval/lib"
fi
else else
OPENSSLCPPFLAGS="" OPENSSLCPPFLAGS=""
OPENSSLLDFLAGS="" OPENSSLLDFLAGS=""
@ -375,6 +486,7 @@ AC_ARG_WITH(openssl,
AC_TRY_LINK([#include <openssl/ssl.h> AC_TRY_LINK([#include <openssl/ssl.h>
],[SSL_library_init()], ],[SSL_library_init()],
[AC_MSG_RESULT(yes) [AC_MSG_RESULT(yes)
cons_with_openssl="YES"
AC_DEFINE(HAVE_OPENSSL) AC_DEFINE(HAVE_OPENSSL)
have_openssl=yes], have_openssl=yes],
[AC_MSG_RESULT(no)])],) [AC_MSG_RESULT(no)])],)
@ -387,13 +499,18 @@ AC_ARG_WITH(openssl,
fi] fi]
) )
cons_with_dmalloc="NO"
AC_ARG_WITH(dmalloc, AC_ARG_WITH(dmalloc,
AC_HELP_STRING([--with-dmalloc@<:@=PATH@:>@], AS_HELP_STRING([--with-dmalloc@<:@=PATH@:>@],
[Compile in dmalloc support]), [Compile in dmalloc support]),
[if test "$withval" != "no"; then [if test "$withval" != "no"; then
if test "$withval" != "yes"; then if test "$withval" != "yes"; then
DMALLOCCPPFLAGS="-I$withval/include" DMALLOCCPPFLAGS="-I$withval/include"
DMALLOCLDFLAGS="-L$withval/lib" if test "$use_dash_r" != "yes"; then
DMALLOCLDFLAGS="-L$withval/lib"
else
DMALLOCLDFLAGS="-L$withval/lib -R$withval/lib"
fi
else else
DMALLOCCPPFLAGS="" DMALLOCCPPFLAGS=""
DMALLOCLDFLAGS="" DMALLOCLDFLAGS=""
@ -413,6 +530,7 @@ AC_ARG_WITH(dmalloc,
AC_TRY_LINK([#include <dmalloc.h> AC_TRY_LINK([#include <dmalloc.h>
],[dmalloc_debug(0)], ],[dmalloc_debug(0)],
[AC_MSG_RESULT(yes) [AC_MSG_RESULT(yes)
cons_with_dmalloc="YES"
AC_DEFINE(HAVE_DMALLOC) AC_DEFINE(HAVE_DMALLOC)
have_dmalloc=yes], have_dmalloc=yes],
[AC_MSG_RESULT(no)])],) [AC_MSG_RESULT(no)])],)
@ -461,9 +579,10 @@ dnl else
dnl AC_MSG_RESULT(no) dnl AC_MSG_RESULT(no)
dnl fi],[AC_MSG_RESULT(no)]) dnl fi],[AC_MSG_RESULT(no)])
cons_with_pam="NO"
AC_MSG_CHECKING(for PAM support) AC_MSG_CHECKING(for PAM support)
AC_ARG_WITH(pam, AC_ARG_WITH(pam,
AC_HELP_STRING([--with-pam], AS_HELP_STRING([--with-pam],
[Enable PAM support]), [Enable PAM support]),
[if test "$withval" = yes; then [if test "$withval" = yes; then
oLIBS="$LIBS" oLIBS="$LIBS"
@ -473,6 +592,7 @@ AC_ARG_WITH(pam,
AC_MSG_CHECKING(for PAM library -lpam) AC_MSG_CHECKING(for PAM library -lpam)
AC_TRY_LINK_FUNC([pam_start], AC_TRY_LINK_FUNC([pam_start],
[AC_MSG_RESULT(yes) [AC_MSG_RESULT(yes)
cons_with_pam="YES"
AC_DEFINE(HAVE_PAM) AC_DEFINE(HAVE_PAM)
CONSLIBS="$CONSLIBS -lpam"], CONSLIBS="$CONSLIBS -lpam"],
[LIBS="$LIBS -ldl" [LIBS="$LIBS -ldl"
@ -480,6 +600,7 @@ AC_ARG_WITH(pam,
AC_MSG_CHECKING(for PAM library -lpam with -ldl) AC_MSG_CHECKING(for PAM library -lpam with -ldl)
AC_TRY_LINK_FUNC([pam_end], AC_TRY_LINK_FUNC([pam_end],
[AC_MSG_RESULT(yes) [AC_MSG_RESULT(yes)
cons_with_pam="YES"
AC_DEFINE(HAVE_PAM) AC_DEFINE(HAVE_PAM)
CONSLIBS="$CONSLIBS -lpam -ldl"], CONSLIBS="$CONSLIBS -lpam -ldl"],
[AC_MSG_RESULT(no)])])],) [AC_MSG_RESULT(no)])])],)
@ -504,8 +625,14 @@ AC_CHECK_HEADERS(pty.h libutil.h util.h)
AC_CHECK_LIB(util, openpty) AC_CHECK_LIB(util, openpty)
AC_CHECK_FUNCS(openpty) AC_CHECK_FUNCS(openpty)
AC_CHECK_FUNCS(getopt strerror getrlimit getsid setsid getuserattr setgroups tcgetpgrp tcsetpgrp tcgetattr tcsetattr tcsendbreak setpgrp getutent setttyent getspnam setlinebuf setvbuf ptsname grantpt unlockpt sigaction setsockopt getdtablesize putenv memset memcpy memcmp memmove sysconf getlogin inet_aton setproctitle) AC_CHECK_FUNCS(getopt strerror getrlimit getsid setsid getuserattr setgroups tcgetpgrp tcsetpgrp tcgetattr tcsetattr tcsendbreak setpgrp getutent setttyent getspnam setlinebuf setvbuf ptsname grantpt unlockpt sigaction setsockopt getdtablesize putenv memset memcpy memcmp memmove sysconf getlogin inet_aton setproctitle gettimeofday strlcpy)
AC_FUNC_SETPGRP if test "$with_cycladests" != "yes"; then
AC_FUNC_SETPGRP
else
AC_DEFINE(SETPGRP_VOID, 1, [Define if setpgrp is POSIX])
AC_MSG_NOTICE([Building for a Cyclades-TS: setting SETPGRP_VOID because we cannot test this in cross-compilation])
fi
AC_CHECK_FUNC(strcasecmp, AC_CHECK_FUNC(strcasecmp,
[AC_DEFINE(HAVE_STRCASECMP, 1, [Define if strcasecmp is available])], [AC_DEFINE(HAVE_STRCASECMP, 1, [Define if strcasecmp is available])],
[AC_CHECK_FUNC(stricmp, [AC_CHECK_FUNC(stricmp,
@ -522,3 +649,16 @@ dnl ### Create output files. #######################################
AC_CONFIG_FILES([Makefile conserver/Makefile conserver.cf/Makefile console/Makefile autologin/Makefile contrib/chat/Makefile]) AC_CONFIG_FILES([Makefile conserver/Makefile conserver.cf/Makefile console/Makefile autologin/Makefile contrib/chat/Makefile])
AC_CONFIG_FILES([conserver/conserver.rc], [chmod +x conserver/conserver.rc]) AC_CONFIG_FILES([conserver/conserver.rc], [chmod +x conserver/conserver.rc])
AC_OUTPUT AC_OUTPUT
[
echo "=============================================================="
echo " Feature Summary"
echo ""
echo " Unix domain sockets (--with-uds) : $cons_with_uds"
echo " TCP wrappers (--with-libwrap): $cons_with_libwrap"
echo " OpenSSL (--with-openssl): $cons_with_openssl"
echo " dmalloc (--with-dmalloc): $cons_with_dmalloc"
echo " PAM support (--with-pam) : $cons_with_pam"
echo ""
echo "=============================================================="
]

View File

@ -1,11 +1,11 @@
The two files you need to set up are the conserver.cf and conserver.passwd The two files you need to set up are the conserver.cf and conserver.passwd
files. See the sample conserver.cf and conserver.passwd files files. See the sample conserver.cf and conserver.passwd files for examples
for examples. You can start with those and then modify extensively. (installed in <DATADIR>/examples/conserver). You can start with those and
The man page for conserver.cf and conserver.passwd should explain the then modify extensively. The man page for conserver.cf and conserver.passwd
files with enough detail to get you going. should explain the files with enough detail to get you going.
That's about it. Good luck. That's about it. Good luck.
# #
# $Id: INSTALL,v 1.3 2003/07/04 18:21:21 bryan Exp $ # $Id: INSTALL,v 1.4 2005/05/21 13:47:18 bryan Exp $
# #

View File

@ -3,7 +3,8 @@ srcdir = @srcdir@
prefix = @prefix@ prefix = @prefix@
mandir = @mandir@ mandir = @mandir@
sysconfdir = @sysconfdir@ sysconfdir = @sysconfdir@
exampledir = $(prefix)/share/examples/conserver datadir = @datadir@
exampledir = $(datadir)/examples/conserver
### Installation programs and flags ### Installation programs and flags
INSTALL = @INSTALL@ INSTALL = @INSTALL@

View File

@ -91,9 +91,10 @@ default * {
default cyclades { default cyclades {
# sets up /dev/ttyC0 through /dev/ttyC31, for a 32 port card # sets up /dev/ttyC0 through /dev/ttyC31, for a 32 port card
# referenced as ports 1 through 32
type device; type device;
device /dev/ttyC.; device /dev/ttyC.;
devicesubst ,.d; devicesubst .=Pd;
portbase -1; portbase -1;
portinc 1; portinc 1;
host none; # not really used, since devicesubst doesn't use it host none; # not really used, since devicesubst doesn't use it

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
.\" $Id: conserver.passwd.man,v 1.9 2003/07/04 20:20:52 bryan Exp $ .\" $Id: conserver.passwd.man,v 1.10 2004/01/08 16:12:33 bryan Exp $
.TH CONSERVER.PASSWD 5 "2003/07/04" "conserver-8.0.9" "conserver" .TH CONSERVER.PASSWD 5 "2004/01/08" "conserver-8.1.15" "conserver"
.SH NAME .SH NAME
conserver.passwd \- user access information for conserver.passwd \- user access information for
.BR conserver (8) .BR conserver (8)
@ -59,7 +59,8 @@ in the system
If PAM support has been enabled If PAM support has been enabled
.RB ( --with-pam ), .RB ( --with-pam ),
PAM lookups will be done instead of PAM lookups will be done instead of
.BR passwd " (or " shadow ") lookups." .BR passwd " (or " shadow ") lookups"
(you may need to edit /etc/pam.conf or create /etc/pam.d/conserver).
If this field is empty, password checking is bypassed for this user. If this field is empty, password checking is bypassed for this user.
.SH EXAMPLE .SH EXAMPLE
.TP 24 .TP 24

View File

@ -48,16 +48,17 @@ default cisco { type host; portbase 2000; portinc 1; }
default xyplex { type host; portbase 2000; portinc 100; } default xyplex { type host; portbase 2000; portinc 100; }
# this is a cyclades card referenced with /dev/ttyC0 through /dev/ttyC31 # this is a cyclades card referenced with /dev/ttyC0 through /dev/ttyC31
# (referenced as ports 1 through 32 in conserver.cf)
# we set the various port calculation bits and pattern substitution to # we set the various port calculation bits and pattern substitution to
# come up with a generic definition # come up with a generic definition
default cyclades { type device; device /dev/ttyC&; baud 9600; parity none; default cyclades { type device; device /dev/ttyC&; baud 9600; parity none;
devicesubst .&d; portbase -1; portinc 1; host unused; } devicesubst &=Pd; portbase -1; portinc 1; host unused; }
## this is a term server accessed with an ssh command ## this is a term server accessed with an ssh command
# it too uses pattern substitution and such to get the job done # it too uses pattern substitution and such to get the job done
default ciscossh { type exec; portbase 2000; portinc 1; default ciscossh { type exec; portbase 2000; portinc 1;
exec /usr/local/bin/ssh -p P -l tsuser H; exec /usr/local/bin/ssh -p P -l tsuser H;
execsubst HPd; } execsubst H=hs,P=Pd; }
# ------- set the global default for the first conserver host ------- # ------- set the global default for the first conserver host -------

View File

@ -47,16 +47,17 @@ default cisco { type host; portbase 2000; portinc 1; }
default xyplex { type host; portbase 2000; portinc 100; } default xyplex { type host; portbase 2000; portinc 100; }
# this is a cyclades card referenced with /dev/ttyC0 through /dev/ttyC31 # this is a cyclades card referenced with /dev/ttyC0 through /dev/ttyC31
# (referenced as ports 1 through 32 in conserver.cf)
# we set the various port calculation bits and pattern substitution to # we set the various port calculation bits and pattern substitution to
# come up with a generic definition # come up with a generic definition
default cyclades { type device; device /dev/ttyC&; baud 9600; parity none; default cyclades { type device; device /dev/ttyC&; baud 9600; parity none;
devicesubst .&d; portbase -1; portinc 1; host unused; } devicesubst &=Pd; portbase -1; portinc 1; host unused; }
## this is a term server accessed with an ssh command ## this is a term server accessed with an ssh command
# it too uses pattern substitution and such to get the job done # it too uses pattern substitution and such to get the job done
default ciscossh { type exec; portbase 2000; portinc 1; default ciscossh { type exec; portbase 2000; portinc 1;
exec /usr/local/bin/ssh -p P -l tsuser H; exec /usr/local/bin/ssh -p P -l tsuser H;
execsubst HPd; } execsubst H=hs,P=Pd; }
# ------- define the consoles on ts1.conserver.com -------- # ------- define the consoles on ts1.conserver.com --------

View File

@ -9,6 +9,7 @@
<META name="author" content= <META name="author" content=
"Bryan Stansell &lt;bryan@conserver.com&gt;"> "Bryan Stansell &lt;bryan@conserver.com&gt;">
<LINK rel="SHORTCUT ICON" href="conserver.ico"> <LINK rel="SHORTCUT ICON" href="conserver.ico">
<LINK rel="icon" href="conserver.ico">
<TITLE>Conserver</TITLE> <TITLE>Conserver</TITLE>
@ -35,7 +36,14 @@
<TD colspan="2" align="center">Please pick your closest <TD colspan="2" align="center">Please pick your closest
mirror: &nbsp;&nbsp;<A href= mirror: &nbsp;&nbsp;<A href=
"http://planetmirror.com/pub/conserver/">Australia</A> "http://planetmirror.com/pub/conserver/">Australia</A>
&nbsp;&nbsp;<A href="http://www.conserver.com/">US &nbsp;&nbsp;<A href=
"http://conserver.linux-mirror.org/">Germany</A>
&nbsp;&nbsp;<A href=
"http://conserver.webdesign-zdg.de/">Germany</A>
&nbsp;&nbsp;<A href=
"http://conserver.oss-mirror.org/">Ireland</A>
&nbsp;&nbsp;<A href="http://conserver.rinet.ru/">Russia</A>
&nbsp;&nbsp;<A href="http://www.conserver.com/">US-West
(Primary)</A><BR> (Primary)</A><BR>
<BR> <BR>
</TD> </TD>
@ -55,11 +63,11 @@
<INPUT type="HIDDEN" name="method" value="and"> <INPUT <INPUT type="HIDDEN" name="method" value="and"> <INPUT
type="HIDDEN" name="format" value="builtin-long"> type="HIDDEN" name="format" value="builtin-long">
<INPUT type="HIDDEN" name="sort" value="score"> <INPUT <INPUT type="HIDDEN" name="sort" value="score"> <INPUT
type="HIDDEN" name="config" value="htdig"> <INPUT type= type="HIDDEN" name="config" value="conserver.com">
"HIDDEN" name="restrict" value=""> <INPUT type="HIDDEN" <INPUT type="HIDDEN" name="restrict" value=""> <INPUT
name="exclude" value=""> <INPUT type="TEXT" size="20" type="HIDDEN" name="exclude" value=""> <INPUT type=
name="words" value=""> <INPUT type="SUBMIT" value= "TEXT" size="20" name="words" value=""> <INPUT type=
"Search"> "SUBMIT" value="Search">
</FORM> </FORM>
</TD> </TD>
</TR> </TR>
@ -158,36 +166,33 @@
He isn't actively developing it, however, according to He isn't actively developing it, however, according to
the website. Next, there's Kevin Braunsdorf's version at the website. Next, there's Kevin Braunsdorf's version at
<A href= <A href=
"ftp://ftp.physics.purdue.edu/pub/pundits/">ftp://ftp.physics.purdue.edu/pub/pundits/</A>. "http://www.npcguild.org/software/pundits/">http://www.npcguild.org/software/pundits/</A>.
Kevin is semi-actively working on his thread. Doesn't It doesn't look like Kevin is working on his thread ony
look like any new versions have been out since August more either. No new versions have been out since August
2000 (version 8.5), but maybe this info will be out of 2000 (version 8.5), but maybe this info will be out of
date by the time you read this. Lastly, the conserver.com date by the time you read this (I last checked Feb 10,
version is based on Kevin's "5.21-Beta" distribution, but 2004). Lastly, the conserver.com version is based on
since <B>HEAVILY</B> modified and enhanced (more details Kevin's "5.21-Beta" distribution, but since
in the "Origin" section above).</P> <B>HEAVILY</B> modified and enhanced (more details in the
"Origin" section above).</P>
<P>If I were looking for a conserver package I would <P>If I were looking for a conserver package I would
either use Kevin's latest distribution or the definitely use the conserver.com distribution. Why? It's
conserver.com distribution. Which one? Well, obviously actively maintained, has many more features than the
I'm biased and believe the conserver.com distribution other versions (see <A href="CHANGES">CHANGES</A> for a
should be your choice, but Kevin's does have UPS (serial semi-scary history), and has an active user community.
port line toggling bits) that the conserver.com version Kevin's version does have UPS support (basic serial port
doesn't have. What does the conserver.com distribution line toggling bits) which is missing in the conserver.com
have? Well, in reality, too many things to list. You'll version, but no one has asked me for it, so does anyone
have to look at the <A href="CHANGES">CHANGES</A> file actually need it?</P>
and see the enhancements, bug fixes, and general
development since the original. Don't let the version
numbers fool you - you'll have to compare and contrast
for yourself.</P>
<H3>Downloading</H3> <H3>Downloading</H3>
<P>The current version, released on Dec 10, 2003, is <A <P>The current version, released on Dec 31, 2006, is <A
href="8.0.9.tar.gz">8.0.9.tar.gz</A>. You can get it via href="8.1.15.tar.gz">8.1.15.tar.gz</A>. You can get it
<A href= via <A href=
"ftp://ftp.conserver.com/conserver/8.0.9.tar.gz">FTP</A> "ftp://ftp.conserver.com/conserver/8.1.15.tar.gz">FTP</A>
or <A href="8.0.9.tar.gz">HTTP</A>. See the <A href= or <A href="8.1.15.tar.gz">HTTP</A>. See the <A href=
"CHANGES">CHANGES</A> file for information on the latest "CHANGES">CHANGES</A> file for information on the latest
updates.</P> updates.</P>
@ -208,6 +213,11 @@
<P>Check the <A href="INSTALL">INSTALL</A> file for <P>Check the <A href="INSTALL">INSTALL</A> file for
instructions.</P> instructions.</P>
<H3>Online Documentation</H3>
<P>I've put a small set of documentation <A href=
"docs/">here</A>. I'm hoping to expand it over time.</P>
<H3>Systems Tested</H3> <H3>Systems Tested</H3>
<P>Here's a list of systems that I've been told can <P>Here's a list of systems that I've been told can
@ -226,7 +236,11 @@
<LI>DEC Tru64 4.0/5.1, native cc</LI> <LI>DEC Tru64 4.0/5.1, native cc</LI>
<LI>FreeBSD 4.2/4.8/5.1 (x86), gcc</LI> <LI>FreeBSD 4.x (i386) gcc</LI>
<LI>FreeBSD 5.x (i386/amd64/sparc64) gcc</LI>
<LI>FreeBSD 6.x/7.x (i386/amd64/sparc64/ia64) gcc</LI>
<LI>HP-UX 10.20, gcc</LI> <LI>HP-UX 10.20, gcc</LI>
@ -247,6 +261,9 @@
<LI>Solaris 2.5.1 thru 9 (sparc/x86), gcc</LI> <LI>Solaris 2.5.1 thru 9 (sparc/x86), gcc</LI>
<LI>Solaris 7/8, native cc</LI> <LI>Solaris 7/8, native cc</LI>
<LI>Solaris 10 and Solaris Express (build 33) (x86),
gcc and native cc</LI>
</UL> </UL>
<H3>Other Good Information</H3> <H3>Other Good Information</H3>

View File

@ -6,7 +6,10 @@ exec_prefix = @exec_prefix@
sbindir = @sbindir@ sbindir = @sbindir@
sysconfdir = @sysconfdir@ sysconfdir = @sysconfdir@
mandir = @mandir@ mandir = @mandir@
exampledir = $(prefix)/share/examples/conserver datadir = @datadir@
libdir = @libdir@
pkglibdir = $(libdir)/conserver
exampledir = $(datadir)/examples/conserver
### Installation programs and flags ### Installation programs and flags
INSTALL = @INSTALL@ INSTALL = @INSTALL@
@ -62,5 +65,7 @@ install: conserver
$(INSTALL) conserver.man $(DESTDIR)$(mandir)/man8/conserver.8 $(INSTALL) conserver.man $(DESTDIR)$(mandir)/man8/conserver.8
$(MKDIR) $(DESTDIR)$(exampledir) $(MKDIR) $(DESTDIR)$(exampledir)
$(INSTALL) conserver.rc $(DESTDIR)$(exampledir) $(INSTALL) conserver.rc $(DESTDIR)$(exampledir)
$(MKDIR) $(DESTDIR)$(pkglibdir)
$(INSTALL) convert $(DESTDIR)$(pkglibdir)/convert
.PHONY: clean distclean install .PHONY: clean distclean install

View File

@ -1,5 +1,5 @@
/* /*
* $Id: access.c,v 5.71 2003/11/20 13:56:38 bryan Exp $ * $Id: access.c,v 5.73 2004/05/23 16:44:25 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -171,7 +171,8 @@ AccType(addr, peername)
hname = he->h_aliases[a++]) { hname = he->h_aliases[a++]) {
if ((revNames[a] = StrDup(hname)) == (char *)0) if ((revNames[a] = StrDup(hname)) == (char *)0)
break; break;
CONDDEBUG((1,"AccType(): revNames[%d]='%s'", a, hname)); CONDDEBUG((1, "AccType(): revNames[%d]='%s'", a,
hname));
} }
} }
} }
@ -280,11 +281,26 @@ SetDefAccess(pAddr, pHost)
char *pHost; char *pHost;
#endif #endif
{ {
char *pcDomain;
char *addr;
ACCESS *a; ACCESS *a;
while (pACList != (ACCESS *)0) {
a = pACList->pACnext;
DestroyAccessList(pACList);
pACList = a;
}
#if USE_UNIX_DOMAIN_SOCKETS
if ((pACList = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0)
OutOfMem();
if ((pACList->pcwho = StrDup("127.0.0.1")) == (char *)0)
OutOfMem();
pACList->ctrust = 'a';
CONDDEBUG((1, "SetDefAccess(): trust=%c, who=%s", pACList->ctrust,
pACList->pcwho));
#else
while (pAddr->s_addr != (in_addr_t) 0) { while (pAddr->s_addr != (in_addr_t) 0) {
char *addr;
addr = inet_ntoa(*pAddr); addr = inet_ntoa(*pAddr);
if ((a = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0) if ((a = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0)
OutOfMem(); OutOfMem();
@ -298,21 +314,7 @@ SetDefAccess(pAddr, pHost)
pACList->pcwho)); pACList->pcwho));
pAddr++; pAddr++;
} }
#endif
if ((char *)0 == (pcDomain = strchr(pHost, '.')))
return;
++pcDomain;
if ((a = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0)
OutOfMem();
if ((a->pcwho = StrDup(pcDomain)) == (char *)0)
OutOfMem();
a->ctrust = 'a';
a->pACnext = pACList;
pACList = a;
CONDDEBUG((1, "SetDefAccess(): trust=%c, who=%s", pACList->ctrust,
pACList->pcwho));
} }
void void

View File

@ -1,5 +1,5 @@
/* /*
* $Id: client.c,v 5.79 2003/11/28 23:36:02 bryan Exp $ * $Id: client.c,v 5.90 2006/04/03 13:32:08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -41,6 +41,7 @@
#include <access.h> #include <access.h>
#include <client.h> #include <client.h>
#include <group.h> #include <group.h>
#include <readcfg.h>
#if defined(USE_LIBWRAP) #if defined(USE_LIBWRAP)
#include <syslog.h> #include <syslog.h>
@ -67,9 +68,7 @@ FindWrite(pCE)
* most recent or some such... I guess it doesn't matter that * most recent or some such... I guess it doesn't matter that
* much. * much.
*/ */
if (pCE->pCLwr != (CONSCLIENT *)0 || pCE->fronly || if (pCE->pCLwr != (CONSCLIENT *)0 || pCE->fronly)
!(pCE->fup && pCE->ioState == ISNORMAL &&
pCE->initfile == (CONSFILE *)0))
return; return;
for (pCL = pCE->pCLon; (CONSCLIENT *)0 != pCL; pCL = pCL->pCLnext) { for (pCL = pCE->pCLon; (CONSCLIENT *)0 != pCL; pCL = pCL->pCLnext) {
@ -89,178 +88,153 @@ FindWrite(pCE)
} }
} }
/* replay last iBack lines of the log file upon connect to console (ksb) void
#if PROTOTYPES
BumpClient(CONSENT *pCE, char *message)
#else
BumpClient(pCE, message)
CONSENT *pCE;
char *message;
#endif
{
if ((CONSCLIENT *)0 == pCE->pCLwr)
return;
if ((char *)0 != message)
FileWrite(pCE->pCLwr->fd, FLAGFALSE, message, -1);
pCE->pCLwr->fwantwr = 0;
pCE->pCLwr->fwr = 0;
pCE->pCLwr = (CONSCLIENT *)0;
}
/* replay last 'back' lines of the log file upon connect to console (ksb)
* *
* NB: we know the console might be spewing when the replay happens, * NB: we know the console might be spewing when the replay happens,
* we want to just output what is in the log file and get out, * we want to just output what is in the log file and get out,
* so we don't drop chars... * so we don't drop chars...
*/ */
#define REPLAYBUFFER 4096
void void
#if PROTOTYPES #if PROTOTYPES
Replay(CONSENT *pCE, CONSFILE *fdOut, int iBack) Replay(CONSENT *pCE, CONSFILE *fdOut, unsigned short back)
#else #else
Replay(pCE, fdOut, iBack) Replay(pCE, fdOut, back)
CONSENT *pCE; CONSENT *pCE;
CONSFILE *fdOut; CONSFILE *fdOut;
int iBack; unsigned short back;
#endif #endif
{ {
CONSFILE *fdLog = (CONSFILE *)0; CONSFILE *fdLog = (CONSFILE *)0;
STRING *line = (STRING *)0;
off_t file_pos; off_t file_pos;
off_t buf_pos; off_t buf_pos;
char *buf; char *buf;
char *bp = (char *)0; char *bp = (char *)0;
char *s;
int r;
int ch; int ch;
struct stat stLog; struct stat stLog;
struct lines {
int is_mark;
STRING *line;
STRING *mark_end;
} *lines;
int n_lines;
int ln; int ln;
int i; int was_mark = 0;
int j;
int u;
int is_mark;
char dummy[4];
#if HAVE_DMALLOC && DMALLOC_MARK_REPLAY #if HAVE_DMALLOC && DMALLOC_MARK_REPLAY
unsigned long dmallocMarkReplay = 0; unsigned long dmallocMarkReplay = 0;
#endif #endif
if (pCE != (CONSENT *)0) { if (pCE != (CONSENT *)0 && pCE->logfile != (char *)0)
fdLog = pCE->fdlog; fdLog = FileOpen(pCE->logfile, O_RDONLY, 0644);
/* no logfile and down and logfile defined? try and open it */
if (fdLog == (CONSFILE *)0 && !pCE->fup &&
pCE->logfile != (char *)0)
fdLog = FileOpen(pCE->logfile, O_RDONLY, 0644);
}
if (fdLog == (CONSFILE *)0) { if (fdLog == (CONSFILE *)0) {
FileWrite(fdOut, FLAGFALSE, "[no log file on this console]\r\n", FileWrite(fdOut, FLAGFALSE, "[no log file on this console]\r\n",
-1); -1);
return; return;
} }
/* find the size of the file
*/
if (0 != FileStat(fdLog, &stLog)) {
return;
}
#if HAVE_DMALLOC && DMALLOC_MARK_REPLAY #if HAVE_DMALLOC && DMALLOC_MARK_REPLAY
dmallocMarkReplay = dmalloc_mark(); dmallocMarkReplay = dmalloc_mark();
#endif #endif
file_pos = stLog.st_size - 1; /* find the size of the file
*/
if (0 != FileStat(fdLog, &stLog))
goto common_exit;
file_pos = stLog.st_size - 1; /* point at last byte */
buf_pos = file_pos + 1; buf_pos = file_pos + 1;
/* get space for the line information and initialize it if ((char *)0 == (buf = malloc(REPLAYBUFFER)))
*
* we allocate room for one more line than requested to be able to
* do the mark ranges
*/
if ((char *)0 == (buf = malloc(BUFSIZ))) {
OutOfMem(); OutOfMem();
} bp = buf + 1; /* just give it something - it resets below */
n_lines = iBack + 1;
lines = (struct lines *)calloc(n_lines, sizeof(*lines)); line = AllocString();
if ((struct lines *)0 == lines) {
OutOfMem();
}
for (i = 0; i < n_lines; i++) {
lines[i].mark_end = AllocString();
lines[i].line = AllocString();
}
ln = -1;
/* loop as long as there is data in the file or we have not found /* loop as long as there is data in the file or we have not found
* the requested number of lines * the requested number of lines
*/ */
while (file_pos >= 0) { ln = -1;
for (; file_pos >= 0; file_pos--, bp--) {
if (file_pos < buf_pos) { if (file_pos < buf_pos) {
int r;
/* read one buffer worth of data a buffer boundary /* read one buffer worth of data a buffer boundary
* *
* the first read will probably not get a full buffer but * the first read will probably not get a full buffer but
* the rest (as we work our way back in the file) should be * the rest (as we work our way back in the file) should be
*/ */
buf_pos = (file_pos / BUFSIZ) * BUFSIZ; buf_pos = (file_pos / REPLAYBUFFER) * REPLAYBUFFER;
if (FileSeek(fdLog, buf_pos, SEEK_SET) < 0) { if (FileSeek(fdLog, buf_pos, SEEK_SET) < 0) {
goto common_exit; goto common_exit;
} }
if ((r = FileRead(fdLog, buf, BUFSIZ)) < 0) { if ((r = FileRead(fdLog, buf, REPLAYBUFFER)) < 0) {
goto common_exit; goto common_exit;
} }
bp = buf + r; bp = buf + r - 1;
} }
/* process the next character /* process the next character
*/ */
--file_pos; if ((ch = *bp) == '\n') {
if ((ch = *--bp) == '\n') {
if (ln >= 0) { if (ln >= 0) {
int i;
int u;
int is_mark = 0;
/* reverse the text to put it in forward order /* reverse the text to put it in forward order
*/ */
u = lines[ln].line->used - 1; u = line->used - 1;
for (i = 0; i < u / 2; i++) { for (i = 0; i < u / 2; i++) {
int temp; int temp;
temp = lines[ln].line->string[i]; temp = line->string[i];
lines[ln].line->string[i] line->string[i] = line->string[u - i - 1];
= lines[ln].line->string[u - i - 1]; line->string[u - i - 1] = temp;
lines[ln].line->string[u - i - 1] = temp;
} }
/* see if this line is a MARK /* see if this line is a MARK
*/ */
if (lines[ln].line->used > 0 && if (line->used > 0 && line->string[0] == '[') {
lines[ln].line->string[0] == '[') { char dummy[4];
i = sscanf(lines[ln].line->string + 1, int j;
i = sscanf(line->string + 1,
"-- MARK -- %3c %3c %d %d:%d:%d %d]\r\n", "-- MARK -- %3c %3c %d %d:%d:%d %d]\r\n",
dummy, dummy, &j, &j, &j, &j, &j); dummy, dummy, &j, &j, &j, &j, &j);
is_mark = (i == 7); is_mark = (i == 7);
} else {
is_mark = 0;
} }
/* process this line /* process this line
*/ */
if (is_mark && ln > 0 && lines[ln - 1].is_mark) { if (is_mark && was_mark) {
/* this is a mark and the previous line is also /* this is a mark and the previous line is also
* a mark, so make (or continue) that range * a mark, so reduce the line count 'cause it'll
* go up by one and we're joining them on output.
*/ */
if (0 == lines[ln - 1].mark_end->allocated) {
/* this is a new range - shuffle pointers
*
* remember that we are moving backward
*/
*(lines[ln - 1].mark_end) = *(lines[ln - 1].line);
InitString(lines[ln - 1].line);
}
/* if unallocated, cheat and shuffle pointers */
if (0 == lines[ln - 1].line->allocated) {
*(lines[ln - 1].line) = *(lines[ln].line);
InitString(lines[ln].line);
} else {
BuildString((char *)0, lines[ln - 1].line);
BuildStringN(lines[ln].line->string,
lines[ln].line->used - 1,
lines[ln - 1].line);
BuildString((char *)0, lines[ln].line);
}
ln--; ln--;
} }
lines[ln].is_mark = is_mark; was_mark = is_mark;
} }
/* advance to the next line and break if we have enough /* advance to the next line and break if we have enough
*/ */
ln++; ln++;
if (ln >= n_lines - 1) { BuildString((char *)0, line);
if (ln >= back) {
break; break;
} }
} }
@ -271,91 +245,122 @@ Replay(pCE, fdOut, iBack)
if (ln < 0) { if (ln < 0) {
ln = 0; ln = 0;
} }
BuildStringChar(ch, lines[ln].line); BuildStringChar(ch, line);
/* if we've processed "a lot" of data for a line, then bail /* if we've processed "a lot" of data for a line, then bail
* why? there must be some very long non-newline terminated * why? there must be some very long non-newline terminated
* strings and if we just keep going back, we could spew lots * strings and if we just keep going back, we could spew lots
* of data and chew up lots of memory * of data and chew up lots of memory
*/ */
if (lines[ln].line->used > MAXREPLAYLINELEN) { if (line->used > MAXREPLAYLINELEN) {
break; break;
} }
} }
free(buf);
buf = (char *)0;
/* if we got back to beginning of file but saw some data, include it /* move forward. either we hit the beginning of the file and we
* move to the first byte, or we hit a \n and we move past it
*/ */
if (ln >= 0 && lines[ln].line->used > 0) { file_pos++;
/* reverse the text to put it in forward order /* Now output the lines, starting from where we stopped */
*/ if (FileSeek(fdLog, file_pos, SEEK_SET) >= 0) {
u = lines[ln].line->used - 1; int eof = 0;
for (i = 0; i < u / 2; i++) { int i = 0;
int temp; int r = 0;
STRING *mark_beg = (STRING *)0;
STRING *mark_end = (STRING *)0;
temp = lines[ln].line->string[i]; mark_beg = AllocString();
lines[ln].line->string[i] mark_end = AllocString();
= lines[ln].line->string[u - i - 1];
lines[ln].line->string[u - i - 1] = temp; ln = 0; /* number of lines output */
BuildString((char *)0, line);
while (ln < back && !eof) {
if (r <= 0) {
if ((r = FileRead(fdLog, buf, REPLAYBUFFER)) < 0)
eof = 1;
i = 0;
}
if (!eof)
BuildStringChar(buf[i], line);
if (buf[i] == '\n' || eof) {
int is_mark = 0;
if (line->used > 0 && line->string[0] == '[') {
char dummy[4];
int j;
int i;
i = sscanf(line->string + 1,
"-- MARK -- %3c %3c %d %d:%d:%d %d]\r\n",
dummy, dummy, &j, &j, &j, &j, &j);
is_mark = (i == 7);
}
if (is_mark) {
if (mark_beg->used > 1) {
BuildString((char *)0, mark_end);
BuildString(line->string, mark_end);
} else
BuildString(line->string, mark_beg);
} else {
if (mark_beg->used > 1) {
if (mark_end->used > 1) {
char *s;
/* output the start of the range, stopping at the ']' */
s = strrchr(mark_beg->string, ']');
if ((char *)0 != s)
*s = '\000';
FileWrite(fdOut, FLAGTRUE, mark_beg->string,
-1);
FileWrite(fdOut, FLAGTRUE, " .. ", 4);
/* build the end string by removing the leading "[-- MARK -- "
* and replacing "]\r\n" on the end with " -- MARK --]\r\n"
*/
s = strrchr(mark_end->string, ']');
if ((char *)0 != s)
*s = '\000';
FileWrite(fdOut, FLAGTRUE,
mark_end->string +
sizeof("[-- MARK -- ") - 1, -1);
FileWrite(fdOut, FLAGFALSE, " -- MARK --]\r\n",
-1);
} else {
FileWrite(fdOut, FLAGFALSE, mark_beg->string,
mark_beg->used - 1);
}
BuildString((char *)0, mark_beg);
BuildString((char *)0, mark_end);
ln++;
if (ln >= back)
break;
}
FileWrite(fdOut, FLAGFALSE, line->string,
line->used - 1);
ln++;
}
BuildString((char *)0, line);
}
/* move the counters */
i++;
r--;
} }
ln++; DestroyString(mark_end);
} DestroyString(mark_beg);
/* copy the lines into the buffer and put them in order
*/
for (i = ln - 1; i >= 0; i--) {
if (lines[i].is_mark && 0 != lines[i].mark_end->used) {
int mark_len;
/* output the start of the range, stopping at the ']'
*/
s = strrchr(lines[i].line->string, ']');
if ((char *)0 != s) {
*s = '\000';
}
FileWrite(fdOut, FLAGTRUE, lines[i].line->string,
lines[i].line->used - 1);
FileWrite(fdOut, FLAGTRUE, " .. ", 4);
/* build the end string by removing the leading "[-- MARK -- "
* and replacing "]\r\n" on the end with " -- MARK --]\r\n"
*/
mark_len = sizeof("[-- MARK -- ") - 1;
s = strrchr(lines[i].mark_end->string + mark_len, ']');
if ((char *)0 != s) {
*s = '\000';
}
FileWrite(fdOut, FLAGTRUE,
lines[i].mark_end->string + mark_len, -1);
FileWrite(fdOut, FLAGFALSE, " -- MARK --]\r\n", -1);
u = lines[i].mark_end->used;
s = lines[i].mark_end->string;
} else
FileWrite(fdOut, FLAGFALSE, lines[i].line->string,
lines[i].line->used - 1);
} }
common_exit: common_exit:
/* if we opened the logfile, close it */ if (line != (STRING *)0)
if (fdLog != pCE->fdlog) DestroyString(line);
if (buf != (char *)0)
free(buf);
if (fdLog != (CONSFILE *)0)
FileClose(&fdLog); FileClose(&fdLog);
if ((struct lines *)0 != lines) {
for (i = 0; i < n_lines; i++) {
DestroyString(lines[i].mark_end);
DestroyString(lines[i].line);
}
free(lines);
lines = (struct lines *)0;
}
if ((char *)0 != buf) {
free(buf);
buf = (char *)0;
}
#if HAVE_DMALLOC && DMALLOC_MARK_REPLAY #if HAVE_DMALLOC && DMALLOC_MARK_REPLAY
CONDDEBUG((1, "Replay(): dmalloc / MarkReplay")); CONDDEBUG((1, "Replay(): dmalloc / MarkReplay"));
dmalloc_log_changed(dmallocMarkReplay, 1, 0, 1); dmalloc_log_changed(dmallocMarkReplay, 1, 0, 1);
@ -367,9 +372,9 @@ Replay(pCE, fdOut, iBack)
*/ */
#define WHEN_SPY 0x01 #define WHEN_SPY 0x01
#define WHEN_ATTACH 0x02 #define WHEN_ATTACH 0x02
#define WHEN_VT100 0x04 #define WHEN_EXPERT 0x04 /* ZZZ no way to set his yet */
#define WHEN_EXPERT 0x08 /* ZZZ no way to set his yet */
#define WHEN_ALWAYS 0x40 #define WHEN_ALWAYS 0x40
#define IS_LIMITED 0x100
#define HALFLINE 40 #define HALFLINE 40
@ -380,6 +385,7 @@ typedef struct HLnode {
static HELP aHLTable[] = { static HELP aHLTable[] = {
{WHEN_ALWAYS, ". disconnect"}, {WHEN_ALWAYS, ". disconnect"},
{WHEN_ALWAYS | IS_LIMITED, "; move to another console"},
{WHEN_ALWAYS, "a attach read/write"}, {WHEN_ALWAYS, "a attach read/write"},
{WHEN_ALWAYS, "b send broadcast message"}, {WHEN_ALWAYS, "b send broadcast message"},
{WHEN_ATTACH, "c toggle flow control"}, {WHEN_ATTACH, "c toggle flow control"},
@ -394,25 +400,23 @@ static HELP aHLTable[] = {
{WHEN_ATTACH, "l1-9 send specific break sequence"}, {WHEN_ATTACH, "l1-9 send specific break sequence"},
{WHEN_ALWAYS, "m display the message of the day"}, {WHEN_ALWAYS, "m display the message of the day"},
{WHEN_ALWAYS, "o (re)open the tty and log file"}, {WHEN_ALWAYS, "o (re)open the tty and log file"},
{WHEN_ALWAYS, "p replay the last 60 lines"}, {WHEN_ALWAYS, "p playback the last %hu lines"},
{WHEN_ALWAYS, "r replay the last 20 lines"}, {WHEN_ALWAYS, "P set number of playback lines"},
{WHEN_ATTACH, "s spy read only"}, {WHEN_ALWAYS, "r replay the last %hu lines"},
{WHEN_ALWAYS, "R set number of replay lines"},
{WHEN_ATTACH, "s spy mode (read only)"},
{WHEN_ALWAYS, "u show host status"}, {WHEN_ALWAYS, "u show host status"},
{WHEN_ALWAYS, "v show version info"}, {WHEN_ALWAYS, "v show version info"},
{WHEN_ALWAYS, "w who is on this console"}, {WHEN_ALWAYS, "w who is on this console"},
{WHEN_ALWAYS, "x show console baud info"}, {WHEN_ALWAYS, "x show console baud info"},
{WHEN_ALWAYS, "z suspend the connection"}, {WHEN_ALWAYS | IS_LIMITED, "z suspend the connection"},
{WHEN_ATTACH, "| attach local command"}, {WHEN_ATTACH | IS_LIMITED, "| attach local command"},
{WHEN_ALWAYS, "<cr> ignore/abort command"},
{WHEN_ALWAYS, "? print this message"}, {WHEN_ALWAYS, "? print this message"},
{WHEN_ALWAYS, "<cr> ignore/abort command"},
{WHEN_ALWAYS, "^R replay the last line"}, {WHEN_ALWAYS, "^R replay the last line"},
{WHEN_ATTACH, "\\ooo send character by octal code"}, {WHEN_ATTACH, "\\ooo send character by octal code"},
{WHEN_EXPERT, "^I toggle tab expansion"}, {WHEN_EXPERT, "^I toggle tab expansion"},
{WHEN_EXPERT, "+(-) do (not) drop line"}, {WHEN_EXPERT, "+(-) do (not) drop line"},
{WHEN_VT100, "PF1 print this message"},
{WHEN_VT100, "PF2 disconnect"},
{WHEN_VT100, "PF3 replay the last 20 lines"},
{WHEN_VT100, "PF4 spy read only"}
}; };
/* list the commands we know for the user (ksb) /* list the commands we know for the user (ksb)
@ -421,7 +425,7 @@ void
#if PROTOTYPES #if PROTOTYPES
HelpUser(CONSCLIENT *pCL) HelpUser(CONSCLIENT *pCL)
#else #else
HelpUser(pCL) HelpUser(pCL, pCE)
CONSCLIENT *pCL; CONSCLIENT *pCL;
#endif #endif
{ {
@ -441,21 +445,33 @@ HelpUser(pCL)
} else { } else {
FileWrite(pCL->fd, FLAGTRUE, acH2, sizeof(acH2) - 1); FileWrite(pCL->fd, FLAGTRUE, acH2, sizeof(acH2) - 1);
} }
if ('\033' == pCL->ic[0] && 'O' == pCL->ic[1]) {
iCmp |= WHEN_VT100;
}
BuildString((char *)0, acLine); BuildString((char *)0, acLine);
for (i = 0; i < sizeof(aHLTable) / sizeof(HELP); ++i) { for (i = 0; i < sizeof(aHLTable) / sizeof(HELP); ++i) {
if (0 == (aHLTable[i].iwhen & iCmp)) { char *text;
if (aHLTable[i].iwhen & IS_LIMITED &&
ConsentUserOk(pLUList, pCL->username->string) == 1)
continue; continue;
if (0 == (aHLTable[i].iwhen & iCmp))
continue;
text = aHLTable[i].actext;
if (text[0] == 'p') {
BuildTmpString((char *)0);
text = BuildTmpStringPrint(text, pCL->playback);
} else if (text[0] == 'r') {
BuildTmpString((char *)0);
text = BuildTmpStringPrint(text, pCL->replay);
} }
if (acLine->used != 0) { /* second part of line */ if (acLine->used != 0) { /* second part of line */
if (strlen(aHLTable[i].actext) < HALFLINE) { if (strlen(text) < HALFLINE) {
for (j = acLine->used; j <= HALFLINE; ++j) { for (j = acLine->used; j <= HALFLINE; ++j) {
BuildStringChar(' ', acLine); BuildStringChar(' ', acLine);
} }
BuildString(aHLTable[i].actext, acLine); BuildString(text, acLine);
BuildString(acEoln, acLine); BuildString(acEoln, acLine);
FileWrite(pCL->fd, FLAGTRUE, acLine->string, FileWrite(pCL->fd, FLAGTRUE, acLine->string,
acLine->used - 1); acLine->used - 1);
@ -470,7 +486,7 @@ HelpUser(pCL)
} }
if (acLine->used == 0) { /* at new line */ if (acLine->used == 0) { /* at new line */
BuildStringChar(' ', acLine); BuildStringChar(' ', acLine);
BuildString(aHLTable[i].actext, acLine); BuildString(text, acLine);
if (acLine->used > HALFLINE) { if (acLine->used > HALFLINE) {
BuildString(acEoln, acLine); BuildString(acEoln, acLine);
FileWrite(pCL->fd, FLAGTRUE, acLine->string, FileWrite(pCL->fd, FLAGTRUE, acLine->string,
@ -495,17 +511,34 @@ ClientAccessOk(pCL)
#endif #endif
{ {
char *peername = (char *)0; char *peername = (char *)0;
int retval = 1;
#if USE_UNIX_DOMAIN_SOCKETS
struct in_addr addr;
# if HAVE_INET_ATON
inet_aton("127.0.0.1", &addr);
# else
addr.s_addr = inet_addr("127.0.0.1");
# endif
pCL->caccess = AccType(&addr, &peername);
if (pCL->caccess == 'r') {
FileWrite(pCL->fd, FLAGFALSE, "access from your host refused\r\n",
-1);
retval = 0;
}
#else
socklen_t so; socklen_t so;
int cfd; int cfd;
struct sockaddr_in in_port; struct sockaddr_in in_port;
int retval = 1;
int getpeer = -1; int getpeer = -1;
cfd = FileFDNum(pCL->fd); cfd = FileFDNum(pCL->fd);
pCL->caccess = 'r'; pCL->caccess = 'r';
#if defined(USE_LIBWRAP) # if defined(USE_LIBWRAP)
{ {
struct request_info request; struct request_info request;
CONDDEBUG((1, "ClientAccessOk(): doing tcpwrappers check"));
request_init(&request, RQ_DAEMON, progname, RQ_FILE, cfd, 0); request_init(&request, RQ_DAEMON, progname, RQ_FILE, cfd, 0);
fromhost(&request); fromhost(&request);
if (!hosts_access(&request)) { if (!hosts_access(&request)) {
@ -515,7 +548,7 @@ ClientAccessOk(pCL)
goto setpeer; goto setpeer;
} }
} }
#endif # endif
so = sizeof(in_port); so = sizeof(in_port);
if (-1 == if (-1 ==
@ -530,16 +563,22 @@ ClientAccessOk(pCL)
-1); -1);
retval = 0; retval = 0;
} }
setpeer: setpeer:
#endif
if (pCL->peername != (STRING *)0) { if (pCL->peername != (STRING *)0) {
BuildString((char *)0, pCL->peername); BuildString((char *)0, pCL->peername);
if (peername != (char *)0) if (peername != (char *)0)
BuildString(peername, pCL->peername); BuildString(peername, pCL->peername);
#if USE_UNIX_DOMAIN_SOCKETS
else
BuildString("127.0.0.1", pCL->peername);
#else
else if (getpeer != -1) else if (getpeer != -1)
BuildString(inet_ntoa(in_port.sin_addr), pCL->peername); BuildString(inet_ntoa(in_port.sin_addr), pCL->peername);
else else
BuildString("<unknown>", pCL->peername); BuildString("<unknown>", pCL->peername);
#endif
} }
if (peername != (char *)0) if (peername != (char *)0)
free(peername); free(peername);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: client.h,v 5.35 2003/11/28 15:55:34 bryan Exp $ * $Id: client.h,v 5.41 2006/04/03 13:32:08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -47,7 +47,10 @@ typedef enum clientState {
S_PASSWD, /* still needs a passwd to connect */ S_PASSWD, /* still needs a passwd to connect */
S_QUOTE, /* send any character we can spell */ S_QUOTE, /* send any character we can spell */
S_BCAST, /* send a broadcast message to all clients */ S_BCAST, /* send a broadcast message to all clients */
S_CWAIT /* wait for client */ S_CWAIT, /* wait for client */
S_CEXEC, /* client execing a program */
S_REPLAY, /* set replay length for 'r' */
S_PLAYBACK /* set replay length for 'p' */
} CLIENTSTATE; } CLIENTSTATE;
typedef struct client { /* Connection Information: */ typedef struct client { /* Connection Information: */
@ -57,6 +60,7 @@ typedef struct client { /* Connection Information: */
short fwantwr; /* (client) wants to write */ short fwantwr; /* (client) wants to write */
short fro; /* read-only permission */ short fro; /* read-only permission */
short fecho; /* echo commands (not set by machines) */ short fecho; /* echo commands (not set by machines) */
short fiwait; /* client wanting for console init */
STRING *acid; /* login and location of client */ STRING *acid; /* login and location of client */
STRING *peername; /* location of client */ STRING *peername; /* location of client */
STRING *username; /* login of client */ STRING *username; /* login of client */
@ -73,17 +77,19 @@ typedef struct client { /* Connection Information: */
*pCLnext; /* next person on this list */ *pCLnext; /* next person on this list */
/* next lists link clients on a console */ /* next lists link clients on a console */
char ic[2]; /* two character escape sequence */ char ic[2]; /* two character escape sequence */
unsigned short replay; /* lines to replay for 'r' */
unsigned short playback; /* lines to replay for 'p' */
CLIENTSTATE iState; /* state for fsm in server */ CLIENTSTATE iState; /* state for fsm in server */
char caccess; /* did we trust the remote machine */ char caccess; /* did we trust the remote machine */
IOSTATE ioState; /* state of the socket */ IOSTATE ioState; /* state of the socket */
time_t stateTimer; /* timer for various ioState states */ time_t stateTimer; /* timer for various ioState states */
STRING *accmd; /* the command the user issued */ STRING *accmd; /* the command the user issued */
STRING *msg; /* the broadcast message */
struct sockaddr_in struct sockaddr_in
cnct_port; /* where from */ cnct_port; /* where from */
} CONSCLIENT; } CONSCLIENT;
extern void Replay PARAMS((CONSENT *, CONSFILE *, int)); extern void Replay PARAMS((CONSENT *, CONSFILE *, unsigned short));
extern void HelpUser PARAMS((CONSCLIENT *)); extern void HelpUser PARAMS((CONSCLIENT *));
extern void FindWrite PARAMS((CONSENT *)); extern void FindWrite PARAMS((CONSENT *));
extern int ClientAccessOk PARAMS((CONSCLIENT *)); extern int ClientAccessOk PARAMS((CONSCLIENT *));
extern void BumpClient PARAMS((CONSENT *, char *));

View File

@ -1,5 +1,5 @@
/* /*
* $Id: consent.c,v 5.133 2003/12/10 18:33:47 bryan Exp $ * $Id: consent.c,v 5.150 2006/06/17 02:03:15 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -52,6 +52,42 @@
BAUD baud[] = { BAUD baud[] = {
#if defined(FOR_CYCLADES_TS)
{"0", 0},
{"50", 1},
{"75", 2},
{"110", 3},
{"134", 4},
{"150", 5},
{"200", 6},
{"300", 7},
{"600", 8},
{"1200", 9},
{"1800", 10},
{"2400", 11},
{"4800", 12},
{"9600", 13},
{"14400", 14},
{"19200", 15},
{"28800", 16},
{"38400", 17},
{"57600", 18},
{"76800", 19},
{"115200", 20},
{"230400", 21},
{"460800", 22},
{"500000", 23},
{"576000", 24},
{"921600", 25},
{"1000000", 26},
{"1152000", 27},
{"1500000", 28},
{"2000000", 29},
{"2500000", 30},
{"3000000", 31},
{"3500000", 32},
{"4000000", 33},
#else /* FOR_CYCLADES_TS */
#if defined(B115200) #if defined(B115200)
{"115200", B115200}, {"115200", B115200},
#endif #endif
@ -83,6 +119,7 @@ BAUD baud[] = {
#if defined(B300) #if defined(B300)
{"300", B300}, {"300", B300},
#endif #endif
#endif /* FOR_CYCLADES_TS */
}; };
@ -236,6 +273,23 @@ TtyDev(pCE)
ConsDown(pCE, FLAGTRUE, FLAGTRUE); ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return -1; return -1;
} }
if (fDebug >= 2) {
int i;
Debug(2, "TtyDev(): [%s] termp.c_iflag=%lu", pCE->server,
(unsigned long)termp.c_iflag);
Debug(2, "TtyDev(): [%s] termp.c_oflag=%lu", pCE->server,
(unsigned long)termp.c_oflag);
Debug(2, "TtyDev(): [%s] termp.c_cflag=%lu", pCE->server,
(unsigned long)termp.c_cflag);
Debug(2, "TtyDev(): [%s] termp.c_lflag=%lu", pCE->server,
(unsigned long)termp.c_lflag);
#if defined(NCCS)
for (i = 0; i < NCCS; i++) {
Debug(2, "TtyDev(): [%s] termp.c_cc[%d]=%lu", pCE->server, i,
(unsigned long)termp.c_cc[i]);
}
#endif
}
# if HAVE_STROPTS_H # if HAVE_STROPTS_H
/* /*
* eat all the streams modules upto and including ttcompat * eat all the streams modules upto and including ttcompat
@ -259,6 +313,12 @@ StopInit(pCE)
if (pCE->initcmd == (char *)0) if (pCE->initcmd == (char *)0)
return; return;
if (pCE->initpid != 0 || pCE->initfile != (CONSFILE *)0)
SendIWaitClientsMsg(pCE,
(pCE->fup &&
pCE->ioState ==
ISNORMAL) ? "up]\r\n" : "down]\r\n");
if (pCE->initpid != 0) { if (pCE->initpid != 0) {
kill(pCE->initpid, SIGHUP); kill(pCE->initpid, SIGHUP);
CONDDEBUG((1, "StopInit(): sending initcmd pid %lu signal %d", CONDDEBUG((1, "StopInit(): sending initcmd pid %lu signal %d",
@ -307,20 +367,6 @@ StartInit(pCE)
StopInit(pCE); StopInit(pCE);
} }
if (pCE->pCLwr != (CONSCLIENT *)0) {
CONSCLIENT *pCL = pCE->pCLwr;
pCL->fwr = 0;
pCL->fwantwr = 1;
/*
FileWrite(pCL->fd,
"[forced to `spy' mode by initialization command]\r\n",
-1);
TagLogfileAct(pCE, "initialization command bumped %s",
pCL->acid->string);
*/
pCE->pCLwr = (CONSCLIENT *)0;
}
/* pin[0] = parent read, pin[1] = child write */ /* pin[0] = parent read, pin[1] = child write */
if (pipe(pin) != 0) { if (pipe(pin) != 0) {
Error("[%s] StartInit(): pipe(): %s", pCE->server, Error("[%s] StartInit(): pipe(): %s", pCE->server,
@ -418,6 +464,13 @@ StartInit(pCE)
close(pout[0]); close(pout[0]);
close(pin[1]); close(pin[1]);
if (geteuid() == 0) {
if (pCE->initgid != 0)
setgid(pCE->initgid);
if (pCE->inituid != 0)
setuid(pCE->inituid);
}
tcsetpgrp(0, iNewGrp); tcsetpgrp(0, iNewGrp);
apcArgv[2] = pCE->initcmd; apcArgv[2] = pCE->initcmd;
@ -507,6 +560,15 @@ VirtDev(pCE)
Error("[%s] fd sync error", pCE->server); Error("[%s] fd sync error", pCE->server);
Bye(EX_OSERR); Bye(EX_OSERR);
} }
if (geteuid() == 0) {
if (pCE->execgid != 0)
setgid(pCE->execgid);
if (pCE->execuid != 0) {
fchown(0, pCE->execuid, -1);
setuid(pCE->execuid);
}
}
# if HAVE_STROPTS_H && !defined(_AIX) # if HAVE_STROPTS_H && !defined(_AIX)
/* SYSVr4 semantics for opening stream ptys (gregf) /* SYSVr4 semantics for opening stream ptys (gregf)
* under PTX (others?) we have to push the compatibility * under PTX (others?) we have to push the compatibility
@ -589,6 +651,39 @@ VirtDev(pCE)
return -1; return -1;
} }
char *
#if PROTOTYPES
ConsState(CONSENT *pCE)
#else
ConsState(pCE)
CONSENT *pCE;
#endif
{
if (!pCE->fup)
return "down";
if (pCE->initfile != (CONSFILE *)0)
return "initializing";
switch (pCE->ioState) {
case ISNORMAL:
return "up";
case INCONNECT:
return "connecting";
case ISDISCONNECTED:
return "disconnected";
#if HAVE_OPENSSL
case INSSLACCEPT:
return "SSL_accept";
case INSSLSHUTDOWN:
return "SSL_shutdown";
#endif
case ISFLUSHING:
return "flushing";
}
return "in unknown state";
}
/* down a console, virtual or real (ksb) /* down a console, virtual or real (ksb)
* *
* this should be kept pretty simple, 'cause the config file reading code * this should be kept pretty simple, 'cause the config file reading code
@ -643,6 +738,9 @@ ConsDown(pCE, downHard, force)
pCE->autoReUp = 0; pCE->autoReUp = 0;
pCE->downHard = downHard; pCE->downHard = downHard;
pCE->ioState = ISDISCONNECTED; pCE->ioState = ISDISCONNECTED;
pCE->telnetState = 0;
pCE->sentDoEcho = FLAGFALSE;
pCE->sentDoSGA = FLAGFALSE;
} }
/* set up a console the way it should be for use to work with it (ksb) /* set up a console the way it should be for use to work with it (ksb)
@ -661,6 +759,40 @@ ConsInit(pCE)
extern int FallBack PARAMS((char **, int *)); extern int FallBack PARAMS((char **, int *));
int cofile = -1; int cofile = -1;
int ret; int ret;
#if HAVE_GETTIMEOFDAY
struct timeval tv;
#else
time_t tv;
#endif
if (pCE->spintimer > 0 && pCE->spinmax > 0) {
#if HAVE_GETTIMEOFDAY
if (gettimeofday(&tv, (void *)0) == 0) {
/* less than pCE->spintimer seconds gone by? */
if ((tv.tv_sec <= pCE->lastInit.tv_sec + pCE->spintimer - 1)
|| (tv.tv_sec == pCE->lastInit.tv_sec + 1 &&
tv.tv_usec <= pCE->lastInit.tv_usec)) {
#else
if ((tv = time((time_t *)0)) != (time_t)-1) {
/* less than pCE->spintimer seconds gone by? (approx) */
if (tv <= pCE->lastInit + pCE->spintimer) {
#endif
pCE->spincount++;
if (pCE->spincount >= pCE->spinmax) {
pCE->spincount = 0;
pCE->lastInit = tv;
Error
("[%s] initialization rate exceeded: forcing down",
pCE->server);
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return;
}
} else
pCE->spincount = 0;
pCE->lastInit = tv;
} else
pCE->spincount = 0;
}
/* clean up old stuff /* clean up old stuff
*/ */
@ -691,7 +823,11 @@ ConsInit(pCE)
TagLogfile(pCE, "Console up"); TagLogfile(pCE, "Console up");
switch (pCE->type) { switch (pCE->type) {
case UNKNOWN: /* shut up gcc */ case UNKNOWNTYPE: /* shut up gcc */
break;
case NOOP:
pCE->fup = 1;
pCE->ioState = ISNORMAL;
break; break;
case EXEC: case EXEC:
if ((cofile = if ((cofile =
@ -717,7 +853,9 @@ ConsInit(pCE)
{ {
struct sockaddr_in port; struct sockaddr_in port;
struct hostent *hp; struct hostent *hp;
size_t one = 1; #if HAVE_SETSOCKOPT
int one = 1;
#endif
usleep(100000); /* Not all terminal servers can keep up */ usleep(100000); /* Not all terminal servers can keep up */
@ -741,7 +879,7 @@ ConsInit(pCE)
hp->h_length); hp->h_length);
#endif #endif
port.sin_family = hp->h_addrtype; port.sin_family = hp->h_addrtype;
port.sin_port = htons(pCE->port); port.sin_port = htons(pCE->netport);
if ((cofile = socket(AF_INET, SOCK_STREAM, 0)) < 0) { if ((cofile = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
Error Error
@ -750,6 +888,7 @@ ConsInit(pCE)
ConsDown(pCE, FLAGTRUE, FLAGTRUE); ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return; return;
} }
#if HAVE_SETSOCKOPT
if (setsockopt if (setsockopt
(cofile, SOL_SOCKET, SO_KEEPALIVE, (char *)&one, (cofile, SOL_SOCKET, SO_KEEPALIVE, (char *)&one,
sizeof(one)) < 0) { sizeof(one)) < 0) {
@ -759,6 +898,7 @@ ConsInit(pCE)
ConsDown(pCE, FLAGTRUE, FLAGTRUE); ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return; return;
} }
#endif
if (!SetFlags(cofile, O_NONBLOCK, 0)) { if (!SetFlags(cofile, O_NONBLOCK, 0)) {
ConsDown(pCE, FLAGTRUE, FLAGTRUE); ConsDown(pCE, FLAGTRUE, FLAGTRUE);
@ -788,19 +928,86 @@ ConsInit(pCE)
if (ret == 0) { if (ret == 0) {
pCE->ioState = ISNORMAL; pCE->ioState = ISNORMAL;
pCE->stateTimer = 0; pCE->stateTimer = 0;
pCE->fup = 1;
} else { } else {
pCE->ioState = INCONNECT; pCE->ioState = INCONNECT;
pCE->stateTimer = time((time_t *)0) + CONNECTTIMEOUT; pCE->stateTimer = time((time_t *)0) + CONNECTTIMEOUT;
if (timers[T_STATE] == (time_t)0 || if (timers[T_STATE] == (time_t)0 ||
timers[T_STATE] > pCE->stateTimer) timers[T_STATE] > pCE->stateTimer)
timers[T_STATE] = pCE->stateTimer; timers[T_STATE] = pCE->stateTimer;
pCE->fup = 1;
} }
pCE->fup = 1;
break;
case UDS:
{
struct sockaddr_un port;
#if HAVE_MEMSET
memset((void *)&port, 0, sizeof(port));
#else
bzero((char *)&port, sizeof(port));
#endif
/* we ensure that pCE->uds exists and fits inside port.sun_path
* in readcfg.c, so we can just defend ourselves here (which
* should never trigger).
*/
if (strlen(pCE->uds) >= sizeof(port.sun_path)) {
Error
("[%s] strlen(uds path) > sizeof(port.sun_path): forcing down",
pCE->server);
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return;
}
StrCpy(port.sun_path, pCE->uds, sizeof(port.sun_path));
port.sun_family = AF_UNIX;
if ((cofile = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
Error
("[%s] socket(AF_UNIX,SOCK_STREAM): %s: forcing down",
pCE->server, strerror(errno));
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return;
}
if (!SetFlags(cofile, O_NONBLOCK, 0)) {
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return;
}
if ((ret =
connect(cofile, (struct sockaddr *)&port,
sizeof(port))) < 0) {
if (errno != EINPROGRESS) {
Error("[%s] connect(%u): %s: forcing down",
pCE->server, cofile, strerror(errno));
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return;
}
}
}
if ((pCE->cofile =
FileOpenFD(cofile, simpleSocket)) == (CONSFILE *)0) {
Error
("[%s] FileOpenFD(%d,simpleSocket) failed: forcing down",
pCE->server, cofile);
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return;
}
if (ret == 0) {
pCE->ioState = ISNORMAL;
pCE->stateTimer = 0;
} else {
pCE->ioState = INCONNECT;
pCE->stateTimer = time((time_t *)0) + CONNECTTIMEOUT;
if (timers[T_STATE] == (time_t)0 ||
timers[T_STATE] > pCE->stateTimer)
timers[T_STATE] = pCE->stateTimer;
}
pCE->fup = 1;
break; break;
case DEVICE: case DEVICE:
if (-1 == if (-1 ==
(cofile = open(pCE->device, O_RDWR | O_NDELAY, 0600))) { (cofile = open(pCE->device, O_RDWR | O_NONBLOCK, 0600))) {
Error("[%s] open(%s): %s: forcing down", pCE->server, Error("[%s] open(%s): %s: forcing down", pCE->server,
pCE->device, strerror(errno)); pCE->device, strerror(errno));
@ -826,40 +1033,48 @@ ConsInit(pCE)
} }
switch (pCE->type) { switch (pCE->type) {
case UNKNOWN: /* shut up gcc */ case UNKNOWNTYPE: /* shut up gcc */
break; break;
case EXEC: case EXEC:
Verbose("[%s] pid %lu on %s", pCE->server, pCE->ipid, Verbose("[%s] pid %lu on %s", pCE->server, pCE->ipid,
pCE->execSlave); pCE->execSlave);
break; break;
case HOST: case HOST:
Verbose("[%s] port %hu on %s", pCE->server, pCE->port, Verbose("[%s] port %hu on %s", pCE->server, pCE->netport,
pCE->host); pCE->host);
break; break;
case NOOP:
Verbose("[%s] noop", pCE->server);
break;
case UDS:
Verbose("[%s] uds %s", pCE->server, pCE->uds);
break;
case DEVICE: case DEVICE:
Verbose("[%s] at %s%c on %s", pCE->server, pCE->baud->acrate, Verbose("[%s] at %s%c on %s", pCE->server, pCE->baud->acrate,
pCE->parity->key[0], pCE->device); pCE->parity->key[0], pCE->device);
break; break;
} }
/* if we're waiting for connect() to finish, watch the if (cofile != -1) {
* write bit, otherwise watch for the read bit /* if we're waiting for connect() to finish, watch the
*/ * write bit, otherwise watch for the read bit
if (pCE->ioState == INCONNECT) */
FD_SET(cofile, &winit); if (pCE->ioState == INCONNECT)
else FD_SET(cofile, &winit);
FD_SET(cofile, &rinit); else
if (maxfd < cofile + 1) FD_SET(cofile, &rinit);
maxfd = cofile + 1; if (maxfd < cofile + 1)
maxfd = cofile + 1;
}
tyme = time((time_t *)0); tyme = time((time_t *)0);
if (pCE->ioState == ISNORMAL) { if (pCE->ioState == ISNORMAL) {
pCE->lastWrite = tyme; pCE->lastWrite = tyme;
if (pCE->idletimeout != (time_t)0 && if (pCE->idletimeout != (time_t)0 &&
(timers[T_IDLE] == (time_t)0 || (timers[T_CIDLE] == (time_t)0 ||
timers[T_IDLE] > pCE->lastWrite + pCE->idletimeout)) timers[T_CIDLE] > pCE->lastWrite + pCE->idletimeout))
timers[T_IDLE] = pCE->lastWrite + pCE->idletimeout; timers[T_CIDLE] = pCE->lastWrite + pCE->idletimeout;
} }
/* If we have marks, adjust the next one so that it's in the future */ /* If we have marks, adjust the next one so that it's in the future */
@ -874,12 +1089,19 @@ ConsInit(pCE)
} }
if (pCE->downHard == FLAGTRUE) { if (pCE->downHard == FLAGTRUE) {
if (pCE->ioState == ISNORMAL) if (pCE->ioState == ISNORMAL) {
Msg("[%s] console up", pCE->server); Msg("[%s] console up", pCE->server);
else pCE->downHard = FLAGFALSE;
Msg("[%s] console inititalizing", pCE->server); } else
pCE->downHard = FLAGFALSE; Msg("[%s] console initializing", pCE->server);
} }
#if HAVE_GETTIMEOFDAY
if (gettimeofday(&tv, (void *)0) == 0)
pCE->lastInit = tv;
#else
if ((tv = time((time_t *)0)) != (time_t)-1)
pCE->lastInit = tv;
#endif
if (pCE->ioState == ISNORMAL) if (pCE->ioState == ISNORMAL)
StartInit(pCE); StartInit(pCE);

View File

@ -1,5 +1,5 @@
/* /*
* $Id: consent.h,v 5.53 2003/11/28 23:36:02 bryan Exp $ * $Id: consent.h,v 5.67 2006/05/28 17:27:14 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -52,10 +52,12 @@ typedef struct parity { /* a parity bits table */
} PARITY; } PARITY;
typedef enum consType { typedef enum consType {
UNKNOWN = 0, UNKNOWNTYPE = 0,
DEVICE, DEVICE,
EXEC, EXEC,
HOST HOST,
NOOP,
UDS
} CONSTYPE; } CONSTYPE;
typedef struct names { typedef struct names {
@ -92,21 +94,33 @@ typedef struct consent { /* console information */
#endif #endif
/* type == HOST */ /* type == HOST */
char *host; /* hostname */ char *host; /* hostname */
unsigned short port; /* port number socket = portbase + */ unsigned short netport; /* final port | netport = portbase + */
unsigned short portbase; /* port base portinc * port */ unsigned short port; /* port number | portinc * port */
unsigned short portbase; /* port base */
unsigned short portinc; /* port increment */ unsigned short portinc; /* port increment */
FLAG raw; /* raw or telnet protocol? */
/* type == EXEC */ /* type == EXEC */
char *exec; /* exec command */ char *exec; /* exec command */
char *execsubst; /* exec substitution pattern */ char *execsubst; /* exec substitution pattern */
uid_t execuid; /* user to run exec as */
gid_t execgid; /* group to run exec as */
/* type == UDS */
char *uds; /* socket file */
char *udssubst; /* socket file substitution pattern */
/* global stuff */ /* global stuff */
char *master; /* master hostname */ char *master; /* master hostname */
unsigned short breakNum; /* break type [1-9] */ unsigned short breakNum; /* break type [1-9] */
char *logfile; /* logfile */ char *logfile; /* logfile */
off_t logfilemax; /* size limit for rolling logfile */ off_t logfilemax; /* size limit for rolling logfile */
char *initcmd; /* initcmd command */ char *initcmd; /* initcmd command */
char *initsubst; /* initcmd substitution pattern */
uid_t inituid; /* user to run initcmd as */
gid_t initgid; /* group to run initcmd as */
char *motd; /* motd */ char *motd; /* motd */
time_t idletimeout; /* idle timeout */ time_t idletimeout; /* idle timeout */
char *idlestring; /* string to print when idle */ char *idlestring; /* string to print when idle */
unsigned short spinmax; /* initialization spin maximum */
unsigned short spintimer; /* initialization spin timer */
/* timestamp stuff */ /* timestamp stuff */
int mark; /* Mark (chime) interval */ int mark; /* Mark (chime) interval */
long nextMark; /* Next mark (chime) time */ long nextMark; /* Next mark (chime) time */
@ -118,6 +132,7 @@ typedef struct consent { /* console information */
FLAG striphigh; /* strip high-bit of console data */ FLAG striphigh; /* strip high-bit of console data */
FLAG autoreinit; /* auto-reinitialize if failed */ FLAG autoreinit; /* auto-reinitialize if failed */
FLAG unloved; /* copy "unloved" data to stdout */ FLAG unloved; /* copy "unloved" data to stdout */
FLAG login; /* allow logins to the console */
/*** runtime settings ***/ /*** runtime settings ***/
CONSFILE *fdlog; /* the local log file */ CONSFILE *fdlog; /* the local log file */
@ -132,11 +147,19 @@ typedef struct consent { /* console information */
IOSTATE ioState; /* state of the socket */ IOSTATE ioState; /* state of the socket */
time_t stateTimer; /* timer for ioState states */ time_t stateTimer; /* timer for ioState states */
time_t lastWrite; /* time of last data sent to console */ time_t lastWrite; /* time of last data sent to console */
#if HAVE_GETTIMEOFDAY
struct timeval lastInit; /* time of last initialization */
#else
time_t lastInit; /* time of last initialization */
#endif
unsigned short spincount; /* initialization spin counter */
/*** state information ***/ /*** state information ***/
char acline[132 * 2 + 2]; /* max chars we will call a line */ char acline[132 * 2 + 2]; /* max chars we will call a line */
int iend; /* length of data stored in acline */ int iend; /* length of data stored in acline */
int telnetState; /* state for telnet negotiations */ int telnetState; /* state for telnet negotiations */
FLAG sentDoEcho; /* have we sent telnet DO ECHO cmd? */
FLAG sentDoSGA; /* have we sent telnet DO SGA cmd? */
unsigned short autoReUp; /* is it coming back up automatically? */ unsigned short autoReUp; /* is it coming back up automatically? */
FLAG downHard; /* did it go down unexpectedly? */ FLAG downHard; /* did it go down unexpectedly? */
unsigned short nolog; /* don't log output */ unsigned short nolog; /* don't log output */
@ -167,3 +190,4 @@ extern REMOTE *FindUniq PARAMS((REMOTE *));
extern void DestroyRemoteConsole PARAMS((REMOTE *)); extern void DestroyRemoteConsole PARAMS((REMOTE *));
extern void StartInit PARAMS((CONSENT *)); extern void StartInit PARAMS((CONSENT *));
extern void StopInit PARAMS((CONSENT *)); extern void StopInit PARAMS((CONSENT *));
extern char *ConsState PARAMS((CONSENT *));

View File

@ -1,6 +1,6 @@
.\" @(#)conserver.8 01/06/91 OSU CIS; Thomas A. Fine .\" @(#)conserver.8 01/06/91 OSU CIS; Thomas A. Fine
.\" $Id: conserver.man,v 1.40 2003/11/10 15:37:24 bryan Exp $ .\" $Id: conserver.man,v 1.54 2006/12/31 02:02:48 bryan Exp $
.TH CONSERVER 8 "2003/11/10" "conserver-8.0.9" "conserver" .TH CONSERVER 8 "2006/12/31" "conserver-8.1.15" "conserver"
.SH NAME .SH NAME
conserver \- console server daemon conserver \- console server daemon
.SH SYNOPSIS .SH SYNOPSIS
@ -11,7 +11,7 @@ conserver \- console server daemon
.RB [ \-m .RB [ \-m
.IR max ] .IR max ]
.RB [ \-M .RB [ \-M
.IR addr ] .IR master ]
.RB [ \-p .RB [ \-p
.IR port ] .IR port ]
.RB [ \-b .RB [ \-b
@ -33,24 +33,36 @@ conserver \- console server daemon
is the daemon that manages is the daemon that manages
remote access to system consoles by multiple users via the remote access to system consoles by multiple users via the
.BR console (1) .BR console (1)
client program and logs all console output. client program and (optionally) log the console output.
It can connect to consoles via local serial ports, terminal It can connect to consoles via local serial ports, Unix domain sockets, TCP
servers that allow network access, or to any external program. sockets (for terminal servers and the like), or any external program.
.PP .PP
When started, When started,
.B conserver .B conserver
reads its reads the
.BR conserver.cf (5) .BR conserver.cf (5)
file for details of each console it should manage, file for details of each console.
including serial port or network parameters and logging options. The console type, logging options, serial or network parameters, and user access
(Also, in environments where multiple servers share a cf file, levels are just a few of the things that can be specified.
any server is able to refer clients to the particular server Command-line options are then applied, possibly overriding
managing a requested console, so that the client need not have .BR conserver.cf (5)
knowledge of the distribution of consoles among servers.) settings.
.B Conserver
categorizes consoles into two types: those it should actively manage, and
those it should just know about, so it can refer clients to other
.B conserver
instances.
If the
.B master
value of a console matches the hostname or ip address of the local machine,
.B conserver
will actively manage the console.
Otherwise, it's considered a ``remote'' console and managed by a different
server.
.B Conserver .B Conserver
forks a child for each group of consoles it must manage forks a child for each group of consoles it must manage
and assigns each process a port number to listen on. and assigns each process a port number to listen on.
The maximum number of consoles managed by each child process is set using The maximum number of consoles managed by each child process is set using the
.B \-m .B \-m
option. option.
The The
@ -76,14 +88,31 @@ the
.BR conserver.cf (5) .BR conserver.cf (5)
access list. access list.
.PP .PP
When Unix domain sockets are used between the client and
server (enabled using
.BR --with-uds ),
authentication checks are done on the hardcoded address ``127.0.0.1''.
Automatic client redirection is also disabled (as if the
.B \-R
option was used) since the client cannot communicate with remote servers.
The directory used to hold the sockets is checked to make sure it's empty
when the server starts.
The server will
.B not
remove any files in the directory itself, just in case the directory is
accidentally specified as ``/etc'' or some other critical location.
The server will do its best to remove all the sockets when it shuts down,
but it could stop ungracefully (crash, ``kill -9'', etc)
and leave files behind.
It would then be up to the admin (or a creative startup script) to clean
up the directory before the server will start again.
.PP
.B Conserver .B Conserver
completely controls any connection to a console. completely controls any connection to a console.
All escape sequences given by the user to All escape sequences given by the user to
.B console .B console
are passed to the server without interpretation. are passed to the server without interpretation.
The server recognizes and processes all escape sequences, The server recognizes and processes all escape sequences.
The suspend sequence is recognized by the server and sent back to the
client as a TCP out-of-band command, which the client processes.
.PP .PP
The The
.B conserver .B conserver
@ -217,7 +246,7 @@ option.
.B \-d .B \-d
Become a daemon. Become a daemon.
Disconnects from the controlling terminal and sends Disconnects from the controlling terminal and sends
all output to the logfile (see all output (including any debug output) to the logfile (see
.BR \-L ). .BR \-L ).
.TP .TP
.B \-D .B \-D
@ -271,11 +300,21 @@ may be changed at compile time using the
.B --with-maxmemb .B --with-maxmemb
option. option.
.TP .TP
.BI \-M addr .BI \-M master
Set the address to listen on. Normally, this allows conserver to bind to a
This allows conserver to bind to a
particular IP address (like `127.0.0.1') instead of all interfaces. particular IP address (like `127.0.0.1') instead of all interfaces.
The default is to bind to all addresses. The default is to bind to all addresses.
However, if
.B --with-uds
was used to enable Unix domain sockets for client/server communication,
this points conserver to the directory where it should store the sockets.
The default
.I master
directory
.RB (`` /tmp/conserver '')
may be changed at compile time using the
.B --with-uds
option.
.TP .TP
.B \-n .B \-n
Obsolete (now a no-op); see Obsolete (now a no-op); see
@ -291,6 +330,9 @@ Enable periodic attempts (every
.I min .I min
minutes) to open (``bring up'') all downed minutes) to open (``bring up'') all downed
consoles (similar to sending a SIGUSR1). consoles (similar to sending a SIGUSR1).
Without this option, or if
.I min
is zero, no periodic attempts occur.
.TP .TP
.BI \-p port .BI \-p port
Set the TCP port for the master process to listen on. Set the TCP port for the master process to listen on.
@ -301,6 +343,9 @@ The default
may be changed at compile time using the may be changed at compile time using the
.B --with-port .B --with-port
option. option.
If the
.B --with-uds
option was used, this option is ignored.
.TP .TP
.BI \-P passwd .BI \-P passwd
Read the table of authorized user data from the file Read the table of authorized user data from the file
@ -324,6 +369,40 @@ connect to remote consoles will result in an informative message to the user.
.B \-S .B \-S
Do not run the server, just perform a syntax check of configuration file and Do not run the server, just perform a syntax check of configuration file and
exit with a non-zero value if there is an error. exit with a non-zero value if there is an error.
Using more than one
.B \-S
will cause conserver to output various information about each console in 5
colon-separated fields, enclosed in curly-braces.
The philosophy behind the output is to provide information to allow external
detection of multiple consoles access the same physical port.
Since this is
.I highly
environment-specific, conserver cannot do the check internally.
.RS
.TP 9
.I name
The name of the console.
.TP
.I master
The hostname of the master conserver host for the console.
.TP
.I aliases
The console aliases in a comma-separated list.
.TP
.I type
The type of console.
Values will be a `/' for a local device, `|' for
a command, `!' for a remote port, `%' for a Unix domain socket,
and `#' for a noop console.
.TP
.I details
Multiple values are comma-separated and depend on the type of the console.
Local devices will have the values of the device file and baud rate/parity.
Commands will have string to invoke.
Remote ports will have the values of the remote hostname and port number.
Unix domain sockets will have the path to the socket.
Noop consoles will have nothing.
.RE
.TP .TP
.B \-u .B \-u
Send unloved console output to Send unloved console output to
@ -363,7 +442,7 @@ The second style is the character-based, escape-sequence mode, while
connected to a console. connected to a console.
.PP .PP
The initial line-based mode begins the same for both the master process The initial line-based mode begins the same for both the master process
and it's children. and its children.
Upon a successful (non-rejected) client connection, an ``ok'' is sent. Upon a successful (non-rejected) client connection, an ``ok'' is sent.
The client then issues a command and the server responds to it with a The client then issues a command and the server responds to it with a
result string (``ok'' being the sign of success for most commands). result string (``ok'' being the sign of success for most commands).
@ -371,7 +450,7 @@ The commands available are ``help'', ``ssl'' (if
SSL was built into the code), ``login'', and ``exit''. SSL was built into the code), ``login'', and ``exit''.
Using the ``login'' command, the client authenticates and gains access to Using the ``login'' command, the client authenticates and gains access to
the extended command set. the extended command set.
This is where the master process and it's children differ. This is where the master process and its children differ.
The master process gives the client access to global commands, and the The master process gives the client access to global commands, and the
child provides commands for interacting with the consoles it manages. child provides commands for interacting with the consoles it manages.
The ``help'' command, in both cases, will provide a complete The ``help'' command, in both cases, will provide a complete
@ -387,14 +466,16 @@ any interaction with the server is done with the default escape sequence.
This is, by no means, a complete description of the entire client/server This is, by no means, a complete description of the entire client/server
interaction. interaction.
It is, however, a brief explanation in order to give a idea of It is, however, a brief explanation in order to give a idea of
what the program does. what the program does. See the
.B \s-1PROTOCOL\s0
file in the distribution for further details.
.SH FILES .SH FILES
.PP .PP
The following default file locations may be overridden The following default file locations may be overridden
at compile time or by the command-line options described above. at compile time or by the command-line options described above.
Run Run
.B conserver \-V .B conserver \-V
(with no other options) to see the defaults set at compile time. to see the defaults set at compile time.
.PP .PP
.PD 0 .PD 0
.TP 25 .TP 25
@ -412,6 +493,9 @@ the master conserver process ID
.TP .TP
.B /var/log/conserver .B /var/log/conserver
log of errors and informational messages log of errors and informational messages
.TP
.B /tmp/conserver
directory to hold Unix domain sockets (if enabled)
.PD .PD
.PP .PP
Additionally, output from individual consoles may be logged Additionally, output from individual consoles may be logged

View File

@ -1,5 +1,5 @@
/* /*
* $Id: convert.c,v 1.8 2003/11/20 13:56:38 bryan Exp $ * $Id: convert.c,v 1.12 2006/04/07 15:47:20 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -41,6 +41,16 @@
#include <master.h> #include <master.h>
#include <main.h> #include <main.h>
#if defined(USE_LIBWRAP)
/* we don't use it...but we link to it */
int allow_severity;
int deny_severity;
#endif
SECTION sections[] = {
{(char *)0, (void *)0, (void *)0, (void *)0, (void *)0}
};
void void
DestroyDataStructures() DestroyDataStructures()
@ -76,7 +86,7 @@ ReadLine2(fp, save, iLine)
|| peek) { || peek) {
/* If we have a previously saved line, use it instead */ /* If we have a previously saved line, use it instead */
if (save->used) { if (save->used) {
strcpy(buf, save->string); StrCpy(buf, save->string, sizeof(buf));
BuildString((char *)0, save); BuildString((char *)0, save);
} }
@ -139,7 +149,7 @@ ReadLine2(fp, save, iLine)
if (!peek && (ret == (char *)0)) { if (!peek && (ret == (char *)0)) {
(*iLine)++; (*iLine)++;
wholeline = BuildString(bufstr->string, wholestr); wholeline = BuildString(bufstr->string, wholestr);
if (wholeline[0] == '\000') if (wholeline != (char *)0 && wholeline[0] == '\000')
wholeline = (char *)0; wholeline = (char *)0;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* /*
* $Id: cutil.h,v 1.57 2003/11/28 00:47:29 bryan Exp $ * $Id: cutil.h,v 1.68 2006/04/07 15:47:20 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -18,9 +18,11 @@
/* communication constants /* communication constants
*/ */
#define OB_IAC 0xff /* quote char */
#define OB_EXEC 'E' /* exec a command on the client */ #define OB_EXEC 'E' /* exec a command on the client */
#define OB_GOTO 'G' /* goto next console */
#define OB_SUSP 'Z' /* suspended by server */ #define OB_SUSP 'Z' /* suspended by server */
#define OB_DROP '.' /* dropped by server */ #define OB_ABRT '.' /* abort */
/* Struct to wrap information about a "file"... /* Struct to wrap information about a "file"...
* This can be a socket, local file, whatever. We do this so * This can be a socket, local file, whatever. We do this so
@ -68,6 +70,13 @@ typedef struct consFile {
int fd; int fd;
int fdout; /* only used when a simplePipe */ int fdout; /* only used when a simplePipe */
STRING *wbuf; STRING *wbuf;
FLAG errored;
FLAG quoteiac;
FLAG sawiac;
FLAG sawiacsusp;
FLAG sawiacexec;
FLAG sawiacabrt;
FLAG sawiacgoto;
#if HAVE_OPENSSL #if HAVE_OPENSSL
/* SSL stuff */ /* SSL stuff */
SSL *ssl; SSL *ssl;
@ -75,8 +84,45 @@ typedef struct consFile {
FLAG waitForRead; FLAG waitForRead;
#endif #endif
/* Add crypto stuff to suit */ /* Add crypto stuff to suit */
#if DEBUG_CONSFILE_IO
int debugrfd;
int debugwfd;
#endif
} CONSFILE; } CONSFILE;
typedef struct item {
char *id;
void (*reg) PARAMS((char *));
} ITEM;
typedef struct section {
char *id;
void (*begin) PARAMS((char *));
void (*end) PARAMS((void));
void (*abort) PARAMS((void));
void (*destroy) PARAMS((void));
ITEM *items;
} SECTION;
typedef enum substToken {
ISNOTHING = 0,
ISNUMBER,
ISSTRING
} SUBSTTOKEN;
typedef struct subst {
/* function to retrieve a token type based on a character
*/
SUBSTTOKEN (*token) PARAMS((char));
/* data for callback function
*/
void *data;
/* function to retrieve a value (as a char* or int or both) for
* a substitution
*/
int (*value) PARAMS((char, char **, int *));
} SUBST;
extern int isMultiProc, fDebug, fVerbose, fErrorPrinted; extern int isMultiProc, fDebug, fVerbose, fErrorPrinted;
extern char *progname; extern char *progname;
extern pid_t thepid; extern pid_t thepid;
@ -88,6 +134,10 @@ extern fd_set winit;
extern int maxfd; extern int maxfd;
extern int debugLineNo; extern int debugLineNo;
extern char *debugFileName; extern char *debugFileName;
extern int line; /* used by ParseFile */
extern char *file; /* used by ParseFile */
extern SECTION sections[]; /* used by ParseFile */
extern int isMaster;
extern const char *StrTime PARAMS((time_t *)); extern const char *StrTime PARAMS((time_t *));
extern void Debug PARAMS((int, char *, ...)); extern void Debug PARAMS((int, char *, ...));
@ -128,6 +178,11 @@ extern STRING *AllocString PARAMS((void));
extern char *ReadLine PARAMS((FILE *, STRING *, int *)); extern char *ReadLine PARAMS((FILE *, STRING *, int *));
extern enum consFileType FileGetType PARAMS((CONSFILE *)); extern enum consFileType FileGetType PARAMS((CONSFILE *));
extern void FileSetType PARAMS((CONSFILE *, enum consFileType)); extern void FileSetType PARAMS((CONSFILE *, enum consFileType));
extern void FileSetQuoteIAC PARAMS((CONSFILE *, FLAG));
extern FLAG FileSawQuoteSusp PARAMS((CONSFILE *));
extern FLAG FileSawQuoteExec PARAMS((CONSFILE *));
extern FLAG FileSawQuoteAbrt PARAMS((CONSFILE *));
extern FLAG FileSawQuoteGoto PARAMS((CONSFILE *));
extern void Bye PARAMS((int)); extern void Bye PARAMS((int));
extern void DestroyDataStructures PARAMS((void)); extern void DestroyDataStructures PARAMS((void));
extern int IsMe PARAMS((char *)); extern int IsMe PARAMS((char *));
@ -136,7 +191,17 @@ extern int FileCanRead PARAMS((CONSFILE *, fd_set *, fd_set *));
extern int FileCanWrite PARAMS((CONSFILE *, fd_set *, fd_set *)); extern int FileCanWrite PARAMS((CONSFILE *, fd_set *, fd_set *));
extern int FileBufEmpty PARAMS((CONSFILE *)); extern int FileBufEmpty PARAMS((CONSFILE *));
extern int SetFlags PARAMS((int, int, int)); extern int SetFlags PARAMS((int, int, int));
extern char *StrDup PARAMS((char *)); extern char *StrDup PARAMS((const char *));
extern int ParseIACBuf PARAMS((CONSFILE *, void *, int *));
extern void *MemMove PARAMS((void *, void *, size_t));
extern char *StringChar PARAMS((STRING *, int, char));
extern void ParseFile PARAMS((char *, FILE *, int));
extern void ProbeInterfaces PARAMS((in_addr_t));
extern void ProcessSubst
PARAMS((SUBST *, char **, char **, char *, char *));
extern char *MyVersion PARAMS((void));
extern unsigned int AtoU PARAMS((char *));
extern void StrCpy PARAMS((char *, const char *, unsigned int));
#if HAVE_OPENSSL #if HAVE_OPENSSL
extern SSL *FileGetSSL PARAMS((CONSFILE *)); extern SSL *FileGetSSL PARAMS((CONSFILE *));
extern void FileSetSSL PARAMS((CONSFILE *, SSL *)); extern void FileSetSSL PARAMS((CONSFILE *, SSL *));

View File

@ -1,5 +1,5 @@
/* /*
* $Id: fallback.c,v 5.60 2003/11/20 13:56:38 bryan Exp $ * $Id: fallback.c,v 5.61 2004/04/16 16:58:09 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -210,7 +210,7 @@ GetPseudoTTY(slave, slaveFD)
continue; continue;
} }
if (0 > (fd = open(acMaster, O_RDWR | O_NDELAY, 0))) { if (0 > (fd = open(acMaster, O_RDWR | O_NONBLOCK, 0))) {
continue; continue;
} }
acSlave[iIndex] = *pcOne; acSlave[iIndex] = *pcOne;

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* /*
* $Id: group.h,v 5.42 2003/11/28 23:36:02 bryan Exp $ * $Id: group.h,v 5.49 2006/04/07 15:36:09 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -36,12 +36,13 @@
/* timers used to have various things happen */ /* timers used to have various things happen */
#define T_STATE 0 #define T_STATE 0
#define T_IDLE 1 #define T_CIDLE 1
#define T_MARK 2 #define T_MARK 2
#define T_REINIT 3 #define T_REINIT 3
#define T_AUTOUP 4 #define T_AUTOUP 4
#define T_ROLL 5 #define T_ROLL 5
#define T_MAX 6 /* T_MAX *must* be last */ #define T_INITDELAY 6
#define T_MAX 7 /* T_MAX *must* be last */
/* return values used by CheckPass() /* return values used by CheckPass()
*/ */
@ -63,7 +64,7 @@ typedef struct grpent { /* group info */
extern time_t timers[]; extern time_t timers[];
extern void Spawn PARAMS((GRPENT *)); extern void Spawn PARAMS((GRPENT *, int));
extern int CheckPass PARAMS((char *, char *)); extern int CheckPass PARAMS((char *, char *));
extern void TagLogfile PARAMS((const CONSENT *, char *, ...)); extern void TagLogfile PARAMS((const CONSENT *, char *, ...));
extern void TagLogfileAct PARAMS((const CONSENT *, char *, ...)); extern void TagLogfileAct PARAMS((const CONSENT *, char *, ...));
@ -79,7 +80,9 @@ PARAMS((GRPENT *, CONSCLIENT *, char *, FLAG));
extern int ClientAccess PARAMS((CONSENT *, char *)); extern int ClientAccess PARAMS((CONSENT *, char *));
extern void DestroyClient PARAMS((CONSCLIENT *)); extern void DestroyClient PARAMS((CONSCLIENT *));
extern int CheckPasswd PARAMS((CONSCLIENT *, char *)); extern int CheckPasswd PARAMS((CONSCLIENT *, char *));
extern void ExpandString PARAMS((char *, CONSENT *, short)); extern void DeUtmp PARAMS((GRPENT *, int));
extern void ClientWantsWrite PARAMS((CONSCLIENT *));
extern void SendIWaitClientsMsg PARAMS((CONSENT *, char *));
#if HAVE_OPENSSL #if HAVE_OPENSSL
extern int AttemptSSL PARAMS((CONSCLIENT *)); extern int AttemptSSL PARAMS((CONSCLIENT *));
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* $Id: main.c,v 5.172 2003/11/20 13:56:39 bryan Exp $ * $Id: main.c,v 5.200 2006/04/03 13:32:08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -40,10 +40,7 @@
#include <readcfg.h> #include <readcfg.h>
#include <version.h> #include <version.h>
#include <net/if.h> #include <dirent.h>
#if HAVE_SYS_SOCKIO_H
# include <sys/sockio.h>
#endif
#if HAVE_OPENSSL #if HAVE_OPENSSL
# include <openssl/opensslv.h> # include <openssl/opensslv.h>
#endif #endif
@ -53,9 +50,8 @@ int fAll = 0, fNoinit = 0, fVersion = 0, fStrip = 0, fReopen =
0, fNoautoreup = 0, fSyntaxOnly = 0; 0, fNoautoreup = 0, fSyntaxOnly = 0;
char *pcConfig = CONFIGFILE; char *pcConfig = CONFIGFILE;
int isMaster = 1;
int cMaxMemb = MAXMEMB; int cMaxMemb = MAXMEMB;
in_addr_t bindAddr; in_addr_t bindAddr = INADDR_ANY;
unsigned short bindPort; unsigned short bindPort;
unsigned short bindBasePort; unsigned short bindBasePort;
static STRING *startedMsg = (STRING *)0; static STRING *startedMsg = (STRING *)0;
@ -63,9 +59,9 @@ CONFIG *optConf = (CONFIG *)0;
CONFIG *config = (CONFIG *)0; CONFIG *config = (CONFIG *)0;
char *interface = (char *)0; char *interface = (char *)0;
CONFIG defConfig = CONFIG defConfig =
{ (STRING *)0, 'r', FLAGFALSE, LOGFILEPATH, PASSWDFILE, DEFPORT, { (STRING *)0, FLAGTRUE, 'r', FLAGFALSE, LOGFILEPATH, PASSWDFILE,
FLAGTRUE, DEFPORT,
FLAGTRUE, 0, DEFBASEPORT, (char *)0 FLAGTRUE, FLAGTRUE, 0, DEFBASEPORT, (char *)0, 0
#if HAVE_SETPROCTITLE #if HAVE_SETPROCTITLE
, FLAGFALSE , FLAGFALSE
#endif #endif
@ -327,6 +323,7 @@ SetupSSL()
#endif #endif
{ {
if (ctx == (SSL_CTX *)0) { if (ctx == (SSL_CTX *)0) {
char *ciphers;
SSL_load_error_strings(); SSL_load_error_strings();
if (!SSL_library_init()) { if (!SSL_library_init()) {
Error("SetupSSL(): SSL_library_init() failed"); Error("SetupSSL(): SSL_library_init() failed");
@ -356,6 +353,9 @@ SetupSSL()
config->sslcredentials); config->sslcredentials);
Bye(EX_SOFTWARE); Bye(EX_SOFTWARE);
} }
ciphers = "ALL:!LOW:!EXP:!MD5:!aNULL:@STRENGTH";
} else {
ciphers = "ALL:!LOW:!EXP:!MD5:@STRENGTH";
} }
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, SSLVerifyCallback); SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, SSLVerifyCallback);
SSL_CTX_set_options(ctx, SSL_CTX_set_options(ctx,
@ -366,8 +366,7 @@ SetupSSL()
SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER |
SSL_MODE_AUTO_RETRY); SSL_MODE_AUTO_RETRY);
SSL_CTX_set_tmp_dh_callback(ctx, TmpDHCallback); SSL_CTX_set_tmp_dh_callback(ctx, TmpDHCallback);
if (SSL_CTX_set_cipher_list(ctx, "ALL:!LOW:!EXP:!MD5:@STRENGTH") != if (SSL_CTX_set_cipher_list(ctx, ciphers) != 1) {
1) {
Error("SetupSSL(): setting SSL cipher list failed"); Error("SetupSSL(): setting SSL cipher list failed");
Bye(EX_SOFTWARE); Bye(EX_SOFTWARE);
} }
@ -419,8 +418,8 @@ ReopenLogfile()
close(2); close(2);
dup(1); dup(1);
if (isMaster && tag) { if (isMaster && tag) {
Msg("%s", THIS_VERSION); Msg(MyVersion());
Msg("%s", startedMsg->string); Msg(startedMsg->string);
} }
tag = 0; tag = 0;
} }
@ -476,6 +475,9 @@ Daemonize()
#if defined(SIGTSTP) #if defined(SIGTSTP)
SimpleSignal(SIGTSTP, SIG_IGN); SimpleSignal(SIGTSTP, SIG_IGN);
#endif #endif
#if defined(SIGXFSZ)
SimpleSignal(SIGXFSZ, SIG_IGN);
#endif
fflush(stdout); fflush(stdout);
fflush(stderr); fflush(stderr);
@ -523,7 +525,7 @@ Usage(wantfull)
#endif #endif
{ {
static char u_terse[] = static char u_terse[] =
"[-7dDEFhinoRSuvV] [-a type] [-m max] [-M addr] [-p port] [-b port] [-c cred] [-C config] [-P passwd] [-L logfile] [-O min] [-U logfile]"; "[-7dDEFhinoRSuvV] [-a type] [-m max] [-M master] [-p port] [-b port] [-c cred] [-C config] [-P passwd] [-L logfile] [-O min] [-U logfile]";
static char *full[] = { static char *full[] = {
"7 strip the high bit off all console data", "7 strip the high bit off all console data",
"a type set the default access type", "a type set the default access type",
@ -546,11 +548,19 @@ Usage(wantfull)
"i initialize console connections on demand", "i initialize console connections on demand",
"L logfile give a new logfile path to the server process", "L logfile give a new logfile path to the server process",
"m max maximum consoles managed per process", "m max maximum consoles managed per process",
"M addr address to listen on (all addresses by default)", #if USE_UNIX_DOMAIN_SOCKETS
"M master directory that holds the Unix domain sockets",
#else
"M master address to listen on (all addresses by default)",
#endif
"n obsolete - see -u", "n obsolete - see -u",
"o reopen downed console on client connect", "o reopen downed console on client connect",
"O min reopen all downed consoles every <min> minutes", "O min reopen all downed consoles every <min> minutes",
#if USE_UNIX_DOMAIN_SOCKETS
"p port ignored - Unix domain sockets compiled into code",
#else
"p port port to listen on", "p port port to listen on",
#endif
"P passwd give a new passwd file to the server process", "P passwd give a new passwd file to the server process",
"R disable automatic client redirection", "R disable automatic client redirection",
"S syntax check of configuration file", "S syntax check of configuration file",
@ -595,6 +605,9 @@ Version()
#endif #endif
#if TRUST_REVERSE_DNS #if TRUST_REVERSE_DNS
"trustrevdns", "trustrevdns",
#endif
#if USE_UNIX_DOMAIN_SOCKETS
"uds",
#endif #endif
(char *)0 (char *)0
}; };
@ -606,7 +619,7 @@ Version()
isMultiProc = 0; isMultiProc = 0;
Msg("%s", THIS_VERSION); Msg(MyVersion());
Msg("default access type `%c'", defConfig.defaultaccess); Msg("default access type `%c'", defConfig.defaultaccess);
Msg("default escape sequence `%s%s'", FmtCtl(DEFATTN, acA1), Msg("default escape sequence `%s%s'", FmtCtl(DEFATTN, acA1),
FmtCtl(DEFESC, acA2)); FmtCtl(DEFESC, acA2));
@ -616,9 +629,13 @@ Version()
Msg("default pidfile is `%s'", PIDFILE); Msg("default pidfile is `%s'", PIDFILE);
Msg("default limit is %d member%s per group", MAXMEMB, Msg("default limit is %d member%s per group", MAXMEMB,
MAXMEMB == 1 ? "" : "s"); MAXMEMB == 1 ? "" : "s");
#if USE_UNIX_DOMAIN_SOCKETS
Msg("default socket directory `%s'", UDSDIR);
#else
Msg("default primary port referenced as `%s'", defConfig.primaryport); Msg("default primary port referenced as `%s'", defConfig.primaryport);
Msg("default secondary base port referenced as `%s'", Msg("default secondary base port referenced as `%s'",
defConfig.secondaryport); defConfig.secondaryport);
#endif
BuildString((char *)0, acA1); BuildString((char *)0, acA1);
if (optionlist[0] == (char *)0) if (optionlist[0] == (char *)0)
@ -639,10 +656,12 @@ Version()
BuildStringChar('0' + DMALLOC_VERSION_MINOR, acA1); BuildStringChar('0' + DMALLOC_VERSION_MINOR, acA1);
BuildStringChar('.', acA1); BuildStringChar('.', acA1);
BuildStringChar('0' + DMALLOC_VERSION_PATCH, acA1); BuildStringChar('0' + DMALLOC_VERSION_PATCH, acA1);
#if defined(DMALLOC_VERSION_BETA)
if (DMALLOC_VERSION_BETA != 0) { if (DMALLOC_VERSION_BETA != 0) {
BuildString("-b", acA1); BuildString("-b", acA1);
BuildStringChar('0' + DMALLOC_VERSION_BETA, acA1); BuildStringChar('0' + DMALLOC_VERSION_BETA, acA1);
} }
#endif
Msg("dmalloc version: %s", acA1->string); Msg("dmalloc version: %s", acA1->string);
#endif #endif
#if HAVE_OPENSSL #if HAVE_OPENSSL
@ -684,6 +703,7 @@ DestroyDataStructures()
pACList = pAC; pACList = pAC;
} }
DestroyConsentUsers(&pADList); DestroyConsentUsers(&pADList);
DestroyConsentUsers(&pLUList);
DestroyConfig(pConfig); DestroyConfig(pConfig);
DestroyConfig(optConf); DestroyConfig(optConf);
@ -708,6 +728,8 @@ DestroyDataStructures()
DestroyBreakList(); DestroyBreakList();
DestroyStrings(); DestroyStrings();
DestroyUserList(); DestroyUserList();
if (substData != (SUBST *)0)
free(substData);
} }
void void
@ -839,13 +861,13 @@ DumpDataStructures()
GRPENT *pGE; GRPENT *pGE;
CONSENT *pCE; CONSENT *pCE;
REMOTE *pRC; REMOTE *pRC;
char *empty = "<empty>";
#if HAVE_DMALLOC && DMALLOC_MARK_MAIN #if HAVE_DMALLOC && DMALLOC_MARK_MAIN
CONDDEBUG((1, "DumpDataStructures(): dmalloc / MarkMain")); CONDDEBUG((1, "DumpDataStructures(): dmalloc / MarkMain"));
dmalloc_log_changed(dmallocMarkMain, 1, 0, 1); dmalloc_log_changed(dmallocMarkMain, 1, 0, 1);
#endif #endif
#define EMPTYSTR(x) x == (char *)0 ? empty : x #define EMPTYSTR(x) x == (char *)0 ? "(null)" : x
#define FLAGSTR(x) x == FLAGTRUE ? "true" : (x == FLAGFALSE ? "false" : "unset")
if (!fDebug) if (!fDebug)
return; return;
@ -853,7 +875,7 @@ DumpDataStructures()
for (pGE = pGroups; pGE != (GRPENT *)0; pGE = pGE->pGEnext) { for (pGE = pGroups; pGE != (GRPENT *)0; pGE = pGE->pGEnext) {
CONDDEBUG((1, CONDDEBUG((1,
"DumpDataStructures(): group: id=%u pid=%lu, port=%hu, imembers=%d", "DumpDataStructures(): group: id=%u port=%hu, pid=%lu, imembers=%d",
pGE->id, pGE->port, (unsigned long)pGE->pid, pGE->id, pGE->port, (unsigned long)pGE->pid,
pGE->imembers)); pGE->imembers));
@ -864,8 +886,9 @@ DumpDataStructures()
"DumpDataStructures(): server=%s, type=DEVICE", "DumpDataStructures(): server=%s, type=DEVICE",
EMPTYSTR(pCE->server))); EMPTYSTR(pCE->server)));
CONDDEBUG((1, CONDDEBUG((1,
"DumpDataStructures(): baud=%s, parity=%s", "DumpDataStructures(): baud=%s, parity=%s, device=%s",
pCE->baud->acrate, pCE->parity->key)); pCE->baud->acrate, pCE->parity->key,
EMPTYSTR(pCE->device)));
break; break;
case EXEC: case EXEC:
CONDDEBUG((1, CONDDEBUG((1,
@ -876,6 +899,9 @@ DumpDataStructures()
EMPTYSTR(pCE->execSlave), EMPTYSTR(pCE->execSlave),
EMPTYSTR(pCE->exec), EMPTYSTR(pCE->exec),
(unsigned long)pCE->ipid)); (unsigned long)pCE->ipid));
CONDDEBUG((1,
"DumpDataStructures(): execuid=%d, execgid=%d",
pCE->execuid, pCE->execgid));
break; break;
case HOST: case HOST:
@ -883,13 +909,25 @@ DumpDataStructures()
"DumpDataStructures(): server=%s, type=HOST", "DumpDataStructures(): server=%s, type=HOST",
EMPTYSTR(pCE->server))); EMPTYSTR(pCE->server)));
CONDDEBUG((1, CONDDEBUG((1,
"DumpDataStructures(): host=%s, port=%hu, telnetState=%d", "DumpDataStructures(): host=%s, raw=%s, netport=%hu, port=%hu, telnetState=%d",
EMPTYSTR(pCE->host), pCE->port, EMPTYSTR(pCE->host), FLAGSTR(pCE->raw),
pCE->telnetState)); pCE->netport, pCE->port, pCE->telnetState));
break; break;
case UNKNOWN: case NOOP:
CONDDEBUG((1, CONDDEBUG((1,
"DumpDataStructures(): server=%s, type=UNKNOWN", "DumpDataStructures(): server=%s, type=NOOP",
EMPTYSTR(pCE->server)));
break;
case UDS:
CONDDEBUG((1,
"DumpDataStructures(): server=%s, type=UDS",
EMPTYSTR(pCE->server)));
CONDDEBUG((1, "DumpDataStructures(): uds=%s",
EMPTYSTR(pCE->uds)));
break;
case UNKNOWNTYPE:
CONDDEBUG((1,
"DumpDataStructures(): server=%s, type=UNKNOWNTYPE",
EMPTYSTR(pCE->server))); EMPTYSTR(pCE->server)));
break; break;
} }
@ -907,36 +945,34 @@ DumpDataStructures()
CONDDEBUG((1, CONDDEBUG((1,
"DumpDataStructures(): mark=%d, nextMark=%ld, autoReup=%hu, downHard=%s", "DumpDataStructures(): mark=%d, nextMark=%ld, autoReup=%hu, downHard=%s",
pCE->mark, pCE->nextMark, pCE->autoReUp, pCE->mark, pCE->nextMark, pCE->autoReUp,
pCE->downHard == FLAGTRUE ? "true" : "false")); FLAGSTR(pCE->downHard)));
CONDDEBUG((1, CONDDEBUG((1,
"DumpDataStructures(): nolog=%d, cofile=%d, activitylog=%s, breaklog=%s", "DumpDataStructures(): nolog=%d, cofile=%d, activitylog=%s, breaklog=%s",
pCE->nolog, FileFDNum(pCE->cofile), pCE->nolog, FileFDNum(pCE->cofile),
pCE->activitylog == FLAGTRUE ? "true" : "false", FLAGSTR(pCE->activitylog), FLAGSTR(pCE->breaklog)));
pCE->breaklog == FLAGTRUE ? "true" : "false"));
CONDDEBUG((1, CONDDEBUG((1,
"DumpDataStructures(): ixon=%s, ixany=%s, ixoff=%s", "DumpDataStructures(): ixon=%s, ixany=%s, ixoff=%s",
pCE->ixon == FLAGTRUE ? "true" : "false", FLAGSTR(pCE->ixon), FLAGSTR(pCE->ixany),
pCE->ixany == FLAGTRUE ? "true" : "false", FLAGSTR(pCE->ixoff)));
pCE->ixoff == FLAGTRUE ? "true" : "false"));
CONDDEBUG((1, CONDDEBUG((1,
"DumpDataStructures(): autoreinit=%s, hupcl=%s, cstopb=%s, ondemand=%s", "DumpDataStructures(): autoreinit=%s, hupcl=%s, cstopb=%s, ondemand=%s",
pCE->autoreinit == FLAGTRUE ? "true" : "false", FLAGSTR(pCE->autoreinit), FLAGSTR(pCE->hupcl),
pCE->hupcl == FLAGTRUE ? "true" : "false", FLAGSTR(pCE->cstopb), FLAGSTR(pCE->ondemand)));
pCE->cstopb == FLAGTRUE ? "true" : "false",
pCE->ondemand == FLAGTRUE ? "true" : "false"));
#if defined(CRTSCTS) #if defined(CRTSCTS)
CONDDEBUG((1, "DumpDataStructures(): crtscts=%s", CONDDEBUG((1, "DumpDataStructures(): crtscts=%s",
pCE->crtscts == FLAGTRUE ? "true" : "false")); FLAGSTR(pCE->crtscts)));
#endif #endif
CONDDEBUG((1, CONDDEBUG((1,
"DumpDataStructures(): reinitoncc=%s, striphigh=%s, unloved=%s", "DumpDataStructures(): reinitoncc=%s, striphigh=%s",
pCE->reinitoncc == FLAGTRUE ? "true" : "false", FLAGSTR(pCE->reinitoncc), FLAGSTR(pCE->striphigh)));
pCE->striphigh == FLAGTRUE ? "true" : "false", CONDDEBUG((1, "DumpDataStructures(): unloved=%s, login=%s",
pCE->unloved == FLAGTRUE ? "true" : "false")); FLAGSTR(pCE->unloved), FLAGSTR(pCE->login)));
CONDDEBUG((1, CONDDEBUG((1,
"DumpDataStructures(): initpid=%lu, initcmd=%s, initfile=%d", "DumpDataStructures(): initpid=%lu, initcmd=%s, initfile=%d",
(unsigned long)pCE->initpid, EMPTYSTR(pCE->initcmd), (unsigned long)pCE->initpid, EMPTYSTR(pCE->initcmd),
FileFDNum(pCE->initfile))); FileFDNum(pCE->initfile)));
CONDDEBUG((1, "DumpDataStructures(): inituid=%d, initgid=%d",
pCE->inituid, pCE->initgid));
CONDDEBUG((1, CONDDEBUG((1,
"DumpDataStructures(): motd=%s, idletimeout=%d, idlestring=%s", "DumpDataStructures(): motd=%s, idletimeout=%d, idlestring=%s",
EMPTYSTR(pCE->motd), pCE->idletimeout, EMPTYSTR(pCE->motd), pCE->idletimeout,
@ -970,187 +1006,93 @@ DumpDataStructures()
} }
} }
/* fills the myAddrs array with host interface addresses */ /* This makes sure a directory exists and tries to create it if it
void * doesn't. returns 0 for success, -1 for error
*/
#if USE_UNIX_DOMAIN_SOCKETS
int
#if PROTOTYPES #if PROTOTYPES
ProbeInterfaces(void) VerifyEmptyDirectory(char *d)
#else #else
ProbeInterfaces() VerifyEmptyDirectory(d)
char *d;
#endif #endif
{ {
#ifdef SIOCGIFCONF struct stat dstat;
struct ifconf ifc; DIR *dir;
struct ifreq *ifr; struct dirent *de;
#ifdef SIOCGIFFLAGS STRING *path = (STRING *)0;
struct ifreq ifrcopy; int retval = 0;
#endif
int sock;
int r = 0, m = 0;
int bufsize = 2048;
int count = 0;
/* if we use -M, just fill the array with that interface */ while (1) {
if (bindAddr != INADDR_ANY) { if (stat(d, &dstat) == -1) {
myAddrs = (struct in_addr *)calloc(2, sizeof(struct in_addr)); if (errno == ENOENT) {
if (myAddrs == (struct in_addr *)0) if (mkdir(d, 0755) == -1) {
OutOfMem(); Error("mkdir(%s): %s", d, strerror(errno));
#if HAVE_MEMCPY return -1;
memcpy(&(myAddrs[0].s_addr), &bindAddr, sizeof(in_addr_t)); }
#else CONDDEBUG((1, "VerifyEmptyDirectory: created `%s'", d));
bcopy(&bindAddr, &(myAddrs[0].s_addr), sizeof(in_addr_t));
#endif
Verbose("interface address %s (-M option)", inet_ntoa(myAddrs[0]));
return;
}
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
Error("ProbeInterfaces(): socket(): %s", strerror(errno));
Bye(EX_OSERR);
}
while (bufsize) {
ifc.ifc_len = bufsize;
ifc.ifc_req = (struct ifreq *)malloc(ifc.ifc_len);
if (ifc.ifc_req == (struct ifreq *)0)
OutOfMem();
if (ioctl(sock, SIOCGIFCONF, &ifc) != 0) {
free(ifc.ifc_req);
close(sock);
Error("ProbeInterfaces(): ioctl(SIOCGIFCONF): %s",
strerror(errno));
Bye(EX_OSERR);
}
/* if the return size plus a 512 byte "buffer zone" is less than
* the buffer we passed in (bufsize), we're done. otherwise
* allocate a bigger buffer and try again. with a too-small
* buffer, some implementations (freebsd) will fill the buffer
* best it can (leaving a gap - returning <=bufsize) and others
* (linux) will return a buffer length the same size as passed
* in (==bufsize). so, we'll assume a 512 byte gap would have
* been big enough to put one more record and as long as we have
* that "buffer zone", we should have all the interfaces.
*/
if (ifc.ifc_len + 512 < bufsize)
break;
free(ifc.ifc_req);
bufsize += 2048;
}
/* this is probably way overkill, but better to kill a few bytes
* than loop through looking for valid interfaces that are up
* twice, huh?
*/
count = ifc.ifc_len / sizeof(*ifr);
CONDDEBUG((1, "ProbeInterfaces(): ifc_len==%d max_count==%d",
ifc.ifc_len, count));
/* set up myAddrs array */
if (myAddrs != (struct in_addr *)0)
free(myAddrs);
myAddrs = (struct in_addr *)0;
if (count == 0) {
free(ifc.ifc_req);
close(sock);
return;
}
myAddrs = (struct in_addr *)calloc(count + 1, sizeof(struct in_addr));
if (myAddrs == (struct in_addr *)0)
OutOfMem();
for (m = r = 0; r < ifc.ifc_len;) {
struct sockaddr *sa;
ifr = (struct ifreq *)&ifc.ifc_buf[r];
sa = (struct sockaddr *)&ifr->ifr_addr;
/* don't use less than a ifreq sized chunk */
if ((ifc.ifc_len - r) < sizeof(*ifr))
break;
#ifdef HAVE_SA_LEN
if (sa->sa_len > sizeof(ifr->ifr_addr))
r += sizeof(ifr->ifr_name) + sa->sa_len;
else
#endif
r += sizeof(*ifr);
if (sa->sa_family == AF_INET) {
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
#ifdef SIOCGIFFLAGS
/* make sure the interface is up */
ifrcopy = *ifr;
if ((ioctl(sock, SIOCGIFFLAGS, &ifrcopy) == 0) &&
((ifrcopy.ifr_flags & IFF_UP) == 0))
continue; continue;
#endif } else {
CONDDEBUG((1, "ProbeInterfaces(): name=%s addr=%s", Error("stat(%s): %s", d, strerror(errno));
ifr->ifr_name, inet_ntoa(sin->sin_addr))); return -1;
#if HAVE_MEMCPY }
memcpy(&myAddrs[m], &(sin->sin_addr), sizeof(struct in_addr));
#else
bcopy(&(sin->sin_addr), &myAddrs[m], sizeof(struct in_addr));
#endif
Verbose("interface address %s (%s)", inet_ntoa(myAddrs[m]),
ifr->ifr_name);
m++;
} }
} if (S_ISDIR(dstat.st_mode))
if (m == 0) { break;
free(myAddrs); return -1;
myAddrs = (struct in_addr *)0;
}
close(sock);
free(ifc.ifc_req);
#else /* use the hostname like the old code did (but use all addresses!) */
int count;
struct hostent *he;
/* if we use -M, just fill the array with that interface */
if (bindAddr != INADDR_ANY) {
myAddrs = (struct in_addr *)calloc(2, sizeof(struct in_addr));
if (myAddrs == (struct in_addr *)0)
OutOfMem();
#if HAVE_MEMCPY
memcpy(&(myAddrs[0].s_addr), &bindAddr, sizeof(in_addr_t));
#else
bcopy(&bindAddr, &(myAddrs[0].s_addr), sizeof(in_addr_t));
#endif
Verbose("interface address %s (-M option)", inet_ntoa(myAddrs[0]));
return;
} }
Verbose("using hostname for interface addresses"); /* now make sure it's empty...erase anything you see, etc */
if ((struct hostent *)0 == (he = gethostbyname(myHostname))) { if ((dir = opendir(d)) == (DIR *) 0) {
Error("ProbeInterfaces(): gethostbyname(%s): %s", myHostname, Error("opendir(%s): %s", d, strerror(errno));
hstrerror(h_errno)); return -1;
return;
}
if (4 != he->h_length || AF_INET != he->h_addrtype) {
Error
("ProbeInterfaces(): gethostbyname(%s): wrong address size (4 != %d) or address family (%d != %d)",
myHostname, he->h_length, AF_INET, he->h_addrtype);
return;
} }
for (count = 0; he->h_addr_list[count] != (char *)0; count++); while ((de = readdir(dir)) != (struct dirent *)0) {
if (myAddrs != (struct in_addr *)0) if ((strcmp(de->d_name, ".") == 0) ||
free(myAddrs); (strcmp(de->d_name, "..") == 0))
myAddrs = (struct in_addr *)0; continue;
if (count == 0) /* we're going to just let the user deal with non-empty directories */
return; Error("non-empty directory `%s'", d);
myAddrs = (struct in_addr *)calloc(count + 1, sizeof(struct in_addr)); retval = -1;
if (myAddrs == (struct in_addr *)0) break;
OutOfMem(); /* this is probably too extreme. if someone happens to point conserver
for (count--; count >= 0; count--) { * at /etc, for example, it could (if running as root) nuke the password
#if HAVE_MEMCPY * database, config files, etc. too many important files could be
memcpy(&(myAddrs[count].s_addr), he->h_addr_list[count], * shredded with a small typo.
he->h_length); */
#else #if 0
bcopy(he->h_addr_list[count], &(myAddrs[count].s_addr), if (path == (STRING *)0)
he->h_length); path = AllocString();
BuildStringPrint(path, "%s/%s", d, de->d_name);
if (stat(path->string, &dstat) == -1) {
Error("stat(%s): %s", path->string, strerror(errno));
retval = -1;
break;
}
if (S_ISDIR(dstat.st_mode)) {
if (rmdir(path->string) != 0) {
Error("rmdir(%s): %s", path->string, strerror(errno));
retval = -1;
break;
}
} else {
if (unlink(path->string) != 0) {
Error("unlink(%s): %s", path->string, strerror(errno));
retval = -1;
break;
}
}
#endif #endif
Verbose("interface address %s (hostname address)",
inet_ntoa(myAddrs[count]));
} }
#endif
if (path != (STRING *)0)
DestroyString(path);
return retval;
} }
#endif
/* find out where/who we are (ksb) /* find out where/who we are (ksb)
* parse optons * parse optons
@ -1179,17 +1121,19 @@ main(argc, argv)
char *curuser = (char *)0; char *curuser = (char *)0;
int curuid = 0; int curuid = 0;
GRPENT *pGE = (GRPENT *)0; GRPENT *pGE = (GRPENT *)0;
#if !USE_UNIX_DOMAIN_SOCKETS
#if HAVE_INET_ATON #if HAVE_INET_ATON
struct in_addr inetaddr; struct in_addr inetaddr;
#endif
#endif #endif
isMultiProc = 1; /* make sure stuff has the pid */ isMultiProc = 1; /* make sure stuff has the pid */
thepid = getpid(); thepid = getpid();
if ((char *)0 == (progname = strrchr(argv[0], '/'))) { if ((char *)0 == (progname = strrchr(argv[0], '/'))) {
progname = StrDup(argv[0]); progname = argv[0];
} else { } else {
progname = StrDup(++progname); ++progname;
} }
setpwent(); setpwent();
@ -1251,7 +1195,7 @@ main(argc, argv)
#endif #endif
break; break;
case 'C': case 'C':
pcConfig = StrDup(optarg); pcConfig = optarg;
break; break;
case 'd': case 'd':
optConf->daemonmode = FLAGTRUE; optConf->daemonmode = FLAGTRUE;
@ -1311,7 +1255,7 @@ main(argc, argv)
optConf->redirect = FLAGFALSE; optConf->redirect = FLAGFALSE;
break; break;
case 'S': case 'S':
fSyntaxOnly = 1; fSyntaxOnly++;
break; break;
case 'u': case 'u':
fAll = 1; fAll = 1;
@ -1340,7 +1284,7 @@ main(argc, argv)
Bye(EX_OK); Bye(EX_OK);
} }
Msg("%s", THIS_VERSION); Msg(MyVersion());
#if HAVE_GETLOGIN #if HAVE_GETLOGIN
origuser = getlogin(); origuser = getlogin();
@ -1378,37 +1322,46 @@ main(argc, argv)
if (fSyntaxOnly) if (fSyntaxOnly)
Msg("performing configuration file syntax check"); Msg("performing configuration file syntax check");
#if USE_UNIX_DOMAIN_SOCKETS
/* Don't do any redirects if we're purely local
* (but it allows them to see where remote consoles are)
*/
optConf->redirect = FLAGFALSE;
if (interface == (char *)0)
interface = UDSDIR;
#else
/* set up the address to bind to */ /* set up the address to bind to */
if (interface == (char *)0 || if (interface == (char *)0 ||
(interface[0] == '*' && interface[1] == '\000')) (interface[0] == '*' && interface[1] == '\000'))
bindAddr = INADDR_ANY; bindAddr = INADDR_ANY;
else { else {
#if HAVE_INET_ATON # if HAVE_INET_ATON
if (inet_aton(interface, &inetaddr) == 0) { if (inet_aton(interface, &inetaddr) == 0) {
Error("inet_aton(%s): %s", interface, "invalid IP address"); Error("inet_aton(%s): %s", interface, "invalid IP address");
Bye(EX_OSERR); Bye(EX_OSERR);
} }
bindAddr = inetaddr.s_addr; bindAddr = inetaddr.s_addr;
#else # else
bindAddr = inet_addr(interface); bindAddr = inet_addr(interface);
if (bindAddr == (in_addr_t) (-1)) { if (bindAddr == (in_addr_t) (-1)) {
Error("inet_addr(%s): %s", interface, "invalid IP address"); Error("inet_addr(%s): %s", interface, "invalid IP address");
Bye(EX_OSERR); Bye(EX_OSERR);
} }
#endif # endif
} }
if (fDebug) { if (fDebug) {
struct in_addr ba; struct in_addr ba;
ba.s_addr = bindAddr; ba.s_addr = bindAddr;
CONDDEBUG((1, "main(): bind address set to `%s'", inet_ntoa(ba))); CONDDEBUG((1, "main(): bind address set to `%s'", inet_ntoa(ba)));
} }
#endif
/* must do all this so IsMe() works right */ /* must do all this so IsMe() works right */
if (gethostname(myHostname, MAXHOSTNAME) != 0) { if (gethostname(myHostname, MAXHOSTNAME) != 0) {
Error("gethostname(): %s", interface, strerror(errno)); Error("gethostname(): %s", strerror(errno));
Bye(EX_OSERR); Bye(EX_OSERR);
} }
ProbeInterfaces(); ProbeInterfaces(bindAddr);
/* initialize the timers */ /* initialize the timers */
for (i = 0; i < T_MAX; i++) for (i = 0; i < T_MAX; i++)
@ -1422,6 +1375,7 @@ main(argc, argv)
ReadCfg(pcConfig, fpConfig); ReadCfg(pcConfig, fpConfig);
fclose(fpConfig); fclose(fpConfig);
#if !USE_UNIX_DOMAIN_SOCKETS
/* set up the port to bind to */ /* set up the port to bind to */
if (optConf->primaryport != (char *)0) if (optConf->primaryport != (char *)0)
config->primaryport = StrDup(optConf->primaryport); config->primaryport = StrDup(optConf->primaryport);
@ -1481,6 +1435,7 @@ main(argc, argv)
bindBasePort = ntohs((unsigned short)pSE->s_port); bindBasePort = ntohs((unsigned short)pSE->s_port);
} }
} }
#endif
if (optConf->passwdfile != (char *)0) if (optConf->passwdfile != (char *)0)
config->passwdfile = StrDup(optConf->passwdfile); config->passwdfile = StrDup(optConf->passwdfile);
@ -1528,6 +1483,13 @@ main(argc, argv)
else else
config->redirect = defConfig.redirect; config->redirect = defConfig.redirect;
if (optConf->autocomplete != FLAGUNKNOWN)
config->autocomplete = optConf->autocomplete;
else if (pConfig->autocomplete != FLAGUNKNOWN)
config->autocomplete = pConfig->autocomplete;
else
config->autocomplete = defConfig.autocomplete;
if (optConf->loghostnames != FLAGUNKNOWN) if (optConf->loghostnames != FLAGUNKNOWN)
config->loghostnames = optConf->loghostnames; config->loghostnames = optConf->loghostnames;
else if (pConfig->loghostnames != FLAGUNKNOWN) else if (pConfig->loghostnames != FLAGUNKNOWN)
@ -1548,6 +1510,14 @@ main(argc, argv)
if (config->unifiedlog == (char *)0) if (config->unifiedlog == (char *)0)
OutOfMem(); OutOfMem();
} }
if (optConf->initdelay != 0)
config->initdelay = optConf->initdelay;
else if (pConfig->initdelay != 0)
config->initdelay = pConfig->initdelay;
else
config->initdelay = defConfig.initdelay;
#if HAVE_OPENSSL #if HAVE_OPENSSL
if (optConf->sslrequired != FLAGUNKNOWN) if (optConf->sslrequired != FLAGUNKNOWN)
config->sslrequired = optConf->sslrequired; config->sslrequired = optConf->sslrequired;
@ -1579,7 +1549,13 @@ main(argc, argv)
if (pGroups == (GRPENT *)0 && pRCList == (REMOTE *)0) { if (pGroups == (GRPENT *)0 && pRCList == (REMOTE *)0) {
Error("no consoles found in configuration file"); Error("no consoles found in configuration file");
} else if (!fSyntaxOnly) { } else if (fSyntaxOnly) {
/* short-circuit */
#if USE_UNIX_DOMAIN_SOCKETS
} else if (VerifyEmptyDirectory(interface) == -1) {
Error("Master(): %s: unusable socket directory", interface);
#endif
} else {
#if HAVE_OPENSSL #if HAVE_OPENSSL
/* Prep the SSL layer */ /* Prep the SSL layer */
SetupSSL(); SetupSSL();
@ -1601,8 +1577,7 @@ main(argc, argv)
if (pGE->imembers == 0) if (pGE->imembers == 0)
continue; continue;
Spawn(pGE); Spawn(pGE, -1);
Verbose("group #%d pid %lu on port %hu", pGE->id, Verbose("group #%d pid %lu on port %hu", pGE->id,
(unsigned long)pGE->pid, pGE->port); (unsigned long)pGE->pid, pGE->port);
} }
@ -1616,8 +1591,13 @@ main(argc, argv)
local += pGE->imembers; local += pGE->imembers;
for (pRC = pRCList; (REMOTE *)0 != pRC; pRC = pRC->pRCnext) for (pRC = pRCList; (REMOTE *)0 != pRC; pRC = pRC->pRCnext)
remote++; remote++;
# if USE_UNIX_DOMAIN_SOCKETS
setproctitle("master: port 0, %d local, %d remote", local,
remote);
#else
setproctitle("master: port %hu, %d local, %d remote", bindPort, setproctitle("master: port %hu, %d local, %d remote", bindPort,
local, remote); local, remote);
#endif
} }
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* $Id: main.h,v 5.51 2003/11/10 15:37:24 bryan Exp $ * $Id: main.h,v 5.53 2004/05/21 04:15:17 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -44,11 +44,13 @@ extern unsigned short bindPort, bindBasePort;
extern char *pcConfig; extern char *pcConfig;
extern int cMaxMemb; extern int cMaxMemb;
extern struct sockaddr_in in_port; extern struct sockaddr_in in_port;
extern int isMaster;
extern CONFIG *optConf; extern CONFIG *optConf;
extern CONFIG *config; extern CONFIG *config;
extern CONFIG defConfig; extern CONFIG defConfig;
extern CONSFILE *unifiedlog; extern CONSFILE *unifiedlog;
#if USE_UNIX_DOMAIN_SOCKETS
extern char *interface;
#endif
#if HAVE_OPENSSL #if HAVE_OPENSSL
extern SSL_CTX *ctx; extern SSL_CTX *ctx;
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* $Id: master.c,v 5.123 2003/11/20 13:56:39 bryan Exp $ * $Id: master.c,v 5.135 2006/04/07 15:47:20 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -36,7 +36,6 @@
#include <access.h> #include <access.h>
#include <master.h> #include <master.h>
#include <readcfg.h> #include <readcfg.h>
#include <version.h>
#include <main.h> #include <main.h>
@ -68,9 +67,10 @@ FlagSawCHLD(sig)
*/ */
static void static void
#if PROTOTYPES #if PROTOTYPES
FixKids() FixKids(int msfd)
#else #else
FixKids() FixKids(msfd)
int msfd;
#endif #endif
{ {
pid_t pid; pid_t pid;
@ -124,7 +124,7 @@ FixKids()
/* this kid kid is dead, start another /* this kid kid is dead, start another
*/ */
Spawn(pGE); Spawn(pGE, msfd);
Verbose("group #%d pid %lu on port %hu", pGE->id, Verbose("group #%d pid %lu on port %hu", pGE->id,
(unsigned long)pGE->pid, pGE->port); (unsigned long)pGE->pid, pGE->port);
} }
@ -292,7 +292,8 @@ CommandCall(pCL, args)
pRCFound = pRC; pRCFound = pRC;
} }
} }
if (found == 0) { /* Then look for substring matches */ if (found == 0 && config->autocomplete == FLAGTRUE) {
/* Then look for substring matches */
NAMES *name = (NAMES *)0; NAMES *name = (NAMES *)0;
int foundOne = 0; int foundOne = 0;
for (pGE = pGroups; pGE != (GRPENT *)0; pGE = pGE->pGEnext) { for (pGE = pGroups; pGE != (GRPENT *)0; pGE = pGE->pGEnext) {
@ -433,7 +434,7 @@ DoNormalRead(pCLServing)
{ {
char *pcCmd; char *pcCmd;
char *pcArgs; char *pcArgs;
int nr, i; int nr, i, l;
unsigned char acIn[BUFSIZ]; unsigned char acIn[BUFSIZ];
/* read connection */ /* read connection */
@ -442,208 +443,267 @@ DoNormalRead(pCLServing)
return; return;
} }
for (i = 0; i < nr; ++i) { while ((l = ParseIACBuf(pCLServing->fd, acIn, &nr)) >= 0) {
if ('\n' != acIn[i]) { if (l == 0) /* we ignore special OB_IAC stuff */
BuildStringChar(acIn[i], pCLServing->accmd);
continue; continue;
} for (i = 0; i < l; ++i) {
if ((pCLServing->accmd->used > 1) && if ('\n' != acIn[i]) {
('\r' == BuildStringChar(acIn[i], pCLServing->accmd);
pCLServing->accmd->string[pCLServing->accmd->used - 2])) { continue;
pCLServing->accmd->string[pCLServing->accmd->used - 2] = }
'\000'; if ((pCLServing->accmd->used > 1) &&
pCLServing->accmd->used--; ('\r' ==
} pCLServing->accmd->string[pCLServing->accmd->used - 2])) {
pCLServing->accmd->string[pCLServing->accmd->used - 2] =
'\000';
pCLServing->accmd->used--;
}
/* process password here...before we corrupt accmd */ /* process password here...before we corrupt accmd */
if (pCLServing->iState == S_PASSWD) { if (pCLServing->iState == S_PASSWD) {
if (CheckPasswd(pCLServing, pCLServing->accmd->string) != if (CheckPasswd(pCLServing, pCLServing->accmd->string) !=
AUTH_SUCCESS) { AUTH_SUCCESS) {
FileWrite(pCLServing->fd, FLAGFALSE, FileWrite(pCLServing->fd, FLAGFALSE,
"invalid password\r\n", -1); "invalid password\r\n", -1);
BuildString((char *)0, pCLServing->accmd);
DropMasterClient(pCLServing, FLAGFALSE);
return;
}
Verbose("<master> login %s", pCLServing->acid->string);
FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", 4);
pCLServing->iState = S_NORMAL;
BuildString((char *)0, pCLServing->accmd); BuildString((char *)0, pCLServing->accmd);
DropMasterClient(pCLServing, FLAGFALSE); continue;
return;
} }
Verbose("<master> login %s", pCLServing->acid->string);
FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", 4);
pCLServing->iState = S_NORMAL;
BuildString((char *)0, pCLServing->accmd);
continue;
}
if ((char *)0 != (pcArgs = strchr(pCLServing->accmd->string, ':'))) { if ((char *)0 !=
*pcArgs++ = '\000'; (pcArgs = strchr(pCLServing->accmd->string, ':'))) {
} else if ((char *)0 != *pcArgs++ = '\000';
(pcArgs = strchr(pCLServing->accmd->string, ' '))) { } else if ((char *)0 !=
*pcArgs++ = '\000'; (pcArgs = strchr(pCLServing->accmd->string, ' '))) {
} *pcArgs++ = '\000';
if (pcArgs != (char *)0)
pcArgs = PruneSpace(pcArgs);
pcCmd = PruneSpace(pCLServing->accmd->string);
if (strcmp(pcCmd, "help") == 0) {
static char *apcHelp1[] = {
"exit disconnect\r\n",
"help this help message\r\n",
"login log in\r\n",
#if HAVE_OPENSSL
"ssl start ssl session\r\n",
#endif
(char *)0
};
static char *apcHelp2[] = {
"call provide port for given console\r\n",
"exit disconnect\r\n",
"groups provide ports for group leaders\r\n",
"help this help message\r\n",
"master provide a list of master servers\r\n",
"pid provide pid of master process\r\n",
"quit* terminate conserver (SIGTERM)\r\n",
"restart* restart conserver (SIGHUP)\r\n",
"version provide version info for server\r\n",
"* = requires admin privileges\r\n",
(char *)0
};
char **ppc;
for (ppc =
(pCLServing->iState == S_IDENT ? apcHelp1 : apcHelp2);
(char *)0 != *ppc; ++ppc) {
FileWrite(pCLServing->fd, FLAGTRUE, *ppc, -1);
} }
FileWrite(pCLServing->fd, FLAGFALSE, (char *)0, 0); if (pcArgs != (char *)0)
} else if (strcmp(pcCmd, "exit") == 0) { pcArgs = PruneSpace(pcArgs);
FileWrite(pCLServing->fd, FLAGFALSE, "goodbye\r\n", -1); pcCmd = PruneSpace(pCLServing->accmd->string);
DropMasterClient(pCLServing, FLAGFALSE); if (strcmp(pcCmd, "help") == 0) {
return; static char *apcHelp1[] = {
"exit disconnect\r\n",
"help this help message\r\n",
"login log in\r\n",
#if HAVE_OPENSSL #if HAVE_OPENSSL
} else if (pCLServing->iState == S_IDENT && "ssl start ssl session\r\n",
strcmp(pcCmd, "ssl") == 0) { #endif
FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", -1); (char *)0
if (!AttemptSSL(pCLServing)) { };
static char *apcHelp2[] = {
"call provide port for given console\r\n",
"exit disconnect\r\n",
"groups provide ports for group leaders\r\n",
"help this help message\r\n",
"master provide a list of master servers\r\n",
"newlogs* close and open all logfiles (SIGUSR2)\r\n",
"pid provide pid of master process\r\n",
"quit* terminate conserver (SIGTERM)\r\n",
"restart* restart conserver (SIGHUP) - deprecated\r\n",
"reconfig* reread config file (SIGHUP)\r\n",
"version provide version info for server\r\n",
"up* bring up all downed consoles (SIGUSR1)\r\n",
"* = requires admin privileges\r\n",
(char *)0
};
char **ppc;
for (ppc =
(pCLServing->iState == S_IDENT ? apcHelp1 : apcHelp2);
(char *)0 != *ppc; ++ppc) {
FileWrite(pCLServing->fd, FLAGTRUE, *ppc, -1);
}
FileWrite(pCLServing->fd, FLAGFALSE, (char *)0, 0);
} else if (strcmp(pcCmd, "exit") == 0) {
FileWrite(pCLServing->fd, FLAGFALSE, "goodbye\r\n", -1);
DropMasterClient(pCLServing, FLAGFALSE); DropMasterClient(pCLServing, FLAGFALSE);
return; return;
}
#endif
} else if (pCLServing->iState == S_IDENT &&
strcmp(pcCmd, "login") == 0) {
#if HAVE_OPENSSL #if HAVE_OPENSSL
if (config->sslrequired == FLAGTRUE && } else if (pCLServing->iState == S_IDENT &&
FileGetType(pCLServing->fd) != SSLSocket) { strcmp(pcCmd, "ssl") == 0) {
FileWrite(pCLServing->fd, FLAGFALSE, FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", -1);
"encryption required\r\n", -1); if (!AttemptSSL(pCLServing)) {
} else { DropMasterClient(pCLServing, FLAGFALSE);
return;
}
#endif #endif
if (pcArgs == (char *)0) { } else if (pCLServing->iState == S_IDENT &&
strcmp(pcCmd, "login") == 0) {
#if HAVE_OPENSSL
if (config->sslrequired == FLAGTRUE &&
FileGetType(pCLServing->fd) != SSLSocket) {
FileWrite(pCLServing->fd, FLAGFALSE, FileWrite(pCLServing->fd, FLAGFALSE,
"login requires argument\r\n", -1); "encryption required\r\n", -1);
} else { } else {
BuildString((char *)0, pCLServing->username);
BuildString((char *)0, pCLServing->acid);
BuildString(pcArgs, pCLServing->username);
BuildString(pcArgs, pCLServing->acid);
BuildStringChar('@', pCLServing->acid);
BuildString(pCLServing->peername->string,
pCLServing->acid);
if (pCLServing->caccess == 't' ||
CheckPasswd(pCLServing, "") == AUTH_SUCCESS) {
pCLServing->iState = S_NORMAL;
Verbose("<master> login %s",
pCLServing->acid->string);
FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", 4);
} else {
FilePrint(pCLServing->fd, FLAGFALSE,
"passwd? %s\r\n", myHostname);
pCLServing->iState = S_PASSWD;
}
}
#if HAVE_OPENSSL
}
#endif #endif
} else if (pCLServing->iState == S_NORMAL && if (pcArgs == (char *)0) {
strcmp(pcCmd, "master") == 0) { FileWrite(pCLServing->fd, FLAGFALSE,
int iSep = 1; "login requires argument\r\n", -1);
} else {
if ((GRPENT *)0 != pGroups) { BuildString((char *)0, pCLServing->username);
struct sockaddr_in lcl; BuildString((char *)0, pCLServing->acid);
socklen_t so = sizeof(lcl); BuildString(pcArgs, pCLServing->username);
if (-1 == BuildString(pcArgs, pCLServing->acid);
getsockname(FileFDNum(pCLServing->fd), BuildStringChar('@', pCLServing->acid);
(struct sockaddr *)&lcl, &so)) { BuildString(pCLServing->peername->string,
FileWrite(pCLServing->fd, FLAGFALSE, pCLServing->acid);
"getsockname failed, try again later\r\n", if (pCLServing->caccess == 't' ||
-1); CheckPasswd(pCLServing, "") == AUTH_SUCCESS) {
Error("Master(): getsockname(%u): %s", pCLServing->iState = S_NORMAL;
FileFDNum(pCLServing->fd), strerror(errno)); Verbose("<master> login %s",
Bye(EX_OSERR); pCLServing->acid->string);
FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n",
4);
} else {
FilePrint(pCLServing->fd, FLAGFALSE,
"passwd? %s\r\n", myHostname);
pCLServing->iState = S_PASSWD;
}
}
#if HAVE_OPENSSL
} }
FilePrint(pCLServing->fd, FLAGTRUE, "@%s", #endif
inet_ntoa(lcl.sin_addr)); } else if (pCLServing->iState == S_NORMAL &&
iSep = 0; strcmp(pcCmd, "master") == 0) {
} int iSep = 1;
if (config->redirect == FLAGTRUE) {
REMOTE *pRC; if ((GRPENT *)0 != pGroups) {
for (pRC = pRCUniq; (REMOTE *)0 != pRC; pRC = pRC->pRCuniq) { #if USE_UNIX_DOMAIN_SOCKETS
FilePrint(pCLServing->fd, FLAGTRUE, ":@%s" + iSep, FilePrint(pCLServing->fd, FLAGTRUE, "@0");
pRC->rhost); iSep = 0;
#else
struct sockaddr_in lcl;
socklen_t so = sizeof(lcl);
if (-1 ==
getsockname(FileFDNum(pCLServing->fd),
(struct sockaddr *)&lcl, &so)) {
FileWrite(pCLServing->fd, FLAGFALSE,
"getsockname failed, try again later\r\n",
-1);
Error("Master(): getsockname(%u): %s",
FileFDNum(pCLServing->fd), strerror(errno));
iSep = -1;
} else {
FilePrint(pCLServing->fd, FLAGTRUE, "@%s",
inet_ntoa(lcl.sin_addr));
iSep = 0;
}
#endif
}
if (iSep >= 0) {
if (config->redirect == FLAGTRUE) {
REMOTE *pRC;
for (pRC = pRCUniq; (REMOTE *)0 != pRC;
pRC = pRC->pRCuniq) {
FilePrint(pCLServing->fd, FLAGTRUE,
":@%s" + iSep, pRC->rhost);
iSep = 0;
}
}
FileWrite(pCLServing->fd, FLAGFALSE, "\r\n", -1);
}
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "pid") == 0) {
FilePrint(pCLServing->fd, FLAGFALSE, "%lu\r\n",
(unsigned long)thepid);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "version") == 0) {
FilePrint(pCLServing->fd, FLAGFALSE, "version `%s'\r\n",
MyVersion());
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "quit") == 0) {
if (ConsentUserOk(pADList, pCLServing->username->string) ==
1) {
Verbose("quit command by %s",
pCLServing->acid->string);
FileWrite(pCLServing->fd, FLAGFALSE,
"ok -- terminated\r\n", -1);
DropMasterClient(pCLServing, FLAGFALSE);
kill(thepid, SIGTERM);
return;
} else
FileWrite(pCLServing->fd, FLAGFALSE,
"unauthorized command\r\n", -1);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "restart") == 0) {
if (ConsentUserOk(pADList, pCLServing->username->string) ==
1) {
FileWrite(pCLServing->fd, FLAGFALSE,
"ok -- restarting\r\n", -1);
Verbose("restart command by %s",
pCLServing->acid->string);
kill(thepid, SIGHUP);
} else
FileWrite(pCLServing->fd, FLAGFALSE,
"unauthorized command\r\n", -1);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "reconfig") == 0) {
if (ConsentUserOk(pADList, pCLServing->username->string) ==
1) {
FileWrite(pCLServing->fd, FLAGFALSE,
"ok -- reconfiguring\r\n", -1);
Verbose("reconfig command by %s",
pCLServing->acid->string);
kill(thepid, SIGHUP);
} else
FileWrite(pCLServing->fd, FLAGFALSE,
"unauthorized command\r\n", -1);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "up") == 0) {
if (ConsentUserOk(pADList, pCLServing->username->string) ==
1) {
FileWrite(pCLServing->fd, FLAGFALSE,
"ok -- bringing up consoles\r\n", -1);
Verbose("up command by %s", pCLServing->acid->string);
kill(thepid, SIGUSR1);
} else
FileWrite(pCLServing->fd, FLAGFALSE,
"unauthorized command\r\n", -1);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "newlogs") == 0) {
if (ConsentUserOk(pADList, pCLServing->username->string) ==
1) {
FileWrite(pCLServing->fd, FLAGFALSE,
"ok -- opening new logfiles\r\n", -1);
Verbose("newlogs command by %s",
pCLServing->acid->string);
kill(thepid, SIGUSR2);
} else
FileWrite(pCLServing->fd, FLAGFALSE,
"unauthorized command\r\n", -1);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "groups") == 0) {
int iSep = 1;
GRPENT *pGE;
for (pGE = pGroups; pGE != (GRPENT *)0; pGE = pGE->pGEnext) {
if (0 == pGE->imembers)
continue;
FilePrint(pCLServing->fd, FLAGTRUE, ":%hu" + iSep,
pGE->port);
iSep = 0; iSep = 0;
} }
FileWrite(pCLServing->fd, FLAGFALSE, "\r\n", 2);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "call") == 0) {
if (pcArgs == (char *)0)
FileWrite(pCLServing->fd, FLAGFALSE,
"call requires argument\r\n", -1);
else
CommandCall(pCLServing, pcArgs);
} else {
FileWrite(pCLServing->fd, FLAGFALSE, "unknown command\r\n",
-1);
} }
FileWrite(pCLServing->fd, FLAGFALSE, "\r\n", -1); BuildString((char *)0, pCLServing->accmd);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "pid") == 0) {
FilePrint(pCLServing->fd, FLAGFALSE, "%lu\r\n",
(unsigned long)thepid);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "version") == 0) {
FilePrint(pCLServing->fd, FLAGFALSE, "version `%s'\r\n",
THIS_VERSION);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "quit") == 0) {
if (ConsentUserOk(pADList, pCLServing->username->string) == 1) {
Verbose("quit command by %s", pCLServing->acid->string);
FileWrite(pCLServing->fd, FLAGFALSE,
"ok -- terminated\r\n", -1);
DropMasterClient(pCLServing, FLAGFALSE);
kill(thepid, SIGTERM);
return;
} else
FileWrite(pCLServing->fd, FLAGFALSE,
"unauthorized command\r\n", -1);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "restart") == 0) {
if (ConsentUserOk(pADList, pCLServing->username->string) == 1) {
FileWrite(pCLServing->fd, FLAGFALSE,
"ok -- restarting\r\n", -1);
Verbose("restart command by %s", pCLServing->acid->string);
kill(thepid, SIGHUP);
} else
FileWrite(pCLServing->fd, FLAGFALSE,
"unauthorized command\r\n", -1);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "groups") == 0) {
int iSep = 1;
GRPENT *pGE;
for (pGE = pGroups; pGE != (GRPENT *)0; pGE = pGE->pGEnext) {
if (0 == pGE->imembers)
continue;
FilePrint(pCLServing->fd, FLAGTRUE, ":%hu" + iSep,
pGE->port);
iSep = 0;
}
FileWrite(pCLServing->fd, FLAGFALSE, "\r\n", 2);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "call") == 0) {
if (pcArgs == (char *)0)
FileWrite(pCLServing->fd, FLAGFALSE,
"call requires argument\r\n", -1);
else
CommandCall(pCLServing, pcArgs);
} else {
FileWrite(pCLServing->fd, FLAGFALSE, "unknown command\r\n",
-1);
} }
BuildString((char *)0, pCLServing->accmd); nr -= l;
MemMove(acIn, acIn + l, nr);
} }
} }
@ -660,8 +720,15 @@ Master()
int msfd; int msfd;
socklen_t so; socklen_t so;
fd_set rmask, wmask; fd_set rmask, wmask;
#if USE_UNIX_DOMAIN_SOCKETS
struct sockaddr_un master_port;
static STRING *portPath = (STRING *)0;
#else
struct sockaddr_in master_port; struct sockaddr_in master_port;
# if HAVE_SETSOCKOPT
int true = 1; int true = 1;
# endif
#endif
FILE *fp; FILE *fp;
CONSCLIENT *pCLServing = (CONSCLIENT *)0; CONSCLIENT *pCLServing = (CONSCLIENT *)0;
CONSCLIENT *pCL = (CONSCLIENT *)0; CONSCLIENT *pCL = (CONSCLIENT *)0;
@ -678,6 +745,9 @@ Master()
#endif #endif
#if defined(SIGPOLL) #if defined(SIGPOLL)
SimpleSignal(SIGPOLL, SIG_IGN); SimpleSignal(SIGPOLL, SIG_IGN);
#endif
#if defined(SIGXFSZ)
SimpleSignal(SIGXFSZ, SIG_IGN);
#endif #endif
SimpleSignal(SIGCHLD, FlagSawCHLD); SimpleSignal(SIGCHLD, FlagSawCHLD);
SimpleSignal(SIGTERM, FlagQuitIt); SimpleSignal(SIGTERM, FlagQuitIt);
@ -702,6 +772,41 @@ Master()
#else #else
bzero((char *)&master_port, sizeof(master_port)); bzero((char *)&master_port, sizeof(master_port));
#endif #endif
#if USE_UNIX_DOMAIN_SOCKETS
master_port.sun_family = AF_UNIX;
if (portPath == (STRING *)0)
portPath = AllocString();
BuildStringPrint(portPath, "%s/0", interface);
if (portPath->used > sizeof(master_port.sun_path)) {
Error("Master(): path to socket too long: %s", portPath->string);
return;
}
StrCpy(master_port.sun_path, portPath->string,
sizeof(master_port.sun_path));
if ((msfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
Error("Master(): socket(AF_UNIX,SOCK_STREAM): %s",
strerror(errno));
return;
}
if (!SetFlags(msfd, O_NONBLOCK, 0))
return;
if (bind(msfd, (struct sockaddr *)&master_port, sizeof(master_port)) <
0) {
Error("Master(): bind(%s): %s", master_port.sun_path,
strerror(errno));
return;
}
if (listen(msfd, SOMAXCONN) < 0) {
Error("Master(): listen(%s): %s", master_port.sun_path,
strerror(errno));
return;
}
#else
master_port.sin_family = AF_INET; master_port.sin_family = AF_INET;
master_port.sin_addr.s_addr = bindAddr; master_port.sin_addr.s_addr = bindAddr;
master_port.sin_port = htons(bindPort); master_port.sin_port = htons(bindPort);
@ -711,7 +816,7 @@ Master()
strerror(errno)); strerror(errno));
return; return;
} }
#if HAVE_SETSOCKOPT # if HAVE_SETSOCKOPT
if (setsockopt if (setsockopt
(msfd, SOL_SOCKET, SO_REUSEADDR, (char *)&true, (msfd, SOL_SOCKET, SO_REUSEADDR, (char *)&true,
sizeof(true)) < 0) { sizeof(true)) < 0) {
@ -719,7 +824,7 @@ Master()
strerror(errno)); strerror(errno));
return; return;
} }
#endif # endif
if (!SetFlags(msfd, O_NONBLOCK, 0)) if (!SetFlags(msfd, O_NONBLOCK, 0))
return; return;
@ -735,6 +840,7 @@ Master()
strerror(errno)); strerror(errno));
return; return;
} }
#endif
fp = fopen(PIDFILE, "w"); fp = fopen(PIDFILE, "w");
if (fp) { if (fp) {
@ -752,7 +858,7 @@ Master()
for (fSawQuit = 0; !fSawQuit; /* can't close here :-( */ ) { for (fSawQuit = 0; !fSawQuit; /* can't close here :-( */ ) {
if (fSawCHLD) { if (fSawCHLD) {
fSawCHLD = 0; fSawCHLD = 0;
FixKids(); FixKids(msfd);
} }
if (fSawHUP) { if (fSawHUP) {
fSawHUP = 0; fSawHUP = 0;
@ -760,7 +866,7 @@ Master()
ReopenLogfile(); ReopenLogfile();
ReopenUnifiedlog(); ReopenUnifiedlog();
SignalKids(SIGHUP); SignalKids(SIGHUP);
ReReadCfg(msfd); ReReadCfg(msfd, msfd);
/* fix up the client descriptors since ReReadCfg() doesn't /* fix up the client descriptors since ReReadCfg() doesn't
* see them like it can in the child processes */ * see them like it can in the child processes */
for (pCL = pCLmall; pCL != (CONSCLIENT *)0; pCL = pCL->pCLscan) { for (pCL = pCLmall; pCL != (CONSCLIENT *)0; pCL = pCL->pCLscan) {
@ -872,9 +978,10 @@ Master()
} }
/* set to non-blocking and wrap in a File object */ /* set to non-blocking and wrap in a File object */
if (SetFlags(cfd, O_NONBLOCK, 0)) if (SetFlags(cfd, O_NONBLOCK, 0)) {
pCLmfree->fd = FileOpenFD(cfd, simpleSocket); pCLmfree->fd = FileOpenFD(cfd, simpleSocket);
else FileSetQuoteIAC(pCLmfree->fd, FLAGTRUE);
} else
pCLmfree->fd = (CONSFILE *)0; pCLmfree->fd = (CONSFILE *)0;
if ((CONSFILE *)0 == pCLmfree->fd) { if ((CONSFILE *)0 == pCLmfree->fd) {
@ -929,6 +1036,9 @@ Master()
} }
close(msfd); close(msfd);
#if USE_UNIX_DOMAIN_SOCKETS
unlink(master_port.sun_path);
#endif
/* clean up the free list */ /* clean up the free list */
while (pCLmfree != (CONSCLIENT *)0) { while (pCLmfree != (CONSCLIENT *)0) {

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* /*
* $Id: readcfg.h,v 5.38 2003/11/10 15:37:24 bryan Exp $ * $Id: readcfg.h,v 5.45 2005/06/07 19:55:51 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -10,6 +10,7 @@
typedef struct config { typedef struct config {
STRING *name; STRING *name;
FLAG autocomplete;
char defaultaccess; char defaultaccess;
FLAG daemonmode; FLAG daemonmode;
char *logfile; char *logfile;
@ -20,6 +21,7 @@ typedef struct config {
int reinitcheck; int reinitcheck;
char *secondaryport; char *secondaryport;
char *unifiedlog; char *unifiedlog;
int initdelay;
#if HAVE_SETPROCTITLE #if HAVE_SETPROCTITLE
FLAG setproctitle; FLAG setproctitle;
#endif #endif
@ -40,11 +42,13 @@ extern REMOTE *pRCList; /* list of remote consoles we know about */
extern REMOTE *pRCUniq; /* list of uniq console servers */ extern REMOTE *pRCUniq; /* list of uniq console servers */
extern ACCESS *pACList; /* `who do you love' (or trust) */ extern ACCESS *pACList; /* `who do you love' (or trust) */
extern CONSENTUSERS *pADList; /* list of admin users */ extern CONSENTUSERS *pADList; /* list of admin users */
extern CONSENTUSERS *pLUList; /* list of limited users */
extern BREAKS breakList[9]; /* list of break sequences */ extern BREAKS breakList[9]; /* list of break sequences */
extern CONFIG *pConfig; /* settings seen by config parser */ extern CONFIG *pConfig; /* settings seen by config parser */
extern SUBST *substData; /* substitution function data */
extern void ReadCfg PARAMS((char *, FILE *)); extern void ReadCfg PARAMS((char *, FILE *));
extern void ReReadCfg PARAMS((int)); extern void ReReadCfg PARAMS((int, int));
extern void DestroyBreakList PARAMS((void)); extern void DestroyBreakList PARAMS((void));
extern void DestroyUserList PARAMS((void)); extern void DestroyUserList PARAMS((void));
extern void DestroyConfig PARAMS((CONFIG *)); extern void DestroyConfig PARAMS((CONFIG *));

View File

@ -1,5 +1,5 @@
/* /*
* $Id: version.h,v 1.55 2003/12/10 18:33:48 bryan Exp $ * $Id: version.h,v 1.74 2007/01/01 04:41:08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -14,4 +14,8 @@
@(#) Copyright 2000 conserver.com.\n\ @(#) Copyright 2000 conserver.com.\n\
All rights reserved.\n" All rights reserved.\n"
#define THIS_VERSION "conserver.com version 8.0.9" #define VERSION_MAJOR 8
#define VERSION_MINOR 1
#define VERSION_REV 15
#define VERSION_TEXT "conserver.com version"
#define VERSION_UINT (VERSION_MAJOR * 1000000 + VERSION_MINOR * 1000 + VERSION_REV)

View File

@ -25,11 +25,11 @@ LIBS = @LIBS@
### Makefile rules - no user-servicable parts below ### Makefile rules - no user-servicable parts below
CONSOLE_OBJS = console.o getpassword.o ../conserver/cutil.o CONSOLE_OBJS = console.o getpassword.o readconf.o ../conserver/cutil.o
CONSOLE_HDRS = ../config.h $(top_srcdir)/compat.h \ CONSOLE_HDRS = ../config.h $(top_srcdir)/compat.h \
$(top_srcdir)/conserver/cutil.h \ $(top_srcdir)/conserver/cutil.h \
$(top_srcdir)/conserver/version.h \ $(top_srcdir)/conserver/version.h \
$(srcdir)/getpassword.h $(srcdir)/getpassword.h $(srcdir)/readconf.h
ALL = console ALL = console

File diff suppressed because it is too large Load Diff

View File

@ -1,45 +1,45 @@
.\" $Id: console.man,v 1.41 2003/11/28 00:47:30 bryan Exp $ .\" $Id: console.man,v 1.61 2006/04/03 13:32:12 bryan Exp $
.TH CONSOLE 1 "2003/11/28" "conserver-8.0.9" "conserver" .TH CONSOLE 1 "2006/04/03" "conserver-8.1.15" "conserver"
.SH NAME .SH NAME
console \- console server client program console \- console server client program
.SH SYNOPSIS .SH SYNOPSIS
.B console .B console
.RB [ \-aAEfFsS ] .RI [ generic-args ]
.RB [ \-7Dv ] .RB [ \-aAfFsS ]
.RB [ \-c
.IR cred ]
.BR [ \-M
.IR mach ]
.BR [ \-p
.IR port ]
.BR [ \-e .BR [ \-e
.IR esc ] .IR esc ]
.BR [ \-l
.IR user ]
.I console .I console
.br .br
.B console .B console
.RB [ \-hiIPrRuVwWx ] .RI [ generic-args ]
.RB [ \-7Dv ] .RB [ \-iIuwWx ]
.RB [ \-M .RI [ console ]
.IR mach ]
.RB [ \-p
.IR port ]
.RB [ \-d
.RI [ user ][\fB@\fP console ]]
.RB [ \- [ bB ]
.IR message ]
.RB [ \-t
.RI [ user ][\fB@\fP console ]
.IR message ]
.br .br
.B console .B console
.RB [ \-qQ ] .RI [ generic-args ]
.RB [ \-7Dv ] .RB [ \-hPqQrRV ]
.RB [ \-M .RB [ \- [ bB ]
.IR mach ] .IR message ]
.RB [ \-p .RB [ \-d
.RI [ user ][\f3@\fP console ]]
.RB [ \-t
.RI [ user ][\f3@\fP console ]
.IR message ]
.RB [ \- [ zZ ]
.IR cmd ]
.PP
.IR generic-args :
.RB [ \-7DEnUv ]
.RB [ \-c
.IR cred ]
.RB [ \-C
.IR config ]
.BR [ \-M
.IR master ]
.BR [ \-p
.IR port ] .IR port ]
.BR [ \-l
.IR user ]
.SH DESCRIPTION .SH DESCRIPTION
.B Console .B Console
is used to manipulate console terminals remotely or to poll running is used to manipulate console terminals remotely or to poll running
@ -51,7 +51,8 @@ In the first form above,
asks the user's password before asks the user's password before
granting interactive access to a console (on a non-trusted system), granting interactive access to a console (on a non-trusted system),
since such a session may provide single-user access. since such a session may provide single-user access.
Only as much of the console name as is required to If the server's autocompletion feature is enabled,
only as much of the console name as is required to
identify it uniquely to the server is required. identify it uniquely to the server is required.
.PP .PP
For non-interactive options, For non-interactive options,
@ -116,6 +117,10 @@ to users on the primary server.
Load an SSL certificate and key from the PEM encoded file Load an SSL certificate and key from the PEM encoded file
.IR cred . .IR cred .
.TP .TP
.BI \-C config
Use the per-user configuration file
.IR config .
.TP
.B \-d .B \-d
Disconnect the users specified by Disconnect the users specified by
.IR user @ console . .IR user @ console .
@ -150,9 +155,13 @@ The default value is
.B \-E .B \-E
If encryption has been built into the code If encryption has been built into the code
.RB ( --with-openssl ), .RB ( --with-openssl ),
encrypted client connections are a requirement. encrypted client connections are, by default, a requirement.
This option allows the client to connect to a console This option disables any attempt at creating an
over a non-encrypted connection. encrypted connection.
If you'd like to use encrypted connections when your server
supports it, but fallback to non-encrypted otherwise, the
.B \-U
option is what you want.
.TP .TP
.B \-f .B \-f
Same as Same as
@ -163,7 +172,7 @@ except it will force any existing connection into spy mode.
Display a brief help message. Display a brief help message.
.TP .TP
.B \-i .B \-i
Display information in a machine-parseable format (see below for the details). Display status information in a machine-parseable format (see below for the details).
.TP .TP
.B \-I .B \-I
Same as Same as
@ -179,19 +188,34 @@ uses $USER if its uid matches the user's real uid,
or $LOGNAME if its uid matches the user's real uid, or $LOGNAME if its uid matches the user's real uid,
or else the name associated with the user's real uid. or else the name associated with the user's real uid.
.TP .TP
.BI \-M mach .BI \-M master
The The
.B console .B console
client program polls client program polls
.I mach .I master
as the primary server, as the primary server,
rather than the default set at compile time (typically rather than the default set at compile time (typically
.RB `` console ''). .RB `` console '').
The default The default
.I mach .I master
may be changed at compile time using the may be changed at compile time using the
.B --with-master .B --with-master
option. option.
If
.B --with-uds
is used to enable Unix domain sockets, however, this option points
.B console
to the directory which holds those sockets.
The default
.I master
directory
.RB (`` /tmp/conserver '')
may be changed at compile time using the
.B --with-uds
option.
.TP
.BI \-n
Do not read the system-wide configuration file.
.TP .TP
.BI \-p port .BI \-p port
Set the port to connect to. Set the port to connect to.
@ -203,6 +227,9 @@ may be changed at compile time
using the using the
.B --with-port .B --with-port
option. option.
If the
.B --with-uds
option was used, this option is ignored.
.TP .TP
.B \-P .B \-P
Display the pid of the master daemon process on each server. Display the pid of the master daemon process on each server.
@ -264,6 +291,18 @@ and attached users
.RI ( user @ host .RI ( user @ host
if attached read-write, `<spies>' if only users in spy mode, or `<none>'). if attached read-write, `<spies>' if only users in spy mode, or `<none>').
.TP .TP
.B \-U
If encryption has been built into the code
.RB ( --with-openssl ),
encrypted client connections are, by default, a requirement.
This option allows the client to attempt an encrypted connection
but fall back to a non-encrypted connection if the server doesn't
support encryption.
If the encryption handshake is failing, disabling encryption on the
client with the
.B \-E
option is probably what you want.
.TP
.B \-v .B \-v
Be more verbose when building the connection(s). Be more verbose when building the connection(s).
Use this option in combination with any of `show' options (below) Use this option in combination with any of `show' options (below)
@ -289,6 +328,72 @@ but just acts on the primary server.
.TP .TP
.B \-x .B \-x
Show a list of consoles and devices. Show a list of consoles and devices.
.TP
.BI \-z cmd
Sends a command
.RI ( cmd )
to each server and displays the result.
The valid commands are:
.RS
.sp
.PD 0
.TP 12
.B bringup
Try to connect all consoles marked as down (this is equivalent
to sending the server a SIGUSR1)
.TP
.B SIGUSR1
Same as
.B bringup
.TP
.B help
Displays the help message
.TP
.B pid
Returns the pid of the server (this is equivalent to
.BR \-P )
.TP
.B quit
Instructs the server to shut down (this is equivalent to
.B \-q
or sending the server a SIGTERM)
.TP
.B SIGTERM
Same as
.B quit
.TP
.B reconfig
Instructs the server to reload the configuration file, then
perform the actions of
.B reopen
(this is equivalent to sending the server a SIGHUP)
.TP
.B SIGHUP
Same as
.B reconfig
.TP
.B reopen
Instructs the server to reopen all logfiles, then
perform the actions of
.B bringup
(this is equivalent to sending the server a SIGUSR2)
.TP
.B SIGUSR2
Same as
.B reopen
.TP
.B version
Returns the version of the server (this is equivalent to
.BR \-V )
.PD
.RE
.TP
.BI \-Z cmd
Same as
.B \-z
but just sends
.I cmd
to the primary server.
.PP .PP
The The
.BR \-A , .BR \-A ,
@ -297,12 +402,19 @@ The
options have the same effect as their lower-case variants. options have the same effect as their lower-case variants.
In addition, they each request the last 20 lines of the console output after In addition, they each request the last 20 lines of the console output after
making the connection (as if making the connection (as if
.RB ` ^Ecr ' .RB `` ^Ecr ''
were typed). were typed).
.PP .PP
The The
.BR \-i ,
.BR \-u ,
.BR \-w ", and"
.B \-x
options can be given a console name, which will limit their output to that console.
.PP
The
.B \-i .B \-i
option outputs information regarding each console in 15 colon-separated fields. option outputs status information regarding each console in 15 colon-separated fields.
.TP .TP
.I name .I name
The name of the console. The name of the console.
@ -314,17 +426,21 @@ the console.
.I type .I type
The type of console. The type of console.
Values will be a `/' for a local device, `|' for Values will be a `/' for a local device, `|' for
a command, or `!' for a remote port. a command, `!' for a remote port, `%' for a Unix domain socket,
and `#' for a noop console.
.TP .TP
.I console-details .I console-details
The details regarding the console. The details regarding the console.
The values here (all comma separated) depend on the type of the console. The values here (all comma-separated) depend on the type of the console.
Local devices will have values of the device file, baud rate, and Local devices will have values of the device file, baud rate/parity, and
file descriptor for the device. file descriptor for the device.
Commands will have values of the command, the command's pid, the Commands will have values of the command, the command's pid, the
pseudo-tty, and file descriptor for the pseudo-tty. pseudo-tty, and file descriptor for the pseudo-tty.
Remote ports will have values of the remote hostname, remote port number, Remote ports will have values of the remote hostname, remote port number,
and file descriptor for the socket connection. ``raw'' or ``telnet'' protocol, and file descriptor for the socket connection.
Unix domain sockets will have the path to the socket and the file
descriptor for the socket connection.
Noop consoles will have nothing.
.TP .TP
.I users-list .I users-list
The details of each user connected to the console. The details of each user connected to the console.
@ -347,9 +463,9 @@ that the server can open the file for read, but not write.
.TP .TP
.I logfile-details .I logfile-details
The details regarding the logging for the console. The details regarding the logging for the console.
The comma separated The comma-separated
values will be the logfile, ``log'' or ``nolog'' (if logging is on values will be the logfile, ``log'' or ``nolog'' (if logging is on
or not - toggled via ^EcL), ``act'' or ``noact'' (if activity logging is or not - toggled via ``^EcL''), ``act'' or ``noact'' (if activity logging is
enabled or not - the `a' timestamp option), the timestamp interval, and enabled or not - the `a' timestamp option), the timestamp interval, and
the file descriptor of the logfile. the file descriptor of the logfile.
.TP .TP
@ -362,10 +478,10 @@ is at work, it will have the value of ``autoup'', otherwise it
will be ``noautoup''. will be ``noautoup''.
.TP .TP
.I aliases .I aliases
The console aliases are presented in a comma separated list. The console aliases are presented in a comma-separated list.
.TP .TP
.I options .I options
The active options for the console are presented in a comma separated list. The active options for the console are presented in a comma-separated list.
.TP .TP
.I initcmd .I initcmd
The initcmd configuration option for the console. The initcmd configuration option for the console.
@ -375,6 +491,309 @@ The idletimeout configuration option for the console.
.TP .TP
.I idlestring .I idlestring
The idlestring configuration option for the console. The idlestring configuration option for the console.
.SH CONFIGURATION
.B Console
reads configuration information from the system-wide configuration file
.RB ( console.cf ),
then the per-user configuration file
.RB ( .consolerc ),
and then applies command-line arguments.
Each configuration location can override the previous.
The same happens when parsing an individual file - the later entries
always override the earlier entries.
Because of that, you should put ``global'' defaults first and
more specific defaults second.
.PP
The configuration file is read using the same parser as
.BR conserver.cf (5),
and you should check that manpage for parser details.
.B Console
recognizes the following configuration blocks.
.TP
\f3config\fP \f2hostname\fP|\f2ipaddr\fP
.br
Define a configuration block for the client host named
.I hostname
or using the address
.IR ipaddr .
If the value of ``*'' is used, the configuration block will be applied to
all client hosts.
.RS
.TP
\f3escape\fP \f2esc\fP
.br
Set the escape sequence (see the
.B \-e
command-line flag).
.TP
\f3master\fP \f2master\fP
.br
Set the default master to
.I master
(see the
.B \-M
command-line flag).
.TP
\f3playback\fP \f2num\fP|\f3""\fP
.br
Override the playback length for the
.B p
escape command to
.I num
lines (if the server supports it).
Using the special value of ``0'' will cause the client to use the number
of lines of the current terminal (if that can be determined).
If the null string (``""'') is used, the playback length will not be overridden.
.TP
\f3port\fP \f2port\fP
.br
Set the default port to
.I port
(see the
.B \-p
command-line flag).
.TP
\f3replay\fP \f2num\fP|\f3""\fP
.br
Override the replay length for the
.B r
escape command to
.I num
lines (if the server supports it).
Using the special value of ``0'' will cause the client to use the number
of lines of the current terminal (if that can be determined).
If the null string (``""'') is used, the replay length will not be overridden.
.TP
\f3sslcredentials\fP \f2filename\fP
.br
Set the
.SM SSL
credentials file location (see the
.B \-c
command-line flag).
.TP
\f3sslenabled\fP \f3yes\fP|\f3true\fP|\f3on\fP|\f3no\fP|\f3false\fP|\f3off\fP
.br
Set whether or not encryption is attempted when talking to servers (see the
.B \-E
command-line flag).
.TP
\f3sslrequired\fP \f3yes\fP|\f3true\fP|\f3on\fP|\f3no\fP|\f3false\fP|\f3off\fP
.br
Set whether or not encryption is required when talking to servers (see the
.B \-U
command-line flag).
.TP
\f3striphigh\fP \f3yes\fP|\f3true\fP|\f3on\fP|\f3no\fP|\f3false\fP|\f3off\fP
.br
Set whether or not to strip the high bit off all data received
(see the
.B \-7
command-line flag).
.TP
\f3username\fP \f2user\fP
.br
Set the username passed to the server to
.I user
(see the
.B \-l
command-line flag).
.RE
.TP
\f3terminal\fP \f2type\fP
.br
Define a configuration block when using a terminal of type
.IR type .
If the value of ``*'' is used, the configuration block will be applied to
all terminal types.
.RS
.TP
\f3attach\fP \f2string\fP|\f3""\fP
.br
Set a
.I string
to print when successfully attached to a console.
Character substitions will be performed based on the
.B attachsubst
value and occur
.I before
interpretation of the special characters below.
If the null string (``\f3""\fP'') is used, no string will be printed.
.I string
is a simple character string with the exception of `\e'
and `^':
.RS
.RS
.sp
.PD 0
.TP 6
.B \ea
alert
.TP
.B \eb
backspace
.TP
.B \ef
form-feed
.TP
.B \en
newline
.TP
.B \er
carriage-return
.TP
.B \et
tab
.TP
.B \ev
vertical-tab
.TP
.B \e\e
backslash
.TP
.B \e^
circumflex
.TP
.BI \e ooo
octal representation of a character (where
.I ooo
is one to three octal digits)
.TP
.BI \e c
character
.I c
.TP
.B ^?
delete
.TP
.BI ^ c
control character
.RI ( c
is ``and''ed with 0x1f)
.PD
.RE
.RE
.IP
An interesting use of
.B attach
and
.B attachsubst
would be:
.RS
.IP
.ft CR
.nf
terminal xterm {
attach "^[]0;conserver: U@C^G";
attachsubst U=us,C=cs;
}
.fi
.ft
.RE
.TP
\f3attachsubst\fP \f2c\fP\f3=\fP\f2t\fP[\f2n\fP]\f2f\fP[\f3,\fP...]|\f3""\fP
.br
Perform character substitutions on the
.B attach
value.
A series of replacements can be defined by specifying a
comma-separated list of
\f2c\fP\f3=\fP\f2t\fP[\f2n\fP]\f2f\fP
sequences where
.I c
is any printable character,
.I t
specifies the replacement value,
.I n
is a field length (optional),
and
.I f
is the format string.
.I t
can be one of the characters below, catagorized as a string replacement
or a numeric replacement, which dictates the use of the
.I n
and
.I f
fields.
.RS
.RS
.sp
.PD 0
.TP
String Replacement
.TP
.B u
username
.TP
.B c
console name
.sp
.PP
Numeric Replacement
.TP
none available (yet)
.PD
.RE
.RE
.IP
For string replacements, if the replacement isn't at least
.I n
characters, it will be padded with space characters on the left.
.I f
must be `s'.
For numeric replacements, the value will be formatted to at least
.I n
characters, padded with 0s if
.I n
begins with a 0, and space characters otherwise.
.I f
must be either `d', `x' or `X', specifying a decimal, lower-case
hexadecimal, or an uppercase hexadecimal conversion.
If the null string (``\f3""\fP'') is used, no replacements will be done.
.TP
\f3detach\fP \f2string\fP|\f3""\fP
.br
Set a
.I string
to print once detached from a console.
Character substitions will be performed based on the
.B detachsubst
value.
See the
.B attach
option for an explanation of
.IR string .
If the null string (``\f3""\fP'') is used, no string will be printed.
.TP
\f3detachsubst\fP \f2c\fP\f3=\fP\f2t\fP[\f2n\fP]\f2f\fP[\f3,\fP...]|\f3""\fP
.br
Perform character substitutions on the
.B detach
value.
See the
.B attachsubst
option for an explanation of the format string.
.RE
.PP
A simple configuration to set a new default escape sequence and override
the master location would be:
.IP
.ft CR
.nf
# override options for all hosts
config * {
master localhost;
escape ^Ee;
}
# set things more specific to host1
# note: if the entries were reversed, host1
# would also use localhost.
config host1 {
master console1;
}
.fi
.ft
.SH "ESCAPE SEQUENCES" .SH "ESCAPE SEQUENCES"
The connection can be controlled by a two-character escape sequence, followed The connection can be controlled by a two-character escape sequence, followed
by a command. by a command.
@ -387,6 +806,12 @@ Commands are:
.sp .sp
.PD 0 .PD 0
.TP 13 .TP 13
.B \.
disconnect
.TP
.B ;
move to another console
.TP
.B a .B a
attach read-write if nobody already is attach read-write if nobody already is
.TP .TP
@ -431,11 +856,17 @@ close (if open) and reopen the line (to clear errors (silo overflows))
and the log file and the log file
.TP .TP
.B p .B p
replay the last 60 lines of output playback the last 60 lines of output
.TP
.B P
set number of playback lines
.TP .TP
.B r .B r
replay the last 20 lines of output replay the last 20 lines of output
.TP .TP
.B R
set number of replay lines
.TP
.B s .B s
switch to spy mode (read-only) switch to spy mode (read-only)
.TP .TP
@ -470,14 +901,12 @@ replay the last line only
send character having octal code send character having octal code
.IR ooo " (must" .IR ooo " (must"
specify three octal digits) specify three octal digits)
.IP \.
disconnect
.PD .PD
.PP .PP
If any other character is hit after the escape sequence, all three characters If any other character is hit after the escape sequence, all three characters
will be discarded. will be discarded.
Note that a line break or a down command Note that a line break or a down command
can only be sent from a full two-way attachment. can only be sent from a read-write connection.
To send the escape sequence through the connection one must redefine To send the escape sequence through the connection one must redefine
the outer escape sequence, or use the outer escape sequence, or use
.BI ^Ec\e ooo .BI ^Ec\e ooo
@ -488,13 +917,17 @@ In the
.B \-u .B \-u
output, the login ``<none>'' indicates no one is output, the login ``<none>'' indicates no one is
viewing that console, and the login ``<spies>'' indicates that viewing that console, and the login ``<spies>'' indicates that
no one has a full two-way attachment. no one has a read-write connection (only read-only).
When no one is attached to .PP
a console its output is cloned to the stdout of the server process if When running a local command via
.B conserver .RB `` ^Ec| '',
was started with the you can type
.B \-u .RB ` ^C '
option. to send the command a SIGHUP,
.RB ` ^\e '
to send the command a SIGKILL, and
.RB ` o '
to toggle the display of the console data.
.SH EXAMPLES .SH EXAMPLES
.TP 15 .TP 15
console \-u console \-u
@ -546,6 +979,22 @@ or number of days is displayed.
console \-e "^[1" lv426 console \-e "^[1" lv426
Requests a connection to the host ``lv426'' with the escape characters Requests a connection to the host ``lv426'' with the escape characters
set to ``escape one''. set to ``escape one''.
.SH FILES
.PP
The following default file locations may be overridden
at compile time or by the command-line options described above.
Run
.B console \-V
to see the defaults set at compile time.
.PP
.PD 0
.TP 25
.B /etc/console.cf
system-wide configuration file
.TP
.B \s-1$HOME\s0/.consolerc
per-user configuration file
.PD
.SH BUGS .SH BUGS
It is possible to create a loop of console connections, with ugly results. It is possible to create a loop of console connections, with ugly results.
Never run Never run

810
console/readconf.c Normal file
View File

@ -0,0 +1,810 @@
/*
* $Id: readconf.c,v 5.5 2006/04/03 13:32:12 bryan Exp $
*
* Copyright conserver.com, 2000
*
* Maintainer/Enhancer: Bryan Stansell (bryan@conserver.com)
*/
#include <compat.h>
#include <cutil.h>
#include <readconf.h>
CONFIG *parserConfigTemp = (CONFIG *)0;
CONFIG *parserConfigDefault = (CONFIG *)0;
CONFIG *pConfig = (CONFIG *)0;
TERM *parserTermTemp = (TERM *)0;
TERM *parserTermDefault = (TERM *)0;
TERM *pTerm = (TERM *)0;
void
#if PROTOTYPES
DestroyConfig(CONFIG *c)
#else
DestroyConfig(c)
CONFIG *c;
#endif
{
if (c == (CONFIG *)0)
return;
if (c->username != (char *)0)
free(c->username);
if (c->master != (char *)0)
free(c->master);
if (c->port != (char *)0)
free(c->port);
if (c->escape != (char *)0)
free(c->escape);
#if HAVE_OPENSSL
if (c->sslcredentials != (char *)0)
free(c->sslcredentials);
#endif
free(c);
}
void
#if PROTOTYPES
ApplyConfigDefault(CONFIG *c)
#else
ApplyConfigDefault(c)
CONFIG *c;
#endif
{
if (parserConfigDefault == (CONFIG *)0)
return;
if (parserConfigDefault->username != (char *)0) {
if (c->username != (char *)0)
free(c->username);
if ((c->username =
StrDup(parserConfigDefault->username)) == (char *)0)
OutOfMem();
}
if (parserConfigDefault->master != (char *)0) {
if (c->master != (char *)0)
free(c->master);
if ((c->master = StrDup(parserConfigDefault->master)) == (char *)0)
OutOfMem();
}
if (parserConfigDefault->port != (char *)0) {
if (c->port != (char *)0)
free(c->port);
if ((c->port = StrDup(parserConfigDefault->port)) == (char *)0)
OutOfMem();
}
if (parserConfigDefault->escape != (char *)0) {
if (c->escape != (char *)0)
free(c->escape);
if ((c->escape = StrDup(parserConfigDefault->escape)) == (char *)0)
OutOfMem();
}
if (parserConfigDefault->striphigh != FLAGUNKNOWN)
c->striphigh = parserConfigDefault->striphigh;
if (parserConfigDefault->replay != FLAGUNKNOWN)
c->replay = parserConfigDefault->replay;
if (parserConfigDefault->playback != FLAGUNKNOWN)
c->playback = parserConfigDefault->playback;
#if HAVE_OPENSSL
if (parserConfigDefault->sslcredentials != (char *)0) {
if (c->sslcredentials != (char *)0)
free(c->sslcredentials);
if ((c->sslcredentials =
StrDup(parserConfigDefault->sslcredentials)) == (char *)0)
OutOfMem();
}
if (parserConfigDefault->sslrequired != FLAGUNKNOWN)
c->sslrequired = parserConfigDefault->sslrequired;
if (parserConfigDefault->sslenabled != FLAGUNKNOWN)
c->sslenabled = parserConfigDefault->sslenabled;
#endif
}
void
#if PROTOTYPES
ConfigBegin(char *id)
#else
ConfigBegin(id)
char *id;
#endif
{
CONDDEBUG((1, "ConfigBegin(%s) [%s:%d]", id, file, line));
if (id == (char *)0 || id[0] == '\000') {
Error("empty config name [%s:%d]", file, line);
return;
}
if (parserConfigTemp != (CONFIG *)0)
DestroyConfig(parserConfigTemp);
if ((parserConfigTemp = (CONFIG *)calloc(1, sizeof(CONFIG)))
== (CONFIG *)0)
OutOfMem();
ApplyConfigDefault(parserConfigTemp);
parserConfigTemp->name = AllocString();
BuildString(id, parserConfigTemp->name);
}
void
#if PROTOTYPES
ConfigEnd(void)
#else
ConfigEnd()
#endif
{
CONDDEBUG((1, "ConfigEnd() [%s:%d]", file, line));
if (parserConfigTemp == (CONFIG *)0)
return;
if (parserConfigTemp->name->used > 1) {
if ((parserConfigTemp->name->string[0] == '*' &&
parserConfigTemp->name->string[1] == '\000') ||
IsMe(parserConfigTemp->name->string)) {
DestroyConfig(parserConfigDefault);
parserConfigDefault = parserConfigTemp;
parserConfigTemp = (CONFIG *)0;
}
}
DestroyConfig(parserConfigTemp);
parserConfigTemp = (CONFIG *)0;
}
void
#if PROTOTYPES
ConfigAbort(void)
#else
ConfigAbort()
#endif
{
CONDDEBUG((1, "ConfigAbort() [%s:%d]", file, line));
if (parserConfigTemp == (CONFIG *)0)
return;
DestroyConfig(parserConfigTemp);
parserConfigTemp = (CONFIG *)0;
}
void
#if PROTOTYPES
ConfigDestroy(void)
#else
ConfigDestroy()
#endif
{
CONDDEBUG((1, "ConfigDestroy() [%s:%d]", file, line));
if (parserConfigTemp != (CONFIG *)0) {
DestroyConfig(parserConfigTemp);
parserConfigTemp = (CONFIG *)0;
}
if (parserConfigDefault != (CONFIG *)0) {
DestroyConfig(pConfig);
pConfig = parserConfigDefault;
parserConfigDefault = (CONFIG *)0;
}
}
void
#if PROTOTYPES
DestroyTerminal(TERM *t)
#else
DestroyTerminal(t)
TERM *t;
#endif
{
if (t == (TERM *)0)
return;
if (t->attach != (char *)0)
free(t->attach);
if (t->attachsubst != (char *)0)
free(t->attachsubst);
if (t->detach != (char *)0)
free(t->detach);
if (t->detachsubst != (char *)0)
free(t->detachsubst);
free(t);
}
void
#if PROTOTYPES
ApplyTermDefault(TERM *t)
#else
ApplyTermDefault(t)
TERM *t;
#endif
{
if (parserTermDefault == (TERM *)0)
return;
if (parserTermDefault->attach != (char *)0) {
if (t->attach != (char *)0)
free(t->attach);
if ((t->attach = StrDup(parserTermDefault->attach)) == (char *)0)
OutOfMem();
}
if (parserTermDefault->attachsubst != (char *)0) {
if (t->attachsubst != (char *)0)
free(t->attachsubst);
if ((t->attachsubst =
StrDup(parserTermDefault->attachsubst)) == (char *)0)
OutOfMem();
}
if (parserTermDefault->detach != (char *)0) {
if (t->detach != (char *)0)
free(t->detach);
if ((t->detach = StrDup(parserTermDefault->detach)) == (char *)0)
OutOfMem();
}
if (parserTermDefault->detachsubst != (char *)0) {
if (t->detachsubst != (char *)0)
free(t->detachsubst);
if ((t->detachsubst =
StrDup(parserTermDefault->detachsubst)) == (char *)0)
OutOfMem();
}
}
void
#if PROTOTYPES
TerminalBegin(char *id)
#else
TerminalBegin(id)
char *id;
#endif
{
CONDDEBUG((1, "TerminalBegin(%s) [%s:%d]", id, file, line));
if (id == (char *)0 || id[0] == '\000') {
Error("empty terminal name [%s:%d]", file, line);
return;
}
if (parserTermTemp != (TERM *)0)
DestroyTerminal(parserTermTemp);
if ((parserTermTemp = (TERM *)calloc(1, sizeof(TERM)))
== (TERM *)0)
OutOfMem();
ApplyTermDefault(parserTermTemp);
parserTermTemp->name = AllocString();
BuildString(id, parserTermTemp->name);
}
void
#if PROTOTYPES
TerminalEnd(void)
#else
TerminalEnd()
#endif
{
static char *term = (char *)0;
CONDDEBUG((1, "TerminalEnd() [%s:%d]", file, line));
if (parserTermTemp == (TERM *)0)
return;
if (term == (char *)0) {
if ((term = getenv("TERM")) == (char *)0) {
term = "";
}
}
if (parserTermTemp->name->used > 1) {
if ((parserTermTemp->name->string[0] == '*' &&
parserTermTemp->name->string[1] == '\000') ||
strcmp(parserTermTemp->name->string, term) == 0) {
DestroyTerminal(parserTermDefault);
parserTermDefault = parserTermTemp;
parserTermTemp = (TERM *)0;
}
}
DestroyTerminal(parserTermTemp);
parserTermTemp = (TERM *)0;
}
void
#if PROTOTYPES
TerminalAbort(void)
#else
TerminalAbort()
#endif
{
CONDDEBUG((1, "TerminalAbort() [%s:%d]", file, line));
if (parserTermTemp == (TERM *)0)
return;
DestroyTerminal(parserTermTemp);
parserTermTemp = (TERM *)0;
}
void
#if PROTOTYPES
TerminalDestroy(void)
#else
TerminalDestroy()
#endif
{
CONDDEBUG((1, "TerminalDestroy() [%s:%d]", file, line));
if (parserTermTemp != (TERM *)0) {
DestroyTerminal(parserTermTemp);
parserTermTemp = (TERM *)0;
}
if (parserTermDefault != (TERM *)0) {
DestroyTerminal(pTerm);
pTerm = parserTermDefault;
parserTermDefault = (TERM *)0;
}
}
void
#if PROTOTYPES
ProcessYesNo(char *id, FLAG *flag)
#else
ProcessYesNo(id, flag)
char *id;
FLAG *flag;
#endif
{
if (id == (char *)0 || id[0] == '\000')
*flag = FLAGFALSE;
else if (strcasecmp("yes", id) == 0 || strcasecmp("true", id) == 0 ||
strcasecmp("on", id) == 0)
*flag = FLAGTRUE;
else if (strcasecmp("no", id) == 0 || strcasecmp("false", id) == 0 ||
strcasecmp("off", id) == 0)
*flag = FLAGFALSE;
}
void
#if PROTOTYPES
ConfigItemEscape(char *id)
#else
ConfigItemEscape(id)
char *id;
#endif
{
CONDDEBUG((1, "ConfigItemEscape(%s) [%s:%d]", id, file, line));
if (parserConfigTemp->escape != (char *)0)
free(parserConfigTemp->escape);
if ((id == (char *)0) || (*id == '\000')) {
parserConfigTemp->escape = (char *)0;
return;
}
if ((parserConfigTemp->escape = StrDup(id)) == (char *)0)
OutOfMem();
}
void
#if PROTOTYPES
ConfigItemMaster(char *id)
#else
ConfigItemMaster(id)
char *id;
#endif
{
CONDDEBUG((1, "ConfigItemMaster(%s) [%s:%d]", id, file, line));
if (parserConfigTemp->master != (char *)0)
free(parserConfigTemp->master);
if ((id == (char *)0) || (*id == '\000')) {
parserConfigTemp->master = (char *)0;
return;
}
if ((parserConfigTemp->master = StrDup(id)) == (char *)0)
OutOfMem();
}
void
#if PROTOTYPES
ConfigItemPlayback(char *id)
#else
ConfigItemPlayback(id)
char *id;
#endif
{
int i;
CONDDEBUG((1, "ConfigItemPlayback(%s) [%s:%d]", id, file, line));
if ((id == (char *)0) || (*id == '\000')) {
parserConfigTemp->playback = 0;
return;
}
for (i = 0; id[i] != '\000'; i++) {
if (!isdigit((int)id[i])) {
Error("invalid playback value [%s:%d]", file, line);
return;
}
}
if (i > 4) {
Error("playback value too large [%s:%d]", file, line);
return;
}
parserConfigTemp->playback = (unsigned short)atoi(id) + 1;
}
void
#if PROTOTYPES
ConfigItemPort(char *id)
#else
ConfigItemPort(id)
char *id;
#endif
{
CONDDEBUG((1, "ConfigItemPort(%s) [%s:%d]", id, file, line));
if (parserConfigTemp->port != (char *)0)
free(parserConfigTemp->port);
if ((id == (char *)0) || (*id == '\000')) {
parserConfigTemp->port = (char *)0;
return;
}
if ((parserConfigTemp->port = StrDup(id)) == (char *)0)
OutOfMem();
}
void
#if PROTOTYPES
ConfigItemReplay(char *id)
#else
ConfigItemReplay(id)
char *id;
#endif
{
int i;
CONDDEBUG((1, "ConfigItemReplay(%s) [%s:%d]", id, file, line));
if ((id == (char *)0) || (*id == '\000')) {
parserConfigTemp->replay = 0;
return;
}
for (i = 0; id[i] != '\000'; i++) {
if (!isdigit((int)id[i])) {
Error("invalid replay value [%s:%d]", file, line);
return;
}
}
if (i > 4) {
Error("replay value too large [%s:%d]", file, line);
return;
}
parserConfigTemp->replay = (unsigned short)atoi(id) + 1;
}
void
#if PROTOTYPES
ConfigItemSslcredentials(char *id)
#else
ConfigItemSslcredentials(id)
char *id;
#endif
{
CONDDEBUG((1, "ConfigItemSslcredentials(%s) [%s:%d]", id, file, line));
#if HAVE_OPENSSL
if (parserConfigTemp->sslcredentials != (char *)0)
free(parserConfigTemp->sslcredentials);
if ((id == (char *)0) || (*id == '\000')) {
parserConfigTemp->sslcredentials = (char *)0;
return;
}
if ((parserConfigTemp->sslcredentials = StrDup(id)) == (char *)0)
OutOfMem();
#else
Error
("sslcredentials ignored - encryption not compiled into code [%s:%d]",
file, line);
#endif
}
void
#if PROTOTYPES
ConfigItemSslrequired(char *id)
#else
ConfigItemSslrequired(id)
char *id;
#endif
{
CONDDEBUG((1, "ConfigItemSslrequired(%s) [%s:%d]", id, file, line));
#if HAVE_OPENSSL
ProcessYesNo(id, &(parserConfigTemp->sslrequired));
#else
Error
("sslrequired ignored - encryption not compiled into code [%s:%d]",
file, line);
#endif
}
void
#if PROTOTYPES
ConfigItemSslenabled(char *id)
#else
ConfigItemSslenabled(id)
char *id;
#endif
{
CONDDEBUG((1, "ConfigItemSslenabled(%s) [%s:%d]", id, file, line));
#if HAVE_OPENSSL
ProcessYesNo(id, &(parserConfigTemp->sslenabled));
#else
Error("sslenabled ignored - encryption not compiled into code [%s:%d]",
file, line);
#endif
}
void
#if PROTOTYPES
ConfigItemStriphigh(char *id)
#else
ConfigItemStriphigh(id)
char *id;
#endif
{
CONDDEBUG((1, "ConfigItemStriphigh(%s) [%s:%d]", id, file, line));
ProcessYesNo(id, &(parserConfigTemp->striphigh));
}
void
#if PROTOTYPES
ConfigItemUsername(char *id)
#else
ConfigItemUsername(id)
char *id;
#endif
{
CONDDEBUG((1, "ConfigItemUsername(%s) [%s:%d]", id, file, line));
if (parserConfigTemp->username != (char *)0)
free(parserConfigTemp->username);
if ((id == (char *)0) || (*id == '\000')) {
parserConfigTemp->username = (char *)0;
return;
}
if ((parserConfigTemp->username = StrDup(id)) == (char *)0)
OutOfMem();
}
SUBST *substData = (SUBST *)0;
SUBSTTOKEN
#if PROTOTYPES
SubstToken(char c)
#else
SubstToken(c)
char c;
#endif
{
switch (c) {
case 'u':
case 'c':
return ISSTRING;
default:
return ISNOTHING;
}
}
int
#if PROTOTYPES
SubstValue(char c, char **s, int *i)
#else
SubstValue(c, s, i)
char c;
char **s;
int *i;
#endif
{
int retval = 0;
if (s != (char **)0) {
CONFIG *pc;
if (substData->data == (void *)0)
return 0;
pc = (CONFIG *)(substData->data);
if (c == 'u') {
(*s) = pc->username;
retval = 1;
} else if (c == 'c') {
(*s) = pc->console;
retval = 1;
}
}
return retval;
}
void
#if PROTOTYPES
InitSubstCallback(void)
#else
InitSubstCallback()
#endif
{
if (substData == (SUBST *)0) {
if ((substData = (SUBST *)calloc(1, sizeof(SUBST))) == (SUBST *)0)
OutOfMem();
substData->value = &SubstValue;
substData->token = &SubstToken;
}
}
void
#if PROTOTYPES
TerminalItemAttach(char *id)
#else
TerminalItemAttach(id)
char *id;
#endif
{
CONDDEBUG((1, "TerminalItemAttach(%s) [%s:%d]", id, file, line));
if (parserTermTemp->attach != (char *)0)
free(parserTermTemp->attach);
if ((id == (char *)0) || (*id == '\000')) {
parserTermTemp->attach = (char *)0;
return;
}
if ((parserTermTemp->attach = StrDup(id)) == (char *)0)
OutOfMem();
}
void
#if PROTOTYPES
TerminalItemAttachsubst(char *id)
#else
TerminalItemAttachsubst(id)
char *id;
#endif
{
CONDDEBUG((1, "TerminalItemAttachsubst(%s) [%s:%d]", id, file, line));
ProcessSubst(substData, (char **)0, &(parserTermTemp->attachsubst),
"attachsubst", id);
}
void
#if PROTOTYPES
TerminalItemDetach(char *id)
#else
TerminalItemDetach(id)
char *id;
#endif
{
CONDDEBUG((1, "TerminalItemDetach(%s) [%s:%d]", id, file, line));
if (parserTermTemp->detach != (char *)0)
free(parserTermTemp->detach);
if ((id == (char *)0) || (*id == '\000')) {
parserTermTemp->detach = (char *)0;
return;
}
if ((parserTermTemp->detach = StrDup(id)) == (char *)0)
OutOfMem();
}
void
#if PROTOTYPES
TerminalItemDetachsubst(char *id)
#else
TerminalItemDetachsubst(id)
char *id;
#endif
{
CONDDEBUG((1, "TerminalItemDetachsubst(%s) [%s:%d]", id, file, line));
ProcessSubst(substData, (char **)0, &(parserTermTemp->detachsubst),
"detachsubst", id);
}
ITEM keyConfig[] = {
{"escape", ConfigItemEscape},
{"master", ConfigItemMaster},
{"playback", ConfigItemPlayback},
{"port", ConfigItemPort},
{"replay", ConfigItemReplay},
{"sslcredentials", ConfigItemSslcredentials},
{"sslrequired", ConfigItemSslrequired},
{"sslenabled", ConfigItemSslenabled},
{"striphigh", ConfigItemStriphigh},
{"username", ConfigItemUsername},
{(char *)0, (void *)0}
};
ITEM keyTerminal[] = {
{"attach", TerminalItemAttach},
{"attachsubst", TerminalItemAttachsubst},
{"detach", TerminalItemDetach},
{"detachsubst", TerminalItemDetachsubst},
{(char *)0, (void *)0}
};
SECTION sections[] = {
{"config", ConfigBegin, ConfigEnd, ConfigAbort, ConfigDestroy,
keyConfig},
{"terminal", TerminalBegin, TerminalEnd, TerminalAbort,
TerminalDestroy, keyTerminal},
{(char *)0, (void *)0, (void *)0, (void *)0, (void *)0}
};
void
#if PROTOTYPES
ReadConf(char *filename, FLAG verbose)
#else
ReadConf(filename, verbose)
char *filename;
FLAG verbose;
#endif
{
FILE *fp;
if ((FILE *)0 == (fp = fopen(filename, "r"))) {
if (verbose == FLAGTRUE)
Error("could not open `%s'", filename);
return;
}
/* initialize the substition bits */
InitSubstCallback();
parserConfigDefault = pConfig;
pConfig = (CONFIG *)0;
parserTermDefault = pTerm;
pTerm = (TERM *)0;
ParseFile(filename, fp, 0);
/* shouldn't really happen, but in case i screw up the stuff
* ParseFile calls...
*/
if (pConfig == (CONFIG *)0) {
if ((pConfig = (CONFIG *)calloc(1, sizeof(CONFIG)))
== (CONFIG *)0)
OutOfMem();
}
if (pTerm == (TERM *)0) {
if ((pTerm = (TERM *)calloc(1, sizeof(TERM)))
== (TERM *)0)
OutOfMem();
}
if (fDebug) {
#define EMPTYSTR(x) x == (char *)0 ? "(null)" : x
#define FLAGSTR(x) x == FLAGTRUE ? "true" : (x == FLAGFALSE ? "false" : "unset")
CONDDEBUG((1, "pConfig->username = %s",
EMPTYSTR(pConfig->username)));
CONDDEBUG((1, "pConfig->master = %s", EMPTYSTR(pConfig->master)));
CONDDEBUG((1, "pConfig->port = %s", EMPTYSTR(pConfig->port)));
CONDDEBUG((1, "pConfig->escape = %s", EMPTYSTR(pConfig->escape)));
CONDDEBUG((1, "pConfig->striphigh = %s",
FLAGSTR(pConfig->striphigh)));
CONDDEBUG((1, "pConfig->replay = %hu", pConfig->replay));
CONDDEBUG((1, "pConfig->playback = %hu", pConfig->playback));
#if HAVE_OPENSSL
CONDDEBUG((1, "pConfig->sslcredentials = %s",
EMPTYSTR(pConfig->sslcredentials)));
CONDDEBUG((1, "pConfig->sslrequired = %s",
FLAGSTR(pConfig->sslrequired)));
CONDDEBUG((1, "pConfig->sslenabled = %s",
FLAGSTR(pConfig->sslenabled)));
#endif
CONDDEBUG((1, "pTerm->attach = %s", EMPTYSTR(pTerm->attach)));
CONDDEBUG((1, "pTerm->attachsubst = %s",
EMPTYSTR(pTerm->attachsubst)));
CONDDEBUG((1, "pTerm->detach = %s", EMPTYSTR(pTerm->detach)));
CONDDEBUG((1, "pTerm->detachsubst = %s",
EMPTYSTR(pTerm->detachsubst)));
}
fclose(fp);
}

40
console/readconf.h Normal file
View File

@ -0,0 +1,40 @@
/*
* $Id: readconf.h,v 5.4 2006/04/03 13:32:12 bryan Exp $
*
* Copyright conserver.com, 2000
*
* Maintainer/Enhancer: Bryan Stansell (bryan@conserver.com)
*/
typedef struct config {
STRING *name;
char *console;
char *username;
char *master;
char *port;
char *escape;
FLAG striphigh;
unsigned short replay;
unsigned short playback;
#if HAVE_OPENSSL
char *sslcredentials;
FLAG sslrequired;
FLAG sslenabled;
#endif
} CONFIG;
typedef struct term {
STRING *name;
char *attach;
char *attachsubst;
char *detach;
char *detachsubst;
} TERM;
extern CONFIG *pConfig;
extern TERM *pTerm;
extern SUBST *substData;
extern void ReadConf PARAMS((char *, FLAG));
extern void DestroyConfig PARAMS((CONFIG *));
extern void DestroyTerminal PARAMS((TERM *));

View File

@ -88,15 +88,6 @@
#define const #define const
#endif #endif
#include <sys/cdefs.h>
#ifndef __NetBSD__
#if 1
static const char rcsid[] = "Id: chat.c,v 1.26 1999/12/23 01:39:54 paulus Exp ";
#else
__RCSID("$NetBSD: chat.c,v 1.25 2001/09/24 13:22:38 wiz Exp $");
#endif
#endif
#include <stdio.h> #include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include <time.h> #include <time.h>

View File

@ -4,7 +4,7 @@
# #
%define pkg conserver %define pkg conserver
%define ver 8.0.9 %define ver 8.1.15
# define the name of the machine on which the main conserver # define the name of the machine on which the main conserver
# daemon will be running if you don't want to use the default # daemon will be running if you don't want to use the default
@ -12,13 +12,13 @@
%define master console %define master console
# what red hat (or other distibution) version are you running? # what red hat (or other distibution) version are you running?
%define distver 6 %define distver 1
Summary: Serial console server daemon/client Summary: Serial console server daemon/client
Name: %{pkg} Name: %{pkg}
Version: %{ver} Version: %{ver}
Release: 1.%{distver} Release: %{distver}
Copyright: distributable License: BSD
Group: System Environment/Daemons Group: System Environment/Daemons
URL: http://www.conserver.com/ URL: http://www.conserver.com/
Source: http://www.conserver.com/%{pkg}-%{ver}.tar.gz Source: http://www.conserver.com/%{pkg}-%{ver}.tar.gz
@ -96,6 +96,7 @@ fi
%config(noreplace) %{_sysconfdir}/conserver.passwd %config(noreplace) %{_sysconfdir}/conserver.passwd
%attr(555,root,root) %{_initrddir}/conserver %attr(555,root,root) %{_initrddir}/conserver
%{prefix}/bin/console %{prefix}/bin/console
%{prefix}/lib/conserver/convert
%{prefix}/share/man/man1/console.1.gz %{prefix}/share/man/man1/console.1.gz
%{prefix}/share/man/man8/conserver.8.gz %{prefix}/share/man/man8/conserver.8.gz
%{prefix}/share/man/man5/conserver.cf.5.gz %{prefix}/share/man/man5/conserver.cf.5.gz

View File

@ -1,7 +1,7 @@
PKG="conserver" PKG="conserver"
NAME="Console server and client" NAME="Console server and client"
CATEGORY="system" CATEGORY="system"
VERSION="8.0.9" VERSION="8.1.15"
DESC="Console server and client" DESC="Console server and client"
CLASSES=none CLASSES=none
ARCH=sparc ARCH=sparc

View File

@ -14,6 +14,7 @@ cleanup()
[ "$i" != "conserver.log" ] && [ -f "$i" ] && rm -f "$i"; [ "$i" != "conserver.log" ] && [ -f "$i" ] && rm -f "$i";
done done
[ "$exitval" = 0 ] && rm -f conserver.log [ "$exitval" = 0 ] && rm -f conserver.log
[ -d 127.0.0.1 ] && sleep 1 && rm -rf 127.0.0.1
exit $exitval exit $exitval
} }
@ -25,14 +26,14 @@ dotest()
eval "$2" > test.out 2>&1 eval "$2" > test.out 2>&1
else else
echo "$1" | \ echo "$1" | \
../console/console -M 127.0.0.1 -p 7777 shell > test.out 2>&1 ../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 shell > test.out 2>&1
fi fi
if [ "$record" ]; then if [ "$record" ]; then
echo "recorded" echo "recorded"
mv test.out results/test$testnum mv test.out results/test$testnum
else else
if [ -f results/test$testnum ]; then if [ -f results/test$testnum ]; then
if diff -i test.out results/test$testnum >test$testnum.diff 2>&1; then if diff -i results/test$testnum >test$testnum.diff test.out 2>&1; then
echo "succeeded" echo "succeeded"
rm -f test$testnum.diff rm -f test$testnum.diff
else else
@ -72,7 +73,7 @@ sleep 3
[ ! -d results ] && mkdir results [ ! -d results ] && mkdir results
dotest EVAL "../console/console -M 127.0.0.1 -p 7777 -u | sed -e 's/[0-9][0-9]*//g' -e 's/[ ][ ]*/ /g'" dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -u | sed -e 's/[0-9][0-9]*//g' -e 's/[ ][ ]*/ /g'"
dotest 'c?c.' dotest 'c?c.'
dotest 'cl?c.' dotest 'cl?c.'
dotest 'cdc.' dotest 'cdc.'
@ -84,14 +85,16 @@ cp test2.cf c.cf
kill -1 $pid kill -1 $pid
sleep 3 sleep 3
dotest EVAL "../console/console -M 127.0.0.1 -p 7777 -u | sed -e 's/[0-9][0-9]*//g' -e 's/[ ][ ]*/ /g'" dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -u | sed -e 's/[0-9][0-9]*//g' -e 's/[ ][ ]*/ /g'"
dotest 'c?c.' dotest 'c?c.'
dotest 'cl?c.' dotest 'cl?c.'
dotest 'cdc.' dotest 'cdc.'
dotest 'coc.' dotest 'cocacoc.'
dotest EVAL "echo 'tu.' | ../console/console -M 127.0.0.1 -p 7777 -e 'tu' shell" dotest EVAL "echo 'tu.' | ../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -e 'tu' shell"
dotest EVAL "../console/console -M 127.0.0.1 -p 7777 -P | sed -e 's/:.*//'" dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -R | sed -e 's/ [^ ]*$//'"
dotest EVAL "../console/console -M 127.0.0.1 -p 7777 -x | sed -e 's/ on [^ ]* */ on /'" dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -x | sed -e 's/ on [^ ]* */ on /'"
dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -x sh | sed -e '1s/^[^:]*//'"
dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -x shell | sed -e 's/ on [^ ]* */ on /'"
cleanup cleanup

View File

@ -1,4 +1,6 @@
console: shell is down [`shell' -- console is down]
[Enter `^Ec?' for help] [Enter `^Ec?' for help]
[up -- attached] [up]
[ok]
[up]
[disconnect] [disconnect]

View File

@ -1 +1 @@
127.0.0.1 version `conserver.com version

2
test/results/test14 Normal file
View File

@ -0,0 +1,2 @@
: ambiguous console abbreviation, `sh'
choices are shellb, shella, shell

1
test/results/test15 Normal file
View File

@ -0,0 +1 @@
shell on at Local

View File

@ -1,17 +1,19 @@
[Enter `^Ec?' for help] [Enter `^Ec?' for help]
[help] [help]
. disconnect a attach read/write . disconnect ; move to another console
b send broadcast message c toggle flow control a attach read/write b send broadcast message
d down a console e change escape sequence c toggle flow control d down a console
f force attach read/write g group info e change escape sequence f force attach read/write
i information dump L toggle logging on/off g group info i information dump
l? break sequence list l0 send break per config file L toggle logging on/off l? break sequence list
l1-9 send specific break sequence m display the message of the day l0 send break per config file l1-9 send specific break sequence
o (re)open the tty and log file p replay the last 60 lines m display the message of the day o (re)open the tty and log file
r replay the last 20 lines s spy read only p playback the last 60 lines P set number of playback lines
u show host status v show version info r replay the last 20 lines R set number of replay lines
w who is on this console x show console baud info s spy mode (read only) u show host status
z suspend the connection | attach local command v show version info w who is on this console
<cr> ignore/abort command ? print this message x show console baud info z suspend the connection
^R replay the last line \ooo send character by octal code | attach local command ? print this message
<cr> ignore/abort command ^R replay the last line
\ooo send character by octal code
[disconnect] [disconnect]

View File

@ -1,4 +1,4 @@
console: shell is down [`shell' -- console is down]
[Enter `^Ec?' for help] [Enter `^Ec?' for help]
[up -- attached] [up]
[disconnect] [disconnect]

View File

@ -1,17 +1,19 @@
[Enter `^Ec?' for help] [Enter `^Ec?' for help]
[help] [help]
. disconnect a attach read/write . disconnect ; move to another console
b send broadcast message c toggle flow control a attach read/write b send broadcast message
d down a console e change escape sequence c toggle flow control d down a console
f force attach read/write g group info e change escape sequence f force attach read/write
i information dump L toggle logging on/off g group info i information dump
l? break sequence list l0 send break per config file L toggle logging on/off l? break sequence list
l1-9 send specific break sequence m display the message of the day l0 send break per config file l1-9 send specific break sequence
o (re)open the tty and log file p replay the last 60 lines m display the message of the day o (re)open the tty and log file
r replay the last 20 lines s spy read only p playback the last 60 lines P set number of playback lines
u show host status v show version info r replay the last 20 lines R set number of replay lines
w who is on this console x show console baud info s spy mode (read only) u show host status
z suspend the connection | attach local command v show version info w who is on this console
<cr> ignore/abort command ? print this message x show console baud info z suspend the connection
^R replay the last line \ooo send character by octal code | attach local command ? print this message
<cr> ignore/abort command ^R replay the last line
\ooo send character by octal code
[disconnect] [disconnect]