Compare commits

...

16 Commits

58 changed files with 15414 additions and 9654 deletions

232
CHANGES
View File

@ -1,6 +1,236 @@
CHANGES
=======
version 8.1.20 (Apr 4, 2014):
- IPMI serial over LAN support via FreeIPMI - based on patch by Anton
D. Kachalov <mouse@yandex-team.ru>
- minor cleanup of code, removal of gcc warnings and such that should
have no fuctional change
version 8.1.19 (Sep 26, 2013):
- prevent select/read loop when EOF on non-pty input (console) -
reported by Chris Marget <chris@marget.com>
- "!" syntax prefixing use of group names not honored - reported by
Zonker <consoleteam@gmail.com>
- fixed memory leak using timestamps - patch by Karvendhan M.
<Karvendhan.M@netapp.com>
- deprecated --with-cycladests (noop now) - cross-compilation should
work without it as autologin now expects setpgrp() to take two
arugments instead of testing for it
- no automatic checks for an empty password when using PAM
authentication - based on discussion with Ryan Kirkpatrick
<linux@rkirkpat.net>
- added 'sslcacertificatefile' and 'sslcacertificatepath' client
configuration options - based on patch by Aki Tuomi <cmouse@cmouse.fi>
- added 'sslcacertificatefile' and 'sslreqclientcert' server
configuration options
- added --with-req-server-cert to force clients to require a certificate
from the server when using SSL - based on emails with Thor Simon
<tls@coyotepoint.com>
- added server-side tasks (see conserver.cf man page) that are invoked
by the client (useful for things like IPMI-based power control of
servers, invoking resets of terminal server ports, or anything else
that requires scripting) - ideas from patch by Anton Lundin
<glance@acc.umu.se> and discussion on mailing list (2011)
- added 'confirm' option to break sequences
- added 'breaklist' option to limit exposure of break sequences to
consoles
- sending of break signals is now announced to all attached clients
version 8.1.18 (Nov 11, 2010):
- install man pages read-only and improved the contributed redhat init
script - patches by Eric Biederman <ebiederm@aristanetworks.com>
- spec file improvements in contrib/redhat-rpm - patch by Jodok Ole
Muellers <jodok.muellers@aschendorff.de>
- GSS-API patch for client code - patch by Andras Horvath
<Andras.Horvath@cern.ch>
version 8.1.17 (Sep 29, 2009):
- fix for interface detection when HAVE_SA_LEN is defined - first
detected on NetBSD 5.0 and patched by Chris Ross
<cross+conserver@distal.com>
- first person to connect to a console wanting read/write now gets it
once the active user drops read/write - suggested by Thomas Gardner
<tmg@pobox.com>
- fix typo when setting nonblocking socket for client connections,
fixing stall issues - patch by Eric Biederman
<ebiederm@aristanetworks.com>
- GSS-API patch (--with-gssapi) to help with Kerberos tokens - patch by
Nate Straz <nstraz@redhat.com>
- authenticate username without @REALM when using GSS-API
(--with-striprealm) - based on patch by Andras Horvath
<Andras.Horvath@cern.ch>
- various contrib/redhat-rpm fixes - patch by Fabien Wernli
<wernli@in2p3.fr>
- fix handling of read(stdin) returning -1 in console client - patch by
Ed Swierk <eswierk@arastra.com>
version 8.1.16 (Apr 10, 2007):
- added 'replstring' substitution option - inspired by
conversation with Owen DeLong <owen@c2company.com>
- added '^Ecn' option for writing a note to the logfile - patch
by Bryan Schmersal <bschmer@yahoo.com>
- fixed leaking file descriptors when 'host' and 'uds' consoles
fail to connect - based on patch by Michael Heironimus
<michael_heironimus@archwayconcepts.com>
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
@ -708,5 +938,5 @@ before version 6.05:
and enhancements of various types were applied.
#
# $Id: CHANGES,v 1.167 2004/04/13 19:40:07 bryan Exp $
# $Id: CHANGES,v 1.239 2014/04/04 16:27:38 bryan Exp $
#

10
INSTALL
View File

@ -228,10 +228,10 @@ Detailed Instructions
step.
+ Next, make sure conserver runs during boot. The init script we
use under Solaris is installed in <PREFIX>/etc/conserver.rc.
Use that or some form of it for your own /etc/init.d script or
an entry in startup files (/etc/rc, /etc/rc.local, or
whatever).
use under Solaris is installed in
<DATADIR>/examples/conserver/conserver.rc. Use that or some
form of it for your own /etc/init.d script or an entry in
startup files (/etc/rc, /etc/rc.local, or whatever).
+ Now for the fun stuff. You need to create a conserver.cf and
conserver.passwd file. Those are defined with the
@ -278,5 +278,5 @@ Other Information And Gotchas
#
# $Id: INSTALL,v 1.38 2004/04/13 18:11:58 bryan Exp $
# $Id: INSTALL,v 1.39 2005/05/21 13:47:16 bryan Exp $
#

View File

@ -1,4 +1,5 @@
### Path settings
datarootdir = @datarootdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = @bindir@

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
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
@ -29,7 +37,9 @@ Systems Tested
Cygwin (w2k),gcc 2.95.3
DEC Tru64 4.0, gcc
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 11.10 parisc and ia64, native cc
Irix 6.15, native cc
@ -40,6 +50,7 @@ Systems Tested
MacOS X, native gcc
Solaris 2.5.1 thru 9 (sparc/x86), gcc
Solaris 7/8, native cc
Solaris 10 and Solaris Express (build 33) (x86), gcc and native cc
Contributions
@ -55,5 +66,5 @@ Contributions
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 $
#

35
TODO
View File

@ -54,8 +54,6 @@ Bryan Stansell
- 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>
- 9600baud log replay?
@ -86,26 +84,29 @@ Bryan Stansell
- 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
xterm title, for example : Richard Threadgill <richardt@tellme.com>
- this probably requires a client config file, so could play well
with the client config file requirement above
- allow for very long replays (hundres of lines) : John Stoffel
<stoffel@lucent.com>
- log rotation by date : Tom Pachla <tom.pachla@nlc-bnc.ca>
- client config file (for -M, etc?) : Erik Sjolund
<erik.sjolund@sbc.su.se>
- strict file permission checks on conserver.passwd/conserver.cf : Erik
Sjolund <erik.sjolund@sbc.su.se>
- embedded startup delays per remote host...or "group" of consoles in
some way 'cause some ssh connections to console servers need
significant throttling : Jay McCanta <mccantaj@amgen.com>
- 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.47 2004/03/12 17:34:49 bryan Exp $
# $Id: TODO,v 1.56 2006/04/03 22:20:34 bryan Exp $
#

View File

@ -1,4 +1,5 @@
### Path settings
datarootdir = @datarootdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
prefix = @prefix@
@ -45,7 +46,7 @@ clean:
distclean: clean
rm -f Makefile
install:
install: autologin
$(MKDIR) $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) autologin $(DESTDIR)$(bindir)

View File

@ -69,11 +69,11 @@
*/
#ifndef lint
char *rcsid = "$Id: autologin.c,v 1.23 2002/09/21 06:29:39 bryan Exp $";
#endif /* not lint */
extern char *progname;
gid_t awGrps[NGROUPS_MAX];
int iGrps = 0;
char *rcsid = "$Id: autologin.c,v 1.27 2013/09/20 21:15:13 bryan Exp $";
#endif /* not lint */
extern char *progname;
gid_t awGrps[NGROUPS_MAX];
int iGrps = 0;
/*
* External variables
@ -82,442 +82,369 @@ int iGrps = 0;
extern int optind;
extern char *optarg;
void make_utmp();
void usage();
void make_utmp();
void usage();
int
Process()
{
register int c;
int iErrs = 0;
int i, iNewGrp;
gid_t wGid;
uid_t wUid;
char *pcCmd = (char *)0,
*pcDevTty = (char *)0;
char *pcTmp;
int iErrs = 0;
int i, iNewGrp;
gid_t wGid;
uid_t wUid;
char *pcCmd = (char *)0, *pcDevTty = (char *)0;
#ifdef HAVE_GETUSERATTR
char *pcGrps;
#endif
struct passwd *pwd;
struct stat st;
#ifdef HAVE_TERMIOS_H
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
char *pcGrps;
#endif
struct passwd *pwd;
struct stat st;
struct termios n_tio;
#if defined(HAVE_BSM_AUDIT_H) && defined(HAVE_LIBBSM)
char my_hostname[MAXHOSTNAMELEN];
char my_hostname[MAXHOSTNAMELEN];
#endif
#if defined(HAVE_BSM_AUDIT_H) && defined(HAVE_LIBBSM)
if (0 != gethostname(my_hostname, sizeof(my_hostname))) {
(void) fprintf(stderr, "%s: gethostname: %s\n", strerror(errno));
exit(1);
/* NOTREACHED */
}
if (0 != gethostname(my_hostname, sizeof(my_hostname))) {
(void)fprintf(stderr, "%s: gethostname: %s\n", progname,
strerror(errno));
exit(1);
/* NOTREACHED */
}
#endif
if ((char *)0 != pcCommand) {
if ((char *)0 == (pcCmd = (char *)malloc(strlen(pcCommand) + 4))) {
(void) fprintf(stderr, "%s: malloc: %s\n", progname, strerror(errno));
exit(1);
/* NOTREACHED */
}
(void)strcpy(pcCmd, "-c ");
(void)strcat(pcCmd, pcCommand);
if ((char *)0 != pcCommand) {
if ((char *)0 == (pcCmd = (char *)malloc(strlen(pcCommand) + 4))) {
(void)fprintf(stderr, "%s: malloc: %s\n", progname,
strerror(errno));
exit(1);
/* NOTREACHED */
}
(void)strcpy(pcCmd, "-c ");
(void)strcat(pcCmd, pcCommand);
}
if ( (char *)0 != pcGroup ) {
iErrs += addgroup(pcGroup);
}
if ((char *)0 != pcGroup) {
iErrs += addgroup(pcGroup);
}
if ( (char *)0 == pcLogin ) {
static char acLogin[17];
if ((struct passwd *)0 == (pwd = getpwuid(geteuid()))) {
(void) fprintf(stderr, "%s: %d: uid unknown\n", progname, geteuid());
exit(1);
/* NOTREACHED */
}
pcLogin = strcpy(acLogin, pwd->pw_name);
} else if ((struct passwd *)0 == (pwd = getpwnam(pcLogin))) {
(void) fprintf(stderr, "%s: %s: login name unknown\n", progname, pcLogin);
exit(1);
/* NOTREACHED */
if ((char *)0 == pcLogin) {
static char acLogin[17];
if ((struct passwd *)0 == (pwd = getpwuid(geteuid()))) {
(void)fprintf(stderr, "%s: %d: uid unknown\n", progname,
geteuid());
exit(1);
/* NOTREACHED */
}
wUid = pwd->pw_uid;
wGid = pwd->pw_gid;
(void)endpwent();
pcLogin = strcpy(acLogin, pwd->pw_name);
} else if ((struct passwd *)0 == (pwd = getpwnam(pcLogin))) {
(void)fprintf(stderr, "%s: %s: login name unknown\n", progname,
pcLogin);
exit(1);
/* NOTREACHED */
}
wUid = pwd->pw_uid;
wGid = pwd->pw_gid;
(void)endpwent();
#ifdef HAVE_GETUSERATTR
/* getuserattr() returns a funny list of groups:
* "grp1\0grp2\0grp3\0\0"
*/
if (0 == getuserattr(pcLogin, S_SUGROUPS, &pcGrps, SEC_LIST)) {
while ('\000' != *pcGrps) {
/* ignore "ALL" and any group beginning with '!' */
if ('!' == *pcGrps || 0 != strcmp(pcGrps, "ALL")) {
iErrs += addgroup(pcGrps);
}
pcGrps = pcGrps + strlen(pcGrps) + 1;
}
/* getuserattr() returns a funny list of groups:
* "grp1\0grp2\0grp3\0\0"
*/
if (0 == getuserattr(pcLogin, S_SUGROUPS, &pcGrps, SEC_LIST)) {
while ('\000' != *pcGrps) {
/* ignore "ALL" and any group beginning with '!' */
if ('!' == *pcGrps || 0 != strcmp(pcGrps, "ALL")) {
iErrs += addgroup(pcGrps);
}
pcGrps = pcGrps + strlen(pcGrps) + 1;
}
#endif /* HAVE_GETUSERATTR */
(void)endgrent();
}
#endif /* HAVE_GETUSERATTR */
(void)endgrent();
if ((char *)0 != pcTty) {
if ( '/' == *pcTty ) {
pcDevTty = pcTty;
} else {
if ( (char *)0 == (pcDevTty = (char *)malloc(strlen(pcTty)+5+1) ) ) {
(void) fprintf(stderr, "%s: malloc: %s\n", progname, strerror(errno));
exit(1);
}
sprintf(pcDevTty, "/dev/%s", pcTty);
}
if ((char *)0 != pcTty) {
if ('/' == *pcTty) {
pcDevTty = pcTty;
} else {
if ((char *)0 ==
(pcDevTty = (char *)malloc(strlen(pcTty) + 5 + 1))) {
(void)fprintf(stderr, "%s: malloc: %s\n", progname,
strerror(errno));
exit(1);
}
sprintf(pcDevTty, "/dev/%s", pcTty);
}
if (0 != stat(pcDevTty, &st)) {
(void) fprintf(stderr, "%s: Can't stat %s: %s\n", progname, pcDevTty, strerror(errno));
++iErrs;
if (0 != stat(pcDevTty, &st)) {
(void)fprintf(stderr, "%s: Can't stat %s: %s\n", progname,
pcDevTty, strerror(errno));
++iErrs;
#if defined(VCHR) && defined(VMPC)
} else if (VCHR != st.st_type && VMPC != st.st_type) {
(void) fprintf(stderr, "%s: %s is not a character device\n", progname, pcDevTty);
++iErrs;
} else if (VCHR != st.st_type && VMPC != st.st_type) {
(void)fprintf(stderr, "%s: %s is not a character device\n",
progname, pcDevTty);
++iErrs;
#endif
}
} else {
pcDevTty = (char *)0;
}
} else {
pcDevTty = (char *)0;
}
if (iErrs) {
usage();
exit(1);
/* NOTREACHED */
}
if (0 != geteuid()) {
(void) fprintf(stderr, "%s: Must be root!!!\n", progname);
exit(1);
/* NOTREACHED */
}
if (iGrps && 0 < setgroups(iGrps, awGrps)) {
(void) fprintf(stderr, "%s: Can't setgroups(): %s\n", progname, strerror(errno));
exit(1);
/* NOTREACHED */
}
if (iErrs) {
usage();
exit(1);
/* NOTREACHED */
}
if (0 != geteuid()) {
(void)fprintf(stderr, "%s: Must be root!!!\n", progname);
exit(1);
/* NOTREACHED */
}
if (iGrps && 0 < setgroups(iGrps, awGrps)) {
(void)fprintf(stderr, "%s: Can't setgroups(): %s\n", progname,
strerror(errno));
exit(1);
/* NOTREACHED */
}
/* Close open files
*/
for (i = (char *)0 == pcTty ? 3 : 0; i < getdtablesize(); ++i) {
(void) close(i);
}
/* Close open files
*/
for (i = (char *)0 == pcTty ? 3 : 0; i < getdtablesize(); ++i) {
(void)close(i);
}
/* Make us a session leader so that when we open /dev/tty
* it will become our controlling terminal.
*/
if (-1 == (iNewGrp = getsid(getpid()))) {
if (-1 == (iNewGrp = setsid())) {
(void) fprintf(stderr, "%s: setsid: %d: %s\n", progname, iNewGrp, strerror(errno));
iNewGrp = getpid();
}
/* Make us a session leader so that when we open /dev/tty
* it will become our controlling terminal.
*/
if (-1 == (iNewGrp = getsid(getpid()))) {
if (-1 == (iNewGrp = setsid())) {
(void)fprintf(stderr, "%s: setsid: %d: %s\n", progname,
iNewGrp, strerror(errno));
iNewGrp = getpid();
}
}
#if defined(HAVE_BSM_AUDIT_H) && defined(HAVE_LIBBSM)
if (!cannot_audit(0)) {
if (!cannot_audit(0)) {
# if defined(HAVE_GETAUDIT_ADDR)
struct auditinfo_addr audit_info;
struct auditinfo_addr audit_info;
# else
struct auditinfo audit_info;
struct auditinfo audit_info;
# endif
au_mask_t audit_mask;
au_mask_t audit_mask;
# if !defined(HAVE_GETAUDIT_ADDR)
struct hostent *hp;
struct hostent *hp;
# endif
int iAuditFile;
int fShowEvent = 1;
token_t *ptAuditToken;
int iAuditFile;
int fShowEvent = 1;
token_t *ptAuditToken;
(void)memset(&audit_info, 0, sizeof(audit_info));
audit_info.ai_auid = wUid;
audit_info.ai_asid = getpid();
audit_mask.am_success = audit_mask.am_failure = 0;
(void) au_user_mask(pcLogin, &audit_mask);
audit_info.ai_mask.am_success = audit_mask.am_success;
audit_info.ai_mask.am_failure = audit_mask.am_failure;
(void)memset(&audit_info, 0, sizeof(audit_info));
audit_info.ai_auid = wUid;
audit_info.ai_asid = getpid();
audit_mask.am_success = audit_mask.am_failure = 0;
(void)au_user_mask(pcLogin, &audit_mask);
audit_info.ai_mask.am_success = audit_mask.am_success;
audit_info.ai_mask.am_failure = audit_mask.am_failure;
# if defined(HAVE_GETAUDIT_ADDR)
(void)aug_get_machine(my_hostname,
&audit_info.ai_termid.at_addr[0],
&audit_info.ai_termid.at_type);
(void)aug_get_machine(my_hostname,
&audit_info.ai_termid.at_addr[0],
&audit_info.ai_termid.at_type);
# else
if ((char *)0 != (hp = gethostbyname(my_hostname))
&& AF_INET == hp->h_addrtype) {
(void)memcpy(&audit_info.ai_termid.machine,
hp->h_addr,
sizeof(audit_info.ai_termid.machine));
}
# endif
# if defined(HAVE_GETAUDIT_ADDR)
if (0 > setaudit_addr(&audit_info, sizeof(audit_info)))
# else
if (0 > setaudit(&audit_info))
# endif
{
fprintf(stderr, "%s: setaudit failed: %s\n",
progname,
strerror(errno));
fShowEvent = 0;
}
if (fShowEvent) {
fShowEvent = au_preselect(AUE_autologin,
&audit_mask,
AU_PRS_SUCCESS,
AU_PRS_REREAD);
}
if (fShowEvent) {
iAuditFile = au_open();
# if defined(HAVE_GETAUDIT_ADDR)
ptAuditToken = au_to_subject_ex(wUid,
wUid,
wGid,
wUid,
wGid,
audit_info.ai_asid,
audit_info.ai_asid,
&audit_info.ai_termid),
# else
ptAuditToken = au_to_subject(wUid,
wUid,
wGid,
wUid,
wGid,
audit_info.ai_asid,
audit_info.ai_asid,
&audit_info.ai_termid),
# endif
(void)au_write(iAuditFile, ptAuditToken);
ptAuditToken = au_to_text(gettext("successful login"));
(void)au_write(iAuditFile, ptAuditToken);
if ((char *)0 != pcCmd) {
ptAuditToken = au_to_text(pcCmd);
(void)au_write(iAuditFile, ptAuditToken);
}
# if defined(HAVE_GETAUDIT_ADDR)
ptAuditToken = au_to_return32(0, 0);
# else
ptAuditToken = au_to_return(0, 0);
# endif
(void)au_write(iAuditFile, ptAuditToken);
if(0 > au_close(iAuditFile, AU_TO_WRITE, AUE_autologin)) {
fprintf(stderr, "%s: audit write failed",
progname,
strerror(errno));
}
}
if ((char *)0 != (hp = gethostbyname(my_hostname))
&& AF_INET == hp->h_addrtype) {
(void)memcpy(&audit_info.ai_termid.machine, hp->h_addr,
sizeof(audit_info.ai_termid.machine));
}
# endif
# if defined(HAVE_GETAUDIT_ADDR)
if (0 > setaudit_addr(&audit_info, sizeof(audit_info)))
# else
if (0 > setaudit(&audit_info))
# endif
{
fprintf(stderr, "%s: setaudit failed: %s\n", progname,
strerror(errno));
fShowEvent = 0;
}
if (fShowEvent) {
fShowEvent =
au_preselect(AUE_autologin, &audit_mask, AU_PRS_SUCCESS,
AU_PRS_REREAD);
}
if (fShowEvent) {
iAuditFile = au_open();
# if defined(HAVE_GETAUDIT_ADDR)
ptAuditToken =
au_to_subject_ex(wUid, wUid, wGid, wUid, wGid,
audit_info.ai_asid, audit_info.ai_asid,
&audit_info.ai_termid),
# else
ptAuditToken =
au_to_subject(wUid, wUid, wGid, wUid, wGid,
audit_info.ai_asid, audit_info.ai_asid,
&audit_info.ai_termid),
# endif
(void)au_write(iAuditFile, ptAuditToken);
ptAuditToken = au_to_text(gettext("successful login"));
(void)au_write(iAuditFile, ptAuditToken);
if ((char *)0 != pcCmd) {
ptAuditToken = au_to_text(pcCmd);
(void)au_write(iAuditFile, ptAuditToken);
}
# if defined(HAVE_GETAUDIT_ADDR)
ptAuditToken = au_to_return32(0, 0);
# else
ptAuditToken = au_to_return(0, 0);
# endif
(void)au_write(iAuditFile, ptAuditToken);
if (0 > au_close(iAuditFile, AU_TO_WRITE, AUE_autologin)) {
fprintf(stderr, "%s: audit write failed: %s", progname,
strerror(errno));
}
}
}
#endif
/* Open the TTY for stdin, stdout and stderr
*/
if ((char *)0 != pcDevTty) {
/* Open the TTY for stdin, stdout and stderr
*/
if ((char *)0 != pcDevTty) {
#ifdef TIOCNOTTY
if (-1 != (i = open("/dev/tty", 2, 0))) {
if ( ioctl(i, TIOCNOTTY, (char *)0) )
(void) fprintf(stderr, "%s: ioctl(%d, TIOCNOTTY, (char *)0): %s\n", progname, i, strerror(errno));
(void) close(i);
}
#endif
if (0 != open(pcDevTty, O_RDWR, 0666)) {
exit(1);
/* NOTREACHED */
}
dup(0);
dup(0);
if (-1 != (i = open("/dev/tty", 2, 0))) {
if (ioctl(i, TIOCNOTTY, (char *)0))
(void)fprintf(stderr,
"%s: ioctl(%d, TIOCNOTTY, (char *)0): %s\n",
progname, i, strerror(errno));
(void)close(i);
}
#endif
if (0 != open(pcDevTty, O_RDWR, 0666)) {
exit(1);
/* NOTREACHED */
}
dup(0);
dup(0);
}
/* put the tty in out process group
*/
/* put the tty in out process group
*/
#ifdef HAVE_TCGETPGRP
if (-1 >= (i = tcgetpgrp(0))){
(void) fprintf(stderr, "%s: tcgetpgrp: %s\n", progname, strerror(errno));
}
if (-1 >= (i = tcgetpgrp(0))) {
(void)fprintf(stderr, "%s: tcgetpgrp: %s\n", progname,
strerror(errno));
}
#endif
#ifndef SETPGRP_VOID
if (-1 != i && setpgrp(0, i) ){
(void) fprintf(stderr, "%s: setpgrp: %s, i = %d\n", progname, strerror(errno), i);
}
#endif
if (-1 != i && setpgrp(0, i)) {
(void)fprintf(stderr, "%s: setpgrp: %s, i = %d\n", progname,
strerror(errno), i);
}
#ifdef HAVE_TCSETPGRP
if (tcsetpgrp(0, iNewGrp)){
(void) fprintf(stderr, "%s: tcsetpgrp: %s\n", progname, strerror(errno));
}
#endif
#ifndef SETPGRP_VOID
if (-1 != iNewGrp && setpgrp(0, iNewGrp)){
(void) fprintf(stderr, "%s: setpgrp: %s, iNewGrp = %d\n", progname, strerror(errno), iNewGrp);
}
if (tcsetpgrp(0, iNewGrp)) {
(void)fprintf(stderr, "%s: tcsetpgrp: %s\n", progname,
strerror(errno));
}
#endif
if (-1 != iNewGrp && setpgrp(0, iNewGrp)) {
(void)fprintf(stderr, "%s: setpgrp: %s, iNewGrp = %d\n", progname,
strerror(errno), iNewGrp);
}
/* 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 */
/* put the tty in the correct mode
*/
#ifdef HAVE_TCGETATTR
if (0 != tcgetattr(0, &n_tio)) {
(void) fprintf(stderr, "%s: tcgetattr: %s\n", progname, strerror(errno));
exit(1);
/* NOTREACHED */
}
if (0 != tcgetattr(0, &n_tio)) {
(void)fprintf(stderr, "%s: tcgetattr: %s\n", progname,
strerror(errno));
exit(1);
/* NOTREACHED */
}
#else
if (0 != ioctl(0, TCGETS, &n_tio)) {
(void) fprintf(stderr, "%s: iotcl: TCGETS: %s\n", progname, strerror(errno));
exit(1);
/* NOTREACHED */
}
if (0 != ioctl(0, TCGETS, &n_tio)) {
(void)fprintf(stderr, "%s: iotcl: TCGETS: %s\n", progname,
strerror(errno));
exit(1);
/* NOTREACHED */
}
#endif
n_tio.c_iflag &= ~(IGNCR|IUCLC);
n_tio.c_iflag |= ICRNL|IXON|IXANY;
n_tio.c_oflag &= ~(OLCUC|ONOCR|ONLRET|OFILL|NLDLY|CRDLY|TABDLY|BSDLY);
n_tio.c_oflag |= OPOST|ONLCR|TAB3;
n_tio.c_lflag &= ~(XCASE|NOFLSH|ECHOK|ECHONL);
n_tio.c_lflag |= ISIG|ICANON|ECHO;
n_tio.c_cc[VEOF] = '\004'; /* ^D */
n_tio.c_cc[VEOL] = '\000'; /* EOL */
n_tio.c_cc[VERASE] = '\010'; /* ^H */
n_tio.c_cc[VINTR] = '\003'; /* ^C */
n_tio.c_cc[VKILL] = '\025'; /* ^U */
/* MIN */
n_tio.c_cc[VQUIT] = '\034'; /* ^\ */
n_tio.c_cc[VSTART] = '\021'; /* ^Q */
n_tio.c_cc[VSTOP] = '\023'; /* ^S */
n_tio.c_cc[VSUSP] = '\032'; /* ^Z */
n_tio.c_iflag &= ~(IGNCR | IUCLC);
n_tio.c_iflag |= ICRNL | IXON | IXANY;
n_tio.c_oflag &=
~(OLCUC | ONOCR | ONLRET | OFILL | NLDLY | CRDLY | TABDLY | BSDLY);
n_tio.c_oflag |= OPOST | ONLCR | TAB3;
n_tio.c_lflag &= ~(XCASE | NOFLSH | ECHOK | ECHONL);
n_tio.c_lflag |= ISIG | ICANON | ECHO;
n_tio.c_cc[VEOF] = '\004'; /* ^D */
n_tio.c_cc[VEOL] = '\000'; /* EOL */
n_tio.c_cc[VERASE] = '\010'; /* ^H */
n_tio.c_cc[VINTR] = '\003'; /* ^C */
n_tio.c_cc[VKILL] = '\025'; /* ^U */
/* MIN */
n_tio.c_cc[VQUIT] = '\034'; /* ^\ */
n_tio.c_cc[VSTART] = '\021'; /* ^Q */
n_tio.c_cc[VSTOP] = '\023'; /* ^S */
n_tio.c_cc[VSUSP] = '\032'; /* ^Z */
#ifdef HAVE_TCSETATTR
if (0 != tcsetattr(0, TCSANOW, &n_tio)) {
(void) fprintf(stderr, "%s: tcsetattr: %s\n", progname, strerror(errno));
exit(1);
/* 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 */
}
if (0 != tcsetattr(0, TCSANOW, &n_tio)) {
(void)fprintf(stderr, "%s: tcsetattr: %s\n", progname,
strerror(errno));
exit(1);
/* NOTREACHED */
}
#endif
#endif
#endif /* setup tty */
if (fMakeUtmp) {
extern char *ttyname();
make_utmp(pcLogin, (char *)0 != pcTty ? pcTty : ttyname(0));
}
/* Change ownership and modes on the tty.
*/
if ((char *)0 != pcDevTty) {
(void) chown(pcDevTty, wUid, wGid);
(void) chmod(pcDevTty, (mode_t) TTYMODE);
}
if (fMakeUtmp) {
extern char *ttyname();
make_utmp(pcLogin, (char *)0 != pcTty ? pcTty : ttyname(0));
}
/* Change ownership and modes on the tty.
*/
if ((char *)0 != pcDevTty) {
(void)chown(pcDevTty, wUid, wGid);
(void)chmod(pcDevTty, (mode_t) TTYMODE);
}
if ((char *)0 != pcCmd) {
execl(PATH_SU, "su", "-", pcLogin, pcCmd, (char *)0);
} else {
execl(PATH_SU, "su", "-", pcLogin, (char *)0);
}
if ((char *)0 != pcCmd) {
execl(PATH_SU, "su", "-", pcLogin, pcCmd, (char *)0);
} else {
execl(PATH_SU, "su", "-", pcLogin, (char *)0);
}
}
#ifndef HAVE_PUTENV
int
putenv(pcAssign)
char *pcAssign;
char *pcAssign;
{
register char *pcEq;
register char *pcEq;
if ((char *)0 != (pcEq = strchr(pcAssign, '='))) {
*pcEq++ = '\000';
(void)setenv(pcAssign, pcEq, 1);
*--pcEq = '=';
} else {
unsetenv(pcAssign);
}
if ((char *)0 != (pcEq = strchr(pcAssign, '='))) {
*pcEq++ = '\000';
(void)setenv(pcAssign, pcEq, 1);
*--pcEq = '=';
} else {
unsetenv(pcAssign);
}
}
#endif
int
addgroup(pcGrp)
char *pcGrp;
char *pcGrp;
{
struct group *grp;
struct group *grp;
grp = getgrnam(pcGrp);
if ((struct group *)0 == grp) {
(void) fprintf(stderr, "%s: Unknown group: %s\n", progname, pcGrp);
return(1);
}
if (iGrps >= NGROUPS_MAX) {
(void) fprintf(stderr, "%s: Too many groups specified with \"%s\".\n", progname, pcGrp);
return(1);
}
awGrps[iGrps++] = grp->gr_gid;
return(0);
grp = getgrnam(pcGrp);
if ((struct group *)0 == grp) {
(void)fprintf(stderr, "%s: Unknown group: %s\n", progname, pcGrp);
return (1);
}
if (iGrps >= NGROUPS_MAX) {
(void)fprintf(stderr,
"%s: Too many groups specified with \"%s\".\n",
progname, pcGrp);
return (1);
}
awGrps[iGrps++] = grp->gr_gid;
return (0);
}
@ -525,69 +452,69 @@ char *pcGrp;
*/
void
make_utmp(pclogin, pctty)
char *pclogin;
char *pctty;
char *pclogin;
char *pctty;
{
register int iFound, iPos;
register int fdUtmp;
register char *pcDev;
register struct utmp *up;
auto struct utmp outmp, utmp;
register int iFound, iPos;
register int fdUtmp;
register char *pcDev;
register struct utmp *up;
auto struct utmp utmp;
if ((char *)0 == pctty) {
return;
if ((char *)0 == pctty) {
return;
}
if ((fdUtmp = open(UTMP_FILE, O_RDWR, 0664)) < 0) {
return;
}
/* create empty utmp entry
*/
(void)memset(&utmp, 0, sizeof(struct utmp));
/* Only the last portion of the tty is saved, unless it's
* all digits. Then back up and include the previous part
* /dev/pty/02 -> pty/02 (not just 02)
*/
if ((char *)0 != (pcDev = strrchr(pctty, '/'))) {
if (!*(pcDev + strspn(pcDev, "/0123456789"))) {
while (pcDev != pctty && *--pcDev != '/') {
}
}
if ((fdUtmp = open(UTMP_FILE, O_RDWR, 0664)) < 0) {
return;
}
/* create empty utmp entry
*/
(void)memset(&utmp, 0, sizeof(struct utmp));
/* Only the last portion of the tty is saved, unless it's
* all digits. Then back up and include the previous part
* /dev/pty/02 -> pty/02 (not just 02)
*/
if ((char *)0 != (pcDev = strrchr(pctty, '/'))) {
if (! *(pcDev + strspn(pcDev, "/0123456789"))) {
while (pcDev != pctty && *--pcDev != '/') {
}
}
if (*pcDev == '/') {
++pcDev;
}
} else {
pcDev = pctty;
if (*pcDev == '/') {
++pcDev;
}
} else {
pcDev = pctty;
}
#ifdef HAVE_GETUTENT
/* look through getutent's by pid
*/
(void)setutent();
utmp.ut_pid = getpid();
iFound = iPos = 0;
while ((up = getutent()) != NULL) {
if (up->ut_pid == utmp.ut_pid) {
utmp = *up;
++iFound;
break;
}
iPos++;
}
(void)endutent();
/* we were an initprocess, now we are a login shell
*/
utmp.ut_type = USER_PROCESS;
(void)strncpy(utmp.ut_user, pclogin, sizeof(utmp.ut_user));
if ('\000' == utmp.ut_line[0]) {
(void)strncpy(utmp.ut_line, pcDev, sizeof(utmp.ut_line));
/* look through getutent's by pid
*/
(void)setutent();
utmp.ut_pid = getpid();
iFound = iPos = 0;
while ((up = getutent()) != NULL) {
if (up->ut_pid == utmp.ut_pid) {
utmp = *up;
++iFound;
break;
}
iPos++;
}
(void)endutent();
/* we were an initprocess, now we are a login shell
*/
utmp.ut_type = USER_PROCESS;
(void)strncpy(utmp.ut_user, pclogin, sizeof(utmp.ut_user));
if ('\000' == utmp.ut_line[0]) {
(void)strncpy(utmp.ut_line, pcDev, sizeof(utmp.ut_line));
}
#else
#ifdef HAVE_SETTTYENT
{
{
register struct ttyent *ty;
/* look through ttyslots by line?
@ -595,56 +522,56 @@ char *pctty;
(void)setttyent();
iFound = iPos = 0;
while ((ty = getttyent()) != NULL) {
if (strcmp(ty->ty_name, pcDev) == 0) {
++iFound;
break;
}
iPos++;
if (strcmp(ty->ty_name, pcDev) == 0) {
++iFound;
break;
}
iPos++;
}
/* fill in utmp from ty ZZZ */
(void)endttyent();
}
(void)strncpy(utmp.ut_line, pcDev, sizeof(utmp.ut_line));
(void)strncpy(utmp.ut_name, pclogin, sizeof(utmp.ut_name));
(void)strncpy(utmp.ut_host, "(autologin)", sizeof(utmp.ut_host));
}
(void)strncpy(utmp.ut_line, pcDev, sizeof(utmp.ut_line));
(void)strncpy(utmp.ut_name, pclogin, sizeof(utmp.ut_name));
(void)strncpy(utmp.ut_host, "(autologin)", sizeof(utmp.ut_host));
#else
/* look through /etc/utmp by hand (sigh)
*/
iFound = iPos = 0;
while (sizeof(utmp) == read(fdUtmp, & utmp, sizeof(utmp))) {
if (0 == strncmp(utmp.ut_line, pcDev, sizeof(utmp.ut_line))) {
++iFound;
break;
}
iPos++;
/* look through /etc/utmp by hand (sigh)
*/
iFound = iPos = 0;
while (sizeof(utmp) == read(fdUtmp, &utmp, sizeof(utmp))) {
if (0 == strncmp(utmp.ut_line, pcDev, sizeof(utmp.ut_line))) {
++iFound;
break;
}
(void)strncpy(utmp.ut_name, pclogin, sizeof(utmp.ut_name));
iPos++;
}
(void)strncpy(utmp.ut_name, pclogin, sizeof(utmp.ut_name));
#endif
#endif
utmp.ut_time = time((time_t *) 0);
utmp.ut_time = time((time_t *)0);
if (0 == iFound) {
fprintf(stderr, "%s: %s: no ttyslot\n", progname, pctty);
} else if (-1 == lseek(fdUtmp, (off_t)(iPos*sizeof(utmp)), 0)) {
fprintf(stderr, "%s: lseek: %s\n", progname, strerror(errno));
} else {
(void)write(fdUtmp, (char *)&utmp, sizeof(utmp));
}
(void)close(fdUtmp);
if (0 == iFound) {
fprintf(stderr, "%s: %s: no ttyslot\n", progname, pctty);
} else if (-1 == lseek(fdUtmp, (off_t) (iPos * sizeof(utmp)), 0)) {
fprintf(stderr, "%s: lseek: %s\n", progname, strerror(errno));
} else {
(void)write(fdUtmp, (char *)&utmp, sizeof(utmp));
}
(void)close(fdUtmp);
}
void
usage()
{
char *u_pch;
int u_loop;
char *u_pch;
int u_loop;
for (u_loop = 0; (char *)0 != (u_pch = au_terse[u_loop]); ++u_loop) {
fprintf(stdout, "%s: usage%s\n", progname, u_pch);
}
for (u_loop = 0; (char *)0 != (u_pch = u_help[u_loop]); ++u_loop) {
fprintf(stdout, "%s\n", u_pch);
}
for (u_loop = 0; (char *)0 != (u_pch = au_terse[u_loop]); ++u_loop) {
fprintf(stdout, "%s: usage%s\n", progname, u_pch);
}
for (u_loop = 0; (char *)0 != (u_pch = u_help[u_loop]); ++u_loop) {
fprintf(stdout, "%s\n", u_pch);
}
}

View File

@ -13,7 +13,7 @@
#ifndef HAVE_GETOPT
static int
optopt; /* character checked for validity */
optopt; /* character checked for validity */
/* get option letter from argument vector, also does -number correctly
* for nice, xargs, and stuff (these extras by ksb)
@ -21,166 +21,168 @@ static int
*/
static int
getopt(nargc, nargv, ostr)
int nargc;
char **nargv, *ostr;
int nargc;
char **nargv, *ostr;
{
register char *oli; /* option letter list index */
static char EMSG[] = ""; /* just a null place */
static char *place = EMSG; /* option letter processing */
register char *oli; /* option letter list index */
static char EMSG[] = ""; /* just a null place */
static char *place = EMSG; /* option letter processing */
if ('\000' == *place) { /* update scanning pointer */
if (optind >= nargc)
return EOF;
if (nargv[optind][0] != '-') {
register int iLen;
return EOF;
}
place = nargv[optind];
if ('\000' == *++place) /* "-" (stdin) */
return EOF;
if (*place == '-' && '\000' == place[1]) {
/* found "--" */
++optind;
return EOF;
}
} /* option letter okay? */
/* if we find the letter, (not a `:')
* or a digit to match a # in the list
*/
if ((optopt = *place++) == ':' ||
((char *)0 == (oli = strchr(ostr,optopt)) &&
(!(isdigit(optopt)||'-'==optopt) || (char *)0 == (oli = strchr(ostr, '#'))))) {
if(!*place) ++optind;
return('?');
if ('\000' == *place) { /* update scanning pointer */
if (optind >= nargc)
return EOF;
if (nargv[optind][0] != '-') {
register int iLen;
return EOF;
}
if ('#' == *oli) { /* accept as -digits */
optarg = place -1;
++optind;
place = EMSG;
return '#';
place = nargv[optind];
if ('\000' == *++place) /* "-" (stdin) */
return EOF;
if (*place == '-' && '\000' == place[1]) {
/* found "--" */
++optind;
return EOF;
}
if (*++oli != ':') { /* don't need argument */
optarg = NULL;
if ('\000' == *place)
++optind;
} else { /* need an argument */
if (*place) { /* no white space */
optarg = place;
} else if (nargc <= ++optind) { /* no arg!! */
place = EMSG;
return '*';
} else {
optarg = nargv[optind]; /* white space */
}
place = EMSG;
++optind;
}
/* option letter okay? */
/* if we find the letter, (not a `:')
* or a digit to match a # in the list
*/
if ((optopt = *place++) == ':' ||
((char *)0 == (oli = strchr(ostr, optopt)) &&
(!(isdigit(optopt) || '-' == optopt) ||
(char *)0 == (oli = strchr(ostr, '#'))))) {
if (!*place)
++optind;
return ('?');
}
if ('#' == *oli) { /* accept as -digits */
optarg = place - 1;
++optind;
place = EMSG;
return '#';
}
if (*++oli != ':') { /* don't need argument */
optarg = NULL;
if ('\000' == *place)
++optind;
} else { /* need an argument */
if (*place) { /* no white space */
optarg = place;
} else if (nargc <= ++optind) { /* no arg!! */
place = EMSG;
return '*';
} else {
optarg = nargv[optind]; /* white space */
}
return optopt; /* dump back option letter */
place = EMSG;
++optind;
}
return optopt; /* dump back option letter */
}
#endif /* ! HAVE_GETOPT */
char
*progname = "$Id: main.c,v 1.1 2003/11/04 02:36:24 bryan Exp $",
*au_terse[] = {
" [-u] [-c cmd] [-e env=value] [-g group] [-l login] [-t tty]",
" -h",
" -V",
(char *)0
},
*u_help[] = {
"c cmd command to run",
"e env=value environment variable to set",
"g group initial group",
"h print this help message",
"l login login name",
"t tty attach to this terminal",
"u do no make utmp entry",
"V show version information",
(char *)0
},
*pcCommand = (char *)0,
*pcGroup = (char *)0,
*pcLogin = (char *)0,
*pcTty = (char *)0;
*progname =
"$Id: main.c,v 1.2 2013/09/20 21:15:13 bryan Exp $", *au_terse[] = {
" [-u] [-c cmd] [-e env=value] [-g group] [-l login] [-t tty]",
" -h",
" -V",
(char *)0
}, *u_help[] = {
"c cmd command to run",
"e env=value environment variable to set",
"g group initial group",
"h print this help message",
"l login login name",
"t tty attach to this terminal",
"u do no make utmp entry",
"V show version information", (char *)0}, *pcCommand =
(char *)0, *pcGroup = (char *)0, *pcLogin = (char *)0, *pcTty =
(char *)0;
int
fMakeUtmp = 1,
iErrs = 0;
fMakeUtmp = 1, iErrs = 0;
#ifndef u_terse
#define u_terse (au_terse[0])
#endif
static char *rcsid =
"$Id: main.c,v 1.1 2003/11/04 02:36:24 bryan Exp $";
static char *rcsid = "$Id: main.c,v 1.2 2013/09/20 21:15:13 bryan Exp $";
/*
* parser
*/
int
main(argc, argv)
int argc;
char **argv;
int argc;
char **argv;
{
static char
sbOpt[] = "c:e:g:hl:t:uV",
*u_pch = (char *)0;
static int
u_loop = 0;
register int u_curopt;
extern int atoi();
static char
sbOpt[] = "c:e:g:hl:t:uV", *u_pch = (char *)0;
static int
u_loop = 0;
register int u_curopt;
extern int atoi();
progname = strrchr(argv[0], '/');
if ((char *)0 == progname)
progname = argv[0];
else
++progname;
while (EOF != (u_curopt = getopt(argc, argv, sbOpt))) {
switch (u_curopt) {
case '*':
fprintf(stderr, "%s: option `-%c\' needs a parameter\n", progname, optopt);
exit(1);
case '?':
fprintf(stderr, "%s: unknown option `-%c\', use `-h\' for help\n", progname, optopt);
exit(1);
case 'c':
pcCommand = optarg;
continue;
case 'e':
if (putenv(optarg) != 0) {
(void) fprintf(stderr, "%s: putenv(\"%s\"): failed\n", progname, optarg);
exit(1);
}
continue;
case 'g':
pcGroup = optarg;
continue;
case 'h':
for (u_loop = 0; (char *)0 != (u_pch = au_terse[u_loop]); ++u_loop) {
if ('\000' == *u_pch) {
fprintf(stdout, "%s: with no parameters\n", progname);
continue;
}
fprintf(stdout, "%s: usage%s\n", progname, u_pch);
}
for (u_loop = 0; (char *)0 != (u_pch = u_help[u_loop]); ++u_loop) {
fprintf(stdout, "%s\n", u_pch);
}
exit(0);
case 'l':
pcLogin = optarg;
continue;
case 't':
pcTty = optarg;
continue;
case 'u':
fMakeUtmp = 0;
continue;
case 'V':
printf("%s: %s\n", progname, rcsid);
exit(0);
progname = strrchr(argv[0], '/');
if ((char *)0 == progname)
progname = argv[0];
else
++progname;
while (EOF != (u_curopt = getopt(argc, argv, sbOpt))) {
switch (u_curopt) {
case '*':
fprintf(stderr, "%s: option `-%c\' needs a parameter\n",
progname, optopt);
exit(1);
case '?':
fprintf(stderr,
"%s: unknown option `-%c\', use `-h\' for help\n",
progname, optopt);
exit(1);
case 'c':
pcCommand = optarg;
continue;
case 'e':
if (putenv(optarg) != 0) {
(void)fprintf(stderr, "%s: putenv(\"%s\"): failed\n",
progname, optarg);
exit(1);
}
break;
continue;
case 'g':
pcGroup = optarg;
continue;
case 'h':
for (u_loop = 0; (char *)0 != (u_pch = au_terse[u_loop]);
++u_loop) {
if ('\000' == *u_pch) {
fprintf(stdout, "%s: with no parameters\n",
progname);
continue;
}
fprintf(stdout, "%s: usage%s\n", progname, u_pch);
}
for (u_loop = 0; (char *)0 != (u_pch = u_help[u_loop]);
++u_loop) {
fprintf(stdout, "%s\n", u_pch);
}
exit(0);
case 'l':
pcLogin = optarg;
continue;
case 't':
pcTty = optarg;
continue;
case 'u':
fMakeUtmp = 0;
continue;
case 'V':
printf("%s: %s\n", progname, rcsid);
exit(0);
}
Process();
exit(iErrs);
break;
}
Process();
exit(iErrs);
}

View File

@ -12,4 +12,3 @@ extern char *pcCommand, *pcGroup, *pcLogin, *pcTty;
/* from std_help.m */
/* from std_version.m */
/* from autologin.m */

View File

@ -8,9 +8,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <netinet/in.h>
#if USE_UNIX_DOMAIN_SOCKETS
#include <sys/un.h>
#endif
#include <arpa/inet.h>
#include <netdb.h>
#include <ctype.h>
@ -37,6 +35,17 @@
# define DEFESC 'c'
#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...
*/
#if ! defined(DEFPORT)
@ -94,6 +103,18 @@ typedef long fd_set;
#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
# include <stropts.h>
#endif
@ -310,3 +331,7 @@ typedef int socklen_t;
#if HAVE_DMALLOC
#include <dmalloc.h>
#endif
#if HAVE_FREEIPMI
#include <ipmiconsole.h>
#endif

667
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. */
/* Client config file path */
#undef CLIENTCONFIGFILE
/* Config file path */
#undef CONFIGFILE
@ -15,6 +18,9 @@
/* Socket used to communicate */
#undef DEFPORT
/* Defined if building for a Cyclades TS */
#undef FOR_CYCLADES_TS
/* Define to 1 if you have the `bigcrypt' function. */
#undef HAVE_BIGCRYPT
@ -27,6 +33,9 @@
/* have dmalloc support */
#undef HAVE_DMALLOC
/* have freeipmi support */
#undef HAVE_FREEIPMI
/* Define to 1 if you have the `getaudit' function. */
#undef HAVE_GETAUDIT
@ -57,6 +66,9 @@
/* Define to 1 if you have the `getspnam' function. */
#undef HAVE_GETSPNAM
/* Define to 1 if you have the `gettimeofday' function. */
#undef HAVE_GETTIMEOFDAY
/* Define to 1 if you have the `getuserattr' function. */
#undef HAVE_GETUSERATTR
@ -66,6 +78,9 @@
/* Define to 1 if you have the `grantpt' function. */
#undef HAVE_GRANTPT
/* have gss-api support */
#undef HAVE_GSSAPI
/* Define to 1 if you have the <hpsecurity.h> header file. */
#undef HAVE_HPSECURITY_H
@ -189,6 +204,9 @@
/* Define to 1 if you have the <string.h> header file. */
#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. */
#undef HAVE_STROPTS_H
@ -237,6 +255,9 @@
/* Define to 1 if you have the <sys/uio.h> header file. */
#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. */
#undef HAVE_SYS_VLIMIT_H
@ -297,6 +318,9 @@
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the home page for this package. */
#undef PACKAGE_URL
/* Define to the version of this package. */
#undef PACKAGE_VERSION
@ -309,15 +333,18 @@
/* Define to 1 if the C compiler supports function prototypes. */
#undef PROTOTYPES
/* Defined if client requires server SSL certificate */
#undef REQ_SERVER_CERT
/* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE
/* Define to 1 if the `setpgrp' function takes no argument. */
#undef SETPGRP_VOID
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
/* retry username without @REALM with gss-api authentication */
#undef STRIP_REALM
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME
@ -333,15 +360,40 @@
/* use tcp_wrappers libwrap */
#undef USE_LIBWRAP
/* Defined if we use Unix domain sockets */
#undef USE_UNIX_DOMAIN_SOCKETS
/* Define to 1 if on AIX 3.
System headers sometimes define this.
We just want to avoid a redefinition error message. */
/* Enable extensions on AIX 3, Interix. */
#ifndef _ALL_SOURCE
# undef _ALL_SOURCE
#endif
/* Enable GNU extensions on systems that have them. */
#ifndef _GNU_SOURCE
# undef _GNU_SOURCE
#endif
/* Enable threading extensions on Solaris. */
#ifndef _POSIX_PTHREAD_SEMANTICS
# undef _POSIX_PTHREAD_SEMANTICS
#endif
/* Enable extensions on HP NonStop. */
#ifndef _TANDEM_SOURCE
# undef _TANDEM_SOURCE
#endif
/* Enable general extensions on Solaris. */
#ifndef __EXTENSIONS__
# undef __EXTENSIONS__
#endif
/* Defined if we use Unix domain sockets */
#undef USE_UNIX_DOMAIN_SOCKETS
/* Define to 1 if on MINIX. */
#undef _MINIX
/* Define to 2 if the system does not provide POSIX.1 features except with
this defined. */
#undef _POSIX_1_SOURCE
/* Define to 1 if you need to in order for `stat' and other things to work. */
#undef _POSIX_SOURCE
/* Define like PROTOTYPES; this can be used by system headers. */
#undef __PROTOTYPES
@ -349,6 +401,9 @@
/* Define to empty if `const' does not conform to ANSI C. */
#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. */
#undef mode_t
@ -358,5 +413,8 @@
/* Define if <signal.h> does not define sig_atomic_t */
#undef sig_atomic_t
/* Define to `unsigned' if <sys/types.h> does not define. */
/* Define to `unsigned int' if <sys/types.h> does not define. */
#undef size_t
/* Define to `int' if <sys/types.h> doesn't define. */
#undef uid_t

227
config.sub vendored
View File

@ -1,9 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script.
# 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, 2007, 2008
# Free Software Foundation, Inc.
timestamp='2004-03-12'
timestamp='2008-01-16'
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
@ -21,14 +22,15 @@ timestamp='2004-03-12'
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
# 02110-1301, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Please send patches to <config-patches@gnu.org>. Submit a context
# diff and a properly formatted ChangeLog entry.
#
@ -70,8 +72,8 @@ Report bugs and patches to <config-patches@gnu.org>."
version="\
GNU config.sub ($timestamp)
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
Free Software Foundation, Inc.
Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@ -83,11 +85,11 @@ Try \`$me --help' for more information."
while test $# -gt 0 ; do
case $1 in
--time-stamp | --time* | -t )
echo "$timestamp" ; exit 0 ;;
echo "$timestamp" ; exit ;;
--version | -v )
echo "$version" ; exit 0 ;;
echo "$version" ; exit ;;
--help | --h* | -h )
echo "$usage"; exit 0 ;;
echo "$usage"; exit ;;
-- ) # Stop option processing
shift; break ;;
- ) # Use stdin as input.
@ -99,7 +101,7 @@ while test $# -gt 0 ; do
*local*)
# First pass through any local machine types.
echo $1
exit 0;;
exit ;;
* )
break ;;
@ -118,8 +120,9 @@ esac
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \
uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | \
storm-chaos* | os2-emx* | rtmk-nova*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@ -145,7 +148,7 @@ case $os in
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-apple | -axis)
-apple | -axis | -knuth | -cray)
os=
basic_machine=$1
;;
@ -170,6 +173,10 @@ case $os in
-hiux*)
os=-hiuxwe2
;;
-sco6)
os=-sco5v6
basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
;;
-sco5)
os=-sco3.2v5
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.
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*)
os=-sco3.2v2
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] \
| alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
| 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 \
| d10v | d30v | dlx | dsp16xx \
| fr30 | frv \
| fido | fr30 | frv \
| h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
| i370 | i860 | i960 | ia64 \
| ip2k | iq2000 \
| m32r | m32rle | m68000 | m68k | m88k | mcore \
| m32c | m32r | m32rle | m68000 | m68k | m88k \
| maxq | mb | microblaze | mcore | mep \
| mips | mipsbe | mipseb | mipsel | mipsle \
| mips16 \
| mips64 | mips64el \
@ -246,6 +259,7 @@ case $basic_machine in
| mips64vr4100 | mips64vr4100el \
| mips64vr4300 | mips64vr4300el \
| mips64vr5000 | mips64vr5000el \
| mips64vr5900 | mips64vr5900el \
| mipsisa32 | mipsisa32el \
| mipsisa32r2 | mipsisa32r2el \
| mipsisa64 | mipsisa64el \
@ -254,20 +268,24 @@ case $basic_machine in
| mipsisa64sr71k | mipsisa64sr71kel \
| mipstx39 | mipstx39el \
| mn10200 | mn10300 \
| mt \
| msp430 \
| nios | nios2 \
| ns16k | ns32k \
| openrisc | or32 \
| or32 \
| pdp10 | pdp11 | pj | pjl \
| powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
| 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 \
| sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \
| strongarm \
| sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
| sparcv8 | sparcv9 | sparcv9b | sparcv9v \
| spu | strongarm \
| tahoe | thumb | tic4x | tic80 | tron \
| v850 | v850e \
| we32k \
| x86 | xscale | xstormy16 | xtensa \
| x86 | xc16x | xscale | xscalee[bl] | xstormy16 | xtensa \
| z8k)
basic_machine=$basic_machine-unknown
;;
@ -278,6 +296,9 @@ case $basic_machine in
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
;;
ms1)
basic_machine=mt-unknown
;;
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
@ -297,20 +318,20 @@ case $basic_machine in
| alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
| alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
| arm-* | armbe-* | armle-* | armeb-* | armv*-* \
| avr-* \
| bs2000-* \
| avr-* | avr32-* \
| bfin-* | bs2000-* \
| c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
| clipper-* | cydra-* \
| clipper-* | craynv-* | cydra-* \
| d10v-* | d30v-* | dlx-* \
| elxsi-* \
| f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
| f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
| h8300-* | h8500-* \
| hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
| i*86-* | i860-* | i960-* | ia64-* \
| ip2k-* | iq2000-* \
| m32r-* | m32rle-* \
| m32c-* | m32r-* | m32rle-* \
| m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
| m88110-* | m88k-* | mcore-* \
| m88110-* | m88k-* | maxq-* | mcore-* \
| mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
| mips16-* \
| mips64-* | mips64el-* \
@ -319,6 +340,7 @@ case $basic_machine in
| mips64vr4100-* | mips64vr4100el-* \
| mips64vr4300-* | mips64vr4300el-* \
| mips64vr5000-* | mips64vr5000el-* \
| mips64vr5900-* | mips64vr5900el-* \
| mipsisa32-* | mipsisa32el-* \
| mipsisa32r2-* | mipsisa32r2el-* \
| mipsisa64-* | mipsisa64el-* \
@ -326,27 +348,35 @@ case $basic_machine in
| mipsisa64sb1-* | mipsisa64sb1el-* \
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
| mipstx39-* | mipstx39el-* \
| mmix-* \
| mt-* \
| msp430-* \
| none-* | np1-* | nv1-* | ns16k-* | ns32k-* \
| nios-* | nios2-* \
| none-* | np1-* | ns16k-* | ns32k-* \
| orion-* \
| pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
| powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
| pyramid-* \
| 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-* \
| sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
| sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
| sparclite-* \
| sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
| tahoe-* | thumb-* \
| tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
| tron-* \
| v850-* | v850e-* | vax-* \
| we32k-* \
| x86-* | x86_64-* | xps100-* | xscale-* | xstormy16-* \
| xtensa-* \
| x86-* | x86_64-* | xc16x-* | xps100-* | xscale-* | xscalee[bl]-* \
| xstormy16-* | xtensa*-* \
| ymp-* \
| z8k-*)
;;
# Recognize the basic CPU types without company name, with glob match.
xtensa*)
basic_machine=$basic_machine-unknown
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
386bsd)
@ -417,6 +447,14 @@ case $basic_machine in
basic_machine=ns32k-sequent
os=-dynix
;;
blackfin)
basic_machine=bfin-unknown
os=-linux
;;
blackfin-*)
basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
c90)
basic_machine=c90-cray
os=-unicos
@ -445,13 +483,20 @@ case $basic_machine in
basic_machine=j90-cray
os=-unicos
;;
cr16c)
basic_machine=cr16c-unknown
craynv)
basic_machine=craynv-cray
os=-unicosmp
;;
cr16)
basic_machine=cr16-unknown
os=-elf
;;
crds | unos)
basic_machine=m68k-crds
;;
crisv32 | crisv32-* | etraxfs*)
basic_machine=crisv32-axis
;;
cris | cris-* | etrax*)
basic_machine=cris-axis
;;
@ -481,6 +526,10 @@ case $basic_machine in
basic_machine=m88k-motorola
os=-sysv3
;;
djgpp)
basic_machine=i586-pc
os=-msdosdjgpp
;;
dpx20 | dpx20-*)
basic_machine=rs6000-bull
os=-bosx
@ -631,6 +680,14 @@ case $basic_machine in
basic_machine=m68k-isi
os=-sysv
;;
m68knommu)
basic_machine=m68k-unknown
os=-linux
;;
m68knommu-*)
basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
m88k-omron*)
basic_machine=m88k-omron
;;
@ -646,6 +703,10 @@ case $basic_machine in
basic_machine=i386-pc
os=-mingw32
;;
mingw32ce)
basic_machine=arm-unknown
os=-mingw32ce
;;
miniframe)
basic_machine=m68000-convergent
;;
@ -659,10 +720,6 @@ case $basic_machine in
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
mmix*)
basic_machine=mmix-knuth
os=-mmixware
;;
monitor)
basic_machine=m68k-rom68k
os=-coff
@ -675,6 +732,9 @@ case $basic_machine in
basic_machine=i386-pc
os=-msdos
;;
ms1-*)
basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
;;
mvs)
basic_machine=i370-ibm
os=-mvs
@ -743,10 +803,6 @@ case $basic_machine in
np1)
basic_machine=np1-gould
;;
nv1)
basic_machine=nv1-cray
os=-unicosmp
;;
nsr-tandem)
basic_machine=nsr-tandem
;;
@ -754,9 +810,8 @@ case $basic_machine in
basic_machine=hppa1.1-oki
os=-proelf
;;
or32 | or32-*)
openrisc | openrisc-*)
basic_machine=or32-unknown
os=-coff
;;
os400)
basic_machine=powerpc-ibm
@ -778,6 +833,14 @@ case $basic_machine in
basic_machine=i860-intel
os=-osf
;;
parisc)
basic_machine=hppa-unknown
os=-linux
;;
parisc-*)
basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
os=-linux
;;
pbd)
basic_machine=sparc-tti
;;
@ -787,6 +850,12 @@ case $basic_machine in
pc532 | 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)
basic_machine=i586-pc
;;
@ -843,6 +912,10 @@ case $basic_machine in
basic_machine=i586-unknown
os=-pw32
;;
rdos)
basic_machine=i386-pc
os=-rdos
;;
rom68k)
basic_machine=m68k-rom68k
os=-coff
@ -869,6 +942,10 @@ case $basic_machine in
sb1el)
basic_machine=mipsisa64sb1el-unknown
;;
sde)
basic_machine=mipsisa32-sde
os=-elf
;;
sei)
basic_machine=mips-sei
os=-seiux
@ -880,6 +957,9 @@ case $basic_machine in
basic_machine=sh-hitachi
os=-hms
;;
sh5el)
basic_machine=sh5le-unknown
;;
sh64)
basic_machine=sh64-unknown
;;
@ -969,6 +1049,10 @@ case $basic_machine in
basic_machine=tic6x-unknown
os=-coff
;;
tile*)
basic_machine=tile-unknown
os=-linux-gnu
;;
tx39)
basic_machine=mipstx39-unknown
;;
@ -1029,6 +1113,10 @@ case $basic_machine in
basic_machine=hppa1.1-winbond
os=-proelf
;;
xbox)
basic_machine=i686-pc
os=-mingw32
;;
xps | xps100)
basic_machine=xps100-honeywell
;;
@ -1059,6 +1147,9 @@ case $basic_machine in
romp)
basic_machine=romp-ibm
;;
mmix)
basic_machine=mmix-knuth
;;
rs6000)
basic_machine=rs6000-ibm
;;
@ -1075,13 +1166,10 @@ case $basic_machine in
we32k)
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
;;
sh64)
basic_machine=sh64-unknown
;;
sparc | sparcv8 | sparcv9 | sparcv9b)
sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
basic_machine=sparc-sun
;;
cydra)
@ -1154,20 +1242,23 @@ case $os in
| -aos* \
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
| -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
| -openbsd* | -solidbsd* \
| -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
| -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -chorusos* | -chorusrdb* \
| -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* \
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*)
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
| -skyos* | -haiku* | -rdos* | -toppers* | -drops*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
-qnx*)
@ -1185,7 +1276,7 @@ case $os in
os=`echo $os | sed -e 's|nto|nto-qnx|'`
;;
-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*)
;;
-mac*)
@ -1294,6 +1385,9 @@ case $os in
-kaos*)
os=-kaos
;;
-zvmoe)
os=-zvmoe
;;
-none)
;;
*)
@ -1316,6 +1410,12 @@ else
# system, and we'll never get to this point.
case $basic_machine in
score-*)
os=-elf
;;
spu-*)
os=-elf
;;
*-acorn)
os=-riscix1.2
;;
@ -1325,9 +1425,9 @@ case $basic_machine in
arm*-semi)
os=-aout
;;
c4x-* | tic4x-*)
os=-coff
;;
c4x-* | tic4x-*)
os=-coff
;;
# This must come before the *-dec entry.
pdp10-*)
os=-tops20
@ -1353,6 +1453,9 @@ case $basic_machine in
m68*-cisco)
os=-aout
;;
mep-*)
os=-elf
;;
mips*-cisco)
os=-elf
;;
@ -1371,9 +1474,15 @@ case $basic_machine in
*-be)
os=-beos
;;
*-haiku)
os=-haiku
;;
*-ibm)
os=-aix
;;
*-knuth)
os=-mmixware
;;
*-wec)
os=-proelf
;;
@ -1539,7 +1648,7 @@ case $basic_machine in
esac
echo $basic_machine$os
exit 0
exit
# Local variables:
# eval: (add-hook 'write-file-hooks 'time-stamp)

10393
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([MASTERHOST], [Hostname of console server])
AH_TEMPLATE([CONFIGFILE], [Config file path])
AH_TEMPLATE([CLIENTCONFIGFILE], [Client config file path])
AH_TEMPLATE([PASSWDFILE], [Password file path])
AH_TEMPLATE([LOGFILEPATH], [Logfile path])
AH_TEMPLATE([MAXMEMB], [Number of consoles per child process])
@ -13,12 +14,17 @@ AH_TEMPLATE([USE_LIBWRAP], [use tcp_wrappers libwrap])
dnl AH_TEMPLATE([HAVE_POSIX_REGCOMP], [have POSIX regcomp])
AH_TEMPLATE([HAVE_PAM], [have PAM support])
AH_TEMPLATE([HAVE_OPENSSL], [have openssl support])
AH_TEMPLATE([HAVE_GSSAPI], [have gss-api support])
AH_TEMPLATE([HAVE_FREEIPMI], [have freeipmi support])
AH_TEMPLATE([STRIP_REALM], [retry username without @REALM with gss-api authentication])
AH_TEMPLATE([HAVE_DMALLOC], [have dmalloc support])
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([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])
AH_TEMPLATE([REQ_SERVER_CERT], [Defined if client requires server SSL certificate])
dnl ### Normal initialization. ######################################
AC_INIT
@ -98,6 +104,26 @@ AC_ARG_WITH(master,
[AC_DEFINE_UNQUOTED(MASTERHOST, "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_ARG_WITH(cffile,
AS_HELP_STRING([--with-cffile=CFFILE],[Specify config filename @<:@SYSCONFDIR/conserver.cf@:>@]),
@ -233,6 +259,7 @@ AC_ARG_WITH(extmsgs,
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@:>@]),
@ -241,6 +268,7 @@ AC_ARG_WITH(uds,
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)
@ -249,6 +277,7 @@ AC_ARG_WITH(uds,
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
@ -258,6 +287,35 @@ AC_ARG_WITH(uds,
;;
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. ###################################
AC_PROG_CC
AC_PROG_INSTALL
@ -287,7 +345,7 @@ if test "$ac_cv_sys_posix_termios" != "yes"; then
AC_MSG_ERROR([POSIX termios interface required])
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
AC_CHECK_HEADERS(sys/proc.h, [], [],
[#if HAVE_SYS_PARAM_H
@ -300,6 +358,7 @@ AC_TYPE_MODE_T
AC_TYPE_SIGNAL
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_CHECK_TYPE([sig_atomic_t],,
AC_DEFINE(sig_atomic_t, volatile int,
@ -343,13 +402,18 @@ AC_SEARCH_LIBS(crypt,crypt)
AC_SUBST(CONSLIBS)
AC_SUBST(CONSCPPFLAGS)
AC_SUBST(CONSLDFLAGS)
cons_with_libwrap="NO"
AC_ARG_WITH(libwrap,
AS_HELP_STRING([--with-libwrap@<:@=PATH@:>@],
[Compile in libwrap (tcp_wrappers) support]),
[if test "$withval" != "no"; then
if test "$withval" != "yes"; then
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
WRAPCPPFLAGS=""
WRAPLDFLAGS=""
@ -370,6 +434,7 @@ AC_ARG_WITH(libwrap,
int deny_severity = 0;
],[hosts_access((void *)0)],
[AC_MSG_RESULT(yes)
cons_with_libwrap="YES"
AC_DEFINE(USE_LIBWRAP)
CONSLIBS="$CONSLIBS -lwrap"
CONSLDFLAGS="$CONSLDFLAGS $WRAPLDFLAGS"
@ -382,6 +447,7 @@ AC_ARG_WITH(libwrap,
int deny_severity = 0;
],[hosts_access((void *)0)],
[AC_MSG_RESULT(yes)
cons_with_libwrap="YES"
AC_DEFINE(USE_LIBWRAP)
CONSLIBS="$CONSLIBS -lwrap -lnsl"
CONSLDFLAGS="$CONSLDFLAGS $WRAPLDFLAGS"
@ -393,13 +459,18 @@ AC_ARG_WITH(libwrap,
fi]
)
cons_with_openssl="NO"
AC_ARG_WITH(openssl,
AS_HELP_STRING([--with-openssl@<:@=PATH@:>@],
[Compile in OpenSSL support]),
[if test "$withval" != "no"; then
if test "$withval" != "yes"; then
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
OPENSSLCPPFLAGS=""
OPENSSLLDFLAGS=""
@ -419,6 +490,7 @@ AC_ARG_WITH(openssl,
AC_TRY_LINK([#include <openssl/ssl.h>
],[SSL_library_init()],
[AC_MSG_RESULT(yes)
cons_with_openssl="YES"
AC_DEFINE(HAVE_OPENSSL)
have_openssl=yes],
[AC_MSG_RESULT(no)])],)
@ -428,16 +500,156 @@ AC_ARG_WITH(openssl,
CPPFLAGS="$oCPPFLAGS"
LDFLAGS="$oLDFLAGS"
fi
AC_MSG_CHECKING(whether to require server cert)
AC_ARG_WITH(req-server-cert,
AS_HELP_STRING([--with-req-server-cert],[Require server SSL certificate by client]),
[case "$withval" in
yes)
AC_DEFINE(REQ_SERVER_CERT)
AC_MSG_RESULT(yes)
;;
*)
AC_MSG_RESULT(no)
;;
esac],[AC_MSG_RESULT(no)])
fi]
)
cons_with_gssapi="NO"
cons_strip_realm="NO"
AC_ARG_WITH(gssapi,
AS_HELP_STRING([--with-gssapi@<:@=PATH@:>@],
[Compile in GSS-API support]),
[if test "$withval" != "no"; then
if test "$withval" != "yes"; then
GSSAPICPPFLAGS="-I$withval/include"
if test "$use_dash_r" != "yes"; then
GSSAPILDFLAGS="-L$withval/lib"
else
GSSAPILDFLAGS="-L$withval/lib -R$withval/lib"
fi
else
GSSAPICPPFLAGS=""
GSSAPILDFLAGS=""
fi
oCPPFLAGS="$CPPFLAGS"
oLDFLAGS="$LDFLAGS"
oLIBS="$LIBS"
have_gssapi=no
CPPFLAGS="$CPPFLAGS $GSSAPICPPFLAGS"
LDFLAGS="$LDFLAGS $GSSAPILDFLAGS"
AC_CHECK_HEADER([gssapi/gssapi.h],
[LIBS="$oLIBS -lgssapi"
AC_MSG_CHECKING(for gssapi library -lgssapi)
AC_TRY_LINK([#include <gssapi/gssapi.h>
],[gss_create_empty_oid_set(NULL, NULL)],
[AC_MSG_RESULT(yes)
cons_with_gssapi="YES"
AC_DEFINE(HAVE_GSSAPI)
have_gssapi=yes],
[AC_MSG_RESULT(no)
LIBS="$oLIBS -lgssglue"
AC_MSG_CHECKING(for gssapi library -lgssglue)
AC_TRY_LINK([#include <gssapi/gssapi.h>
],[gss_create_empty_oid_set(NULL, NULL)],
[AC_MSG_RESULT(yes)
cons_with_gssapi="YES"
AC_DEFINE(HAVE_GSSAPI)
have_gssapi=yes],
[AC_MSG_RESULT(no)
LIBS="$oLIBS -lgss"
AC_MSG_CHECKING(for gssapi library -lgss)
AC_TRY_LINK([#include <gssapi/gssapi.h>
],[gss_create_empty_oid_set(NULL, NULL)],
[AC_MSG_RESULT(yes)
cons_with_gssapi="YES"
AC_DEFINE(HAVE_GSSAPI)
have_gssapi=yes],
[AC_MSG_RESULT(no)])])])],)
if test $have_gssapi = no; then
LIBS="$oLIBS"
CPPFLAGS="$oCPPFLAGS"
LDFLAGS="$oLDFLAGS"
else
AC_MSG_CHECKING(whether to fallback to username without @REALM)
AC_ARG_WITH(striprealm,
AS_HELP_STRING([--with-striprealm],[retry username without @REALM with gss-api authentication]),
[case "$withval" in
yes)
AC_DEFINE(STRIP_REALM)
AC_MSG_RESULT(yes)
cons_strip_realm="YES"
;;
*)
AC_MSG_RESULT(no)
;;
esac],[AC_MSG_RESULT(no)])
fi
fi]
)
cons_with_freeipmi="NO"
AC_ARG_WITH(freeipmi,
AS_HELP_STRING([--with-freeipmi@<:@=PATH@:>@],
[Compile in FreeIPMI support]),
[if test "$withval" != "no"; then
if test "$withval" != "yes"; then
FREEIPMICPPFLAGS="-I$withval/include"
if test "$use_dash_r" != "yes"; then
FREEIPMILDFLAGS="-L$withval/lib"
else
FREEIPMILDFLAGS="-L$withval/lib -R$withval/lib"
fi
else
FREEIPMICPPFLAGS=""
FREEIPMILDFLAGS=""
fi
oCPPFLAGS="$CPPFLAGS"
oLDFLAGS="$LDFLAGS"
oLIBS="$LIBS"
have_freeipmi=no
CPPFLAGS="$CPPFLAGS $FREEIPMICPPFLAGS"
LDFLAGS="$LDFLAGS $FREEIPMILDFLAGS"
AC_CHECK_HEADER([ipmiconsole.h],
[LIBS="$LIBS -lipmiconsole"
AC_MSG_CHECKING(for freeipmi libraries -lipmiconsole)
AC_TRY_LINK([#include <ipmiconsole.h>
],[ipmiconsole_ctx_fd(0)],
[AC_MSG_RESULT(yes)
cons_with_freeipmi="YES"
AC_DEFINE(HAVE_FREEIPMI)
CONSLIBS="$CONSLIBS -lipmiconsole"
have_freeipmi=yes],
[AC_MSG_RESULT(no)])],)
LIBS="$oLIBS"
if test $have_freeipmi = no; then
CPPFLAGS="$oCPPFLAGS"
LDFLAGS="$oLDFLAGS"
fi
fi]
)
cons_with_dmalloc="NO"
AC_ARG_WITH(dmalloc,
AS_HELP_STRING([--with-dmalloc@<:@=PATH@:>@],
[Compile in dmalloc support]),
[if test "$withval" != "no"; then
if test "$withval" != "yes"; then
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
DMALLOCCPPFLAGS=""
DMALLOCLDFLAGS=""
@ -457,6 +669,7 @@ AC_ARG_WITH(dmalloc,
AC_TRY_LINK([#include <dmalloc.h>
],[dmalloc_debug(0)],
[AC_MSG_RESULT(yes)
cons_with_dmalloc="YES"
AC_DEFINE(HAVE_DMALLOC)
have_dmalloc=yes],
[AC_MSG_RESULT(no)])],)
@ -505,6 +718,7 @@ dnl else
dnl AC_MSG_RESULT(no)
dnl fi],[AC_MSG_RESULT(no)])
cons_with_pam="NO"
AC_MSG_CHECKING(for PAM support)
AC_ARG_WITH(pam,
AS_HELP_STRING([--with-pam],
@ -517,6 +731,7 @@ AC_ARG_WITH(pam,
AC_MSG_CHECKING(for PAM library -lpam)
AC_TRY_LINK_FUNC([pam_start],
[AC_MSG_RESULT(yes)
cons_with_pam="YES"
AC_DEFINE(HAVE_PAM)
CONSLIBS="$CONSLIBS -lpam"],
[LIBS="$LIBS -ldl"
@ -524,6 +739,7 @@ AC_ARG_WITH(pam,
AC_MSG_CHECKING(for PAM library -lpam with -ldl)
AC_TRY_LINK_FUNC([pam_end],
[AC_MSG_RESULT(yes)
cons_with_pam="YES"
AC_DEFINE(HAVE_PAM)
CONSLIBS="$CONSLIBS -lpam -ldl"],
[AC_MSG_RESULT(no)])])],)
@ -548,8 +764,7 @@ AC_CHECK_HEADERS(pty.h libutil.h util.h)
AC_CHECK_LIB(util, 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_FUNC_SETPGRP
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_CHECK_FUNC(strcasecmp,
[AC_DEFINE(HAVE_STRCASECMP, 1, [Define if strcasecmp is available])],
[AC_CHECK_FUNC(stricmp,
@ -566,3 +781,21 @@ dnl ### Create output files. #######################################
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_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 " GSS-API (--with-gssapi) : $cons_with_gssapi"
echo " FreeIPMI (--with-freeipmi) : $cons_with_freeipmi"
if [ $cons_with_gssapi = "YES" ]; then
echo " strip @REALM (--with-striprealm): $cons_strip_realm"
fi
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
files. See the sample conserver.cf and conserver.passwd files
for examples. You can start with those and then modify extensively.
The man page for conserver.cf and conserver.passwd should explain the
files with enough detail to get you going.
files. See the sample conserver.cf and conserver.passwd files for examples
(installed in <DATADIR>/examples/conserver). You can start with those and
then modify extensively. The man page for conserver.cf and conserver.passwd
should explain the files with enough detail to get you going.
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

@ -1,4 +1,5 @@
### Path settings
datarootdir = @datarootdir@
srcdir = @srcdir@
prefix = @prefix@
mandir = @mandir@
@ -24,8 +25,8 @@ distclean: clean
install:
$(MKDIR) $(DESTDIR)$(mandir)/man5
$(INSTALL) conserver.cf.man $(DESTDIR)$(mandir)/man5/conserver.cf.5
$(INSTALL) conserver.passwd.man $(DESTDIR)$(mandir)/man5/conserver.passwd.5
$(INSTALL) -m 0644 conserver.cf.man $(DESTDIR)$(mandir)/man5/conserver.cf.5
$(INSTALL) -m 0644 conserver.passwd.man $(DESTDIR)$(mandir)/man5/conserver.passwd.5
$(MKDIR) $(DESTDIR)$(exampledir)
$(INSTALL) -m 0644 conserver.cf $(DESTDIR)$(exampledir)
$(INSTALL) -m 0644 conserver.passwd $(DESTDIR)$(exampledir)

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
.\" $Id: conserver.passwd.man,v 1.10 2004/01/08 16:12:33 bryan Exp $
.TH CONSERVER.PASSWD 5 "2004/01/08" "conserver-8.1.4" "conserver"
.TH CONSERVER.PASSWD 5 "2004/01/08" "conserver-8.1.20" "conserver"
.SH NAME
conserver.passwd \- user access information for
.BR conserver (8)

View File

@ -1,273 +1,280 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META name="generator" content=
"HTML Tidy for Solaris (vers 1st May 2002), see www.w3.org">
<META name="keywords" content=
"conserver,serial,console,serial console,unix,tty,ttya,ttyb, rs-232,rs232,bryan stansell,stansell,console server,terminal server,headless">
<META name="author" content=
"Bryan Stansell &lt;bryan@conserver.com&gt;">
<LINK rel="SHORTCUT ICON" href="conserver.ico">
<LINK rel="icon" href="conserver.ico">
<HEAD>
<META name="generator" content=
"HTML Tidy for Solaris (vers 25 March 2009), see www.w3.org">
<META name="keywords" content=
"conserver,serial,console,serial console,unix,tty,ttya,ttyb, rs-232,rs232,bryan stansell,stansell,console server,terminal server,headless">
<META name="author" content=
"Bryan Stansell &lt;bryan@conserver.com&gt;">
<LINK rel="SHORTCUT ICON" href="conserver.ico">
<LINK rel="icon" href="conserver.ico">
<TITLE>Conserver</TITLE>
<STYLE type="text/css">
body {
<TITLE>Conserver</TITLE>
<STYLE type="text/css">
body {
background-color: #EEEEEE;
color: black;
}
</STYLE>
</HEAD>
}
</STYLE>
</HEAD>
<BODY>
<TABLE summary="Logo" bgcolor="black" width="100%" align=
"center">
<TR>
<TD align="center"><IMG src="conserver.jpg" alt=
"Conserver"><BR>
</TD>
</TR>
</TABLE>
<BODY>
<TABLE summary="Logo" bgcolor="black" width="100%" align=
"center">
<TR>
<TD align="center"><IMG src="conserver.jpg" alt=
"Conserver"><BR></TD>
</TR>
</TABLE>
<TABLE summary="Conserver Page" width="80%" align="center">
<TR>
<TD colspan="2" align="center">Please pick your closest
mirror: &nbsp;&nbsp;<A href=
"http://planetmirror.com/pub/conserver/">Australia</A>
&nbsp;&nbsp;<A href="http://www.conserver.com/">US
(Primary)</A><BR>
<BR>
</TD>
</TR>
<TABLE summary="Conserver Page" width="80%" align="center">
<TR>
<TD colspan="2" align="center">Please pick your closest
mirror: &nbsp;&nbsp;<A href=
"http://planetmirror.com/pub/conserver/">Australia</A>
&nbsp;&nbsp;<A href=
"http://conserver.linux-mirror.org/">Germany</A>
&nbsp;&nbsp;<A href="http://conserver.rayba.co/">Germany</A>
&nbsp;&nbsp;<A href=
"http://conserver.cybermirror.org/">Germany</A>
&nbsp;&nbsp;<A href=
"http://conserver.oss-mirror.org/">Ireland</A>
&nbsp;&nbsp;<A href="http://conserver.shape.ws/">Malaysia</A>
&nbsp;&nbsp;<A href="http://conserver.rinet.ru/">Russia</A>
&nbsp;&nbsp;<A href="http://www.conserver.com/">US-West
(Primary)</A><BR>
<BR></TD>
</TR>
<TR>
<TD>
<!-- empty cell here, then search box on right spans two rows,
then we have the text that appears on the left, so things
appear in the right order so they look right in lynx
-->
</TD>
<TR>
<TD>
<!-- empty cell here, then search box on right spans two rows,
then we have the text that appears on the left, so things
appear in the right order so they look right in lynx
--></TD>
<TD rowspan="2" align="right">
<FORM method="post" action=
"http://www.conserver.com/cgi-bin/htsearch">
<INPUT type="HIDDEN" name="method" value="and"> <INPUT
type="HIDDEN" name="format" value="builtin-long">
<INPUT type="HIDDEN" name="sort" value="score"> <INPUT
type="HIDDEN" name="config" value="conserver.com">
<INPUT type="HIDDEN" name="restrict" value=""> <INPUT
type="HIDDEN" name="exclude" value=""> <INPUT type=
"TEXT" size="20" name="words" value=""> <INPUT type=
"SUBMIT" value="Search">
</FORM>
</TD>
</TR>
<TD rowspan="2" align="right">
<FORM method="get" action=
"http://www.conserver.com/cgi-bin/omega">
<INPUT type="hidden" name="DEFAULTOP" value="and">
<INPUT type="text" size="20" name="P" value="">
<INPUT type="submit" value="Search">
</FORM>
</TD>
</TR>
<TR>
<TD>
<H3>What is conserver?</H3>
</TD>
</TR>
<TR>
<TD>
<H3>What is conserver?</H3>
</TD>
</TR>
<TR>
<TD colspan="2">
<P>From an email I once sent...</P>
<TR>
<TD colspan="2">
<P>From an email I once sent...</P>
<P>Conserver is an application that allows multiple users
to watch a serial console at the same time. It can log
the data, allows users to take write-access of a console
(one at a time), and has a variety of bells and whistles
to accentuate that basic functionality. The idea is that
conserver will log all your serial traffic so you can go
back and review why something crashed, look at changes
(if done on the console), or tie the console logs into a
monitoring system (just watch the logfiles it creates).
With multi-user capabilities you can work on equipment
with others, mentor, train, etc. It also does all that
client-server stuff so that, assuming you have a network
connection, you can interact with any of the equipment
from home or wherever.</P>
<P>Conserver is an application that allows multiple users
to watch a serial console at the same time. It can log the
data, allows users to take write-access of a console (one
at a time), and has a variety of bells and whistles to
accentuate that basic functionality. The idea is that
conserver will log all your serial traffic so you can go
back and review why something crashed, look at changes (if
done on the console), or tie the console logs into a
monitoring system (just watch the logfiles it creates).
With multi-user capabilities you can work on equipment with
others, mentor, train, etc. It also does all that
client-server stuff so that, assuming you have a network
connection, you can interact with any of the equipment from
home or wherever.</P>
<H3>The FAQ</H3>
Here's the conserver <A href="FAQ">FAQ</A>. Got any
additions? Let me know.
<H3>The FAQ</H3>Here's the conserver <A href="FAQ">FAQ</A>.
Got any additions? Let me know.
<H3>Mailing Lists</H3>
<H3>Mailing Lists</H3>
<P>There are currently two mailing lists available. <A
href=
"mailto:announce@conserver.com">announce@conserver.com</A>
is an announcement-only mailing list for informing of new
versions, major developments, etc. <A href=
"mailto:users@conserver.com">users@conserver.com</A> is
for general Q&amp;A, discussions, ideas, etc. for
conserver users. You can sign up by sending a message to
<A href=
"mailto:announce-request@conserver.com">announce-request@conserver.com</A>
or <A href=
"mailto:users-request@conserver.com">users-request@conserver.com</A>
with a subject of "subscribe" or head over to the online
<A href="https://www.conserver.com/mailman/listinfo">web
pages</A>.</P>
<P>There are currently two mailing lists available.
<A href="mailto:announce@conserver.com">announce@conserver.com</A>
is an announcement-only mailing list for informing of new
versions, major developments, etc. <A href=
"mailto:users@conserver.com">users@conserver.com</A> is for
general Q&amp;A, discussions, ideas, etc. for conserver
users. You can sign up by sending a message to <A href=
"mailto:announce-request@conserver.com">announce-request@conserver.com</A>
or <A href=
"mailto:users-request@conserver.com">users-request@conserver.com</A>
with a subject of "subscribe" or head over to the online
<A href="https://www.conserver.com/mailman/listinfo">web
pages</A>.</P>
<H3>Origin</H3>
<H3>Origin</H3>
<P>The console server software found here is a heavily
modified version originally written by <A href=
"http://hea-www.harvard.edu/~fine/">Tom Fine</A> (<A
href=
"mailto:fine@head-cfa.harvard.edu">fine@head-cfa.harvard.edu</A>)
at <A href="http://www.ohio-state.edu/">Ohio State</A>
and then Kevin S Braunsdorf (<A href=
"mailto:ksb+conserver@sa.fedex.com">ksb+conserver@sa.fedex.com</A>)
at <A href="http://www.purdue.edu/">Purdue
University</A>. Patches from Robert Olson (<A href=
"mailto:olson@mcs.anl.gov">olson@mcs.anl.gov</A>) at <A
href="http://www.anl.gov/">Argonne National
Laboratory</A> were then applied to get network console
support.</P>
<P>The console server software found here is a heavily
modified version originally written by <A href=
"http://hea-www.harvard.edu/~fine/">Tom Fine</A> (<A href=
"mailto:fine@head-cfa.harvard.edu">fine@head-cfa.harvard.edu</A>)
at <A href="http://www.ohio-state.edu/">Ohio State</A> and
then Kevin S Braunsdorf (<A href=
"mailto:ksb+conserver@sa.fedex.com">ksb+conserver@sa.fedex.com</A>)
at <A href="http://www.purdue.edu/">Purdue University</A>.
Patches from Robert Olson (<A href=
"mailto:olson@mcs.anl.gov">olson@mcs.anl.gov</A>) at
<A href="http://www.anl.gov/">Argonne National
Laboratory</A> were then applied to get network console
support.</P>
<P>Arnold de Leon (<A href=
"mailto:arnold@corp.webtv.net">arnold@corp.webtv.net</A>)
then fixed various bugs and added enhancements while at
<A href="http://www.synopsys.com/">Synopsys</A>. I then
took the result, continued fixing things, and added
features we found useful.</P>
<P>Arnold de Leon (<A href=
"mailto:arnold@corp.webtv.net">arnold@corp.webtv.net</A>)
then fixed various bugs and added enhancements while at
<A href="http://www.synopsys.com/">Synopsys</A>. I then
took the result, continued fixing things, and added
features we found useful.</P>
<P><A href="http://www.gnac.com/">GNAC</A> (Global
Networking and Computing - currently <A href=
"http://www.certaintysolutions.com/">Certainty
Solutions</A>) has been supporting my coding efforts (in
too many ways to list) since 1996.</P>
<P><A href="http://www.gnac.com/">GNAC</A> (Global
Networking and Computing - currently <A href=
"http://www.certaintysolutions.com/">Certainty
Solutions</A>) has been supporting my coding efforts (in
too many ways to list) since 1996.</P>
<H3>The conserver.com Distribution</H3>
<H3>The conserver.com Distribution</H3>
<P>The result is a combination of many people's work.
This version is being released in hopes that it will help
others. There is no warranty or support implied by the
distribution of the software.</P>
<P>The result is a combination of many people's work. This
version is being released in hopes that it will help
others. There is no warranty or support implied by the
distribution of the software.</P>
<P>So, what the heck is up with all the different
conserver versions? Well, the original authors are
continuing to distribute their own threads of the
software so you have three main threads (as far as I
know). First, there's Tom Fine's thread at <A href=
"http://hea-www.harvard.edu/~fine/Tech/console-server.html">
http://hea-www.harvard.edu/~fine/Tech/console-server.html</A>.
He isn't actively developing it, however, according to
the website. Next, there's Kevin Braunsdorf's version at
<A href=
"ftp://ftp.physics.purdue.edu/pub/pundits/">ftp://ftp.physics.purdue.edu/pub/pundits/</A>.
It doesn't look like Kevin is working on his thread ony
more either. No new versions have been out since August
2000 (version 8.5), but maybe this info will be out of
date by the time you read this (I last checked Feb 10,
2004). Lastly, the conserver.com version is based on
Kevin's "5.21-Beta" distribution, but since
<B>HEAVILY</B> modified and enhanced (more details in the
"Origin" section above).</P>
<P>So, what the heck is up with all the different conserver
versions? Well, the original authors are continuing to
distribute their own threads of the software so you have
three main threads (as far as I know). First, there's Tom
Fine's thread at <A href=
"http://hea-www.harvard.edu/~fine/Tech/console-server.html">
http://hea-www.harvard.edu/~fine/Tech/console-server.html</A>.
He isn't actively developing it, however, according to the
website. Next, there's Kevin Braunsdorf's version at
<A href=
"http://www.npcguild.org/software/pundits/">http://www.npcguild.org/software/pundits/</A>.
It doesn't look like Kevin is working on his thread ony
more either. No new versions have been out since August
2000 (version 8.5), but maybe this info will be out of date
by the time you read this (I last checked Feb 10, 2004).
Lastly, the conserver.com version is based on Kevin's
"5.21-Beta" distribution, but since <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
definitely use the conserver.com distribution. Why? It's
actively maintained, has many more features than the
other versions (see <A href="CHANGES">CHANGES</A> for a
semi-scary history), and has an active user community.
Kevin's version does have UPS support (basic serial port
line toggling bits) which is missing in the conserver.com
version, but no one has asked me for it, so does anyone
actually need it?</P>
<P>If I were looking for a conserver package I would
definitely use the conserver.com distribution. Why? It's
actively maintained, has many more features than the other
versions (see <A href="CHANGES">CHANGES</A> for a
semi-scary history), and has an active user community.
Kevin's version does have UPS support (basic serial port
line toggling bits) which is missing in the conserver.com
version, but no one has asked me for it, so does anyone
actually need it?</P>
<H3>Downloading</H3>
<H3>Downloading</H3>
<P>The current version, released on Apr 13, 2004, is <A
href="8.1.4.tar.gz">8.1.4.tar.gz</A>. You can get it via
<A href=
"ftp://ftp.conserver.com/conserver/8.1.4.tar.gz">FTP</A>
or <A href="8.1.4.tar.gz">HTTP</A>. See the <A href=
"CHANGES">CHANGES</A> file for information on the latest
updates.</P>
<P>The current version, released on Apr 4, 2014, is
<A href="8.1.20.tar.gz">8.1.20.tar.gz</A>. See the <A href=
"CHANGES">CHANGES</A> file for information on the latest
updates.</P>
<P>As of version 6.1.7, the packaging and numbering
scheme has changed. I used to package conserver as
conserver-GNAC-v.vv. Since <A href=
"http://www.gnac.com/">GNAC</A> (now <A href=
"http://www.certaintysolutions.com/">Certainty
Solutions</A>) has changed its name I've decided to drop
the GNAC portion and use a three-digit version number
(conserver-v.v.v). Why change the version numbering? I
need to differentiate this thread of the code from the
original authors' and I couldn't come up with a good
replacement for the GNAC name - sad, but true.</P>
<P>For those worried about legal issues, the <A href=
"LICENSE">LICENSE</A> file should help show it's
distributed under a <A href=
"http://www.opensource.org/licenses/bsd-license.php">BSD
license.</A></P>
<H3>Installation</H3>
<P>As of version 6.1.7, the packaging and numbering scheme
has changed. I used to package conserver as
conserver-GNAC-v.vv. Since <A href=
"http://www.gnac.com/">GNAC</A> (now <A href=
"http://www.certaintysolutions.com/">Certainty
Solutions</A>) has changed its name I've decided to drop
the GNAC portion and use a three-digit version number
(conserver-v.v.v). Why change the version numbering? I need
to differentiate this thread of the code from the original
authors' and I couldn't come up with a good replacement for
the GNAC name - sad, but true.</P>
<P>Check the <A href="INSTALL">INSTALL</A> file for
instructions.</P>
<H3>Installation</H3>
<H3>Online Documentation</H3>
<P>Check the <A href="INSTALL">INSTALL</A> file for
instructions.</P>
<P>I've put a small set of documentation <A href=
"docs/">here</A>. I'm hoping to expand it over time.</P>
<H3>Online Documentation</H3>
<H3>Systems Tested</H3>
<P>I've put a small set of documentation <A href=
"docs/">here</A>. I'm hoping to expand it over time.</P>
<P>Here's a list of systems that I've been told can
successfully compile conserver. If anyone has more to add
to this list (or something on the list doesn't work any
more), please let me know.</P>
<H3>Systems Tested</H3>
<UL>
<LI>AIX 4.3.3/5.1/5.2, native cc</LI>
<P>Here's a list of systems that I've been told can
successfully compile conserver. If anyone has more to add
to this list (or something on the list doesn't work any
more), please let me know.</P>
<LI>BSDI BSD/OS 3.X, gcc</LI>
<UL>
<LI>AIX 4.3.3/5.1/5.2, native cc</LI>
<LI>Cygwin (w2k),gcc 2.95.3</LI>
<LI>BSDI BSD/OS 3.X, gcc</LI>
<LI>DEC Tru64 4.0, gcc</LI>
<LI>Cygwin (w2k),gcc 2.95.3</LI>
<LI>DEC Tru64 4.0/5.1, native cc</LI>
<LI>DEC Tru64 4.0, gcc</LI>
<LI>FreeBSD 4.2/4.8/5.1 (x86), gcc</LI>
<LI>DEC Tru64 4.0/5.1, native cc</LI>
<LI>HP-UX 10.20, gcc</LI>
<LI>FreeBSD 4.x (i386) gcc</LI>
<LI>HP-UX 11.10 parisc and ia64, native cc</LI>
<LI>FreeBSD 5.x (i386/amd64/sparc64) gcc</LI>
<LI>Irix 6.15, native cc</LI>
<LI>FreeBSD 6.x/7.x (i386/amd64/sparc64/ia64) gcc</LI>
<LI>Linux 2.2.18 (x86), gcc</LI>
<LI>HP-UX 10.20, gcc</LI>
<LI>Linux 2.4.2 (x86), gcc</LI>
<LI>HP-UX 11.10 parisc and ia64, native cc</LI>
<LI>Linux ia64, native gcc</LI>
<LI>Irix 6.15, native cc</LI>
<LI>Linux RedHat 6.2 and 7.2 (x86), native gcc</LI>
<LI>Linux 2.2.18 (x86), gcc</LI>
<LI>MacOS X, native gcc</LI>
<LI>Linux 2.4.2 (x86), gcc</LI>
<LI>Solaris 2.5.1 thru 9 (sparc/x86), gcc</LI>
<LI>Linux ia64, native gcc</LI>
<LI>Solaris 7/8, native cc</LI>
</UL>
<LI>Linux RedHat 6.2 and 7.2 (x86), native gcc</LI>
<H3>Other Good Information</H3>
<LI>MacOS X, native gcc</LI>
<P>Zonker Harris has fabulous documents regarding the
hookup of consoles to terminal servers and other such
devices. His <A href="consoles/">Greater Scroll of
Console Knowledge</A> is a great place to start.</P>
<HR noshade>
<LI>Solaris 2.5.1 thru 9 (sparc/x86), gcc</LI>
<ADDRESS>
Bryan Stansell (<A href=
"mailto:bryan@conserver.com">bryan@conserver.com</A>)<BR>
<LI>Solaris 7/8, native cc</LI>
</ADDRESS>
</TD>
</TR>
</TABLE>
</BODY>
<LI>Solaris 10 and Solaris Express (build 33) (x86), gcc
and native cc</LI>
</UL>
<H3>Other Good Information</H3>
<P>Zonker Harris has fabulous documents regarding the
hookup of consoles to terminal servers and other such
devices. His <A href="consoles/">Greater Scroll of Console
Knowledge</A> is a great place to start.</P>
<P>User community <A href="contrib/">contributions</A>
contain a variety of helpful items.</P>
<HR noshade>
<ADDRESS>
Bryan Stansell (<A href=
"mailto:bryan@conserver.com">bryan@conserver.com</A>)<BR>
</ADDRESS>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>

View File

@ -1,4 +1,5 @@
### Path settings
datarootdir = @datarootdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
prefix = @prefix@
@ -7,6 +8,8 @@ sbindir = @sbindir@
sysconfdir = @sysconfdir@
mandir = @mandir@
datadir = @datadir@
libdir = @libdir@
pkglibdir = $(libdir)/conserver
exampledir = $(datadir)/examples/conserver
### Installation programs and flags
@ -60,8 +63,10 @@ install: conserver
$(MKDIR) $(DESTDIR)$(sbindir)
$(INSTALL_PROGRAM) conserver $(DESTDIR)$(sbindir)
$(MKDIR) $(DESTDIR)$(mandir)/man8
$(INSTALL) conserver.man $(DESTDIR)$(mandir)/man8/conserver.8
$(INSTALL) -m 0644 conserver.man $(DESTDIR)$(mandir)/man8/conserver.8
$(MKDIR) $(DESTDIR)$(exampledir)
$(INSTALL) conserver.rc $(DESTDIR)$(exampledir)
$(MKDIR) $(DESTDIR)$(pkglibdir)
$(INSTALL) convert $(DESTDIR)$(pkglibdir)/convert
.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
*
@ -171,7 +171,8 @@ AccType(addr, peername)
hname = he->h_aliases[a++]) {
if ((revNames[a] = StrDup(hname)) == (char *)0)
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;
#endif
{
char *pcDomain;
char *addr;
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) {
char *addr;
addr = inet_ntoa(*pAddr);
if ((a = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0)
OutOfMem();
@ -298,21 +314,7 @@ SetDefAccess(pAddr, pHost)
pACList->pcwho));
pAddr++;
}
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));
#endif
}
void

View File

@ -1,5 +1,5 @@
/*
* $Id: client.c,v 5.83 2004/04/13 18:12:00 bryan Exp $
* $Id: client.c,v 5.96 2014/04/02 04:45:31 bryan Exp $
*
* Copyright conserver.com, 2000
*
@ -41,6 +41,7 @@
#include <access.h>
#include <client.h>
#include <group.h>
#include <readcfg.h>
#if defined(USE_LIBWRAP)
#include <syslog.h>
@ -60,207 +61,182 @@ FindWrite(pCE)
CONSENT *pCE;
#endif
{
CONSCLIENT *pCLfound = (CONSCLIENT *)0;
CONSCLIENT *pCL;
/* make the first guy to have the `want write' bit set the writer
* (tell him of the promotion, too) we could look for the
* most recent or some such... I guess it doesn't matter that
* much.
/* make the first guy (last on the list) to have the `want write' bit set
* the writer (tell him of the promotion, too) we could look for the most
* recent or some such... I guess it doesn't matter that much.
*/
if (pCE->pCLwr != (CONSCLIENT *)0 || pCE->fronly ||
!(pCE->fup && pCE->ioState == ISNORMAL &&
pCE->initfile == (CONSFILE *)0))
if (pCE->pCLwr != (CONSCLIENT *)0 || pCE->fronly)
return;
for (pCL = pCE->pCLon; (CONSCLIENT *)0 != pCL; pCL = pCL->pCLnext) {
if (!pCL->fwantwr || pCL->fro)
continue;
pCL->fwantwr = 0;
pCL->fwr = 1;
if (pCL->fwantwr && !pCL->fro)
pCLfound = pCL;
}
if (pCLfound != (CONSCLIENT *)0) {
pCLfound->fwantwr = 0;
pCLfound->fwr = 1;
if (pCE->nolog) {
FileWrite(pCL->fd, FLAGFALSE, "\r\n[attached (nologging)]\r\n",
-1);
FileWrite(pCLfound->fd, FLAGFALSE,
"\r\n[attached (nologging)]\r\n", -1);
} else {
FileWrite(pCL->fd, FLAGFALSE, "\r\n[attached]\r\n", -1);
FileWrite(pCLfound->fd, FLAGFALSE, "\r\n[attached]\r\n", -1);
}
TagLogfileAct(pCE, "%s attached", pCL->acid->string);
pCE->pCLwr = pCL;
return;
TagLogfileAct(pCE, "%s attached", pCLfound->acid->string);
pCE->pCLwr = pCLfound;
}
}
/* 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,
* we want to just output what is in the log file and get out,
* so we don't drop chars...
*/
#define REPLAYBUFFER 4096
void
#if PROTOTYPES
Replay(CONSENT *pCE, CONSFILE *fdOut, int iBack)
Replay(CONSENT *pCE, CONSFILE *fdOut, unsigned short back)
#else
Replay(pCE, fdOut, iBack)
Replay(pCE, fdOut, back)
CONSENT *pCE;
CONSFILE *fdOut;
int iBack;
unsigned short back;
#endif
{
CONSFILE *fdLog = (CONSFILE *)0;
STRING *line = (STRING *)0;
off_t file_pos;
off_t buf_pos;
char *buf;
char *buf = (char *)0;
char *bp = (char *)0;
char *s;
int r;
int ch;
struct stat stLog;
struct lines {
int is_mark;
STRING *line;
STRING *mark_end;
} *lines;
int n_lines;
int ln;
int i;
int j;
int u;
int is_mark;
char dummy[4];
int was_mark = 0;
#if HAVE_DMALLOC && DMALLOC_MARK_REPLAY
unsigned long dmallocMarkReplay = 0;
#endif
if (pCE != (CONSENT *)0) {
fdLog = pCE->fdlog;
/* 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 (pCE != (CONSENT *)0 && pCE->logfile != (char *)0)
fdLog = FileOpen(pCE->logfile, O_RDONLY, 0644);
if (fdLog == (CONSFILE *)0) {
FileWrite(fdOut, FLAGFALSE, "[no log file on this console]\r\n",
-1);
return;
}
/* find the size of the file
*/
if (0 != FileStat(fdLog, &stLog)) {
return;
}
#if HAVE_DMALLOC && DMALLOC_MARK_REPLAY
dmallocMarkReplay = dmalloc_mark();
#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;
/* get space for the line information and initialize it
*
* we allocate room for one more line than requested to be able to
* do the mark ranges
*/
if ((char *)0 == (buf = malloc(BUFSIZ))) {
if ((char *)0 == (buf = malloc(REPLAYBUFFER)))
OutOfMem();
}
n_lines = iBack + 1;
lines = (struct lines *)calloc(n_lines, sizeof(*lines));
if ((struct lines *)0 == lines) {
OutOfMem();
}
for (i = 0; i < n_lines; i++) {
lines[i].mark_end = AllocString();
lines[i].line = AllocString();
}
ln = -1;
bp = buf + 1; /* just give it something - it resets below */
line = AllocString();
/* loop as long as there is data in the file or we have not found
* the requested number of lines
*/
while (file_pos >= 0) {
ln = -1;
for (; file_pos >= 0; file_pos--, bp--) {
if (file_pos < buf_pos) {
int r;
/* read one buffer worth of data a buffer boundary
*
* the first read will probably not get a full buffer but
* 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) {
goto common_exit;
}
if ((r = FileRead(fdLog, buf, BUFSIZ)) < 0) {
if ((r = FileRead(fdLog, buf, REPLAYBUFFER)) < 0) {
goto common_exit;
}
bp = buf + r;
bp = buf + r - 1;
}
/* process the next character
*/
--file_pos;
if ((ch = *--bp) == '\n') {
if ((ch = *bp) == '\n') {
if (ln >= 0) {
int i;
int u;
int is_mark = 0;
/* 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++) {
int temp;
temp = lines[ln].line->string[i];
lines[ln].line->string[i]
= lines[ln].line->string[u - i - 1];
lines[ln].line->string[u - i - 1] = temp;
temp = line->string[i];
line->string[i] = line->string[u - i - 1];
line->string[u - i - 1] = temp;
}
/* see if this line is a MARK
*/
if (lines[ln].line->used > 0 &&
lines[ln].line->string[0] == '[') {
i = sscanf(lines[ln].line->string + 1,
if (line->used > 0 && line->string[0] == '[') {
char dummy[4];
int j;
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);
} else {
is_mark = 0;
}
/* 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
* 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--;
}
lines[ln].is_mark = is_mark;
was_mark = is_mark;
}
/* advance to the next line and break if we have enough
*/
ln++;
if (ln >= n_lines - 1) {
BuildString((char *)0, line);
if (ln >= back) {
break;
}
}
@ -271,90 +247,122 @@ Replay(pCE, fdOut, iBack)
if (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
* why? there must be some very long non-newline terminated
* strings and if we just keep going back, we could spew lots
* of data and chew up lots of memory
*/
if (lines[ln].line->used > MAXREPLAYLINELEN) {
if (line->used > MAXREPLAYLINELEN) {
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
*/
u = lines[ln].line->used - 1;
for (i = 0; i < u / 2; i++) {
int temp;
/* Now output the lines, starting from where we stopped */
if (FileSeek(fdLog, file_pos, SEEK_SET) >= 0) {
int eof = 0;
int i = 0;
int r = 0;
STRING *mark_beg = (STRING *)0;
STRING *mark_end = (STRING *)0;
temp = lines[ln].line->string[i];
lines[ln].line->string[i]
= lines[ln].line->string[u - i - 1];
lines[ln].line->string[u - i - 1] = temp;
mark_beg = AllocString();
mark_end = AllocString();
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++;
}
/* 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, -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);
DestroyString(mark_end);
DestroyString(mark_beg);
}
common_exit:
/* if we opened the logfile, close it */
if (fdLog != pCE->fdlog)
if (line != (STRING *)0)
DestroyString(line);
if (buf != (char *)0)
free(buf);
if (fdLog != (CONSFILE *)0)
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
CONDDEBUG((1, "Replay(): dmalloc / MarkReplay"));
dmalloc_log_changed(dmallocMarkReplay, 1, 0, 1);
@ -368,6 +376,7 @@ Replay(pCE, fdOut, iBack)
#define WHEN_ATTACH 0x02
#define WHEN_EXPERT 0x04 /* ZZZ no way to set his yet */
#define WHEN_ALWAYS 0x40
#define IS_LIMITED 0x100
#define HALFLINE 40
@ -378,7 +387,7 @@ typedef struct HLnode {
static HELP aHLTable[] = {
{WHEN_ALWAYS, ". disconnect"},
{WHEN_ALWAYS, "; move to another console"},
{WHEN_ALWAYS | IS_LIMITED, "; move to another console"},
{WHEN_ALWAYS, "a attach read/write"},
{WHEN_ALWAYS, "b send broadcast message"},
{WHEN_ATTACH, "c toggle flow control"},
@ -392,22 +401,24 @@ static HELP aHLTable[] = {
{WHEN_ATTACH, "l0 send break per config file"},
{WHEN_ATTACH, "l1-9 send specific break sequence"},
{WHEN_ALWAYS, "m display the message of the day"},
{WHEN_ALWAYS, "n write a note to the logfile"},
{WHEN_ALWAYS, "o (re)open the tty and log file"},
{WHEN_ALWAYS, "p replay the last 60 lines"},
{WHEN_ALWAYS, "r replay the last 20 lines"},
{WHEN_ATTACH, "s spy read only"},
{WHEN_ALWAYS, "p playback the last %hu lines"},
{WHEN_ALWAYS, "P set number of playback lines"},
{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, "v show version info"},
{WHEN_ALWAYS, "w who is on this console"},
{WHEN_ALWAYS, "x show console baud info"},
{WHEN_ALWAYS, "z suspend the connection"},
{WHEN_ATTACH, "| attach local command"},
{WHEN_ALWAYS | IS_LIMITED, "z suspend the connection"},
{WHEN_ATTACH, "! invoke task"},
{WHEN_ATTACH | IS_LIMITED, "| attach local command"},
{WHEN_ALWAYS, "? print this message"},
{WHEN_ALWAYS, "<cr> ignore/abort command"},
{WHEN_ALWAYS, "^R replay the last line"},
{WHEN_ATTACH, "\\ooo send character by octal code"},
{WHEN_EXPERT, "^I toggle tab expansion"},
{WHEN_EXPERT, "+(-) do (not) drop line"},
};
/* list the commands we know for the user (ksb)
@ -416,7 +427,7 @@ void
#if PROTOTYPES
HelpUser(CONSCLIENT *pCL)
#else
HelpUser(pCL)
HelpUser(pCL, pCE)
CONSCLIENT *pCL;
#endif
{
@ -439,15 +450,30 @@ HelpUser(pCL)
BuildString((char *)0, acLine);
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;
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 (strlen(aHLTable[i].actext) < HALFLINE) {
if (strlen(text) < HALFLINE) {
for (j = acLine->used; j <= HALFLINE; ++j) {
BuildStringChar(' ', acLine);
}
BuildString(aHLTable[i].actext, acLine);
BuildString(text, acLine);
BuildString(acEoln, acLine);
FileWrite(pCL->fd, FLAGTRUE, acLine->string,
acLine->used - 1);
@ -462,7 +488,7 @@ HelpUser(pCL)
}
if (acLine->used == 0) { /* at new line */
BuildStringChar(' ', acLine);
BuildString(aHLTable[i].actext, acLine);
BuildString(text, acLine);
if (acLine->used > HALFLINE) {
BuildString(acEoln, acLine);
FileWrite(pCL->fd, FLAGTRUE, acLine->string,
@ -514,6 +540,7 @@ ClientAccessOk(pCL)
# if defined(USE_LIBWRAP)
{
struct request_info request;
CONDDEBUG((1, "ClientAccessOk(): doing tcpwrappers check"));
request_init(&request, RQ_DAEMON, progname, RQ_FILE, cfd, 0);
fromhost(&request);
if (!hosts_access(&request)) {

View File

@ -1,5 +1,5 @@
/*
* $Id: client.h,v 5.36 2003/12/25 19:22:00 bryan Exp $
* $Id: client.h,v 5.44 2013/09/23 22:58:21 bryan Exp $
*
* Copyright conserver.com, 2000
*
@ -48,7 +48,12 @@ typedef enum clientState {
S_QUOTE, /* send any character we can spell */
S_BCAST, /* send a broadcast message to all clients */
S_CWAIT, /* wait for client */
S_CEXEC /* client execing a program */
S_CEXEC, /* client execing a program */
S_REPLAY, /* set replay length for 'r' */
S_PLAYBACK, /* set replay length for 'p' */
S_NOTE, /* send a note to the logfile */
S_TASK, /* invoke a task on the server side */
S_CONFIRM /* confirm input */
} CLIENTSTATE;
typedef struct client { /* Connection Information: */
@ -58,6 +63,7 @@ typedef struct client { /* Connection Information: */
short fwantwr; /* (client) wants to write */
short fro; /* read-only permission */
short fecho; /* echo commands (not set by machines) */
short fiwait; /* client wanting for console init */
STRING *acid; /* login and location of client */
STRING *peername; /* location of client */
STRING *username; /* login of client */
@ -74,17 +80,22 @@ typedef struct client { /* Connection Information: */
*pCLnext; /* next person on this list */
/* next lists link clients on a console */
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 */
char caccess; /* did we trust the remote machine */
IOSTATE ioState; /* state of the socket */
time_t stateTimer; /* timer for various ioState states */
STRING *accmd; /* the command the user issued */
STRING *msg; /* the broadcast message */
struct sockaddr_in
cnct_port; /* where from */
FLAG confirmed; /* confirm state */
CLIENTSTATE cState; /* state needing confirmation */
char cOption; /* option initiating the confirmation */
} CONSCLIENT;
extern void Replay PARAMS((CONSENT *, CONSFILE *, int));
extern void Replay PARAMS((CONSENT *, CONSFILE *, unsigned short));
extern void HelpUser PARAMS((CONSCLIENT *));
extern void FindWrite PARAMS((CONSENT *));
extern int ClientAccessOk PARAMS((CONSCLIENT *));
extern void BumpClient PARAMS((CONSENT *, char *));

View File

@ -1,5 +1,5 @@
/*
* $Id: consent.c,v 5.137 2004/02/20 14:58:13 bryan Exp $
* $Id: consent.c,v 5.154 2014/04/02 04:45:31 bryan Exp $
*
* Copyright conserver.com, 2000
*
@ -52,6 +52,42 @@
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)
{"115200", B115200},
#endif
@ -83,6 +119,7 @@ BAUD baud[] = {
#if defined(B300)
{"300", B300},
#endif
#endif /* FOR_CYCLADES_TS */
};
@ -276,6 +313,12 @@ StopInit(pCE)
if (pCE->initcmd == (char *)0)
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) {
kill(pCE->initpid, SIGHUP);
CONDDEBUG((1, "StopInit(): sending initcmd pid %lu signal %d",
@ -296,6 +339,54 @@ StopInit(pCE)
}
}
#if HAVE_FREEIPMI
ipmiconsole_ctx_t
#if PROTOTYPES
IpmiSOLCreate(CONSENT *pCE)
#else
IpmiSOLCreate(pCE)
CONSENT *pCE;
#endif
{
ipmiconsole_ctx_t ctx;
struct ipmiconsole_ipmi_config ipmi;
struct ipmiconsole_protocol_config protocol;
struct ipmiconsole_engine_config engine;
if (ipmiconsole_engine_init(1, 0) < 0)
return 0;
ipmi.username = pCE->username;
ipmi.password = pCE->password;
if (pCE->ipmikg->used <= 1) { /* 1 == NULL only */
ipmi.k_g = NULL;
ipmi.k_g_len = 0;
} else {
ipmi.k_g = (unsigned char *)pCE->ipmikg->string;
ipmi.k_g_len = pCE->ipmikg->used - 1;
}
ipmi.privilege_level = pCE->ipmiprivlevel;
ipmi.cipher_suite_id = pCE->ipmiciphersuite;
ipmi.workaround_flags = pCE->ipmiworkaround;
protocol.session_timeout_len = -1;
protocol.retransmission_timeout_len = -1;
protocol.retransmission_backoff_count = -1;
protocol.keepalive_timeout_len = -1;
protocol.retransmission_keepalive_timeout_len = -1;
protocol.acceptable_packet_errors_count = -1;
protocol.maximum_retransmission_count = -1;
engine.engine_flags = IPMICONSOLE_ENGINE_OUTPUT_ON_SOL_ESTABLISHED;
engine.behavior_flags = 0;
engine.debug_flags = 0;
ctx = ipmiconsole_ctx_create(pCE->host, &ipmi, &protocol, &engine);
return ctx;
}
#endif
/* invoke the initcmd command */
void
#if PROTOTYPES
@ -324,20 +415,6 @@ StartInit(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 */
if (pipe(pin) != 0) {
Error("[%s] StartInit(): pipe(): %s", pCE->server,
@ -430,11 +507,18 @@ StartInit(pCE)
if (dup(pout[0]) != 0 || dup(pin[1]) != 1) {
Error("[%s] StartInit(): fd sync error", pCE->server);
Bye(EX_OSERR);
exit(EX_OSERR);
}
close(pout[0]);
close(pin[1]);
if (geteuid() == 0) {
if (pCE->initgid != 0)
setgid(pCE->initgid);
if (pCE->inituid != 0)
setuid(pCE->inituid);
}
tcsetpgrp(0, iNewGrp);
apcArgv[2] = pCE->initcmd;
@ -444,10 +528,62 @@ StartInit(pCE)
execve(apcArgv[0], apcArgv, environ);
Error("[%s] execve(%s): %s", pCE->server, apcArgv[2], strerror(errno));
Bye(EX_OSERR);
exit(EX_OSERR);
return;
}
/* We exit() here, so only call this in a child process before an exec() */
void
#if PROTOTYPES
SetupTty(CONSENT *pCE, int fd)
#else
SetupTty(pCE, fd)
CONSENT *pCE;
int fd;
#endif
{
struct termios n_tio;
# if HAVE_STROPTS_H && !defined(_AIX)
/* SYSVr4 semantics for opening stream ptys (gregf)
* under PTX (others?) we have to push the compatibility
* streams modules `ptem', `ld', and `ttcompat'
*/
ioctl(1, I_PUSH, "ptem");
ioctl(1, I_PUSH, "ldterm");
ioctl(1, I_PUSH, "ttcompat");
# endif
if (0 != tcgetattr(1, &n_tio)) {
exit(EX_OSERR);
}
n_tio.c_iflag &= ~(IGNCR | IUCLC);
n_tio.c_iflag |= ICRNL;
if (pCE->ixon == FLAGTRUE)
n_tio.c_iflag |= IXON;
if (pCE->ixany == FLAGTRUE)
n_tio.c_iflag |= IXANY;
if (pCE->ixoff == FLAGTRUE)
n_tio.c_iflag |= IXOFF;
n_tio.c_oflag &=
~(OLCUC | ONOCR | ONLRET | OFILL | NLDLY | CRDLY | TABDLY | BSDLY);
n_tio.c_oflag |= OPOST | ONLCR;
n_tio.c_lflag &= ~(XCASE | NOFLSH | ECHOK | ECHONL);
n_tio.c_lflag |= ISIG | ICANON | ECHO;
n_tio.c_cc[VEOF] = '\004';
n_tio.c_cc[VEOL] = '\000';
n_tio.c_cc[VERASE] = '\010';
n_tio.c_cc[VINTR] = '\003';
n_tio.c_cc[VKILL] = '@';
/* MIN */
n_tio.c_cc[VQUIT] = '\034';
n_tio.c_cc[VSTART] = '\021';
n_tio.c_cc[VSTOP] = '\023';
n_tio.c_cc[VSUSP] = '\032';
if (0 != tcsetattr(1, TCSANOW, &n_tio))
exit(EX_OSERR);
}
/* setup a virtual device (ksb)
*/
static int
@ -458,7 +594,6 @@ VirtDev(pCE)
CONSENT *pCE;
#endif
{
static struct termios n_tio;
int i;
pid_t iNewGrp;
extern char **environ;
@ -522,55 +657,20 @@ VirtDev(pCE)
if (dup(pCE->execSlaveFD) != 0 || dup(pCE->execSlaveFD) != 1) {
Error("[%s] fd sync error", pCE->server);
Bye(EX_OSERR);
exit(EX_OSERR);
}
# if HAVE_STROPTS_H && !defined(_AIX)
/* SYSVr4 semantics for opening stream ptys (gregf)
* under PTX (others?) we have to push the compatibility
* streams modules `ptem', `ld', and `ttcompat'
*/
CONDDEBUG((1, "VirtDev(): pushing ptemp onto pseudo-terminal"));
ioctl(0, I_PUSH, "ptem");
CONDDEBUG((1, "VirtDev(): pushing ldterm onto pseudo-terminal"));
ioctl(0, I_PUSH, "ldterm");
CONDDEBUG((1, "VirtDev(): pushing ttcompat onto pseudo-terminal"));
ioctl(0, I_PUSH, "ttcompat");
CONDDEBUG((1, "VirtDev(): done pushing modules onto pseudo-terminal"));
# endif
if (0 != tcgetattr(0, &n_tio)) {
Error("[%s] tcgetattr(0): %s", pCE->server, strerror(errno));
Bye(EX_OSERR);
}
n_tio.c_iflag &= ~(IGNCR | IUCLC);
n_tio.c_iflag |= ICRNL;
if (pCE->ixon == FLAGTRUE)
n_tio.c_iflag |= IXON;
if (pCE->ixany == FLAGTRUE)
n_tio.c_iflag |= IXANY;
if (pCE->ixoff == FLAGTRUE)
n_tio.c_iflag |= IXOFF;
n_tio.c_oflag &=
~(OLCUC | ONOCR | ONLRET | OFILL | NLDLY | CRDLY | TABDLY | BSDLY);
n_tio.c_oflag |= OPOST | ONLCR;
n_tio.c_lflag &= ~(XCASE | NOFLSH | ECHOK | ECHONL);
n_tio.c_lflag |= ISIG | ICANON | ECHO;
n_tio.c_cc[VEOF] = '\004';
n_tio.c_cc[VEOL] = '\000';
n_tio.c_cc[VERASE] = '\010';
n_tio.c_cc[VINTR] = '\003';
n_tio.c_cc[VKILL] = '@';
/* MIN */
n_tio.c_cc[VQUIT] = '\034';
n_tio.c_cc[VSTART] = '\021';
n_tio.c_cc[VSTOP] = '\023';
n_tio.c_cc[VSUSP] = '\032';
if (0 != tcsetattr(0, TCSANOW, &n_tio)) {
Error("[%s] tcsetattr(0,TCSANOW): %s", pCE->server,
strerror(errno));
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);
}
}
SetupTty(pCE, 0);
tcsetpgrp(0, iNewGrp);
/* if the command is null we should run root's shell, directly
@ -602,10 +702,43 @@ VirtDev(pCE)
execve(pcShell, ppcArgv, environ);
Error("[%s] execve(): %s", pCE->server, strerror(errno));
Bye(EX_OSERR);
exit(EX_OSERR);
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)
*
* this should be kept pretty simple, 'cause the config file reading code
@ -643,6 +776,14 @@ ConsDown(pCE, downHard, force)
FD_CLR(cofile, &winit);
FileClose(&pCE->cofile);
}
#if HAVE_FREEIPMI
/* need to do this after cofile close above as
* ipmiconsole_ctx_destroy will close the fd */
if (pCE->ipmictx != (ipmiconsole_ctx_t) 0) {
ipmiconsole_ctx_destroy(pCE->ipmictx);
pCE->ipmictx = (ipmiconsole_ctx_t) 0;
}
#endif
if (pCE->fdlog != (CONSFILE *)0) {
if (pCE->nolog) {
TagLogfile(pCE, "Console logging restored");
@ -660,6 +801,9 @@ ConsDown(pCE, downHard, force)
pCE->autoReUp = 0;
pCE->downHard = downHard;
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)
@ -678,6 +822,40 @@ ConsInit(pCE)
extern int FallBack PARAMS((char **, int *));
int cofile = -1;
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
*/
@ -710,6 +888,10 @@ ConsInit(pCE)
switch (pCE->type) {
case UNKNOWNTYPE: /* shut up gcc */
break;
case NOOP:
pCE->fup = 1;
pCE->ioState = ISNORMAL;
break;
case EXEC:
if ((cofile =
FallBack(&pCE->execSlave, &pCE->execSlaveFD)) == -1) {
@ -734,7 +916,9 @@ ConsInit(pCE)
{
struct sockaddr_in port;
struct hostent *hp;
size_t one = 1;
#if HAVE_SETSOCKOPT
int one = 1;
#endif
usleep(100000); /* Not all terminal servers can keep up */
@ -767,6 +951,7 @@ ConsInit(pCE)
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return;
}
#if HAVE_SETSOCKOPT
if (setsockopt
(cofile, SOL_SOCKET, SO_KEEPALIVE, (char *)&one,
sizeof(one)) < 0) {
@ -774,11 +959,14 @@ ConsInit(pCE)
("[%s] setsockopt(%u,SO_KEEPALIVE): %s: forcing down",
pCE->server, cofile, strerror(errno));
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
close(cofile);
return;
}
#endif
if (!SetFlags(cofile, O_NONBLOCK, 0)) {
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
close(cofile);
return;
}
@ -790,6 +978,7 @@ ConsInit(pCE)
Error("[%s] connect(%u): %s: forcing down",
pCE->server, cofile, strerror(errno));
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
close(cofile);
return;
}
}
@ -800,24 +989,95 @@ ConsInit(pCE)
("[%s] FileOpenFD(%d,simpleSocket) failed: forcing down",
pCE->server, cofile);
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
close(cofile);
return;
}
if (ret == 0) {
pCE->ioState = ISNORMAL;
pCE->stateTimer = 0;
pCE->fup = 1;
} 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;
}
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);
close(cofile);
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);
close(cofile);
return;
}
}
}
if ((pCE->cofile =
FileOpenFD(cofile, simpleSocket)) == (CONSFILE *)0) {
Error
("[%s] FileOpenFD(%d,simpleSocket) failed: forcing down",
pCE->server, cofile);
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
close(cofile);
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;
case DEVICE:
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,
pCE->device, strerror(errno));
@ -835,6 +1095,56 @@ ConsInit(pCE)
TtyDev(pCE);
pCE->ioState = ISNORMAL;
break;
#if HAVE_FREEIPMI
case IPMI:
if (!(pCE->ipmictx = IpmiSOLCreate(pCE))) {
Error("[%s] Could not create IPMI context: forcing down",
pCE->server);
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return;
}
if (ipmiconsole_engine_submit(pCE->ipmictx, NULL, NULL) < 0) {
Error
("[%s] Could not connect to IPMI host `%s': forcing down",
pCE->server, pCE->host);
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return;
}
cofile = ipmiconsole_ctx_fd(pCE->ipmictx);
if (!SetFlags(cofile, O_NONBLOCK, 0)) {
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return;
}
if ((pCE->cofile =
FileOpenFD(cofile, simpleFile)) == (CONSFILE *)0) {
Error("[%s] FileOpenFD(simpleFile) failed: forcing down",
pCE->server);
ConsDown(pCE, FLAGTRUE, FLAGTRUE);
return;
}
if (ipmiconsole_ctx_status(pCE->ipmictx) ==
IPMICONSOLE_CTX_STATUS_SOL_ESTABLISHED) {
/* Read in the NULL from OUTPUT_ON_SOL_ESTABLISHED flag */
char b[1];
FileRead(pCE->cofile, b, 1); /* trust it's NULL */
pCE->ioState = ISNORMAL;
pCE->stateTimer = 0;
} else {
/* Error status cases will be handled in Kiddie() */
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;
#endif
}
if (!pCE->fup) {
@ -853,21 +1163,39 @@ ConsInit(pCE)
Verbose("[%s] port %hu on %s", pCE->server, pCE->netport,
pCE->host);
break;
#if HAVE_FREEIPMI
case IPMI:
Verbose("[%s] on %s", pCE->server);
break;
#endif
case NOOP:
Verbose("[%s] noop", pCE->server);
break;
case UDS:
Verbose("[%s] uds %s", pCE->server, pCE->uds);
break;
case DEVICE:
Verbose("[%s] at %s%c on %s", pCE->server, pCE->baud->acrate,
pCE->parity->key[0], pCE->device);
break;
}
/* 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);
else
FD_SET(cofile, &rinit);
if (maxfd < cofile + 1)
maxfd = cofile + 1;
if (cofile != -1) {
/* if we're waiting for connect() to finish, watch the
* write bit, otherwise watch for the read bit
*/
if (pCE->ioState == INCONNECT
#if HAVE_FREEIPMI
/* We wait for read() with the libipmiconsole */
&& pCE->type != IPMI
#endif
)
FD_SET(cofile, &winit);
else
FD_SET(cofile, &rinit);
if (maxfd < cofile + 1)
maxfd = cofile + 1;
}
tyme = time((time_t *)0);
@ -891,12 +1219,19 @@ ConsInit(pCE)
}
if (pCE->downHard == FLAGTRUE) {
if (pCE->ioState == ISNORMAL)
if (pCE->ioState == ISNORMAL) {
Msg("[%s] console up", pCE->server);
else
pCE->downHard = FLAGFALSE;
} else
Msg("[%s] console initializing", pCE->server);
pCE->downHard = FLAGFALSE;
}
#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)
StartInit(pCE);

View File

@ -1,5 +1,5 @@
/*
* $Id: consent.h,v 5.56 2004/02/20 14:58:14 bryan Exp $
* $Id: consent.h,v 5.74 2014/04/04 16:17:10 bryan Exp $
*
* Copyright conserver.com, 2000
*
@ -55,9 +55,21 @@ typedef enum consType {
UNKNOWNTYPE = 0,
DEVICE,
EXEC,
HOST
HOST,
NOOP,
UDS,
#if HAVE_FREEIPMI
IPMI,
#endif
} CONSTYPE;
#if HAVE_FREEIPMI
#define IPMIL_UNKNOWN (0)
#define IPMIL_USER (IPMICONSOLE_PRIVILEGE_USER+1)
#define IPMIL_OPERATOR (IPMICONSOLE_PRIVILEGE_OPERATOR+1)
#define IPMIL_ADMIN (IPMICONSOLE_PRIVILEGE_ADMIN+1)
#endif
typedef struct names {
char *name;
struct names *next;
@ -89,6 +101,17 @@ typedef struct consent { /* console information */
FLAG ixoff; /* XON/XOFF flow control on input */
#if defined(CRTSCTS)
FLAG crtscts; /* use hardware flow control */
#endif
#if HAVE_FREEIPMI
/* type == IPMI */
int ipmiprivlevel; /* IPMI authentication level */
ipmiconsole_ctx_t ipmictx; /* IPMI ctx */
unsigned int ipmiworkaround; /* IPMI workaround flags */
short ipmiwrkset; /* workaround flags set in config */
int ipmiciphersuite; /* IPMI cipher suite */
char *username; /* Username to log as */
char *password; /* Login Password */
STRING *ipmikg; /* IPMI k_g auth key */
#endif
/* type == HOST */
char *host; /* hostname */
@ -96,10 +119,15 @@ typedef struct consent { /* console information */
unsigned short port; /* port number | portinc * port */
unsigned short portbase; /* port base */
unsigned short portinc; /* port increment */
unsigned short raw; /* raw or telnet protocol? */
FLAG raw; /* raw or telnet protocol? */
/* type == EXEC */
char *exec; /* exec command */
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 */
char *master; /* master hostname */
unsigned short breakNum; /* break type [1-9] */
@ -107,20 +135,29 @@ typedef struct consent { /* console information */
off_t logfilemax; /* size limit for rolling logfile */
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 */
time_t idletimeout; /* idle timeout */
char *idlestring; /* string to print when idle */
unsigned short spinmax; /* initialization spin maximum */
unsigned short spintimer; /* initialization spin timer */
char *replstring; /* generic string for replacements */
char *tasklist; /* list of valid tasks */
char *breaklist; /* list of valid break sequences */
/* timestamp stuff */
int mark; /* Mark (chime) interval */
long nextMark; /* Next mark (chime) time */
FLAG activitylog; /* log attach/detach/bump */
FLAG breaklog; /* log breaks sent */
FLAG tasklog; /* log tasks invoked */
/* options */
FLAG ondemand; /* bring up on-demand */
FLAG reinitoncc; /* open if down on client connect */
FLAG striphigh; /* strip high-bit of console data */
FLAG autoreinit; /* auto-reinitialize if failed */
FLAG unloved; /* copy "unloved" data to stdout */
FLAG login; /* allow logins to the console */
/*** runtime settings ***/
CONSFILE *fdlog; /* the local log file */
@ -130,16 +167,26 @@ typedef struct consent { /* console information */
pid_t ipid; /* pid of virtual command */
pid_t initpid; /* pid of initcmd command */
CONSFILE *initfile; /* the command run on init */
pid_t taskpid; /* pid of task running */
CONSFILE *taskfile; /* the output from the task (read-only) */
STRING *wbuf; /* write() buffer */
int wbufIAC; /* next IAC location in wbuf */
IOSTATE ioState; /* state of the socket */
time_t stateTimer; /* timer for ioState states */
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 ***/
char acline[132 * 2 + 2]; /* max chars we will call a line */
int iend; /* length of data stored in acline */
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? */
FLAG downHard; /* did it go down unexpectedly? */
unsigned short nolog; /* don't log output */
@ -170,3 +217,5 @@ extern REMOTE *FindUniq PARAMS((REMOTE *));
extern void DestroyRemoteConsole PARAMS((REMOTE *));
extern void StartInit PARAMS((CONSENT *));
extern void StopInit PARAMS((CONSENT *));
extern char *ConsState PARAMS((CONSENT *));
extern void SetupTty PARAMS((CONSENT *, int));

View File

@ -1,6 +1,6 @@
.\" @(#)conserver.8 01/06/91 OSU CIS; Thomas A. Fine
.\" $Id: conserver.man,v 1.46 2004/04/13 18:19:26 bryan Exp $
.TH CONSERVER 8 "2004/04/13" "conserver-8.1.4" "conserver"
.\" $Id: conserver.man,v 1.54 2006/12/31 02:02:48 bryan Exp $
.TH CONSERVER 8 "2006/12/31" "conserver-8.1.20" "conserver"
.SH NAME
conserver \- console server daemon
.SH SYNOPSIS
@ -33,20 +33,32 @@ conserver \- console server daemon
is the daemon that manages
remote access to system consoles by multiple users via the
.BR console (1)
client program and logs all console output.
It can connect to consoles via local serial ports, terminal
servers that allow network access, or to any external program.
client program and (optionally) log the console output.
It can connect to consoles via local serial ports, Unix domain sockets, TCP
sockets (for terminal servers and the like), or any external program.
.PP
When started,
.B conserver
reads its
reads the
.BR conserver.cf (5)
file for details of each console it should manage,
including serial port or network parameters and logging options.
(Also, in environments where multiple servers share a cf file,
any server is able to refer clients to the particular server
managing a requested console, so that the client need not have
knowledge of the distribution of consoles among servers.)
file for details of each console.
The console type, logging options, serial or network parameters, and user access
levels are just a few of the things that can be specified.
Command-line options are then applied, possibly overriding
.BR conserver.cf (5)
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
forks a child for each group of consoles it must manage
and assigns each process a port number to listen on.
@ -89,10 +101,10 @@ 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 it's best to remove all the sockets when it shuts down,
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's would then be up to the admin (or a creative startup script) to clean
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
@ -297,8 +309,9 @@ However, if
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
.IR master
directory, ``/tmp/conserver'',
.I master
directory
.RB (`` /tmp/conserver '')
may be changed at compile time using the
.B --with-uds
option.
@ -317,6 +330,9 @@ Enable periodic attempts (every
.I min
minutes) to open (``bring up'') all downed
consoles (similar to sending a SIGUSR1).
Without this option, or if
.I min
is zero, no periodic attempts occur.
.TP
.BI \-p port
Set the TCP port for the master process to listen on.
@ -376,13 +392,16 @@ The console aliases in a comma-separated list.
.I type
The type of console.
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
.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
.B \-u
@ -423,7 +442,7 @@ The second style is the character-based, escape-sequence mode, while
connected to a console.
.PP
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.
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).
@ -431,7 +450,7 @@ The commands available are ``help'', ``ssl'' (if
SSL was built into the code), ``login'', and ``exit''.
Using the ``login'' command, the client authenticates and gains access to
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
child provides commands for interacting with the consoles it manages.
The ``help'' command, in both cases, will provide a complete
@ -447,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
interaction.
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
.PP
The following default file locations may be overridden
at compile time or by the command-line options described above.
Run
.B conserver \-V
(with no other options) to see the defaults set at compile time.
to see the defaults set at compile time.
.PP
.PD 0
.TP 25

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.13 2014/04/02 04:45:32 bryan Exp $
*
* Copyright conserver.com, 2000
*
@ -41,6 +41,16 @@
#include <master.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
DestroyDataStructures()
@ -60,7 +70,7 @@ ReadLine2(fp, save, iLine)
static char buf[1024];
char *wholeline = (char *)0;
char *ret = (char *)0;
int i, buflen, peek, commentCheck = 1, comment = 0;
int i, buflen, peek, commentCheck = 1;
static STRING *bufstr = (STRING *)0;
static STRING *wholestr = (STRING *)0;
@ -76,7 +86,7 @@ ReadLine2(fp, save, iLine)
|| peek) {
/* If we have a previously saved line, use it instead */
if (save->used) {
strcpy(buf, save->string);
StrCpy(buf, save->string, sizeof(buf));
BuildString((char *)0, save);
}
@ -102,7 +112,6 @@ ReadLine2(fp, save, iLine)
if (!isspace((int)buf[i]))
break;
if (buf[i] == '#') {
comment = 1;
commentCheck = 0;
} else if (buf[i] != '\000') {
commentCheck = 0;
@ -113,14 +122,11 @@ ReadLine2(fp, save, iLine)
buflen = strlen(buf);
if ((buflen >= 1) && (buf[buflen - 1] == '\n')) {
(*iLine)++; /* Finally have a whole line */
/* if (comment == 0 && commentCheck == 0) { */
/* Finish off the chunk without the \n */
buf[buflen - 1] = '\000';
BuildString(buf, bufstr);
wholeline = BuildString(bufstr->string, wholestr);
/* }*/
peek = 1;
comment = 0;
commentCheck = 1;
BuildString((char *)0, bufstr);
} else {
@ -132,14 +138,10 @@ ReadLine2(fp, save, iLine)
/* If we hit the EOF and weren't peeking ahead
* and it's not a comment
*/
/*
if (!peek && (ret == (char *)0) && (comment == 0) &&
(commentCheck == 0)) {
*/
if (!peek && (ret == (char *)0)) {
(*iLine)++;
wholeline = BuildString(bufstr->string, wholestr);
if (wholeline[0] == '\000')
if (wholeline != (char *)0 && wholeline[0] == '\000')
wholeline = (char *)0;
}
@ -422,7 +424,6 @@ ReadCfg(pcFile, fp)
(unsigned char *)ReadLine2(fp, acInSave,
&iLine)) != (unsigned char *)0) {
char *pcNext;
char cType;
acStart = PruneSpace((char *)acIn);
if (acStart[0] == '#') {
@ -468,7 +469,6 @@ ReadCfg(pcFile, fp)
printf("\ttrusted %s;\n", pcNext);
break;
default:
cType = ' ';
Error("%s(%d) unknown access key `%s'", pcFile, iLine,
acStart);
break;

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* $Id: cutil.h,v 1.61 2004/03/10 02:55:45 bryan Exp $
* $Id: cutil.h,v 1.69 2009/09/26 09:23:04 bryan Exp $
*
* Copyright conserver.com, 2000
*
@ -15,6 +15,9 @@
#include <openssl/ssl.h>
#include <openssl/err.h>
#endif
#if HAVE_GSSAPI
#include <gssapi/gssapi.h>
#endif
/* communication constants
*/
@ -45,6 +48,9 @@ typedef enum IOState {
#if HAVE_OPENSSL
INSSLACCEPT,
INSSLSHUTDOWN,
#endif
#if HAVE_GSSAPI
INGSSACCEPT,
#endif
ISFLUSHING
} IOSTATE;
@ -70,6 +76,7 @@ typedef struct consFile {
int fd;
int fdout; /* only used when a simplePipe */
STRING *wbuf;
FLAG errored;
FLAG quoteiac;
FLAG sawiac;
FLAG sawiacsusp;
@ -89,6 +96,39 @@ typedef struct consFile {
#endif
} 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 char *progname;
extern pid_t thepid;
@ -100,6 +140,10 @@ extern fd_set winit;
extern int maxfd;
extern int debugLineNo;
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 void Debug PARAMS((int, char *, ...));
@ -153,10 +197,17 @@ extern int FileCanRead PARAMS((CONSFILE *, fd_set *, fd_set *));
extern int FileCanWrite PARAMS((CONSFILE *, fd_set *, fd_set *));
extern int FileBufEmpty PARAMS((CONSFILE *));
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
extern SSL *FileGetSSL PARAMS((CONSFILE *));
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
*
@ -210,7 +210,7 @@ GetPseudoTTY(slave, slaveFD)
continue;
}
if (0 > (fd = open(acMaster, O_RDWR | O_NDELAY, 0))) {
if (0 > (fd = open(acMaster, O_RDWR | O_NONBLOCK, 0))) {
continue;
}
acSlave[iIndex] = *pcOne;

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/*
* $Id: group.h,v 5.43 2003/12/20 06:11:53 bryan Exp $
* $Id: group.h,v 5.51 2013/09/23 23:17:42 bryan Exp $
*
* Copyright conserver.com, 2000
*
@ -41,7 +41,8 @@
#define T_REINIT 3
#define T_AUTOUP 4
#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()
*/
@ -63,8 +64,8 @@ typedef struct grpent { /* group info */
extern time_t timers[];
extern void Spawn PARAMS((GRPENT *));
extern int CheckPass PARAMS((char *, char *));
extern void Spawn PARAMS((GRPENT *, int));
extern int CheckPass PARAMS((char *, char *, FLAG));
extern void TagLogfile PARAMS((const CONSENT *, char *, ...));
extern void TagLogfileAct PARAMS((const CONSENT *, char *, ...));
extern void DestroyGroup PARAMS((GRPENT *));
@ -78,8 +79,10 @@ extern void DisconnectClient
PARAMS((GRPENT *, CONSCLIENT *, char *, FLAG));
extern int ClientAccess PARAMS((CONSENT *, char *));
extern void DestroyClient PARAMS((CONSCLIENT *));
extern int CheckPasswd PARAMS((CONSCLIENT *, char *));
extern void ExpandString PARAMS((char *, CONSENT *, short));
extern int CheckPasswd PARAMS((CONSCLIENT *, char *, FLAG));
extern void DeUtmp PARAMS((GRPENT *, int));
extern void ClientWantsWrite PARAMS((CONSCLIENT *));
extern void SendIWaitClientsMsg PARAMS((CONSENT *, char *));
#if HAVE_OPENSSL
extern int AttemptSSL PARAMS((CONSCLIENT *));
#endif

View File

@ -1,5 +1,5 @@
/*
* $Id: main.c,v 5.179 2004/04/13 18:12:00 bryan Exp $
* $Id: main.c,v 5.210 2014/04/04 16:17:10 bryan Exp $
*
* Copyright conserver.com, 2000
*
@ -40,23 +40,21 @@
#include <readcfg.h>
#include <version.h>
#include <net/if.h>
#include <dirent.h>
#if HAVE_SYS_SOCKIO_H
# include <sys/sockio.h>
#endif
#if HAVE_OPENSSL
# include <openssl/opensslv.h>
#endif
#if HAVE_GSSAPI
# include <gssapi/gssapi.h>
#endif
int fAll = 0, fNoinit = 0, fVersion = 0, fStrip = 0, fReopen =
0, fNoautoreup = 0, fSyntaxOnly = 0;
char *pcConfig = CONFIGFILE;
int isMaster = 1;
int cMaxMemb = MAXMEMB;
in_addr_t bindAddr;
in_addr_t bindAddr = INADDR_ANY;
unsigned short bindPort;
unsigned short bindBasePort;
static STRING *startedMsg = (STRING *)0;
@ -64,14 +62,14 @@ CONFIG *optConf = (CONFIG *)0;
CONFIG *config = (CONFIG *)0;
char *interface = (char *)0;
CONFIG defConfig =
{ (STRING *)0, 'r', FLAGFALSE, LOGFILEPATH, PASSWDFILE, DEFPORT,
FLAGTRUE,
FLAGTRUE, 0, DEFBASEPORT, (char *)0
{ (STRING *)0, FLAGTRUE, 'r', FLAGFALSE, LOGFILEPATH, PASSWDFILE,
DEFPORT,
FLAGTRUE, FLAGTRUE, 0, DEFBASEPORT, (char *)0, 0
#if HAVE_SETPROCTITLE
, FLAGFALSE
#endif
#if HAVE_OPENSSL
, (char *)0, FLAGTRUE
, (char *)0, FLAGTRUE, FLAGFALSE, (char *)0
#endif
};
@ -328,6 +326,8 @@ SetupSSL()
#endif
{
if (ctx == (SSL_CTX *)0) {
char *ciphers;
int verifymode;
SSL_load_error_strings();
if (!SSL_library_init()) {
Error("SetupSSL(): SSL_library_init() failed");
@ -357,8 +357,35 @@ SetupSSL()
config->sslcredentials);
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);
if (config->sslcacertificatefile != (char *)0) {
STACK_OF(X509_NAME) * cert_names;
cert_names =
SSL_load_client_CA_file(config->sslcacertificatefile);
if (cert_names != NULL) {
SSL_CTX_set_client_CA_list(ctx, cert_names);
if (SSL_CTX_load_verify_locations
(ctx, config->sslcacertificatefile, NULL) != 1) {
Error("Could not setup CA certificate file to '%s'",
config->sslcacertificatefile);
Bye(EX_UNAVAILABLE);
}
} else {
Error
("SetupSSL(): could not load SSL client CA list from `%s'",
config->sslcacertificatefile);
Bye(EX_SOFTWARE);
}
}
verifymode = SSL_VERIFY_PEER;
if (config->sslreqclientcert == FLAGTRUE)
verifymode |= SSL_VERIFY_FAIL_IF_NO_PEER_CERT;
SSL_CTX_set_verify(ctx, verifymode, SSLVerifyCallback);
SSL_CTX_set_options(ctx,
SSL_OP_ALL | SSL_OP_NO_SSLv2 |
SSL_OP_SINGLE_DH_USE);
@ -367,8 +394,7 @@ SetupSSL()
SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER |
SSL_MODE_AUTO_RETRY);
SSL_CTX_set_tmp_dh_callback(ctx, TmpDHCallback);
if (SSL_CTX_set_cipher_list(ctx, "ALL:!LOW:!EXP:!MD5:@STRENGTH") !=
1) {
if (SSL_CTX_set_cipher_list(ctx, ciphers) != 1) {
Error("SetupSSL(): setting SSL cipher list failed");
Bye(EX_SOFTWARE);
}
@ -380,6 +406,42 @@ SetupSSL()
}
#endif
#if HAVE_GSSAPI
gss_name_t gss_myname = GSS_C_NO_NAME;
gss_cred_id_t gss_mycreds = GSS_C_NO_CREDENTIAL;
void
#if PROTOTYPES
SetupGSSAPI(void)
#else
SetupGSSAPI()
#endif
{
OM_uint32 stmaj, stmin;
char namestr[128];
gss_buffer_desc namebuf;
snprintf(namestr, 128, "host@%s", myHostname);
namebuf.value = namestr;
namebuf.length = strlen(namestr) + 1;
stmaj =
gss_import_name(&stmin, &namebuf, GSS_C_NT_HOSTBASED_SERVICE,
&gss_myname);
/* XXX: handle error */
if (stmaj != GSS_S_COMPLETE) {
Error("gss_import_name failed");
}
/* Get some initial credentials */
stmaj =
gss_acquire_cred(&stmin, gss_myname, 0, GSS_C_NULL_OID_SET,
GSS_C_ACCEPT, &gss_mycreds, NULL, NULL);
if (stmaj != GSS_S_COMPLETE) {
Error("Could not acquire GSS-API credentials");
}
}
#endif
void
#if PROTOTYPES
ReopenLogfile(void)
@ -420,8 +482,8 @@ ReopenLogfile()
close(2);
dup(1);
if (isMaster && tag) {
Msg("%s", THIS_VERSION);
Msg("%s", startedMsg->string);
Msg(MyVersion());
Msg(startedMsg->string);
}
tag = 0;
}
@ -477,6 +539,9 @@ Daemonize()
#if defined(SIGTSTP)
SimpleSignal(SIGTSTP, SIG_IGN);
#endif
#if defined(SIGXFSZ)
SimpleSignal(SIGXFSZ, SIG_IGN);
#endif
fflush(stdout);
fflush(stderr);
@ -593,6 +658,9 @@ Version()
#if HAVE_DMALLOC
"dmalloc",
#endif
#if HAVE_FREEIPMI
"freeipmi",
#endif
#if USE_LIBWRAP
"libwrap",
#endif
@ -604,6 +672,9 @@ Version()
#endif
#if TRUST_REVERSE_DNS
"trustrevdns",
#endif
#if USE_UNIX_DOMAIN_SOCKETS
"uds",
#endif
(char *)0
};
@ -615,7 +686,7 @@ Version()
isMultiProc = 0;
Msg("%s", THIS_VERSION);
Msg(MyVersion());
Msg("default access type `%c'", defConfig.defaultaccess);
Msg("default escape sequence `%s%s'", FmtCtl(DEFATTN, acA1),
FmtCtl(DEFESC, acA2));
@ -652,12 +723,23 @@ Version()
BuildStringChar('0' + DMALLOC_VERSION_MINOR, acA1);
BuildStringChar('.', acA1);
BuildStringChar('0' + DMALLOC_VERSION_PATCH, acA1);
#if defined(DMALLOC_VERSION_BETA)
if (DMALLOC_VERSION_BETA != 0) {
BuildString("-b", acA1);
BuildStringChar('0' + DMALLOC_VERSION_BETA, acA1);
}
#endif
Msg("dmalloc version: %s", acA1->string);
#endif
#if HAVE_FREEIPMI
BuildString((char *)0, acA1);
BuildStringChar('0' + LIBIPMICONSOLE_VERSION_MAJOR, acA1);
BuildStringChar('.', acA1);
BuildStringChar('0' + LIBIPMICONSOLE_VERSION_MINOR, acA1);
BuildStringChar('.', acA1);
BuildStringChar('0' + LIBIPMICONSOLE_VERSION_PATCH, acA1);
Msg("freeipmi version: %s", acA1->string);
#endif
#if HAVE_OPENSSL
Msg("openssl version: %s", OPENSSL_VERSION_TEXT);
#endif
@ -697,6 +779,7 @@ DestroyDataStructures()
pACList = pAC;
}
DestroyConsentUsers(&pADList);
DestroyConsentUsers(&pLUList);
DestroyConfig(pConfig);
DestroyConfig(optConf);
@ -719,8 +802,11 @@ DestroyDataStructures()
free(myAddrs);
DestroyBreakList();
DestroyTaskList();
DestroyStrings();
DestroyUserList();
if (substData != (SUBST *)0)
free(substData);
}
void
@ -774,12 +860,26 @@ SummarizeDataStructures()
size += strlen(pCE->motd);
if (pCE->idlestring != (char *)0)
size += strlen(pCE->idlestring);
if (pCE->replstring != (char *)0)
size += strlen(pCE->replstring);
if (pCE->tasklist != (char *)0)
size += strlen(pCE->tasklist);
if (pCE->breaklist != (char *)0)
size += strlen(pCE->breaklist);
#if HAVE_FREEIPMI
if (pCE->username != (char *)0)
size += strlen(pCE->username);
if (pCE->password != (char *)0)
size += strlen(pCE->password);
#endif
if (pCE->fdlog != (CONSFILE *)0)
size += sizeof(CONSFILE);
if (pCE->cofile != (CONSFILE *)0)
size += sizeof(CONSFILE);
if (pCE->initfile != (CONSFILE *)0)
size += sizeof(CONSFILE);
if (pCE->taskfile != (CONSFILE *)0)
size += sizeof(CONSFILE);
if (pCE->aliases != (NAMES *)0) {
NAMES *n;
for (n = pCE->aliases; n != (NAMES *)0; n = n->next) {
@ -852,13 +952,20 @@ DumpDataStructures()
GRPENT *pGE;
CONSENT *pCE;
REMOTE *pRC;
char *empty = "<empty>";
int i;
TASKS *t;
#if HAVE_FREEIPMI
static STRING *tmpString = (STRING *)0;
if (tmpString == (STRING *)0)
tmpString = AllocString();
#endif
#if HAVE_DMALLOC && DMALLOC_MARK_MAIN
CONDDEBUG((1, "DumpDataStructures(): dmalloc / MarkMain"));
dmalloc_log_changed(dmallocMarkMain, 1, 0, 1);
#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)
return;
@ -890,16 +997,52 @@ DumpDataStructures()
EMPTYSTR(pCE->execSlave),
EMPTYSTR(pCE->exec),
(unsigned long)pCE->ipid));
CONDDEBUG((1,
"DumpDataStructures(): execuid=%d, execgid=%d",
pCE->execuid, pCE->execgid));
break;
#if HAVE_FREEIPMI
case IPMI:
CONDDEBUG((1,
"DumpDataStructures(): server=%s, type=IPMI",
EMPTYSTR(pCE->server)));
CONDDEBUG((1,
"DumpDataStructures(): host=%s, username=%s, password=%s, ipmiprivlevel=%d",
EMPTYSTR(pCE->host),
EMPTYSTR(pCE->username),
EMPTYSTR(pCE->password),
pCE->ipmiprivlevel));
CONDDEBUG((1,
"DumpDataStructures(): ipmiwrkset=%d, ipmiworkaround=%u, ipmiciphersuite=%d",
pCE->ipmiwrkset, pCE->ipmiworkaround,
pCE->ipmiciphersuite));
FmtCtlStr(pCE->ipmikg->string, pCE->ipmikg->used - 1,
tmpString);
CONDDEBUG((1, "DumpDataStructures(): ipmikg=%s",
EMPTYSTR(tmpString->string)));
break;
#endif
case HOST:
CONDDEBUG((1,
"DumpDataStructures(): server=%s, type=HOST",
EMPTYSTR(pCE->server)));
CONDDEBUG((1,
"DumpDataStructures(): host=%s, raw=%hu, netport=%hu, port=%hu, telnetState=%d",
EMPTYSTR(pCE->host), pCE->raw, pCE->netport,
pCE->port, pCE->telnetState));
"DumpDataStructures(): host=%s, raw=%s, netport=%hu, port=%hu, telnetState=%d",
EMPTYSTR(pCE->host), FLAGSTR(pCE->raw),
pCE->netport, pCE->port, pCE->telnetState));
break;
case NOOP:
CONDDEBUG((1,
"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,
@ -921,40 +1064,44 @@ DumpDataStructures()
CONDDEBUG((1,
"DumpDataStructures(): mark=%d, nextMark=%ld, autoReup=%hu, downHard=%s",
pCE->mark, pCE->nextMark, pCE->autoReUp,
pCE->downHard == FLAGTRUE ? "true" : "false"));
FLAGSTR(pCE->downHard)));
CONDDEBUG((1,
"DumpDataStructures(): nolog=%d, cofile=%d, activitylog=%s, breaklog=%s",
pCE->nolog, FileFDNum(pCE->cofile),
pCE->activitylog == FLAGTRUE ? "true" : "false",
pCE->breaklog == FLAGTRUE ? "true" : "false"));
FLAGSTR(pCE->activitylog), FLAGSTR(pCE->breaklog)));
CONDDEBUG((1,
"DumpDataStructures(): ixon=%s, ixany=%s, ixoff=%s",
pCE->ixon == FLAGTRUE ? "true" : "false",
pCE->ixany == FLAGTRUE ? "true" : "false",
pCE->ixoff == FLAGTRUE ? "true" : "false"));
"DumpDataStructures(): tasklog=%s, ixon=%s, ixany=%s, ixoff=%s",
FLAGSTR(pCE->tasklog), FLAGSTR(pCE->ixon),
FLAGSTR(pCE->ixany), FLAGSTR(pCE->ixoff)));
CONDDEBUG((1,
"DumpDataStructures(): autoreinit=%s, hupcl=%s, cstopb=%s, ondemand=%s",
pCE->autoreinit == FLAGTRUE ? "true" : "false",
pCE->hupcl == FLAGTRUE ? "true" : "false",
pCE->cstopb == FLAGTRUE ? "true" : "false",
pCE->ondemand == FLAGTRUE ? "true" : "false"));
FLAGSTR(pCE->autoreinit), FLAGSTR(pCE->hupcl),
FLAGSTR(pCE->cstopb), FLAGSTR(pCE->ondemand)));
#if defined(CRTSCTS)
CONDDEBUG((1, "DumpDataStructures(): crtscts=%s",
pCE->crtscts == FLAGTRUE ? "true" : "false"));
FLAGSTR(pCE->crtscts)));
#endif
CONDDEBUG((1,
"DumpDataStructures(): reinitoncc=%s, striphigh=%s, unloved=%s",
pCE->reinitoncc == FLAGTRUE ? "true" : "false",
pCE->striphigh == FLAGTRUE ? "true" : "false",
pCE->unloved == FLAGTRUE ? "true" : "false"));
"DumpDataStructures(): reinitoncc=%s, striphigh=%s",
FLAGSTR(pCE->reinitoncc), FLAGSTR(pCE->striphigh)));
CONDDEBUG((1, "DumpDataStructures(): unloved=%s, login=%s",
FLAGSTR(pCE->unloved), FLAGSTR(pCE->login)));
CONDDEBUG((1,
"DumpDataStructures(): initpid=%lu, initcmd=%s, initfile=%d",
(unsigned long)pCE->initpid, EMPTYSTR(pCE->initcmd),
FileFDNum(pCE->initfile)));
CONDDEBUG((1, "DumpDataStructures(): inituid=%d, initgid=%d",
pCE->inituid, pCE->initgid));
CONDDEBUG((1,
"DumpDataStructures(): motd=%s, idletimeout=%d, idlestring=%s",
"DumpDataStructures(): motd=%s, idletimeout=%d, idlestring=%s, replstring=%s",
EMPTYSTR(pCE->motd), pCE->idletimeout,
EMPTYSTR(pCE->idlestring)));
EMPTYSTR(pCE->idlestring),
EMPTYSTR(pCE->replstring)));
CONDDEBUG((1,
"DumpDataStructures(): tasklist=%s, breaklist=%s, taskpid=%lu, taskfile=%d",
EMPTYSTR(pCE->tasklist), EMPTYSTR(pCE->breaklist),
(unsigned long)pCE->taskpid,
FileFDNum(pCE->taskfile)));
if (pCE->ro) {
CONSENTUSERS *u;
for (u = pCE->ro; u != (CONSENTUSERS *)0; u = u->next) {
@ -982,188 +1129,19 @@ DumpDataStructures()
}
}
}
}
/* fills the myAddrs array with host interface addresses */
void
#if PROTOTYPES
ProbeInterfaces(void)
#else
ProbeInterfaces()
#endif
{
#ifdef SIOCGIFCONF
struct ifconf ifc;
struct ifreq *ifr;
#ifdef SIOCGIFFLAGS
struct ifreq ifrcopy;
#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 */
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;
for (i = 0; i < 9; i++) {
CONDDEBUG((1,
"DumpDataStructures(): break: string=%s, delay=%d, confirm=%s",
EMPTYSTR(breakList[i].seq->string), breakList[i].delay,
FLAGSTR(breakList[i].confirm)));
}
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
Error("ProbeInterfaces(): socket(): %s", strerror(errno));
Bye(EX_OSERR);
for (t = taskList; t != (TASKS *)0; t = t->next) {
CONDDEBUG((1,
"DumpDataStructures(): task: id=%c, cmd=%s, descr=%s, uid=%d, gid=%d, subst=%s, confirm=%s",
t->id, EMPTYSTR(t->cmd->string),
EMPTYSTR(t->descr->string), t->uid, t->gid,
EMPTYSTR(t->subst), FLAGSTR(t->confirm)));
}
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;
#endif
CONDDEBUG((1, "ProbeInterfaces(): name=%s addr=%s",
ifr->ifr_name, inet_ntoa(sin->sin_addr)));
#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 (m == 0) {
free(myAddrs);
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");
if ((struct hostent *)0 == (he = gethostbyname(myHostname))) {
Error("ProbeInterfaces(): gethostbyname(%s): %s", myHostname,
hstrerror(h_errno));
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++);
if (myAddrs != (struct in_addr *)0)
free(myAddrs);
myAddrs = (struct in_addr *)0;
if (count == 0)
return;
myAddrs = (struct in_addr *)calloc(count + 1, sizeof(struct in_addr));
if (myAddrs == (struct in_addr *)0)
OutOfMem();
for (count--; count >= 0; count--) {
#if HAVE_MEMCPY
memcpy(&(myAddrs[count].s_addr), he->h_addr_list[count],
he->h_length);
#else
bcopy(he->h_addr_list[count], &(myAddrs[count].s_addr),
he->h_length);
#endif
Verbose("interface address %s (hostname address)",
inet_ntoa(myAddrs[count]));
}
#endif
}
/* This makes sure a directory exists and tries to create it if it
@ -1291,9 +1269,9 @@ main(argc, argv)
thepid = getpid();
if ((char *)0 == (progname = strrchr(argv[0], '/'))) {
progname = StrDup(argv[0]);
progname = argv[0];
} else {
progname = StrDup(++progname);
++progname;
}
setpwent();
@ -1355,7 +1333,7 @@ main(argc, argv)
#endif
break;
case 'C':
pcConfig = StrDup(optarg);
pcConfig = optarg;
break;
case 'd':
optConf->daemonmode = FLAGTRUE;
@ -1444,7 +1422,7 @@ main(argc, argv)
Bye(EX_OK);
}
Msg("%s", THIS_VERSION);
Msg(MyVersion());
#if HAVE_GETLOGIN
origuser = getlogin();
@ -1521,7 +1499,7 @@ main(argc, argv)
Error("gethostname(): %s", strerror(errno));
Bye(EX_OSERR);
}
ProbeInterfaces();
ProbeInterfaces(bindAddr);
/* initialize the timers */
for (i = 0; i < T_MAX; i++)
@ -1643,6 +1621,13 @@ main(argc, argv)
else
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)
config->loghostnames = optConf->loghostnames;
else if (pConfig->loghostnames != FLAGUNKNOWN)
@ -1663,6 +1648,14 @@ main(argc, argv)
if (config->unifiedlog == (char *)0)
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 (optConf->sslrequired != FLAGUNKNOWN)
config->sslrequired = optConf->sslrequired;
@ -1671,12 +1664,29 @@ main(argc, argv)
else
config->sslrequired = defConfig.sslrequired;
if (optConf->sslreqclientcert != FLAGUNKNOWN)
config->sslreqclientcert = optConf->sslreqclientcert;
else if (pConfig->sslreqclientcert != FLAGUNKNOWN)
config->sslreqclientcert = pConfig->sslreqclientcert;
else
config->sslreqclientcert = defConfig.sslreqclientcert;
if (optConf->sslcredentials != (char *)0)
config->sslcredentials = StrDup(optConf->sslcredentials);
else if (pConfig->sslcredentials != (char *)0)
config->sslcredentials = StrDup(pConfig->sslcredentials);
else
config->sslcredentials = StrDup(defConfig.sslcredentials);
if (optConf->sslcacertificatefile != (char *)0)
config->sslcacertificatefile =
StrDup(optConf->sslcacertificatefile);
else if (pConfig->sslcacertificatefile != (char *)0)
config->sslcacertificatefile =
StrDup(pConfig->sslcacertificatefile);
else
config->sslcacertificatefile =
StrDup(defConfig.sslcacertificatefile);
#endif
#if HAVE_SETPROCTITLE
@ -1705,6 +1715,9 @@ main(argc, argv)
/* Prep the SSL layer */
SetupSSL();
#endif
#if HAVE_GSSAPI
SetupGSSAPI();
#endif
if (config->daemonmode == FLAGTRUE)
Daemonize();
@ -1722,7 +1735,7 @@ main(argc, argv)
if (pGE->imembers == 0)
continue;
Spawn(pGE);
Spawn(pGE, -1);
Verbose("group #%d pid %lu on port %hu", pGE->id,
(unsigned long)pGE->pid, pGE->port);
}

View File

@ -1,5 +1,5 @@
/*
* $Id: main.h,v 5.52 2004/04/13 18:12:00 bryan Exp $
* $Id: main.h,v 5.54 2009/09/26 09:23:04 bryan Exp $
*
* Copyright conserver.com, 2000
*
@ -44,7 +44,6 @@ extern unsigned short bindPort, bindBasePort;
extern char *pcConfig;
extern int cMaxMemb;
extern struct sockaddr_in in_port;
extern int isMaster;
extern CONFIG *optConf;
extern CONFIG *config;
extern CONFIG defConfig;
@ -55,6 +54,10 @@ extern char *interface;
#if HAVE_OPENSSL
extern SSL_CTX *ctx;
#endif
#if HAVE_GSSAPI
extern gss_name_t gss_myname;
extern gss_cred_id_t gss_mycreds;
#endif
extern void ReopenLogfile PARAMS((void));
extern void ReopenUnifiedlog PARAMS((void));
extern void DumpDataStructures PARAMS((void));

View File

@ -1,5 +1,5 @@
/*
* $Id: master.c,v 5.125 2004/04/13 18:12:00 bryan Exp $
* $Id: master.c,v 5.139 2013/09/23 23:17:42 bryan Exp $
*
* Copyright conserver.com, 2000
*
@ -36,7 +36,6 @@
#include <access.h>
#include <master.h>
#include <readcfg.h>
#include <version.h>
#include <main.h>
@ -68,9 +67,10 @@ FlagSawCHLD(sig)
*/
static void
#if PROTOTYPES
FixKids()
FixKids(int msfd)
#else
FixKids()
FixKids(msfd)
int msfd;
#endif
{
pid_t pid;
@ -124,7 +124,7 @@ FixKids()
/* this kid kid is dead, start another
*/
Spawn(pGE);
Spawn(pGE, msfd);
Verbose("group #%d pid %lu on port %hu", pGE->id,
(unsigned long)pGE->pid, pGE->port);
}
@ -292,7 +292,8 @@ CommandCall(pCL, args)
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;
int foundOne = 0;
for (pGE = pGroups; pGE != (GRPENT *)0; pGE = pGE->pGEnext) {
@ -460,8 +461,9 @@ DoNormalRead(pCLServing)
/* process password here...before we corrupt accmd */
if (pCLServing->iState == S_PASSWD) {
if (CheckPasswd(pCLServing, pCLServing->accmd->string) !=
AUTH_SUCCESS) {
if (CheckPasswd
(pCLServing, pCLServing->accmd->string, FLAGFALSE)
!= AUTH_SUCCESS) {
FileWrite(pCLServing->fd, FLAGFALSE,
"invalid password\r\n", -1);
BuildString((char *)0, pCLServing->accmd);
@ -492,19 +494,25 @@ DoNormalRead(pCLServing)
"login log in\r\n",
#if HAVE_OPENSSL
"ssl start ssl session\r\n",
#endif
#if HAVE_GSSAPI
"gssapi log in with gssapi\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",
"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
};
@ -527,6 +535,14 @@ DoNormalRead(pCLServing)
DropMasterClient(pCLServing, FLAGFALSE);
return;
}
#endif
#if HAVE_GSSAPI
} else if (pCLServing->iState == S_IDENT &&
strcmp(pcCmd, "gssapi") == 0) {
FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", -1);
/* Change the I/O mode right away, we'll do the read
* and accept when the select gets back to us */
pCLServing->ioState = INGSSACCEPT;
#endif
} else if (pCLServing->iState == S_IDENT &&
strcmp(pcCmd, "login") == 0) {
@ -549,7 +565,8 @@ DoNormalRead(pCLServing)
BuildString(pCLServing->peername->string,
pCLServing->acid);
if (pCLServing->caccess == 't' ||
CheckPasswd(pCLServing, "") == AUTH_SUCCESS) {
CheckPasswd(pCLServing, "",
FLAGTRUE) == AUTH_SUCCESS) {
pCLServing->iState = S_NORMAL;
Verbose("<master> login %s",
pCLServing->acid->string);
@ -571,6 +588,7 @@ DoNormalRead(pCLServing)
if ((GRPENT *)0 != pGroups) {
#if USE_UNIX_DOMAIN_SOCKETS
FilePrint(pCLServing->fd, FLAGTRUE, "@0");
iSep = 0;
#else
struct sockaddr_in lcl;
socklen_t so = sizeof(lcl);
@ -582,23 +600,26 @@ DoNormalRead(pCLServing)
-1);
Error("Master(): getsockname(%u): %s",
FileFDNum(pCLServing->fd), strerror(errno));
Bye(EX_OSERR);
}
FilePrint(pCLServing->fd, FLAGTRUE, "@%s",
inet_ntoa(lcl.sin_addr));
#endif
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 = -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);
}
FileWrite(pCLServing->fd, FLAGFALSE, "\r\n", -1);
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "pid") == 0) {
FilePrint(pCLServing->fd, FLAGFALSE, "%lu\r\n",
@ -606,7 +627,7 @@ DoNormalRead(pCLServing)
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "version") == 0) {
FilePrint(pCLServing->fd, FLAGFALSE, "version `%s'\r\n",
THIS_VERSION);
MyVersion());
} else if (pCLServing->iState == S_NORMAL &&
strcmp(pcCmd, "quit") == 0) {
if (ConsentUserOk(pADList, pCLServing->username->string) ==
@ -633,6 +654,41 @@ DoNormalRead(pCLServing)
} 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;
@ -682,7 +738,9 @@ Master()
static STRING *portPath = (STRING *)0;
#else
struct sockaddr_in master_port;
# if HAVE_SETSOCKOPT
int true = 1;
# endif
#endif
FILE *fp;
CONSCLIENT *pCLServing = (CONSCLIENT *)0;
@ -700,6 +758,9 @@ Master()
#endif
#if defined(SIGPOLL)
SimpleSignal(SIGPOLL, SIG_IGN);
#endif
#if defined(SIGXFSZ)
SimpleSignal(SIGXFSZ, SIG_IGN);
#endif
SimpleSignal(SIGCHLD, FlagSawCHLD);
SimpleSignal(SIGTERM, FlagQuitIt);
@ -735,7 +796,8 @@ Master()
Error("Master(): path to socket too long: %s", portPath->string);
return;
}
strcpy(master_port.sun_path, portPath->string);
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",
@ -809,7 +871,7 @@ Master()
for (fSawQuit = 0; !fSawQuit; /* can't close here :-( */ ) {
if (fSawCHLD) {
fSawCHLD = 0;
FixKids();
FixKids(msfd);
}
if (fSawHUP) {
fSawHUP = 0;
@ -817,7 +879,7 @@ Master()
ReopenLogfile();
ReopenUnifiedlog();
SignalKids(SIGHUP);
ReReadCfg(msfd);
ReReadCfg(msfd, msfd);
/* fix up the client descriptors since ReReadCfg() doesn't
* see them like it can in the child processes */
for (pCL = pCLmall; pCL != (CONSCLIENT *)0; pCL = pCL->pCLscan) {
@ -871,6 +933,17 @@ Master()
pCLServing->ioState = ISNORMAL;
}
break;
#endif
#if HAVE_GSSAPI
case INGSSACCEPT:
{
int r;
if ((r = AttemptGSSAPI(pCLServing)) < 0)
DropMasterClient(pCLServing, FLAGFALSE);
else if (r == 1)
pCLServing->ioState = ISNORMAL;
}
break;
#endif
case ISNORMAL:
if (FileCanRead(pCLServing->fd, &rmask, &wmask))

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.49 2013/09/23 22:58:21 bryan Exp $
*
* Copyright conserver.com, 2000
*
@ -10,6 +10,7 @@
typedef struct config {
STRING *name;
FLAG autocomplete;
char defaultaccess;
FLAG daemonmode;
char *logfile;
@ -20,32 +21,52 @@ typedef struct config {
int reinitcheck;
char *secondaryport;
char *unifiedlog;
int initdelay;
#if HAVE_SETPROCTITLE
FLAG setproctitle;
#endif
#if HAVE_OPENSSL
char *sslcredentials;
FLAG sslrequired;
FLAG sslreqclientcert;
char *sslcacertificatefile;
#endif
} CONFIG;
typedef struct breaks {
STRING *seq;
int delay;
FLAG confirm;
} BREAKS;
typedef struct tasks {
char id;
STRING *cmd;
STRING *descr;
uid_t uid;
gid_t gid;
char *subst;
FLAG confirm;
struct tasks *next;
} TASKS;
extern NAMES *userList; /* user list */
extern GRPENT *pGroups; /* group info */
extern REMOTE *pRCList; /* list of remote consoles we know about */
extern REMOTE *pRCUniq; /* list of uniq console servers */
extern ACCESS *pACList; /* `who do you love' (or trust) */
extern CONSENTUSERS *pADList; /* list of admin users */
extern CONSENTUSERS *pLUList; /* list of limited users */
extern BREAKS breakList[9]; /* list of break sequences */
extern TASKS *taskList; /* list of tasks */
extern SUBST *taskSubst; /* substitution function data for tasks */
extern CONFIG *pConfig; /* settings seen by config parser */
extern SUBST *substData; /* substitution function data */
extern void ReadCfg PARAMS((char *, FILE *));
extern void ReReadCfg PARAMS((int));
extern void ReReadCfg PARAMS((int, int));
extern void DestroyBreakList PARAMS((void));
extern void DestroyTaskList PARAMS((void));
extern void DestroyUserList PARAMS((void));
extern void DestroyConfig PARAMS((CONFIG *));
extern NAMES *FindUserList PARAMS((char *));

View File

@ -1,5 +1,5 @@
/*
* $Id: version.h,v 1.60 2004/04/03 15:44:49 bryan Exp $
* $Id: version.h,v 1.79 2014/04/02 04:45:32 bryan Exp $
*
* Copyright conserver.com, 2000
*
@ -14,4 +14,8 @@
@(#) Copyright 2000 conserver.com.\n\
All rights reserved.\n"
#define THIS_VERSION "conserver.com version 8.1.4"
#define VERSION_MAJOR 8
#define VERSION_MINOR 1
#define VERSION_REV 20
#define VERSION_TEXT "conserver.com version"
#define VERSION_UINT (VERSION_MAJOR * 1000000 + VERSION_MINOR * 1000 + VERSION_REV)

View File

@ -1,4 +1,5 @@
### Path settings
datarootdir = @datarootdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
prefix = @prefix@
@ -25,11 +26,11 @@ LIBS = @LIBS@
### 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 \
$(top_srcdir)/conserver/cutil.h \
$(top_srcdir)/conserver/version.h \
$(srcdir)/getpassword.h
$(srcdir)/getpassword.h $(srcdir)/readconf.h
ALL = console
@ -56,6 +57,6 @@ install: console
$(MKDIR) $(DESTDIR)$(bindir)
$(INSTALL_PROGRAM) console $(DESTDIR)$(bindir)
$(MKDIR) $(DESTDIR)$(mandir)/man1
$(INSTALL) console.man $(DESTDIR)$(mandir)/man1/console.1
$(INSTALL) -m 0644 console.man $(DESTDIR)$(mandir)/man1/console.1
.PHONY: clean distclean install

File diff suppressed because it is too large Load Diff

View File

@ -1,45 +1,45 @@
.\" $Id: console.man,v 1.46 2004/03/23 18:32:09 bryan Exp $
.TH CONSOLE 1 "2004/03/23" "conserver-8.1.4" "conserver"
.\" $Id: console.man,v 1.65 2013/09/25 22:10:30 bryan Exp $
.TH CONSOLE 1 "2013/09/25" "conserver-8.1.20" "conserver"
.SH NAME
console \- console server client program
.SH SYNOPSIS
.B console
.RB [ \-aAEfFsS ]
.RB [ \-7Dv ]
.RB [ \-c
.IR cred ]
.BR [ \-M
.IR mach ]
.BR [ \-p
.IR port ]
.RI [ generic-args ]
.RB [ \-aAfFsS ]
.BR [ \-e
.IR esc ]
.BR [ \-l
.IR user ]
.I console
.br
.B console
.RB [ \-hiIPrRuVwWx ]
.RB [ \-7Dv ]
.RB [ \-M
.IR mach ]
.RB [ \-p
.IR port ]
.RB [ \-d
.RI [ user ][\f3@\fP console ]]
.RI [ generic-args ]
.RB [ \-iIuwWx ]
.RI [ console ]
.br
.B console
.RI [ generic-args ]
.RB [ \-hPqQrRV ]
.RB [ \- [ bB ]
.IR message ]
.RB [ \-d
.RI [ user ][\f3@\fP console ]]
.RB [ \-t
.RI [ user ][\f3@\fP console ]
.IR message ]
.br
.B console
.RB [ \-qQ ]
.RB [ \-7Dv ]
.RB [ \-M
.IR mach ]
.RB [ \-p
.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 ]
.BR [ \-l
.IR user ]
.SH DESCRIPTION
.B Console
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
granting interactive access to a console (on a non-trusted system),
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.
.PP
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
.IR cred .
.TP
.BI \-C config
Use the per-user configuration file
.IR config .
.TP
.B \-d
Disconnect the users specified by
.IR user @ console .
@ -150,9 +155,13 @@ The default value is
.B \-E
If encryption has been built into the code
.RB ( --with-openssl ),
encrypted client connections are a requirement.
This option allows the client to connect to a console
over a non-encrypted connection.
encrypted client connections are, by default, a requirement.
This option disables any attempt at creating an
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
.B \-f
Same as
@ -163,7 +172,7 @@ except it will force any existing connection into spy mode.
Display a brief help message.
.TP
.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
.B \-I
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 else the name associated with the user's real uid.
.TP
.BI \-M mach
.BI \-M master
The
.B console
client program polls
.I mach
.I master
as the primary server,
rather than the default set at compile time (typically
.RB `` console '').
The default
.I mach
.I master
may be changed at compile time using the
.B --with-master
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
.BI \-p port
Set the port to connect to.
@ -203,6 +227,9 @@ may be changed at compile time
using the
.B --with-port
option.
If the
.B --with-uds
option was used, this option is ignored.
.TP
.B \-P
Display the pid of the master daemon process on each server.
@ -264,6 +291,18 @@ and attached users
.RI ( user @ host
if attached read-write, `<spies>' if only users in spy mode, or `<none>').
.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
Be more verbose when building the connection(s).
Use this option in combination with any of `show' options (below)
@ -289,6 +328,72 @@ but just acts on the primary server.
.TP
.B \-x
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
The
.BR \-A ,
@ -297,12 +402,19 @@ The
options have the same effect as their lower-case variants.
In addition, they each request the last 20 lines of the console output after
making the connection (as if
.RB ` ^Ecr '
.RB `` ^Ecr ''
were typed).
.PP
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
option outputs information regarding each console in 15 colon-separated fields.
option outputs status information regarding each console in 15 colon-separated fields.
.TP
.I name
The name of the console.
@ -314,7 +426,8 @@ the console.
.I type
The type of console.
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
.I console-details
The details regarding the console.
@ -325,6 +438,9 @@ Commands will have values of the command, the command's pid, the
pseudo-tty, and file descriptor for the pseudo-tty.
Remote ports will have values of the remote hostname, remote port number,
``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
.I users-list
The details of each user connected to the console.
@ -349,7 +465,7 @@ that the server can open the file for read, but not write.
The details regarding the logging for the console.
The comma-separated
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
the file descriptor of the logfile.
.TP
@ -375,6 +491,321 @@ The idletimeout configuration option for the console.
.TP
.I idlestring
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
\f3sslcacertificatefile\fP \f2filename\fP
.br
Load the valid CA certificates for the
.SM SSL
connection from the PEM encoded file.
.TP
\f3sslcacertificatepath\fP \f2directory\fP
.br
Load the valid CA certificates for the
.SM SSL
connection from the PEM encoded files in the directory.
.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"
The connection can be controlled by a two-character escape sequence, followed
by a command.
@ -437,13 +868,19 @@ close (if open) and reopen the line (to clear errors (silo overflows))
and the log file
.TP
.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
.B r
replay the last 20 lines of output
.TP
.B R
set number of replay lines
.TP
.B s
switch to spy mode (read-only)
switch to spy mode (read only)
.TP
.B u
show status of hosts/users in this group
@ -460,6 +897,9 @@ examine this group's devices and modes
.B z
suspend this connection
.TP
.B !
invoke task
.TP
.B |
attach a local command to the console
.TP
@ -481,7 +921,7 @@ specify three octal digits)
If any other character is hit after the escape sequence, all three characters
will be discarded.
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
the outer escape sequence, or use
.BI ^Ec\e ooo
@ -492,13 +932,17 @@ In the
.B \-u
output, the login ``<none>'' indicates no one is
viewing that console, and the login ``<spies>'' indicates that
no one has a full two-way attachment.
When no one is attached to
a console its output is cloned to the stdout of the server process if
.B conserver
was started with the
.B \-u
option.
no one has a read-write connection (only read-only).
.PP
When running a local command via
.RB `` ^Ec| '',
you can type
.RB ` ^C '
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
.TP 15
console \-u
@ -550,6 +994,22 @@ or number of days is displayed.
console \-e "^[1" lv426
Requests a connection to the host ``lv426'' with the escape characters
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
It is possible to create a loop of console connections, with ugly results.
Never run

890
console/readconf.c Normal file
View File

@ -0,0 +1,890 @@
/*
* $Id: readconf.c,v 5.7 2013/09/18 14:31:39 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);
if (c->sslcacertificatefile != (char *)0)
free(c->sslcacertificatefile);
if (c->sslcacertificatepath != (char *)0)
free(c->sslcacertificatepath);
#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->sslcacertificatefile != (char *)0) {
if (c->sslcacertificatefile != (char *)0)
free(c->sslcacertificatefile);
if ((c->sslcacertificatefile =
StrDup(parserConfigDefault->sslcacertificatefile)) ==
(char *)0)
OutOfMem();
}
if (parserConfigDefault->sslcacertificatepath != (char *)0) {
if (c->sslcacertificatepath != (char *)0)
free(c->sslcacertificatepath);
if ((c->sslcacertificatepath =
StrDup(parserConfigDefault->sslcacertificatepath)) ==
(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
ConfigItemSslcacertificatefile(char *id)
#else
ConfigItemSslcacertificatefile(id)
char *id;
#endif
{
CONDDEBUG((1, "ConfigItemSslcacertificatefile(%s) [%s:%d]", id, file,
line));
#if HAVE_OPENSSL
if (parserConfigTemp->sslcacertificatefile != (char *)0)
free(parserConfigTemp->sslcacertificatefile);
if ((id == (char *)0) || (*id == '\000')) {
parserConfigTemp->sslcacertificatefile = (char *)0;
return;
}
if ((parserConfigTemp->sslcacertificatefile = StrDup(id)) == (char *)0)
OutOfMem();
#else
Error
("sslcacertificatefile ignored - encryption not compiled into code [%s:%d]",
file, line);
#endif
}
void
#if PROTOTYPES
ConfigItemSslcacertificatepath(char *id)
#else
ConfigItemSslcacertificatepath(id)
char *id;
#endif
{
CONDDEBUG((1, "ConfigItemSslcacertificatepath(%s) [%s:%d]", id, file,
line));
#if HAVE_OPENSSL
if (parserConfigTemp->sslcacertificatepath != (char *)0)
free(parserConfigTemp->sslcacertificatepath);
if ((id == (char *)0) || (*id == '\000')) {
parserConfigTemp->sslcacertificatepath = (char *)0;
return;
}
if ((parserConfigTemp->sslcacertificatepath = StrDup(id)) == (char *)0)
OutOfMem();
#else
Error
("sslcacertificatepath 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},
{"sslcacertificatefile", ConfigItemSslcacertificatefile},
{"sslcacertificatepath", ConfigItemSslcacertificatepath},
{"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->sslcacertificatefile = %s",
EMPTYSTR(pConfig->sslcacertificatefile)));
CONDDEBUG((1, "pConfig->sslcacertificatepath = %s",
EMPTYSTR(pConfig->sslcacertificatepath)));
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);
}

42
console/readconf.h Normal file
View File

@ -0,0 +1,42 @@
/*
* $Id: readconf.h,v 5.6 2013/09/18 14:31:39 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;
char *sslcacertificatefile;
char *sslcacertificatepath;
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

@ -1,4 +1,5 @@
### Path settings
datarootdir = @datarootdir@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
prefix = @prefix@

View File

@ -6,12 +6,13 @@
# outside of my own purposes. If this helps, cool. In the end I put the
# rootcert.pem file in my global certs directory (OPENSSL_ROOT/ssl/certs),
# point the server to server.pem and point the client at client.pem. I
# then run the c_rehash command (I supposed it helps or is important).
# When it asks for a passphrase, use 'pass', otherwise this script won't
# work. Ugly, yeah, but it's an ok test.
# then run the c_rehash command.
#
# You can also use the sslcacertificatefile options to point the client/server
# at rootcert.pem instead of populating the global repository
#
[ -f rootreq.pem -a -f rootkey.pem ] || cat <<EOD | openssl req -newkey rsa:1024 -sha1 -keyout rootkey.pem -out rootreq.pem -passin pass:pass -passout pass:pass
[ -f rootreq.pem -a -f rootkey.pem ] || cat <<EOD | openssl req -newkey rsa:1024 -sha1 -keyout rootkey.pem -out rootreq.pem -nodes
US
California
Folsom
@ -25,7 +26,7 @@ EOD
[ -f rootcert.pem ] || openssl x509 -req -in rootreq.pem -sha1 -extensions v3_ca -signkey rootkey.pem -out rootcert.pem
[ -f root.pem ] || cat rootcert.pem rootkey.pem > root.pem
[ -f serverreq.pem -a -f serverkey.pem ] || cat <<EOD | openssl req -newkey rsa:1024 -sha1 -keyout serverkey.pem -out serverreq.pem -passin pass:pass -passout pass:pass
[ -f serverreq.pem -a -f serverkey.pem ] || cat <<EOD | openssl req -newkey rsa:1024 -sha1 -keyout serverkey.pem -out serverreq.pem -nodes
US
California
Folsom
@ -39,7 +40,7 @@ EOD
[ -f servercert.pem ] || openssl x509 -req -in serverreq.pem -sha1 -extensions usr_cert -CA root.pem -CAkey root.pem -CAcreateserial -out servercert.pem
[ -f server.pem ] || cat servercert.pem serverkey.pem rootcert.pem > server.pem
[ -f clientreq.pem -a -f clientkey.pem ] || cat <<EOD | openssl req -newkey rsa:1024 -sha1 -keyout clientkey.pem -out clientreq.pem -passin pass:pass -passout pass:pass
[ -f clientreq.pem -a -f clientkey.pem ] || cat <<EOD | openssl req -newkey rsa:1024 -sha1 -keyout clientkey.pem -out clientreq.pem -nodes
US
California
Folsom

View File

@ -0,0 +1,5 @@
# server options
#OPTIONS="-p 33000 -d"
# run as different user that root
#RUNAS=conservr

View File

@ -7,44 +7,66 @@
# config: /etc/conserver.cf
#
DAEMON=/usr/sbin/conserver
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Source defaults
. /etc/default/conserver
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
# make sure conserver is installed and executable
[ -x /usr/sbin/conserver ] || exit 1
[ -x $DAEMON ] || exit 1
start()
{
echo -n "Starting conserver: "
daemon --user "${RUNAS-}" $DAEMON ${OPTIONS--d}
RETVAL=$?
[ "$RETVAL" = 0 ] && touch /var/lock/subsys/conserver
echo
}
stop()
{
echo -n "Shutting down conserver: "
killproc conserver
RETVAL=$?
[ "$RETVAL" = 0 ] && rm -f /var/lock/subsys/conserver
echo
}
# See how we were called.
case "$1" in
start)
echo -n "Starting conserver: "
daemon conserver -d
echo
touch /var/lock/subsys/conserver
start
;;
stop)
echo -n "Shutting down conserver: "
killproc conserver
echo
rm -f /var/lock/subsys/conserver
stop
;;
status)
status conserver
;;
restart)
echo -n "Restarting conserver: "
stop
start
;;
reload)
echo -n "Reloading conserver: "
killproc conserver -HUP
RETVAL=$?
echo
;;
*)
echo "Usage: conserver {start|stop|restart|status}"
exit 1
echo "Usage: conserver {start|stop|restart|reload|status}"
RETVAL=1
esac
exit 0
exit $RETVAL

View File

@ -4,7 +4,7 @@
#
%define pkg conserver
%define ver 8.1.4
%define ver 8.1.20
# define the name of the machine on which the main conserver
# daemon will be running if you don't want to use the default
@ -12,26 +12,71 @@
%define master console
# what red hat (or other distibution) version are you running?
%define distver 6
%define distver 1
# compile arguments. defaults to 0
# example: rpmbuild -bb conserver.spec --with openssl
%define with_openssl %{?_with_openssl: 1} %{?!_with_openssl: 0}
%define with_libwrap %{?_with_libwrap: 1} %{?!_with_libwrap: 0}
%define with_pam %{?_with_pam: 1} %{?!_with_pam: 0}
%define with_dmalloc %{?_with_dmalloc: 1} %{?!_with_dmalloc: 0}
%define with_freeipmi %{?_with_freeipmi: 1} %{?!_with_freeipmi: 0}
# additionally you can use macros logfile pidfile
# example: rpmbuild -bb conserver.spec --define "pidfile /var/run/conserver/pid"
Summary: Serial console server daemon/client
Name: %{pkg}
Version: %{ver}
Release: 1.%{distver}
Copyright: distributable
Release: %{distver}
License: BSD
Summary: Serial console server daemon/client
Group: System Environment/Daemons
URL: http://www.conserver.com/
Source: http://www.conserver.com/%{pkg}-%{ver}.tar.gz
BuildRoot: %{_tmppath}/%{pkg}-buildroot
%if %{with_openssl}
Requires: openssl
BuildRequires: openssl-devel
%endif
%if %{with_pam}
BuildRequires: pam-devel
%endif
%if %{with_libwrap}
Requires: tcp_wrappers
%endif
%if %{with_dmalloc}
Requires: dmalloc
BuildRequires: dmalloc
%endif
%if %{with_freeipmi}
Requires: freeipmi
BuildRequires: freeipmi-devel
%endif
Prefix: %{_prefix}
%package server
Summary: Serial console server daemon
Group: System Environment/Daemons
%package client
Summary: Serial console server client
Group: Applications/Internet
%description
Conserver is an application that allows multiple users to watch a
Conserver is a daemon that allows multiple users to watch a
serial console at the same time. It can log the data, allows users to
take write-access of a console (one at a time), and has a variety of
bells and whistles to accentuate that basic functionality.
%description server
conserver-server is a daemon that allows multiple users to watch a
serial console at the same time. It can log the data, allows users to
take write-access of a console (one at a time), and has a variety of
bells and whistles to accentuate that basic functionality.
%description client
conserver-client to connect to conserver-server using a tcp port.
Allows multiple users to watch a serial console at the same time.
%prep
%{__rm} -rf %{buildroot}
@ -44,7 +89,8 @@ f="conserver/Makefile.in"
%{__mv} $f $f.orig
%{__sed} -e 's/^.*conserver\.rc.*$//' < $f.orig > $f
%configure --with-master=%{master}
%configure %{?_with_openssl} %{?_with_libwrap} %{?_with_dmalloc} %{?_with_freeipmi} %{?_with_pam} %{?logfile: --with-logfile=%{logfile}} %{?pidfile: --with-pidfile=%{pidfile}} %{?master: --with-master=%{master}}
make
@ -65,12 +111,15 @@ make
%{__mkdir_p} %{buildroot}/%{_initrddir}
%{__cp} contrib/redhat-rpm/conserver.init %{buildroot}/%{_initrddir}/conserver
# install copy of init script defaults
%{__mkdir_p} %{buildroot}/%{_sysconfdir}/default
%{__cp} contrib/redhat-rpm/conserver.defaults %{buildroot}/%{_sysconfdir}/default/conserver
%clean
%{__rm} -rf %{buildroot}
%post
%post server
if [ -x %{_initrddir}/conserver ]; then
/sbin/chkconfig --add conserver
fi
@ -80,7 +129,7 @@ if ! egrep '\<conserver\>' /etc/services > /dev/null 2>&1 ; then
fi
%preun
%preun server
if [ "$1" = 0 ]; then
if [ -x %{_initrddir}/conserver ]; then
%{_initrddir}/conserver stop
@ -88,18 +137,37 @@ if [ "$1" = 0 ]; then
fi
fi
# we need this even if empty
#%files
%files
%files server
%defattr(-,root,root)
%doc CHANGES FAQ INSTALL README conserver.cf
%config(noreplace) %{_sysconfdir}/conserver.cf
%config(noreplace) %{_sysconfdir}/conserver.passwd
%config(noreplace) %{_sysconfdir}/default/conserver
%attr(555,root,root) %{_initrddir}/conserver
%{prefix}/bin/console
%{prefix}/share/man/man1/console.1.gz
%{prefix}/share/man/man8/conserver.8.gz
%{prefix}/share/man/man5/conserver.cf.5.gz
%{prefix}/share/man/man5/conserver.passwd.5.gz
%{prefix}/share/examples/conserver/conserver.cf
%{prefix}/share/examples/conserver/conserver.passwd
%{prefix}/sbin/conserver
%{_libdir}/conserver/convert
%{_mandir}/man8/conserver.8.gz
%{_mandir}/man5/conserver.cf.5.gz
%{_mandir}/man5/conserver.passwd.5.gz
%{_datadir}/examples/conserver/conserver.cf
%{_datadir}/examples/conserver/conserver.passwd
%{_sbindir}/conserver
%files client
%defattr(-,root,root)
%doc CHANGES FAQ INSTALL README
%{_bindir}/console
%{_mandir}/man1/console.1.gz
%changelog
* Wed Oct 14 2009 Jodok Ole Muellers <muellejo@aschendorff.de>
- Changed the conserver.spec file to create separate subpackages
for client and server by using the %package directive.
* Wed Sep 25 2009 Fabien Wernli
- added configure prerequisites
* Thu Sep 24 2009 Fabien Wernli
- added prefix to configure
- changed some hardcoded values to proper macros:
didn't work on x64 lib -> lib64

View File

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

View File

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

View File

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

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

@ -7,11 +7,13 @@
g group info i information dump
L toggle logging on/off l? break sequence list
l0 send break per config file l1-9 send specific break sequence
m display the message of the day o (re)open the tty and log file
p replay the last 60 lines r replay the last 20 lines
s spy read only u show host status
v show version info w who is on this console
x show console baud info z suspend the connection
m display the message of the day n write a note to the logfile
o (re)open the tty and log file p playback the last 60 lines
P set number of playback lines r replay the last 20 lines
R set number of replay lines s spy mode (read only)
u show host status v show version info
w who is on this console x show console baud info
z suspend the connection ! invoke task
| attach local command ? print this message
<cr> ignore/abort command ^R replay the last line
\ooo send character by octal code

View File

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

View File

@ -7,11 +7,13 @@
g group info i information dump
L toggle logging on/off l? break sequence list
l0 send break per config file l1-9 send specific break sequence
m display the message of the day o (re)open the tty and log file
p replay the last 60 lines r replay the last 20 lines
s spy read only u show host status
v show version info w who is on this console
x show console baud info z suspend the connection
m display the message of the day n write a note to the logfile
o (re)open the tty and log file p playback the last 60 lines
P set number of playback lines r replay the last 20 lines
R set number of replay lines s spy mode (read only)
u show host status v show version info
w who is on this console x show console baud info
z suspend the connection ! invoke task
| attach local command ? print this message
<cr> ignore/abort command ^R replay the last line
\ooo send character by octal code