mirror of
https://github.com/bstansell/conserver.git
synced 2025-06-25 01:59:08 +00:00
Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
cf461c7ce8 | |||
5c430d220b | |||
8cd506c093 |
42
CHANGES
42
CHANGES
@ -1,6 +1,46 @@
|
|||||||
CHANGES
|
CHANGES
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
version 8.1.6 (May 25, 2004):
|
||||||
|
- added ability to configure client via sytem-wide console.cf
|
||||||
|
file and per-user .consolerc - suggested by Erik Sjolund
|
||||||
|
<erik.sjolund@sbc.su.se>
|
||||||
|
- fixed bug where break strings were not properly sent -
|
||||||
|
reported by Tim Small <tim@buttersideup.com>
|
||||||
|
- fixed bug in config file 'protocol' value handling - reported
|
||||||
|
by Kees Cook <kees@osdl.org>
|
||||||
|
- conserver no longer uses the local domain name in the default
|
||||||
|
access list (the default list is only created if no access
|
||||||
|
list is specified in the configuration file) - inspired by
|
||||||
|
William P LePera <lepera@us.ibm.com>
|
||||||
|
- added a 'terminal' console configuration block for printing
|
||||||
|
strings when attaching and detaching from consoles - suggested
|
||||||
|
by Richard Threadgill <richardt@tellme.com>
|
||||||
|
|
||||||
|
version 8.1.5 (May 7, 2004):
|
||||||
|
- changed remaining O_NDELAY flags to O_NONBLOCK
|
||||||
|
- added PROTOCOLS file to describe the client/server protocol
|
||||||
|
- added '#include' capability to conserver.cf file
|
||||||
|
- added '@group' syntax to conserver.cf file to support use of
|
||||||
|
system groups
|
||||||
|
- added -U client option to allow client to ask for encryption
|
||||||
|
but fall back to non-encrypted connections otherwise -
|
||||||
|
suggested by Mike Hendon <mike.hendon@uk.nomura.com>
|
||||||
|
- fixed bug where socket not properly deleted on exit - reported
|
||||||
|
by William P LePera <lepera@us.ibm.com>
|
||||||
|
- added 'initdelay' option for throttling startup of consoles -
|
||||||
|
suggested by Jay McCanta <mccantaj@amgen.com>
|
||||||
|
|
||||||
|
version 8.1.4 (Apr 13, 2004):
|
||||||
|
- fixed macro use in manpages to hopefully be more compatible
|
||||||
|
- removed extra newline of --MARK-- range output
|
||||||
|
- fixed bug where server -b option wasn't working - reported by
|
||||||
|
Nathan R. Hruby <nhruby@uga.edu>
|
||||||
|
- fixed client segfault when using -R, -t, -d, and -b options
|
||||||
|
- added a --with-uds configure option to have all client/server
|
||||||
|
communication happen via unix domain sockets - suggested by
|
||||||
|
William P LePera <lepera@us.ibm.com>
|
||||||
|
|
||||||
version 8.1.3 (Mar 22, 2004):
|
version 8.1.3 (Mar 22, 2004):
|
||||||
- fixed small memory and file descriptor leak in client when
|
- fixed small memory and file descriptor leak in client when
|
||||||
using '^Ec;'
|
using '^Ec;'
|
||||||
@ -698,5 +738,5 @@ before version 6.05:
|
|||||||
and enhancements of various types were applied.
|
and enhancements of various types were applied.
|
||||||
|
|
||||||
#
|
#
|
||||||
# $Id: CHANGES,v 1.162 2004/03/23 00:55:04 bryan Exp $
|
# $Id: CHANGES,v 1.179 2004/05/26 00:14:07 bryan Exp $
|
||||||
#
|
#
|
||||||
|
14
INSTALL
14
INSTALL
@ -165,6 +165,9 @@ Detailed Instructions
|
|||||||
--with-maxmemb=MAXMEMB Specify maximum consoles per process [16]
|
--with-maxmemb=MAXMEMB Specify maximum consoles per process [16]
|
||||||
--with-timeout=TIMEOUT Specify connect() timeout in seconds [10]
|
--with-timeout=TIMEOUT Specify connect() timeout in seconds [10]
|
||||||
--with-trustrevdns Trust reverse DNS information
|
--with-trustrevdns Trust reverse DNS information
|
||||||
|
--with-extmsgs Produce extended messages
|
||||||
|
--with-uds[=DIR] Use Unix domain sockets for client/server
|
||||||
|
communication [/tmp/conserver]
|
||||||
--with-libwrap[=PATH] Compile in libwrap (tcp_wrappers) support
|
--with-libwrap[=PATH] Compile in libwrap (tcp_wrappers) support
|
||||||
--with-openssl[=PATH] Compile in OpenSSL support
|
--with-openssl[=PATH] Compile in OpenSSL support
|
||||||
--with-dmalloc[=PATH] Compile in dmalloc support
|
--with-dmalloc[=PATH] Compile in dmalloc support
|
||||||
@ -182,10 +185,11 @@ Detailed Instructions
|
|||||||
A couple of notes. First, --with-libwrap will add tcp_wrappers
|
A couple of notes. First, --with-libwrap will add tcp_wrappers
|
||||||
lookups to all socket connections in the server. --with-openssl
|
lookups to all socket connections in the server. --with-openssl
|
||||||
will add encryption between the client and server when you connect
|
will add encryption between the client and server when you connect
|
||||||
to a console. things such as 'console -q', 'console -w', etc. are
|
to a console. --with-uds will cause the client and server to use
|
||||||
still unencrypted, as well as connections from conserver to any
|
unix domain sockets for their communication, eliminating the
|
||||||
terminal servers. --with-dmalloc should only be used to do memory
|
tcp communication they normally do (which means --with-master and
|
||||||
allocation debugging and not used in production.
|
--with-port are not used). --with-dmalloc should only be used to
|
||||||
|
do memory allocation debugging and not used in production.
|
||||||
|
|
||||||
- Run './configure'. This will detect system specific
|
- Run './configure'. This will detect system specific
|
||||||
information. The --prefix option will redirect where things are
|
information. The --prefix option will redirect where things are
|
||||||
@ -274,5 +278,5 @@ Other Information And Gotchas
|
|||||||
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# $Id: INSTALL,v 1.37 2004/03/23 00:55:04 bryan Exp $
|
# $Id: INSTALL,v 1.38 2004/04/13 18:11:58 bryan Exp $
|
||||||
#
|
#
|
||||||
|
290
PROTOCOL
Normal file
290
PROTOCOL
Normal file
@ -0,0 +1,290 @@
|
|||||||
|
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
|
||||||
|
pid provide pid of master process
|
||||||
|
quit* terminate conserver (SIGTERM)
|
||||||
|
restart* restart conserver (SIGHUP)
|
||||||
|
version provide version info for server
|
||||||
|
* = 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 "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 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 not disconnected.
|
||||||
|
|
||||||
|
The "version" command responds with the version string. The client is
|
||||||
|
not disconnected.
|
||||||
|
|
||||||
|
|
||||||
|
"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.1 2004/04/16 16:50:55 bryan Exp $
|
||||||
|
#
|
14
TODO
14
TODO
@ -86,26 +86,14 @@ Bryan Stansell
|
|||||||
- not even sure if this is possible w/o confusing the client,
|
- 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!
|
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
|
- allow for very long replays (hundres of lines) : John Stoffel
|
||||||
<stoffel@lucent.com>
|
<stoffel@lucent.com>
|
||||||
|
|
||||||
- log rotation by date : Tom Pachla <tom.pachla@nlc-bnc.ca>
|
- 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
|
- strict file permission checks on conserver.passwd/conserver.cf : Erik
|
||||||
Sjolund <erik.sjolund@sbc.su.se>
|
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>
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# $Id: TODO,v 1.47 2004/03/12 17:34:49 bryan Exp $
|
# $Id: TODO,v 1.49 2004/05/25 00:38:11 bryan Exp $
|
||||||
#
|
#
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
.\" $Id: autologin.man,v 1.1 2003/11/04 02:36:24 bryan Exp $
|
.\" $Id: autologin.man,v 1.2 2004/03/23 18:32:06 bryan Exp $
|
||||||
.TH AUTOLOGIN 8L PUCC
|
.TH AUTOLOGIN 8L PUCC
|
||||||
.SH NAME
|
.SH NAME
|
||||||
autologin \- create an automatic login session from /etc/inittab
|
autologin \- create an automatic login session from /etc/inittab
|
||||||
@ -112,12 +112,21 @@ environment variable set to
|
|||||||
ss10:2:respawn:/usr/local/etc/autologin \-e TERM=reg20 \-t/dev/tty10 \-lssinfo
|
ss10:2:respawn:/usr/local/etc/autologin \-e TERM=reg20 \-t/dev/tty10 \-lssinfo
|
||||||
.ad
|
.ad
|
||||||
.PP
|
.PP
|
||||||
Adding the following line to \fI/etc/ttytab\fP on a Sun 4.1.\fIx\fP
|
Adding the following line to
|
||||||
|
.I /etc/ttytab
|
||||||
|
on a Sun
|
||||||
|
.RI 4.1. x
|
||||||
machine establishes a root login on the console device:
|
machine establishes a root login on the console device:
|
||||||
|
.br
|
||||||
.na
|
.na
|
||||||
console "/usr/local/etc/autologin \-lroot \-t" xterm on local secure
|
console "/usr/local/etc/autologin \-lroot \-t" xterm on local secure
|
||||||
.ad
|
.ad
|
||||||
Note that \fIinit\fP provides the \fItty\fP argument on the end of the command.
|
.PP
|
||||||
|
Note that
|
||||||
|
.I init
|
||||||
|
provides the
|
||||||
|
.I tty
|
||||||
|
argument on the end of the command.
|
||||||
.SH FILES
|
.SH FILES
|
||||||
/bin/su
|
/bin/su
|
||||||
.br
|
.br
|
||||||
|
3
compat.h
3
compat.h
@ -8,6 +8,9 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
#include <sys/un.h>
|
||||||
|
#endif
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
/* config.h.in. Generated from configure.in by autoheader. */
|
/* config.h.in. Generated from configure.in by autoheader. */
|
||||||
|
|
||||||
|
/* Client config file path */
|
||||||
|
#undef CLIENTCONFIGFILE
|
||||||
|
|
||||||
/* Config file path */
|
/* Config file path */
|
||||||
#undef CONFIGFILE
|
#undef CONFIGFILE
|
||||||
|
|
||||||
@ -324,12 +327,18 @@
|
|||||||
/* Defined if we trust reverse DNS */
|
/* Defined if we trust reverse DNS */
|
||||||
#undef TRUST_REVERSE_DNS
|
#undef TRUST_REVERSE_DNS
|
||||||
|
|
||||||
|
/* Directory for Unix domain sockets */
|
||||||
|
#undef UDSDIR
|
||||||
|
|
||||||
/* Defined if we produce extended messages */
|
/* Defined if we produce extended messages */
|
||||||
#undef USE_EXTENDED_MESSAGES
|
#undef USE_EXTENDED_MESSAGES
|
||||||
|
|
||||||
/* use tcp_wrappers libwrap */
|
/* use tcp_wrappers libwrap */
|
||||||
#undef USE_LIBWRAP
|
#undef USE_LIBWRAP
|
||||||
|
|
||||||
|
/* Defined if we use Unix domain sockets */
|
||||||
|
#undef USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
|
||||||
/* Define to 1 if on AIX 3.
|
/* Define to 1 if on AIX 3.
|
||||||
System headers sometimes define this.
|
System headers sometimes define this.
|
||||||
We just want to avoid a redefinition error message. */
|
We just want to avoid a redefinition error message. */
|
||||||
|
120
configure
vendored
120
configure
vendored
@ -847,6 +847,8 @@ Optional Packages:
|
|||||||
--with-port=PORT Specify port number [conserver]
|
--with-port=PORT Specify port number [conserver]
|
||||||
--with-base=PORT Base port for secondary channel [0]
|
--with-base=PORT Base port for secondary channel [0]
|
||||||
--with-master=MASTER Specify master server hostname [console]
|
--with-master=MASTER Specify master server hostname [console]
|
||||||
|
--with-ccffile=CFFILE Specify client config filename
|
||||||
|
[SYSCONFDIR/console.cf]
|
||||||
--with-cffile=CFFILE Specify config filename
|
--with-cffile=CFFILE Specify config filename
|
||||||
[SYSCONFDIR/conserver.cf]
|
[SYSCONFDIR/conserver.cf]
|
||||||
--with-pwdfile=PWDFILE Specify password filename
|
--with-pwdfile=PWDFILE Specify password filename
|
||||||
@ -857,6 +859,9 @@ Optional Packages:
|
|||||||
--with-timeout=TIMEOUT Specify connect() timeout in seconds [10]
|
--with-timeout=TIMEOUT Specify connect() timeout in seconds [10]
|
||||||
--with-trustrevdns Trust reverse DNS information
|
--with-trustrevdns Trust reverse DNS information
|
||||||
--with-extmsgs Produce extended messages
|
--with-extmsgs Produce extended messages
|
||||||
|
--with-uds[=DIR]
|
||||||
|
Use Unix domain sockets for client/server
|
||||||
|
communication [/tmp/conserver]
|
||||||
--with-libwrap[=PATH]
|
--with-libwrap[=PATH]
|
||||||
Compile in libwrap (tcp_wrappers) support
|
Compile in libwrap (tcp_wrappers) support
|
||||||
--with-openssl[=PATH]
|
--with-openssl[=PATH]
|
||||||
@ -1312,6 +1317,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ac_config_headers="$ac_config_headers config.h"
|
ac_config_headers="$ac_config_headers config.h"
|
||||||
|
|
||||||
@ -1428,6 +1434,47 @@ _ACEOF
|
|||||||
echo "${ECHO_T}'console'" >&6
|
echo "${ECHO_T}'console'" >&6
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
|
echo "$as_me:$LINENO: checking for client configuration filename" >&5
|
||||||
|
echo $ECHO_N "checking for client configuration filename... $ECHO_C" >&6
|
||||||
|
|
||||||
|
# Check whether --with-ccffile or --without-ccffile was given.
|
||||||
|
if test "${with_ccffile+set}" = set; then
|
||||||
|
withval="$with_ccffile"
|
||||||
|
case "$withval" in
|
||||||
|
yes|no)
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define CLIENTCONFIGFILE SYSCONFDIR "/console.cf"
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
echo "$as_me:$LINENO: result: '$sysconfdir/console.cf'" >&5
|
||||||
|
echo "${ECHO_T}'$sysconfdir/console.cf'" >&6
|
||||||
|
;;
|
||||||
|
[\\/]* | ?:[\\/]* )
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define CLIENTCONFIGFILE "$withval"
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
echo "$as_me:$LINENO: result: '$withval'" >&5
|
||||||
|
echo "${ECHO_T}'$withval'" >&6
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define CLIENTCONFIGFILE SYSCONFDIR "/$withval"
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
echo "$as_me:$LINENO: result: '$sysconfdir/$withval'" >&5
|
||||||
|
echo "${ECHO_T}'$sysconfdir/$withval'" >&6
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define CLIENTCONFIGFILE SYSCONFDIR "/console.cf"
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
echo "$as_me:$LINENO: result: '$sysconfdir/console.cf'" >&5
|
||||||
|
echo "${ECHO_T}'$sysconfdir/console.cf'" >&6
|
||||||
|
fi;
|
||||||
|
|
||||||
echo "$as_me:$LINENO: checking for configuration filename" >&5
|
echo "$as_me:$LINENO: checking for configuration filename" >&5
|
||||||
echo $ECHO_N "checking for configuration filename... $ECHO_C" >&6
|
echo $ECHO_N "checking for configuration filename... $ECHO_C" >&6
|
||||||
|
|
||||||
@ -1692,6 +1739,56 @@ else
|
|||||||
echo "${ECHO_T}no" >&6
|
echo "${ECHO_T}no" >&6
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
|
echo "$as_me:$LINENO: checking whether to use Unix domain sockets" >&5
|
||||||
|
echo $ECHO_N "checking whether to use Unix domain sockets... $ECHO_C" >&6
|
||||||
|
cons_with_uds="NO"
|
||||||
|
|
||||||
|
# Check whether --with-uds or --without-uds was given.
|
||||||
|
if test "${with_uds+set}" = set; then
|
||||||
|
withval="$with_uds"
|
||||||
|
case "$withval" in
|
||||||
|
yes)
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define UDSDIR "/tmp/conserver"
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define USE_UNIX_DOMAIN_SOCKETS 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
echo "$as_me:$LINENO: result: /tmp/conserver" >&5
|
||||||
|
echo "${ECHO_T}/tmp/conserver" >&6
|
||||||
|
cons_with_uds="YES"
|
||||||
|
;;
|
||||||
|
no)
|
||||||
|
echo "$as_me:$LINENO: result: no" >&5
|
||||||
|
echo "${ECHO_T}no" >&6
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define UDSDIR "$withval"
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
cat >>confdefs.h <<\_ACEOF
|
||||||
|
#define USE_UNIX_DOMAIN_SOCKETS 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
|
echo "$as_me:$LINENO: result: '$withval'" >&5
|
||||||
|
echo "${ECHO_T}'$withval'" >&6
|
||||||
|
cons_with_uds="YES"
|
||||||
|
if expr "$withval" : '/' >/dev/null 2>&1; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo "*** WARNING *** you may have better success using a fully-qualified path"
|
||||||
|
echo "*** WARNING *** instead of '$withval'"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo "$as_me:$LINENO: result: no" >&5
|
||||||
|
echo "${ECHO_T}no" >&6
|
||||||
|
fi;
|
||||||
|
|
||||||
ac_ext=c
|
ac_ext=c
|
||||||
ac_cpp='$CPP $CPPFLAGS'
|
ac_cpp='$CPP $CPPFLAGS'
|
||||||
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
|
||||||
@ -5373,6 +5470,7 @@ fi
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cons_with_libwrap="NO"
|
||||||
|
|
||||||
# Check whether --with-libwrap or --without-libwrap was given.
|
# Check whether --with-libwrap or --without-libwrap was given.
|
||||||
if test "${with_libwrap+set}" = set; then
|
if test "${with_libwrap+set}" = set; then
|
||||||
@ -5576,6 +5674,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
|||||||
(exit $ac_status); }; }; then
|
(exit $ac_status); }; }; then
|
||||||
echo "$as_me:$LINENO: result: yes" >&5
|
echo "$as_me:$LINENO: result: yes" >&5
|
||||||
echo "${ECHO_T}yes" >&6
|
echo "${ECHO_T}yes" >&6
|
||||||
|
cons_with_libwrap="YES"
|
||||||
cat >>confdefs.h <<\_ACEOF
|
cat >>confdefs.h <<\_ACEOF
|
||||||
#define USE_LIBWRAP 1
|
#define USE_LIBWRAP 1
|
||||||
_ACEOF
|
_ACEOF
|
||||||
@ -5634,6 +5733,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
|||||||
(exit $ac_status); }; }; then
|
(exit $ac_status); }; }; then
|
||||||
echo "$as_me:$LINENO: result: yes" >&5
|
echo "$as_me:$LINENO: result: yes" >&5
|
||||||
echo "${ECHO_T}yes" >&6
|
echo "${ECHO_T}yes" >&6
|
||||||
|
cons_with_libwrap="YES"
|
||||||
cat >>confdefs.h <<\_ACEOF
|
cat >>confdefs.h <<\_ACEOF
|
||||||
#define USE_LIBWRAP 1
|
#define USE_LIBWRAP 1
|
||||||
_ACEOF
|
_ACEOF
|
||||||
@ -5663,6 +5763,7 @@ fi
|
|||||||
|
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
|
cons_with_openssl="NO"
|
||||||
|
|
||||||
# Check whether --with-openssl or --without-openssl was given.
|
# Check whether --with-openssl or --without-openssl was given.
|
||||||
if test "${with_openssl+set}" = set; then
|
if test "${with_openssl+set}" = set; then
|
||||||
@ -5865,6 +5966,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
|||||||
(exit $ac_status); }; }; then
|
(exit $ac_status); }; }; then
|
||||||
echo "$as_me:$LINENO: result: yes" >&5
|
echo "$as_me:$LINENO: result: yes" >&5
|
||||||
echo "${ECHO_T}yes" >&6
|
echo "${ECHO_T}yes" >&6
|
||||||
|
cons_with_openssl="YES"
|
||||||
cat >>confdefs.h <<\_ACEOF
|
cat >>confdefs.h <<\_ACEOF
|
||||||
#define HAVE_OPENSSL 1
|
#define HAVE_OPENSSL 1
|
||||||
_ACEOF
|
_ACEOF
|
||||||
@ -5892,6 +5994,7 @@ fi
|
|||||||
|
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
|
cons_with_dmalloc="NO"
|
||||||
|
|
||||||
# Check whether --with-dmalloc or --without-dmalloc was given.
|
# Check whether --with-dmalloc or --without-dmalloc was given.
|
||||||
if test "${with_dmalloc+set}" = set; then
|
if test "${with_dmalloc+set}" = set; then
|
||||||
@ -6094,6 +6197,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
|||||||
(exit $ac_status); }; }; then
|
(exit $ac_status); }; }; then
|
||||||
echo "$as_me:$LINENO: result: yes" >&5
|
echo "$as_me:$LINENO: result: yes" >&5
|
||||||
echo "${ECHO_T}yes" >&6
|
echo "${ECHO_T}yes" >&6
|
||||||
|
cons_with_dmalloc="YES"
|
||||||
cat >>confdefs.h <<\_ACEOF
|
cat >>confdefs.h <<\_ACEOF
|
||||||
#define HAVE_DMALLOC 1
|
#define HAVE_DMALLOC 1
|
||||||
_ACEOF
|
_ACEOF
|
||||||
@ -6124,6 +6228,7 @@ fi;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
cons_with_pam="NO"
|
||||||
echo "$as_me:$LINENO: checking for PAM support" >&5
|
echo "$as_me:$LINENO: checking for PAM support" >&5
|
||||||
echo $ECHO_N "checking for PAM support... $ECHO_C" >&6
|
echo $ECHO_N "checking for PAM support... $ECHO_C" >&6
|
||||||
|
|
||||||
@ -6320,6 +6425,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
|||||||
(exit $ac_status); }; }; then
|
(exit $ac_status); }; }; then
|
||||||
echo "$as_me:$LINENO: result: yes" >&5
|
echo "$as_me:$LINENO: result: yes" >&5
|
||||||
echo "${ECHO_T}yes" >&6
|
echo "${ECHO_T}yes" >&6
|
||||||
|
cons_with_pam="YES"
|
||||||
cat >>confdefs.h <<\_ACEOF
|
cat >>confdefs.h <<\_ACEOF
|
||||||
#define HAVE_PAM 1
|
#define HAVE_PAM 1
|
||||||
_ACEOF
|
_ACEOF
|
||||||
@ -6380,6 +6486,7 @@ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
|
|||||||
(exit $ac_status); }; }; then
|
(exit $ac_status); }; }; then
|
||||||
echo "$as_me:$LINENO: result: yes" >&5
|
echo "$as_me:$LINENO: result: yes" >&5
|
||||||
echo "${ECHO_T}yes" >&6
|
echo "${ECHO_T}yes" >&6
|
||||||
|
cons_with_pam="YES"
|
||||||
cat >>confdefs.h <<\_ACEOF
|
cat >>confdefs.h <<\_ACEOF
|
||||||
#define HAVE_PAM 1
|
#define HAVE_PAM 1
|
||||||
_ACEOF
|
_ACEOF
|
||||||
@ -8614,3 +8721,16 @@ if test "$no_create" != yes; then
|
|||||||
$ac_cs_success || { (exit 1); exit 1; }
|
$ac_cs_success || { (exit 1); exit 1; }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo "=============================================================="
|
||||||
|
echo " Feature Summary"
|
||||||
|
echo ""
|
||||||
|
echo " Unix domain sockets (--with-uds) : $cons_with_uds"
|
||||||
|
echo " TCP wrappers (--with-libwrap): $cons_with_libwrap"
|
||||||
|
echo " OpenSSL (--with-openssl): $cons_with_openssl"
|
||||||
|
echo " dmalloc (--with-dmalloc): $cons_with_dmalloc"
|
||||||
|
echo " PAM support (--with-pam) : $cons_with_pam"
|
||||||
|
echo ""
|
||||||
|
echo "=============================================================="
|
||||||
|
|
||||||
|
106
configure.in
106
configure.in
@ -4,6 +4,7 @@ AH_TEMPLATE([DEFPORT], [Socket used to communicate])
|
|||||||
AH_TEMPLATE([DEFBASEPORT], [Base socket used for secondary channel])
|
AH_TEMPLATE([DEFBASEPORT], [Base socket used for secondary channel])
|
||||||
AH_TEMPLATE([MASTERHOST], [Hostname of console server])
|
AH_TEMPLATE([MASTERHOST], [Hostname of console server])
|
||||||
AH_TEMPLATE([CONFIGFILE], [Config file path])
|
AH_TEMPLATE([CONFIGFILE], [Config file path])
|
||||||
|
AH_TEMPLATE([CLIENTCONFIGFILE], [Client config file path])
|
||||||
AH_TEMPLATE([PASSWDFILE], [Password file path])
|
AH_TEMPLATE([PASSWDFILE], [Password file path])
|
||||||
AH_TEMPLATE([LOGFILEPATH], [Logfile path])
|
AH_TEMPLATE([LOGFILEPATH], [Logfile path])
|
||||||
AH_TEMPLATE([MAXMEMB], [Number of consoles per child process])
|
AH_TEMPLATE([MAXMEMB], [Number of consoles per child process])
|
||||||
@ -17,9 +18,12 @@ AH_TEMPLATE([HAVE_DMALLOC], [have dmalloc support])
|
|||||||
AH_TEMPLATE([HAVE_SA_LEN],[Defined if sa_len member exists in struct sockaddr])
|
AH_TEMPLATE([HAVE_SA_LEN],[Defined if sa_len member exists in struct sockaddr])
|
||||||
AH_TEMPLATE([TRUST_REVERSE_DNS],[Defined if we trust reverse DNS])
|
AH_TEMPLATE([TRUST_REVERSE_DNS],[Defined if we trust reverse DNS])
|
||||||
AH_TEMPLATE([USE_EXTENDED_MESSAGES],[Defined if we produce extended messages])
|
AH_TEMPLATE([USE_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])
|
||||||
|
|
||||||
dnl ### Normal initialization. ######################################
|
dnl ### Normal initialization. ######################################
|
||||||
AC_INIT
|
AC_INIT
|
||||||
|
AC_PREREQ(2.59)
|
||||||
AC_CONFIG_SRCDIR([conserver/main.c])
|
AC_CONFIG_SRCDIR([conserver/main.c])
|
||||||
AC_CONFIG_HEADER(config.h)
|
AC_CONFIG_HEADER(config.h)
|
||||||
|
|
||||||
@ -49,7 +53,7 @@ dnl AC_MSG_RESULT($with_64bit)
|
|||||||
|
|
||||||
AC_MSG_CHECKING(for port number specification)
|
AC_MSG_CHECKING(for port number specification)
|
||||||
AC_ARG_WITH(port,
|
AC_ARG_WITH(port,
|
||||||
AC_HELP_STRING([--with-port=PORT],[Specify port number @<:@conserver@:>@]),
|
AS_HELP_STRING([--with-port=PORT],[Specify port number @<:@conserver@:>@]),
|
||||||
[case "$withval" in
|
[case "$withval" in
|
||||||
yes|no)
|
yes|no)
|
||||||
AC_DEFINE_UNQUOTED(DEFPORT, "conserver")
|
AC_DEFINE_UNQUOTED(DEFPORT, "conserver")
|
||||||
@ -65,7 +69,7 @@ AC_ARG_WITH(port,
|
|||||||
|
|
||||||
AC_MSG_CHECKING(for secondary channel base port)
|
AC_MSG_CHECKING(for secondary channel base port)
|
||||||
AC_ARG_WITH(base,
|
AC_ARG_WITH(base,
|
||||||
AC_HELP_STRING([--with-base=PORT], [Base port for secondary channel @<:@0@:>@]),
|
AS_HELP_STRING([--with-base=PORT], [Base port for secondary channel @<:@0@:>@]),
|
||||||
[case "$withval" in
|
[case "$withval" in
|
||||||
yes|no)
|
yes|no)
|
||||||
AC_DEFINE_UNQUOTED(DEFBASEPORT, "0")
|
AC_DEFINE_UNQUOTED(DEFBASEPORT, "0")
|
||||||
@ -81,7 +85,7 @@ AC_ARG_WITH(base,
|
|||||||
|
|
||||||
AC_MSG_CHECKING(for master conserver hostname)
|
AC_MSG_CHECKING(for master conserver hostname)
|
||||||
AC_ARG_WITH(master,
|
AC_ARG_WITH(master,
|
||||||
AC_HELP_STRING([--with-master=MASTER],[Specify master server hostname @<:@console@:>@]),
|
AS_HELP_STRING([--with-master=MASTER],[Specify master server hostname @<:@console@:>@]),
|
||||||
[case "$withval" in
|
[case "$withval" in
|
||||||
yes|no)
|
yes|no)
|
||||||
AC_DEFINE_UNQUOTED(MASTERHOST, "console")
|
AC_DEFINE_UNQUOTED(MASTERHOST, "console")
|
||||||
@ -95,9 +99,29 @@ AC_ARG_WITH(master,
|
|||||||
[AC_DEFINE_UNQUOTED(MASTERHOST, "console")
|
[AC_DEFINE_UNQUOTED(MASTERHOST, "console")
|
||||||
AC_MSG_RESULT('console')])
|
AC_MSG_RESULT('console')])
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(for client configuration filename)
|
||||||
|
AC_ARG_WITH(ccffile,
|
||||||
|
AS_HELP_STRING([--with-ccffile=CFFILE],[Specify client config filename @<:@SYSCONFDIR/console.cf@:>@]),
|
||||||
|
[case "$withval" in
|
||||||
|
yes|no)
|
||||||
|
AC_DEFINE_UNQUOTED(CLIENTCONFIGFILE, [SYSCONFDIR "/console.cf"])
|
||||||
|
AC_MSG_RESULT('$sysconfdir/console.cf')
|
||||||
|
;;
|
||||||
|
[[\\/]]* | ?:[[\\/]]* )
|
||||||
|
AC_DEFINE_UNQUOTED(CLIENTCONFIGFILE, ["$withval"])
|
||||||
|
AC_MSG_RESULT('$withval')
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_DEFINE_UNQUOTED(CLIENTCONFIGFILE, [SYSCONFDIR "/$withval"])
|
||||||
|
AC_MSG_RESULT('$sysconfdir/$withval')
|
||||||
|
;;
|
||||||
|
esac],
|
||||||
|
[AC_DEFINE_UNQUOTED(CLIENTCONFIGFILE, [SYSCONFDIR "/console.cf"])
|
||||||
|
AC_MSG_RESULT('$sysconfdir/console.cf')])
|
||||||
|
|
||||||
AC_MSG_CHECKING(for configuration filename)
|
AC_MSG_CHECKING(for configuration filename)
|
||||||
AC_ARG_WITH(cffile,
|
AC_ARG_WITH(cffile,
|
||||||
AC_HELP_STRING([--with-cffile=CFFILE],[Specify config filename @<:@SYSCONFDIR/conserver.cf@:>@]),
|
AS_HELP_STRING([--with-cffile=CFFILE],[Specify config filename @<:@SYSCONFDIR/conserver.cf@:>@]),
|
||||||
[case "$withval" in
|
[case "$withval" in
|
||||||
yes|no)
|
yes|no)
|
||||||
AC_DEFINE_UNQUOTED(CONFIGFILE, [SYSCONFDIR "/conserver.cf"])
|
AC_DEFINE_UNQUOTED(CONFIGFILE, [SYSCONFDIR "/conserver.cf"])
|
||||||
@ -117,7 +141,7 @@ AC_ARG_WITH(cffile,
|
|||||||
|
|
||||||
AC_MSG_CHECKING(for password filename)
|
AC_MSG_CHECKING(for password filename)
|
||||||
AC_ARG_WITH(pwdfile,
|
AC_ARG_WITH(pwdfile,
|
||||||
AC_HELP_STRING([--with-pwdfile=PWDFILE],[Specify password filename @<:@SYSCONFDIR/conserver.passwd@:>@]),
|
AS_HELP_STRING([--with-pwdfile=PWDFILE],[Specify password filename @<:@SYSCONFDIR/conserver.passwd@:>@]),
|
||||||
[case "$withval" in
|
[case "$withval" in
|
||||||
yes|no)
|
yes|no)
|
||||||
AC_DEFINE_UNQUOTED(PASSWDFILE, [SYSCONFDIR "/conserver.passwd"])
|
AC_DEFINE_UNQUOTED(PASSWDFILE, [SYSCONFDIR "/conserver.passwd"])
|
||||||
@ -137,7 +161,7 @@ AC_ARG_WITH(pwdfile,
|
|||||||
|
|
||||||
AC_MSG_CHECKING(for log filename)
|
AC_MSG_CHECKING(for log filename)
|
||||||
AC_ARG_WITH(logfile,
|
AC_ARG_WITH(logfile,
|
||||||
AC_HELP_STRING([--with-logfile=LOGFILE],[Specify log filename @<:@/var/log/conserver@:>@]),
|
AS_HELP_STRING([--with-logfile=LOGFILE],[Specify log filename @<:@/var/log/conserver@:>@]),
|
||||||
[case "$withval" in
|
[case "$withval" in
|
||||||
yes|no)
|
yes|no)
|
||||||
AC_DEFINE_UNQUOTED(LOGFILEPATH, "/var/log/conserver")
|
AC_DEFINE_UNQUOTED(LOGFILEPATH, "/var/log/conserver")
|
||||||
@ -154,7 +178,7 @@ AC_ARG_WITH(logfile,
|
|||||||
AC_SUBST(PIDFILE)
|
AC_SUBST(PIDFILE)
|
||||||
AC_MSG_CHECKING(for PID filename)
|
AC_MSG_CHECKING(for PID filename)
|
||||||
AC_ARG_WITH(pidfile,
|
AC_ARG_WITH(pidfile,
|
||||||
AC_HELP_STRING([--with-pidfile=PIDFILE],[Specify PID filepath @<:@/var/run/conserver.pid@:>@]),
|
AS_HELP_STRING([--with-pidfile=PIDFILE],[Specify PID filepath @<:@/var/run/conserver.pid@:>@]),
|
||||||
[case "$withval" in
|
[case "$withval" in
|
||||||
yes|no)
|
yes|no)
|
||||||
PIDFILE="/var/run/conserver.pid"
|
PIDFILE="/var/run/conserver.pid"
|
||||||
@ -169,7 +193,7 @@ AC_MSG_RESULT('$PIDFILE')
|
|||||||
|
|
||||||
AC_MSG_CHECKING(for MAXMEMB setting)
|
AC_MSG_CHECKING(for MAXMEMB setting)
|
||||||
AC_ARG_WITH(maxmemb,
|
AC_ARG_WITH(maxmemb,
|
||||||
AC_HELP_STRING([--with-maxmemb=MAXMEMB],[Specify maximum consoles per process @<:@16@:>@]),
|
AS_HELP_STRING([--with-maxmemb=MAXMEMB],[Specify maximum consoles per process @<:@16@:>@]),
|
||||||
[case "$withval" in
|
[case "$withval" in
|
||||||
yes|no)
|
yes|no)
|
||||||
AC_DEFINE_UNQUOTED(MAXMEMB, 16)
|
AC_DEFINE_UNQUOTED(MAXMEMB, 16)
|
||||||
@ -191,7 +215,7 @@ AC_ARG_WITH(maxmemb,
|
|||||||
|
|
||||||
AC_MSG_CHECKING(for connect() timeout)
|
AC_MSG_CHECKING(for connect() timeout)
|
||||||
AC_ARG_WITH(timeout,
|
AC_ARG_WITH(timeout,
|
||||||
AC_HELP_STRING([--with-timeout=TIMEOUT],[Specify connect() timeout in seconds @<:@10@:>@]),
|
AS_HELP_STRING([--with-timeout=TIMEOUT],[Specify connect() timeout in seconds @<:@10@:>@]),
|
||||||
[if expr "$withval" : '[[0-9]]*$' >/dev/null 2>&1 &&
|
[if expr "$withval" : '[[0-9]]*$' >/dev/null 2>&1 &&
|
||||||
test "$withval" -gt 0 -a "$withval" -lt 300; then
|
test "$withval" -gt 0 -a "$withval" -lt 300; then
|
||||||
AC_DEFINE_UNQUOTED(CONNECTTIMEOUT, $withval)
|
AC_DEFINE_UNQUOTED(CONNECTTIMEOUT, $withval)
|
||||||
@ -205,7 +229,7 @@ AC_ARG_WITH(timeout,
|
|||||||
|
|
||||||
AC_MSG_CHECKING(whether to trust reverse DNS)
|
AC_MSG_CHECKING(whether to trust reverse DNS)
|
||||||
AC_ARG_WITH(trustrevdns,
|
AC_ARG_WITH(trustrevdns,
|
||||||
AC_HELP_STRING([--with-trustrevdns],[Trust reverse DNS information]),
|
AS_HELP_STRING([--with-trustrevdns],[Trust reverse DNS information]),
|
||||||
[case "$withval" in
|
[case "$withval" in
|
||||||
yes)
|
yes)
|
||||||
AC_DEFINE(TRUST_REVERSE_DNS)
|
AC_DEFINE(TRUST_REVERSE_DNS)
|
||||||
@ -218,7 +242,7 @@ AC_ARG_WITH(trustrevdns,
|
|||||||
|
|
||||||
AC_MSG_CHECKING(whether to display extended messages)
|
AC_MSG_CHECKING(whether to display extended messages)
|
||||||
AC_ARG_WITH(extmsgs,
|
AC_ARG_WITH(extmsgs,
|
||||||
AC_HELP_STRING([--with-extmsgs],[Produce extended messages]),
|
AS_HELP_STRING([--with-extmsgs],[Produce extended messages]),
|
||||||
[case "$withval" in
|
[case "$withval" in
|
||||||
yes)
|
yes)
|
||||||
AC_DEFINE(USE_EXTENDED_MESSAGES)
|
AC_DEFINE(USE_EXTENDED_MESSAGES)
|
||||||
@ -229,6 +253,35 @@ AC_ARG_WITH(extmsgs,
|
|||||||
;;
|
;;
|
||||||
esac],[AC_MSG_RESULT(no)])
|
esac],[AC_MSG_RESULT(no)])
|
||||||
|
|
||||||
|
AC_MSG_CHECKING(whether to use Unix domain sockets)
|
||||||
|
cons_with_uds="NO"
|
||||||
|
AC_ARG_WITH(uds,
|
||||||
|
AS_HELP_STRING([--with-uds@<:@=DIR@:>@ ],
|
||||||
|
[Use Unix domain sockets for client/server communication @<:@/tmp/conserver@:>@]),
|
||||||
|
[case "$withval" in
|
||||||
|
yes)
|
||||||
|
AC_DEFINE_UNQUOTED(UDSDIR, "/tmp/conserver")
|
||||||
|
AC_DEFINE(USE_UNIX_DOMAIN_SOCKETS)
|
||||||
|
AC_MSG_RESULT([/tmp/conserver])
|
||||||
|
cons_with_uds="YES"
|
||||||
|
;;
|
||||||
|
no)
|
||||||
|
AC_MSG_RESULT(no)
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
AC_DEFINE_UNQUOTED(UDSDIR, "$withval")
|
||||||
|
AC_DEFINE(USE_UNIX_DOMAIN_SOCKETS)
|
||||||
|
AC_MSG_RESULT('$withval')
|
||||||
|
cons_with_uds="YES"
|
||||||
|
if expr "$withval" : '/' >/dev/null 2>&1; then
|
||||||
|
:
|
||||||
|
else
|
||||||
|
echo "*** WARNING *** you may have better success using a fully-qualified path"
|
||||||
|
echo "*** WARNING *** instead of '$withval'"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac],[AC_MSG_RESULT(no)])
|
||||||
|
|
||||||
dnl ### Check for compiler et al. ###################################
|
dnl ### Check for compiler et al. ###################################
|
||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
@ -314,8 +367,9 @@ AC_SEARCH_LIBS(crypt,crypt)
|
|||||||
AC_SUBST(CONSLIBS)
|
AC_SUBST(CONSLIBS)
|
||||||
AC_SUBST(CONSCPPFLAGS)
|
AC_SUBST(CONSCPPFLAGS)
|
||||||
AC_SUBST(CONSLDFLAGS)
|
AC_SUBST(CONSLDFLAGS)
|
||||||
|
cons_with_libwrap="NO"
|
||||||
AC_ARG_WITH(libwrap,
|
AC_ARG_WITH(libwrap,
|
||||||
AC_HELP_STRING([--with-libwrap@<:@=PATH@:>@],
|
AS_HELP_STRING([--with-libwrap@<:@=PATH@:>@],
|
||||||
[Compile in libwrap (tcp_wrappers) support]),
|
[Compile in libwrap (tcp_wrappers) support]),
|
||||||
[if test "$withval" != "no"; then
|
[if test "$withval" != "no"; then
|
||||||
if test "$withval" != "yes"; then
|
if test "$withval" != "yes"; then
|
||||||
@ -341,6 +395,7 @@ AC_ARG_WITH(libwrap,
|
|||||||
int deny_severity = 0;
|
int deny_severity = 0;
|
||||||
],[hosts_access((void *)0)],
|
],[hosts_access((void *)0)],
|
||||||
[AC_MSG_RESULT(yes)
|
[AC_MSG_RESULT(yes)
|
||||||
|
cons_with_libwrap="YES"
|
||||||
AC_DEFINE(USE_LIBWRAP)
|
AC_DEFINE(USE_LIBWRAP)
|
||||||
CONSLIBS="$CONSLIBS -lwrap"
|
CONSLIBS="$CONSLIBS -lwrap"
|
||||||
CONSLDFLAGS="$CONSLDFLAGS $WRAPLDFLAGS"
|
CONSLDFLAGS="$CONSLDFLAGS $WRAPLDFLAGS"
|
||||||
@ -353,6 +408,7 @@ AC_ARG_WITH(libwrap,
|
|||||||
int deny_severity = 0;
|
int deny_severity = 0;
|
||||||
],[hosts_access((void *)0)],
|
],[hosts_access((void *)0)],
|
||||||
[AC_MSG_RESULT(yes)
|
[AC_MSG_RESULT(yes)
|
||||||
|
cons_with_libwrap="YES"
|
||||||
AC_DEFINE(USE_LIBWRAP)
|
AC_DEFINE(USE_LIBWRAP)
|
||||||
CONSLIBS="$CONSLIBS -lwrap -lnsl"
|
CONSLIBS="$CONSLIBS -lwrap -lnsl"
|
||||||
CONSLDFLAGS="$CONSLDFLAGS $WRAPLDFLAGS"
|
CONSLDFLAGS="$CONSLDFLAGS $WRAPLDFLAGS"
|
||||||
@ -364,8 +420,9 @@ AC_ARG_WITH(libwrap,
|
|||||||
fi]
|
fi]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cons_with_openssl="NO"
|
||||||
AC_ARG_WITH(openssl,
|
AC_ARG_WITH(openssl,
|
||||||
AC_HELP_STRING([--with-openssl@<:@=PATH@:>@],
|
AS_HELP_STRING([--with-openssl@<:@=PATH@:>@],
|
||||||
[Compile in OpenSSL support]),
|
[Compile in OpenSSL support]),
|
||||||
[if test "$withval" != "no"; then
|
[if test "$withval" != "no"; then
|
||||||
if test "$withval" != "yes"; then
|
if test "$withval" != "yes"; then
|
||||||
@ -390,6 +447,7 @@ AC_ARG_WITH(openssl,
|
|||||||
AC_TRY_LINK([#include <openssl/ssl.h>
|
AC_TRY_LINK([#include <openssl/ssl.h>
|
||||||
],[SSL_library_init()],
|
],[SSL_library_init()],
|
||||||
[AC_MSG_RESULT(yes)
|
[AC_MSG_RESULT(yes)
|
||||||
|
cons_with_openssl="YES"
|
||||||
AC_DEFINE(HAVE_OPENSSL)
|
AC_DEFINE(HAVE_OPENSSL)
|
||||||
have_openssl=yes],
|
have_openssl=yes],
|
||||||
[AC_MSG_RESULT(no)])],)
|
[AC_MSG_RESULT(no)])],)
|
||||||
@ -402,8 +460,9 @@ AC_ARG_WITH(openssl,
|
|||||||
fi]
|
fi]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
cons_with_dmalloc="NO"
|
||||||
AC_ARG_WITH(dmalloc,
|
AC_ARG_WITH(dmalloc,
|
||||||
AC_HELP_STRING([--with-dmalloc@<:@=PATH@:>@],
|
AS_HELP_STRING([--with-dmalloc@<:@=PATH@:>@],
|
||||||
[Compile in dmalloc support]),
|
[Compile in dmalloc support]),
|
||||||
[if test "$withval" != "no"; then
|
[if test "$withval" != "no"; then
|
||||||
if test "$withval" != "yes"; then
|
if test "$withval" != "yes"; then
|
||||||
@ -428,6 +487,7 @@ AC_ARG_WITH(dmalloc,
|
|||||||
AC_TRY_LINK([#include <dmalloc.h>
|
AC_TRY_LINK([#include <dmalloc.h>
|
||||||
],[dmalloc_debug(0)],
|
],[dmalloc_debug(0)],
|
||||||
[AC_MSG_RESULT(yes)
|
[AC_MSG_RESULT(yes)
|
||||||
|
cons_with_dmalloc="YES"
|
||||||
AC_DEFINE(HAVE_DMALLOC)
|
AC_DEFINE(HAVE_DMALLOC)
|
||||||
have_dmalloc=yes],
|
have_dmalloc=yes],
|
||||||
[AC_MSG_RESULT(no)])],)
|
[AC_MSG_RESULT(no)])],)
|
||||||
@ -476,9 +536,10 @@ dnl else
|
|||||||
dnl AC_MSG_RESULT(no)
|
dnl AC_MSG_RESULT(no)
|
||||||
dnl fi],[AC_MSG_RESULT(no)])
|
dnl fi],[AC_MSG_RESULT(no)])
|
||||||
|
|
||||||
|
cons_with_pam="NO"
|
||||||
AC_MSG_CHECKING(for PAM support)
|
AC_MSG_CHECKING(for PAM support)
|
||||||
AC_ARG_WITH(pam,
|
AC_ARG_WITH(pam,
|
||||||
AC_HELP_STRING([--with-pam],
|
AS_HELP_STRING([--with-pam],
|
||||||
[Enable PAM support]),
|
[Enable PAM support]),
|
||||||
[if test "$withval" = yes; then
|
[if test "$withval" = yes; then
|
||||||
oLIBS="$LIBS"
|
oLIBS="$LIBS"
|
||||||
@ -488,6 +549,7 @@ AC_ARG_WITH(pam,
|
|||||||
AC_MSG_CHECKING(for PAM library -lpam)
|
AC_MSG_CHECKING(for PAM library -lpam)
|
||||||
AC_TRY_LINK_FUNC([pam_start],
|
AC_TRY_LINK_FUNC([pam_start],
|
||||||
[AC_MSG_RESULT(yes)
|
[AC_MSG_RESULT(yes)
|
||||||
|
cons_with_pam="YES"
|
||||||
AC_DEFINE(HAVE_PAM)
|
AC_DEFINE(HAVE_PAM)
|
||||||
CONSLIBS="$CONSLIBS -lpam"],
|
CONSLIBS="$CONSLIBS -lpam"],
|
||||||
[LIBS="$LIBS -ldl"
|
[LIBS="$LIBS -ldl"
|
||||||
@ -495,6 +557,7 @@ AC_ARG_WITH(pam,
|
|||||||
AC_MSG_CHECKING(for PAM library -lpam with -ldl)
|
AC_MSG_CHECKING(for PAM library -lpam with -ldl)
|
||||||
AC_TRY_LINK_FUNC([pam_end],
|
AC_TRY_LINK_FUNC([pam_end],
|
||||||
[AC_MSG_RESULT(yes)
|
[AC_MSG_RESULT(yes)
|
||||||
|
cons_with_pam="YES"
|
||||||
AC_DEFINE(HAVE_PAM)
|
AC_DEFINE(HAVE_PAM)
|
||||||
CONSLIBS="$CONSLIBS -lpam -ldl"],
|
CONSLIBS="$CONSLIBS -lpam -ldl"],
|
||||||
[AC_MSG_RESULT(no)])])],)
|
[AC_MSG_RESULT(no)])])],)
|
||||||
@ -537,3 +600,16 @@ dnl ### Create output files. #######################################
|
|||||||
AC_CONFIG_FILES([Makefile conserver/Makefile conserver.cf/Makefile console/Makefile autologin/Makefile contrib/chat/Makefile])
|
AC_CONFIG_FILES([Makefile conserver/Makefile conserver.cf/Makefile console/Makefile autologin/Makefile contrib/chat/Makefile])
|
||||||
AC_CONFIG_FILES([conserver/conserver.rc], [chmod +x conserver/conserver.rc])
|
AC_CONFIG_FILES([conserver/conserver.rc], [chmod +x conserver/conserver.rc])
|
||||||
AC_OUTPUT
|
AC_OUTPUT
|
||||||
|
|
||||||
|
[
|
||||||
|
echo "=============================================================="
|
||||||
|
echo " Feature Summary"
|
||||||
|
echo ""
|
||||||
|
echo " Unix domain sockets (--with-uds) : $cons_with_uds"
|
||||||
|
echo " TCP wrappers (--with-libwrap): $cons_with_libwrap"
|
||||||
|
echo " OpenSSL (--with-openssl): $cons_with_openssl"
|
||||||
|
echo " dmalloc (--with-dmalloc): $cons_with_dmalloc"
|
||||||
|
echo " PAM support (--with-pam) : $cons_with_pam"
|
||||||
|
echo ""
|
||||||
|
echo "=============================================================="
|
||||||
|
]
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
.\" $Id: conserver.cf.man,v 1.58 2004/02/24 02:59:36 bryan Exp $
|
.\" $Id: conserver.cf.man,v 1.63 2004/05/07 03:42:51 bryan Exp $
|
||||||
.TH CONSERVER.CF 5 "2004/02/24" "conserver-8.1.3" "conserver"
|
.TH CONSERVER.CF 5 "2004/05/07" "conserver-8.1.6" "conserver"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
conserver.cf \- console configuration file for
|
conserver.cf \- console configuration file for
|
||||||
.BR conserver (8)
|
.BR conserver (8)
|
||||||
@ -107,6 +107,24 @@ of things, we have:
|
|||||||
"defa"ult my\e defs { rw *; in\eclude "other defs" ; }
|
"defa"ult my\e defs { rw *; in\eclude "other defs" ; }
|
||||||
.fi
|
.fi
|
||||||
.ft
|
.ft
|
||||||
|
.PP
|
||||||
|
There is one special line the parser recognizes: a ``#include'' statement.
|
||||||
|
It is of the form:
|
||||||
|
.IP
|
||||||
|
.B #include
|
||||||
|
.I filename
|
||||||
|
.PP
|
||||||
|
Any whitespace around
|
||||||
|
.I filename
|
||||||
|
is ignored, but whitespace embedded inside is preserved.
|
||||||
|
Everything in
|
||||||
|
.I filename
|
||||||
|
is taken literally, so none of the normal parser quoting applies.
|
||||||
|
The
|
||||||
|
.B #include
|
||||||
|
must begin in ``column 0'' - no whitespace is allowed between it and
|
||||||
|
the start of the physical line.
|
||||||
|
There is an include file depth limit of 10 to prevent infinite recursion.
|
||||||
.SH BLOCKS
|
.SH BLOCKS
|
||||||
.TP 8
|
.TP 8
|
||||||
.B access
|
.B access
|
||||||
@ -123,7 +141,7 @@ fashion (top down), so order is important.
|
|||||||
.RS
|
.RS
|
||||||
.TP 15
|
.TP 15
|
||||||
.B admin
|
.B admin
|
||||||
.RI "[ [\fB!\fP]" username ,...
|
.RI "[ [\f3!\fP]" username ,...
|
||||||
| "" ]
|
| "" ]
|
||||||
.br
|
.br
|
||||||
Define a list of users making up the admin list for the console server.
|
Define a list of users making up the admin list for the console server.
|
||||||
@ -132,7 +150,18 @@ If
|
|||||||
matches a previously defined group name, all members of the previous
|
matches a previously defined group name, all members of the previous
|
||||||
group are applied to the admin list (with access reversed if prefixed
|
group are applied to the admin list (with access reversed if prefixed
|
||||||
with a `!').
|
with a `!').
|
||||||
Otherwise, users will be granted (or denied if prefixed with `!') access.
|
If
|
||||||
|
.I username
|
||||||
|
doesn't match a previously defined group and
|
||||||
|
.I username
|
||||||
|
begins with `@', the name (minus the `@') is checked against the
|
||||||
|
host's group database.
|
||||||
|
All users found in the group will be granted (or denied, if prefixed
|
||||||
|
with `!') access.
|
||||||
|
If
|
||||||
|
.I username
|
||||||
|
doesn't match a previous group and doesn't begin with `@', the users
|
||||||
|
will be granted (or denied, if prefixed with `!') access.
|
||||||
If the null string (``""'') is used, any
|
If the null string (``""'') is used, any
|
||||||
users previously defined for the console servers's admin list are removed.
|
users previously defined for the console servers's admin list are removed.
|
||||||
.TP
|
.TP
|
||||||
@ -264,7 +293,8 @@ all conserver hosts.
|
|||||||
.RS
|
.RS
|
||||||
.TP 15
|
.TP 15
|
||||||
.B defaultaccess
|
.B defaultaccess
|
||||||
.RB [ " rejected " | " trusted " | " allowed " ]
|
.RB [ " rejected " | " trusted "
|
||||||
|
.RB | " allowed " ]
|
||||||
.br
|
.br
|
||||||
Set the default access permission for all hosts not matched by
|
Set the default access permission for all hosts not matched by
|
||||||
an access list (see the
|
an access list (see the
|
||||||
@ -272,12 +302,41 @@ an access list (see the
|
|||||||
command-line flag).
|
command-line flag).
|
||||||
.TP
|
.TP
|
||||||
.B daemonmode
|
.B daemonmode
|
||||||
.RB [ " yes " | " true " | " on " | " no " | " false " | " off " ]
|
.RB [ " yes " | " true "
|
||||||
|
.RB | " on " | " no "
|
||||||
|
.RB | " false " | " off " ]
|
||||||
.br
|
.br
|
||||||
Set whether or not to become a daemon when run (see the
|
Set whether or not to become a daemon when run (see the
|
||||||
.B \-d
|
.B \-d
|
||||||
command-line flag).
|
command-line flag).
|
||||||
.TP
|
.TP
|
||||||
|
.B initdelay
|
||||||
|
.I number
|
||||||
|
.br
|
||||||
|
Set the number of seconds between console initializations.
|
||||||
|
All consoles with the same
|
||||||
|
.B host
|
||||||
|
value will be throttled as a group (those without a
|
||||||
|
.B host
|
||||||
|
value are their own group).
|
||||||
|
In other words, each console within a group will only be initialized after
|
||||||
|
.I number
|
||||||
|
seconds passes from the previous initialization of a console in that group.
|
||||||
|
Different throttle groups are initialized simultaneously.
|
||||||
|
One warning: since consoles are split up and managed by seperate conserver
|
||||||
|
processes, it's possible for more than one conserver process to
|
||||||
|
have a throttle group based on a particular
|
||||||
|
.B host
|
||||||
|
value.
|
||||||
|
If this happens, each conserver process will throttle their groups
|
||||||
|
independently of the other conserver processes, which results in a
|
||||||
|
more rapid initialization (per
|
||||||
|
.B host
|
||||||
|
value) than one might otherwise expect.
|
||||||
|
If
|
||||||
|
.I number
|
||||||
|
is zero, all consoles are initialized without delay.
|
||||||
|
.TP
|
||||||
.B logfile
|
.B logfile
|
||||||
.I filename
|
.I filename
|
||||||
.br
|
.br
|
||||||
@ -300,7 +359,9 @@ Set the port used by the master conserver process (see the
|
|||||||
command-line flag).
|
command-line flag).
|
||||||
.TP
|
.TP
|
||||||
.B redirect
|
.B redirect
|
||||||
.RB [ " yes " | " true " | " on " | " no " | " false " | " off " ]
|
.RB [ " yes " | " true "
|
||||||
|
.RB | " on " | " no "
|
||||||
|
.RB | " false " | " off " ]
|
||||||
.br
|
.br
|
||||||
Turn redirection on or off (see the
|
Turn redirection on or off (see the
|
||||||
.B \-R
|
.B \-R
|
||||||
@ -309,7 +370,7 @@ command-line flag).
|
|||||||
.B reinitcheck
|
.B reinitcheck
|
||||||
.I number
|
.I number
|
||||||
.br
|
.br
|
||||||
Set the number of seconds used between reinitialization checks (see the
|
Set the number of minutes used between reinitialization checks (see the
|
||||||
.B \-O
|
.B \-O
|
||||||
command-line flag).
|
command-line flag).
|
||||||
.TP
|
.TP
|
||||||
@ -321,7 +382,9 @@ Set the base port number used by child processes (see the
|
|||||||
command-line flag).
|
command-line flag).
|
||||||
.TP
|
.TP
|
||||||
.B setproctitle
|
.B setproctitle
|
||||||
.RB [ " yes " | " true " | " on " | " no " | " false " | " off " ]
|
.RB [ " yes " | " true "
|
||||||
|
.RB | " on " | " no "
|
||||||
|
.RB | " false " | " off " ]
|
||||||
.br
|
.br
|
||||||
Set whether or not the process title shows master/group functionality
|
Set whether or not the process title shows master/group functionality
|
||||||
as well as the port number the process is listening on and how many
|
as well as the port number the process is listening on and how many
|
||||||
@ -340,7 +403,9 @@ credentials file location (see the
|
|||||||
command-line flag).
|
command-line flag).
|
||||||
.TP
|
.TP
|
||||||
.B sslrequired
|
.B sslrequired
|
||||||
.RB [ " yes " | " true " | " on " | " no " | " false " | " off " ]
|
.RB [ " yes " | " true "
|
||||||
|
.RB | " on " | " no "
|
||||||
|
.RB | " false " | " off " ]
|
||||||
.br
|
.br
|
||||||
Set whether or not encryption is required when talking to clients (see the
|
Set whether or not encryption is required when talking to clients (see the
|
||||||
.B \-E
|
.B \-E
|
||||||
@ -388,8 +453,11 @@ of their definition).
|
|||||||
.RS
|
.RS
|
||||||
.TP 15
|
.TP 15
|
||||||
.B baud
|
.B baud
|
||||||
.RB [ " 300 " | " 600 " | " 1800 " | " 2400 " | " 4800"
|
.RB [ " 300 " | " 600 "
|
||||||
.RB | " 9600 " | " 19200 " | " 38400 " | " 57600 " | " 115200 " ]
|
.RB | " 1800 " | " 2400 "
|
||||||
|
.RB | " 4800 " | " 9600 "
|
||||||
|
.RB | " 19200 " | " 38400 "
|
||||||
|
.RB | " 57600 " | " 115200 " ]
|
||||||
.br
|
.br
|
||||||
Assign the baud rate to the console.
|
Assign the baud rate to the console.
|
||||||
Only consoles of type ``device'' will use this value.
|
Only consoles of type ``device'' will use this value.
|
||||||
@ -411,7 +479,7 @@ as the access to the console.
|
|||||||
Only consoles of type ``device'' will use this value.
|
Only consoles of type ``device'' will use this value.
|
||||||
.TP
|
.TP
|
||||||
.B devicesubst
|
.B devicesubst
|
||||||
.RI [ c = t [ n ] f "[,...]"
|
[\f2c\fP=\f2t\fP[\f2n\fP]\f2f\fP[,...]
|
||||||
| "" ]
|
| "" ]
|
||||||
.br
|
.br
|
||||||
Perform character substitutions on the
|
Perform character substitutions on the
|
||||||
@ -419,7 +487,7 @@ Perform character substitutions on the
|
|||||||
value.
|
value.
|
||||||
A series of replacements can be defined by specifying a
|
A series of replacements can be defined by specifying a
|
||||||
comma-separated list of
|
comma-separated list of
|
||||||
.IR c = t [ n ] f
|
\f2c\fP=\f2t\fP[\f2n\fP]\f2f\fP
|
||||||
sequences where
|
sequences where
|
||||||
.I c
|
.I c
|
||||||
is any printable character,
|
is any printable character,
|
||||||
@ -488,14 +556,14 @@ Assign the string
|
|||||||
.I command
|
.I command
|
||||||
as the command to access the console.
|
as the command to access the console.
|
||||||
Conserver will run the command by
|
Conserver will run the command by
|
||||||
invoking ``/bin/sh -ce "\fIcommand\fP"''.
|
invoking ``/bin/sh -ce "\f2command\fP"''.
|
||||||
If the null string (``""'') is used or no
|
If the null string (``""'') is used or no
|
||||||
.B exec
|
.B exec
|
||||||
keyword is specified, conserver will use the command ``/bin/sh -i''.
|
keyword is specified, conserver will use the command ``/bin/sh -i''.
|
||||||
Only consoles of type ``exec'' will use this value.
|
Only consoles of type ``exec'' will use this value.
|
||||||
.TP
|
.TP
|
||||||
.B execsubst
|
.B execsubst
|
||||||
.RI [ c = t [ n ] f "[,...]"
|
[\f2c\fP=\f2t\fP[\f2n\fP]\f2f\fP[,...]
|
||||||
| "" ]
|
| "" ]
|
||||||
.br
|
.br
|
||||||
Perform character substitutions on the
|
Perform character substitutions on the
|
||||||
@ -543,7 +611,7 @@ use the default delay time.
|
|||||||
The default string is ``\en''.
|
The default string is ``\en''.
|
||||||
.TP
|
.TP
|
||||||
.B idletimeout
|
.B idletimeout
|
||||||
.BR \fInumber\fP [ s | m | h ]
|
\f2number\fP[\f3s\fP|\f3m\fP|\f3h\fP]
|
||||||
.br
|
.br
|
||||||
Set the idle timeout of the console to
|
Set the idle timeout of the console to
|
||||||
.I number
|
.I number
|
||||||
@ -577,7 +645,7 @@ If the null string (``""'') is used, the command is unset and
|
|||||||
nothing is invoked.
|
nothing is invoked.
|
||||||
.TP
|
.TP
|
||||||
.B initsubst
|
.B initsubst
|
||||||
.RI [ c = t [ n ] f "[,...]"
|
[\f2c\fP=\f2t\fP[\f2n\fP]\f2f\fP[,...]
|
||||||
| "" ]
|
| "" ]
|
||||||
.br
|
.br
|
||||||
Perform character substitutions on the
|
Perform character substitutions on the
|
||||||
@ -602,7 +670,7 @@ If the null string (``""'') is used, the logfile name is unset and
|
|||||||
no logging will occur.
|
no logging will occur.
|
||||||
.TP
|
.TP
|
||||||
.B logfilemax
|
.B logfilemax
|
||||||
.BR \fInumber\fP [ k | m ]
|
\f2number\fP[\f3k\fP|\f3m\fP]
|
||||||
.br
|
.br
|
||||||
Enable automatic rotation of
|
Enable automatic rotation of
|
||||||
.B logfile
|
.B logfile
|
||||||
@ -772,7 +840,9 @@ Default is
|
|||||||
.RE
|
.RE
|
||||||
.TP
|
.TP
|
||||||
.B parity
|
.B parity
|
||||||
.RB [ " even " | " mark " | " none " | " odd " | " space " ]
|
.RB [ " even " | " mark "
|
||||||
|
.RB | " none " | " odd "
|
||||||
|
.RB | " space " ]
|
||||||
.br
|
.br
|
||||||
Set the parity option for the console.
|
Set the parity option for the console.
|
||||||
Only consoles of type ``device'' will use this value.
|
Only consoles of type ``device'' will use this value.
|
||||||
@ -858,7 +928,7 @@ console option still applies when data is read by the server, and if enabled,
|
|||||||
can impact the encapsulation process.
|
can impact the encapsulation process.
|
||||||
.TP
|
.TP
|
||||||
.B ro
|
.B ro
|
||||||
.RI "[ [\fB!\fP]" username ,...
|
.RI "[ [\f3!\fP]" username ,...
|
||||||
| "" ]
|
| "" ]
|
||||||
.br
|
.br
|
||||||
Define a list of users making up the read-only access list
|
Define a list of users making up the read-only access list
|
||||||
@ -868,13 +938,23 @@ If
|
|||||||
matches a previously defined group name, all members of the previous
|
matches a previously defined group name, all members of the previous
|
||||||
group are applied to the read-only access list (with access reversed
|
group are applied to the read-only access list (with access reversed
|
||||||
if prefixed with a `!').
|
if prefixed with a `!').
|
||||||
Otherwise, users will be granted (or denied if prefixed with `!')
|
If
|
||||||
read-only access.
|
.I username
|
||||||
|
doesn't match a previously defined group and
|
||||||
|
.I username
|
||||||
|
begins with `@', the name (minus the `@') is checked against the
|
||||||
|
host's group database.
|
||||||
|
All users found in the group will be granted (or denied, if prefixed
|
||||||
|
with `!') read-only access.
|
||||||
|
If
|
||||||
|
.I username
|
||||||
|
doesn't match a previous group and doesn't begin with `@', the users
|
||||||
|
will be granted (or denied, if prefixed with `!') read-only access.
|
||||||
If the null string (``""'') is used, any
|
If the null string (``""'') is used, any
|
||||||
users previously defined for the console's read-only list are removed.
|
users previously defined for the console's read-only list are removed.
|
||||||
.TP
|
.TP
|
||||||
.B rw
|
.B rw
|
||||||
.RI "[ [\fB!\fP]" username ,...
|
.RI "[ [\f3!\fP]" username ,...
|
||||||
| "" ]
|
| "" ]
|
||||||
.br
|
.br
|
||||||
Define a list of users making up the read-write access list
|
Define a list of users making up the read-write access list
|
||||||
@ -884,14 +964,24 @@ If
|
|||||||
matches a previously defined group name, all members of the previous
|
matches a previously defined group name, all members of the previous
|
||||||
group are applied to the read-write access list (with access reversed
|
group are applied to the read-write access list (with access reversed
|
||||||
if prefixed with a `!').
|
if prefixed with a `!').
|
||||||
Otherwise, users will be granted (or denied if prefixed with `!')
|
If
|
||||||
read-write access.
|
.I username
|
||||||
|
doesn't match a previously defined group and
|
||||||
|
.I username
|
||||||
|
begins with `@', the name (minus the `@') is checked against the
|
||||||
|
host's group database.
|
||||||
|
All users found in the group will be granted (or denied, if prefixed
|
||||||
|
with `!') read-write access.
|
||||||
|
If
|
||||||
|
.I username
|
||||||
|
doesn't match a previous group and doesn't begin with `@', the users
|
||||||
|
will be granted (or denied, if prefixed with `!') read-write access.
|
||||||
If the null string (``""'') is used, any
|
If the null string (``""'') is used, any
|
||||||
users previously defined for the console's read-write list are removed.
|
users previously defined for the console's read-write list are removed.
|
||||||
.TP
|
.TP
|
||||||
.B timestamp
|
.B timestamp
|
||||||
[
|
[
|
||||||
.RB [ \fInumber\fP [ m | h | d | l ]][ a ][ b ]
|
[\f2number\fP[\f3m\fP|\f3h\fP|\f3d\fP|\f3l\fP]][\f3a\fP][\f3b\fP]
|
||||||
| "" ]
|
| "" ]
|
||||||
.br
|
.br
|
||||||
Specifies the time between timestamps applied to the console
|
Specifies the time between timestamps applied to the console
|
||||||
@ -922,7 +1012,8 @@ A
|
|||||||
can be specified to add logging of break sequences sent to the console.
|
can be specified to add logging of break sequences sent to the console.
|
||||||
.TP
|
.TP
|
||||||
.B type
|
.B type
|
||||||
.RB [ " device " | " exec " | " host " ]
|
.RB [ " device " | " exec "
|
||||||
|
.RB | " host " ]
|
||||||
.br
|
.br
|
||||||
Set the type of console.
|
Set the type of console.
|
||||||
The type
|
The type
|
||||||
@ -951,7 +1042,7 @@ Define a user group identified as
|
|||||||
.RS
|
.RS
|
||||||
.TP 15
|
.TP 15
|
||||||
.B users
|
.B users
|
||||||
.RI "[ [\fB!\fP]" username ,...
|
.RI "[ [\f3!\fP]" username ,...
|
||||||
| "" ]
|
| "" ]
|
||||||
.br
|
.br
|
||||||
Define a list of users making up the group
|
Define a list of users making up the group
|
||||||
@ -961,8 +1052,18 @@ If
|
|||||||
matches a previously defined group name, all members of the previous
|
matches a previously defined group name, all members of the previous
|
||||||
group are applied to the current group (with access reversed
|
group are applied to the current group (with access reversed
|
||||||
if prefixed with a `!').
|
if prefixed with a `!').
|
||||||
Otherwise, users will be recorded with (or without if prefixed with `!')
|
If
|
||||||
access.
|
.I username
|
||||||
|
doesn't match a previously defined group and
|
||||||
|
.I username
|
||||||
|
begins with `@', the name (minus the `@') is checked against the
|
||||||
|
host's group database.
|
||||||
|
All users found in the group will be recorded with (or without, if prefixed
|
||||||
|
with `!') access.
|
||||||
|
If
|
||||||
|
.I username
|
||||||
|
doesn't match a previous group and doesn't begin with `@', the users
|
||||||
|
will be recorded with (or without, if prefixed with `!') access.
|
||||||
If the null string (``""'') is used, any
|
If the null string (``""'') is used, any
|
||||||
users previously defined for this group are removed.
|
users previously defined for this group are removed.
|
||||||
.RE
|
.RE
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
.\" $Id: conserver.passwd.man,v 1.10 2004/01/08 16:12:33 bryan Exp $
|
.\" $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.3" "conserver"
|
.TH CONSERVER.PASSWD 5 "2004/01/08" "conserver-8.1.6" "conserver"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
conserver.passwd \- user access information for
|
conserver.passwd \- user access information for
|
||||||
.BR conserver (8)
|
.BR conserver (8)
|
||||||
|
@ -181,11 +181,11 @@
|
|||||||
|
|
||||||
<H3>Downloading</H3>
|
<H3>Downloading</H3>
|
||||||
|
|
||||||
<P>The current version, released on Mar 22, 2004, is <A
|
<P>The current version, released on May 25, 2004, is <A
|
||||||
href="8.1.3.tar.gz">8.1.3.tar.gz</A>. You can get it via
|
href="8.1.6.tar.gz">8.1.6.tar.gz</A>. You can get it via
|
||||||
<A href=
|
<A href=
|
||||||
"ftp://ftp.conserver.com/conserver/8.1.3.tar.gz">FTP</A>
|
"ftp://ftp.conserver.com/conserver/8.1.6.tar.gz">FTP</A>
|
||||||
or <A href="8.1.3.tar.gz">HTTP</A>. See the <A href=
|
or <A href="8.1.6.tar.gz">HTTP</A>. See the <A href=
|
||||||
"CHANGES">CHANGES</A> file for information on the latest
|
"CHANGES">CHANGES</A> file for information on the latest
|
||||||
updates.</P>
|
updates.</P>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: access.c,v 5.71 2003/11/20 13:56:38 bryan Exp $
|
* $Id: access.c,v 5.73 2004/05/23 16:44:25 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -171,7 +171,8 @@ AccType(addr, peername)
|
|||||||
hname = he->h_aliases[a++]) {
|
hname = he->h_aliases[a++]) {
|
||||||
if ((revNames[a] = StrDup(hname)) == (char *)0)
|
if ((revNames[a] = StrDup(hname)) == (char *)0)
|
||||||
break;
|
break;
|
||||||
CONDDEBUG((1,"AccType(): revNames[%d]='%s'", a, hname));
|
CONDDEBUG((1, "AccType(): revNames[%d]='%s'", a,
|
||||||
|
hname));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -280,11 +281,26 @@ SetDefAccess(pAddr, pHost)
|
|||||||
char *pHost;
|
char *pHost;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
char *pcDomain;
|
|
||||||
char *addr;
|
|
||||||
ACCESS *a;
|
ACCESS *a;
|
||||||
|
|
||||||
|
while (pACList != (ACCESS *)0) {
|
||||||
|
a = pACList->pACnext;
|
||||||
|
DestroyAccessList(pACList);
|
||||||
|
pACList = a;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
if ((pACList = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0)
|
||||||
|
OutOfMem();
|
||||||
|
if ((pACList->pcwho = StrDup("127.0.0.1")) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
pACList->ctrust = 'a';
|
||||||
|
CONDDEBUG((1, "SetDefAccess(): trust=%c, who=%s", pACList->ctrust,
|
||||||
|
pACList->pcwho));
|
||||||
|
#else
|
||||||
while (pAddr->s_addr != (in_addr_t) 0) {
|
while (pAddr->s_addr != (in_addr_t) 0) {
|
||||||
|
char *addr;
|
||||||
|
|
||||||
addr = inet_ntoa(*pAddr);
|
addr = inet_ntoa(*pAddr);
|
||||||
if ((a = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0)
|
if ((a = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0)
|
||||||
OutOfMem();
|
OutOfMem();
|
||||||
@ -298,21 +314,7 @@ SetDefAccess(pAddr, pHost)
|
|||||||
pACList->pcwho));
|
pACList->pcwho));
|
||||||
pAddr++;
|
pAddr++;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if ((char *)0 == (pcDomain = strchr(pHost, '.')))
|
|
||||||
return;
|
|
||||||
++pcDomain;
|
|
||||||
|
|
||||||
if ((a = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0)
|
|
||||||
OutOfMem();
|
|
||||||
if ((a->pcwho = StrDup(pcDomain)) == (char *)0)
|
|
||||||
OutOfMem();
|
|
||||||
a->ctrust = 'a';
|
|
||||||
a->pACnext = pACList;
|
|
||||||
pACList = a;
|
|
||||||
|
|
||||||
CONDDEBUG((1, "SetDefAccess(): trust=%c, who=%s", pACList->ctrust,
|
|
||||||
pACList->pcwho));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: client.c,v 5.81 2004/03/20 14:40:40 bryan Exp $
|
* $Id: client.c,v 5.83 2004/04/13 18:12:00 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -315,8 +315,7 @@ Replay(pCE, fdOut, iBack)
|
|||||||
if ((char *)0 != s) {
|
if ((char *)0 != s) {
|
||||||
*s = '\000';
|
*s = '\000';
|
||||||
}
|
}
|
||||||
FileWrite(fdOut, FLAGTRUE, lines[i].line->string,
|
FileWrite(fdOut, FLAGTRUE, lines[i].line->string, -1);
|
||||||
lines[i].line->used - 1);
|
|
||||||
FileWrite(fdOut, FLAGTRUE, " .. ", 4);
|
FileWrite(fdOut, FLAGTRUE, " .. ", 4);
|
||||||
|
|
||||||
/* build the end string by removing the leading "[-- MARK -- "
|
/* build the end string by removing the leading "[-- MARK -- "
|
||||||
@ -488,15 +487,31 @@ ClientAccessOk(pCL)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
char *peername = (char *)0;
|
char *peername = (char *)0;
|
||||||
|
int retval = 1;
|
||||||
|
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
struct in_addr addr;
|
||||||
|
|
||||||
|
# if HAVE_INET_ATON
|
||||||
|
inet_aton("127.0.0.1", &addr);
|
||||||
|
# else
|
||||||
|
addr.s_addr = inet_addr("127.0.0.1");
|
||||||
|
# endif
|
||||||
|
pCL->caccess = AccType(&addr, &peername);
|
||||||
|
if (pCL->caccess == 'r') {
|
||||||
|
FileWrite(pCL->fd, FLAGFALSE, "access from your host refused\r\n",
|
||||||
|
-1);
|
||||||
|
retval = 0;
|
||||||
|
}
|
||||||
|
#else
|
||||||
socklen_t so;
|
socklen_t so;
|
||||||
int cfd;
|
int cfd;
|
||||||
struct sockaddr_in in_port;
|
struct sockaddr_in in_port;
|
||||||
int retval = 1;
|
|
||||||
int getpeer = -1;
|
int getpeer = -1;
|
||||||
|
|
||||||
cfd = FileFDNum(pCL->fd);
|
cfd = FileFDNum(pCL->fd);
|
||||||
pCL->caccess = 'r';
|
pCL->caccess = 'r';
|
||||||
#if defined(USE_LIBWRAP)
|
# if defined(USE_LIBWRAP)
|
||||||
{
|
{
|
||||||
struct request_info request;
|
struct request_info request;
|
||||||
request_init(&request, RQ_DAEMON, progname, RQ_FILE, cfd, 0);
|
request_init(&request, RQ_DAEMON, progname, RQ_FILE, cfd, 0);
|
||||||
@ -508,7 +523,7 @@ ClientAccessOk(pCL)
|
|||||||
goto setpeer;
|
goto setpeer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
so = sizeof(in_port);
|
so = sizeof(in_port);
|
||||||
if (-1 ==
|
if (-1 ==
|
||||||
@ -523,16 +538,22 @@ ClientAccessOk(pCL)
|
|||||||
-1);
|
-1);
|
||||||
retval = 0;
|
retval = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
setpeer:
|
setpeer:
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pCL->peername != (STRING *)0) {
|
if (pCL->peername != (STRING *)0) {
|
||||||
BuildString((char *)0, pCL->peername);
|
BuildString((char *)0, pCL->peername);
|
||||||
if (peername != (char *)0)
|
if (peername != (char *)0)
|
||||||
BuildString(peername, pCL->peername);
|
BuildString(peername, pCL->peername);
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
else
|
||||||
|
BuildString("127.0.0.1", pCL->peername);
|
||||||
|
#else
|
||||||
else if (getpeer != -1)
|
else if (getpeer != -1)
|
||||||
BuildString(inet_ntoa(in_port.sin_addr), pCL->peername);
|
BuildString(inet_ntoa(in_port.sin_addr), pCL->peername);
|
||||||
else
|
else
|
||||||
BuildString("<unknown>", pCL->peername);
|
BuildString("<unknown>", pCL->peername);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (peername != (char *)0)
|
if (peername != (char *)0)
|
||||||
free(peername);
|
free(peername);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: consent.c,v 5.137 2004/02/20 14:58:13 bryan Exp $
|
* $Id: consent.c,v 5.138 2004/04/16 16:58:09 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -817,7 +817,7 @@ ConsInit(pCE)
|
|||||||
break;
|
break;
|
||||||
case DEVICE:
|
case DEVICE:
|
||||||
if (-1 ==
|
if (-1 ==
|
||||||
(cofile = open(pCE->device, O_RDWR | O_NDELAY, 0600))) {
|
(cofile = open(pCE->device, O_RDWR | O_NONBLOCK, 0600))) {
|
||||||
|
|
||||||
Error("[%s] open(%s): %s: forcing down", pCE->server,
|
Error("[%s] open(%s): %s: forcing down", pCE->server,
|
||||||
pCE->device, strerror(errno));
|
pCE->device, strerror(errno));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: consent.h,v 5.56 2004/02/20 14:58:14 bryan Exp $
|
* $Id: consent.h,v 5.57 2004/05/21 04:38:02 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -96,7 +96,7 @@ typedef struct consent { /* console information */
|
|||||||
unsigned short port; /* port number | portinc * port */
|
unsigned short port; /* port number | portinc * port */
|
||||||
unsigned short portbase; /* port base */
|
unsigned short portbase; /* port base */
|
||||||
unsigned short portinc; /* port increment */
|
unsigned short portinc; /* port increment */
|
||||||
unsigned short raw; /* raw or telnet protocol? */
|
FLAG raw; /* raw or telnet protocol? */
|
||||||
/* type == EXEC */
|
/* type == EXEC */
|
||||||
char *exec; /* exec command */
|
char *exec; /* exec command */
|
||||||
char *execsubst; /* exec substitution pattern */
|
char *execsubst; /* exec substitution pattern */
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
.\" @(#)conserver.8 01/06/91 OSU CIS; Thomas A. Fine
|
.\" @(#)conserver.8 01/06/91 OSU CIS; Thomas A. Fine
|
||||||
.\" $Id: conserver.man,v 1.43 2004/03/23 01:02:29 bryan Exp $
|
.\" $Id: conserver.man,v 1.47 2004/05/21 04:15:17 bryan Exp $
|
||||||
.TH CONSERVER 8 "2004/03/23" "conserver-8.1.3" "conserver"
|
.TH CONSERVER 8 "2004/05/21" "conserver-8.1.6" "conserver"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
conserver \- console server daemon
|
conserver \- console server daemon
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -11,7 +11,7 @@ conserver \- console server daemon
|
|||||||
.RB [ \-m
|
.RB [ \-m
|
||||||
.IR max ]
|
.IR max ]
|
||||||
.RB [ \-M
|
.RB [ \-M
|
||||||
.IR addr ]
|
.IR master ]
|
||||||
.RB [ \-p
|
.RB [ \-p
|
||||||
.IR port ]
|
.IR port ]
|
||||||
.RB [ \-b
|
.RB [ \-b
|
||||||
@ -50,7 +50,7 @@ knowledge of the distribution of consoles among servers.)
|
|||||||
.B Conserver
|
.B Conserver
|
||||||
forks a child for each group of consoles it must manage
|
forks a child for each group of consoles it must manage
|
||||||
and assigns each process a port number to listen on.
|
and assigns each process a port number to listen on.
|
||||||
The maximum number of consoles managed by each child process is set using
|
The maximum number of consoles managed by each child process is set using the
|
||||||
.B \-m
|
.B \-m
|
||||||
option.
|
option.
|
||||||
The
|
The
|
||||||
@ -76,14 +76,31 @@ the
|
|||||||
.BR conserver.cf (5)
|
.BR conserver.cf (5)
|
||||||
access list.
|
access list.
|
||||||
.PP
|
.PP
|
||||||
|
When Unix domain sockets are used between the client and
|
||||||
|
server (enabled using
|
||||||
|
.BR --with-uds ),
|
||||||
|
authentication checks are done on the hardcoded address ``127.0.0.1''.
|
||||||
|
Automatic client redirection is also disabled (as if the
|
||||||
|
.B \-R
|
||||||
|
option was used) since the client cannot communicate with remote servers.
|
||||||
|
The directory used to hold the sockets is checked to make sure it's empty
|
||||||
|
when the server starts.
|
||||||
|
The server will
|
||||||
|
.B not
|
||||||
|
remove any files in the directory itself, just in case the directory is
|
||||||
|
accidentally specified as ``/etc'' or some other critical location.
|
||||||
|
The server will do it's 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
|
||||||
|
up the directory before the server will start again.
|
||||||
|
.PP
|
||||||
.B Conserver
|
.B Conserver
|
||||||
completely controls any connection to a console.
|
completely controls any connection to a console.
|
||||||
All escape sequences given by the user to
|
All escape sequences given by the user to
|
||||||
.B console
|
.B console
|
||||||
are passed to the server without interpretation.
|
are passed to the server without interpretation.
|
||||||
The server recognizes and processes all escape sequences,
|
The server recognizes and processes all escape sequences.
|
||||||
The suspend sequence is recognized by the server and sent back to the
|
|
||||||
client as a TCP out-of-band command, which the client processes.
|
|
||||||
.PP
|
.PP
|
||||||
The
|
The
|
||||||
.B conserver
|
.B conserver
|
||||||
@ -217,7 +234,7 @@ option.
|
|||||||
.B \-d
|
.B \-d
|
||||||
Become a daemon.
|
Become a daemon.
|
||||||
Disconnects from the controlling terminal and sends
|
Disconnects from the controlling terminal and sends
|
||||||
all output to the logfile (see
|
all output (including any debug output) to the logfile (see
|
||||||
.BR \-L ).
|
.BR \-L ).
|
||||||
.TP
|
.TP
|
||||||
.B \-D
|
.B \-D
|
||||||
@ -271,11 +288,21 @@ may be changed at compile time using the
|
|||||||
.B --with-maxmemb
|
.B --with-maxmemb
|
||||||
option.
|
option.
|
||||||
.TP
|
.TP
|
||||||
.BI \-M addr
|
.BI \-M master
|
||||||
Set the address to listen on.
|
Normally, this allows conserver to bind to a
|
||||||
This allows conserver to bind to a
|
|
||||||
particular IP address (like `127.0.0.1') instead of all interfaces.
|
particular IP address (like `127.0.0.1') instead of all interfaces.
|
||||||
The default is to bind to all addresses.
|
The default is to bind to all addresses.
|
||||||
|
However, if
|
||||||
|
.B --with-uds
|
||||||
|
was used to enable Unix domain sockets for client/server communication,
|
||||||
|
this points conserver to the directory where it should store the sockets.
|
||||||
|
The default
|
||||||
|
.I master
|
||||||
|
directory
|
||||||
|
.RB (`` /tmp/conserver '')
|
||||||
|
may be changed at compile time using the
|
||||||
|
.B --with-uds
|
||||||
|
option.
|
||||||
.TP
|
.TP
|
||||||
.B \-n
|
.B \-n
|
||||||
Obsolete (now a no-op); see
|
Obsolete (now a no-op); see
|
||||||
@ -301,6 +328,9 @@ The default
|
|||||||
may be changed at compile time using the
|
may be changed at compile time using the
|
||||||
.B --with-port
|
.B --with-port
|
||||||
option.
|
option.
|
||||||
|
If the
|
||||||
|
.B --with-uds
|
||||||
|
option was used, this option is ignored.
|
||||||
.TP
|
.TP
|
||||||
.BI \-P passwd
|
.BI \-P passwd
|
||||||
Read the table of authorized user data from the file
|
Read the table of authorized user data from the file
|
||||||
@ -425,7 +455,7 @@ The following default file locations may be overridden
|
|||||||
at compile time or by the command-line options described above.
|
at compile time or by the command-line options described above.
|
||||||
Run
|
Run
|
||||||
.B conserver \-V
|
.B conserver \-V
|
||||||
(with no other options) to see the defaults set at compile time.
|
to see the defaults set at compile time.
|
||||||
.PP
|
.PP
|
||||||
.PD 0
|
.PD 0
|
||||||
.TP 25
|
.TP 25
|
||||||
@ -443,6 +473,9 @@ the master conserver process ID
|
|||||||
.TP
|
.TP
|
||||||
.B /var/log/conserver
|
.B /var/log/conserver
|
||||||
log of errors and informational messages
|
log of errors and informational messages
|
||||||
|
.TP
|
||||||
|
.B /tmp/conserver
|
||||||
|
directory to hold Unix domain sockets (if enabled)
|
||||||
.PD
|
.PD
|
||||||
.PP
|
.PP
|
||||||
Additionally, output from individual consoles may be logged
|
Additionally, output from individual consoles may be logged
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: convert.c,v 1.8 2003/11/20 13:56:38 bryan Exp $
|
* $Id: convert.c,v 1.9 2004/05/21 04:15:17 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -42,6 +42,10 @@
|
|||||||
#include <main.h>
|
#include <main.h>
|
||||||
|
|
||||||
|
|
||||||
|
SECTION sections[] = {
|
||||||
|
{(char *)0, (void *)0, (void *)0, (void *)0, (void *)0}
|
||||||
|
};
|
||||||
|
|
||||||
void
|
void
|
||||||
DestroyDataStructures()
|
DestroyDataStructures()
|
||||||
{
|
{
|
||||||
@ -139,7 +143,7 @@ ReadLine2(fp, save, iLine)
|
|||||||
if (!peek && (ret == (char *)0)) {
|
if (!peek && (ret == (char *)0)) {
|
||||||
(*iLine)++;
|
(*iLine)++;
|
||||||
wholeline = BuildString(bufstr->string, wholestr);
|
wholeline = BuildString(bufstr->string, wholestr);
|
||||||
if (wholeline[0] == '\000')
|
if (wholeline != (char *)0 && wholeline[0] == '\000')
|
||||||
wholeline = (char *)0;
|
wholeline = (char *)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: cutil.c,v 1.116 2004/03/19 05:23:21 bryan Exp $
|
* $Id: cutil.c,v 1.118 2004/05/25 00:38:15 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -10,6 +10,10 @@
|
|||||||
|
|
||||||
#include <cutil.h>
|
#include <cutil.h>
|
||||||
|
|
||||||
|
#include <net/if.h>
|
||||||
|
#if HAVE_SYS_SOCKIO_H
|
||||||
|
# include <sys/sockio.h>
|
||||||
|
#endif
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#endif
|
#endif
|
||||||
@ -29,6 +33,7 @@ fd_set winit;
|
|||||||
int maxfd = 0;
|
int maxfd = 0;
|
||||||
int debugLineNo = 0;
|
int debugLineNo = 0;
|
||||||
char *debugFileName = (char *)0;
|
char *debugFileName = (char *)0;
|
||||||
|
int isMaster = 1;
|
||||||
|
|
||||||
/* in the routines below (the init code) we can bomb if malloc fails (ksb)
|
/* in the routines below (the init code) we can bomb if malloc fails (ksb)
|
||||||
*/
|
*/
|
||||||
@ -2122,6 +2127,189 @@ PruneSpace(string)
|
|||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* fills the myAddrs array with host interface addresses */
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ProbeInterfaces(in_addr_t bindAddr)
|
||||||
|
#else
|
||||||
|
ProbeInterfaces(bindAddr)
|
||||||
|
in_addr_t bindAddr;
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
||||||
|
Error("ProbeInterfaces(): socket(): %s", strerror(errno));
|
||||||
|
Bye(EX_OSERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (bufsize) {
|
||||||
|
ifc.ifc_len = bufsize;
|
||||||
|
ifc.ifc_req = (struct ifreq *)malloc(ifc.ifc_len);
|
||||||
|
if (ifc.ifc_req == (struct ifreq *)0)
|
||||||
|
OutOfMem();
|
||||||
|
if (ioctl(sock, SIOCGIFCONF, &ifc) != 0) {
|
||||||
|
free(ifc.ifc_req);
|
||||||
|
close(sock);
|
||||||
|
Error("ProbeInterfaces(): ioctl(SIOCGIFCONF): %s",
|
||||||
|
strerror(errno));
|
||||||
|
Bye(EX_OSERR);
|
||||||
|
}
|
||||||
|
/* if the return size plus a 512 byte "buffer zone" is less than
|
||||||
|
* the buffer we passed in (bufsize), we're done. otherwise
|
||||||
|
* allocate a bigger buffer and try again. with a too-small
|
||||||
|
* buffer, some implementations (freebsd) will fill the buffer
|
||||||
|
* best it can (leaving a gap - returning <=bufsize) and others
|
||||||
|
* (linux) will return a buffer length the same size as passed
|
||||||
|
* in (==bufsize). so, we'll assume a 512 byte gap would have
|
||||||
|
* been big enough to put one more record and as long as we have
|
||||||
|
* that "buffer zone", we should have all the interfaces.
|
||||||
|
*/
|
||||||
|
if (ifc.ifc_len + 512 < bufsize)
|
||||||
|
break;
|
||||||
|
free(ifc.ifc_req);
|
||||||
|
bufsize += 2048;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* this is probably way overkill, but better to kill a few bytes
|
||||||
|
* than loop through looking for valid interfaces that are up
|
||||||
|
* twice, huh?
|
||||||
|
*/
|
||||||
|
count = ifc.ifc_len / sizeof(*ifr);
|
||||||
|
CONDDEBUG((1, "ProbeInterfaces(): ifc_len==%d max_count==%d",
|
||||||
|
ifc.ifc_len, count));
|
||||||
|
|
||||||
|
/* set up myAddrs array */
|
||||||
|
if (myAddrs != (struct in_addr *)0)
|
||||||
|
free(myAddrs);
|
||||||
|
myAddrs = (struct in_addr *)0;
|
||||||
|
if (count == 0) {
|
||||||
|
free(ifc.ifc_req);
|
||||||
|
close(sock);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
myAddrs = (struct in_addr *)calloc(count + 1, sizeof(struct in_addr));
|
||||||
|
if (myAddrs == (struct in_addr *)0)
|
||||||
|
OutOfMem();
|
||||||
|
|
||||||
|
for (m = r = 0; r < ifc.ifc_len;) {
|
||||||
|
struct sockaddr *sa;
|
||||||
|
ifr = (struct ifreq *)&ifc.ifc_buf[r];
|
||||||
|
sa = (struct sockaddr *)&ifr->ifr_addr;
|
||||||
|
/* don't use less than a ifreq sized chunk */
|
||||||
|
if ((ifc.ifc_len - r) < sizeof(*ifr))
|
||||||
|
break;
|
||||||
|
#ifdef HAVE_SA_LEN
|
||||||
|
if (sa->sa_len > sizeof(ifr->ifr_addr))
|
||||||
|
r += sizeof(ifr->ifr_name) + sa->sa_len;
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
r += sizeof(*ifr);
|
||||||
|
|
||||||
|
if (sa->sa_family == AF_INET) {
|
||||||
|
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
|
||||||
|
#ifdef SIOCGIFFLAGS
|
||||||
|
/* make sure the interface is up */
|
||||||
|
ifrcopy = *ifr;
|
||||||
|
if ((ioctl(sock, SIOCGIFFLAGS, &ifrcopy) == 0) &&
|
||||||
|
((ifrcopy.ifr_flags & IFF_UP) == 0))
|
||||||
|
continue;
|
||||||
|
#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
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
#if PROTOTYPES
|
#if PROTOTYPES
|
||||||
IsMe(char *id)
|
IsMe(char *id)
|
||||||
@ -2388,3 +2576,725 @@ ParseIACBuf(cfp, msg, len)
|
|||||||
}
|
}
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* the format of the file should be as follows
|
||||||
|
*
|
||||||
|
* <section keyword> [section name] {
|
||||||
|
* <item keyword> [item value];
|
||||||
|
* .
|
||||||
|
* .
|
||||||
|
* }
|
||||||
|
*
|
||||||
|
* whitespace gets retained in [section name], and [item value]
|
||||||
|
* values. for example,
|
||||||
|
*
|
||||||
|
* users bryan todd ;
|
||||||
|
*
|
||||||
|
* will give users the value of 'bryan todd'. the leading and
|
||||||
|
* trailing whitespace is nuked, but the middle stuff isn't.
|
||||||
|
*
|
||||||
|
* a little note about the 'state' var...
|
||||||
|
* START = before <section keyword>
|
||||||
|
* NAME = before [section name]
|
||||||
|
* LEFTB = before left curly brace
|
||||||
|
* KEY = before <item keyword>
|
||||||
|
* VALUE = before [item value]
|
||||||
|
* SEMI = before semi-colon
|
||||||
|
*/
|
||||||
|
|
||||||
|
typedef enum states {
|
||||||
|
START,
|
||||||
|
NAME,
|
||||||
|
LEFTB,
|
||||||
|
KEY,
|
||||||
|
VALUE,
|
||||||
|
SEMI
|
||||||
|
} STATES;
|
||||||
|
|
||||||
|
typedef enum tokens {
|
||||||
|
DONE,
|
||||||
|
LEFTBRACE,
|
||||||
|
RIGHTBRACE,
|
||||||
|
SEMICOLON,
|
||||||
|
WORD,
|
||||||
|
INCLUDE
|
||||||
|
} TOKEN;
|
||||||
|
|
||||||
|
int line = 1; /* current line number */
|
||||||
|
char *file = (char *)0;
|
||||||
|
|
||||||
|
TOKEN
|
||||||
|
#if PROTOTYPES
|
||||||
|
GetWord(FILE *fp, int *line, short spaceok, STRING *word)
|
||||||
|
#else
|
||||||
|
GetWord(fp, line, spaceok, word)
|
||||||
|
FILE *fp;
|
||||||
|
int *line;
|
||||||
|
short spaceok;
|
||||||
|
STRING *word;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
int c;
|
||||||
|
short backslash = 0;
|
||||||
|
short quote = 0;
|
||||||
|
short comment = 0;
|
||||||
|
short sawQuote = 0;
|
||||||
|
short quotedBackslash = 0;
|
||||||
|
char *include = "include";
|
||||||
|
short checkInc = -1;
|
||||||
|
/* checkInc == -3, saw #include
|
||||||
|
* == -2, saw nothin'
|
||||||
|
* == -1, saw \n or start of file
|
||||||
|
* == 0, saw "\n#"
|
||||||
|
*/
|
||||||
|
|
||||||
|
BuildString((char *)0, word);
|
||||||
|
while ((c = fgetc(fp)) != EOF) {
|
||||||
|
if (c == '\n') {
|
||||||
|
(*line)++;
|
||||||
|
if (checkInc == -2)
|
||||||
|
checkInc = -1;
|
||||||
|
}
|
||||||
|
if (comment) {
|
||||||
|
if (c == '\n')
|
||||||
|
comment = 0;
|
||||||
|
if (checkInc >= 0) {
|
||||||
|
if (include[checkInc] == '\000') {
|
||||||
|
if (isspace(c))
|
||||||
|
checkInc = -3;
|
||||||
|
} else if (c == include[checkInc])
|
||||||
|
checkInc++;
|
||||||
|
else
|
||||||
|
checkInc = -2;
|
||||||
|
} else if (checkInc == -3) {
|
||||||
|
static STRING *fname = (STRING *)0;
|
||||||
|
if (fname == (STRING *)0)
|
||||||
|
fname = AllocString();
|
||||||
|
if (fname->used != 0 || !isspace(c)) {
|
||||||
|
if (c == '\n') {
|
||||||
|
if (fname->used > 0) {
|
||||||
|
while (fname->used > 1 && isspace((int)
|
||||||
|
(fname->
|
||||||
|
string
|
||||||
|
[fname->
|
||||||
|
used -
|
||||||
|
2])))
|
||||||
|
fname->used--;
|
||||||
|
if (fname->used > 0)
|
||||||
|
fname->string[fname->used - 1] = '\000';
|
||||||
|
}
|
||||||
|
checkInc = -2;
|
||||||
|
if (fname->used > 0) {
|
||||||
|
BuildString((char *)0, word);
|
||||||
|
BuildString(fname->string, word);
|
||||||
|
BuildString((char *)0, fname);
|
||||||
|
return INCLUDE;
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
BuildStringChar(c, fname);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (backslash) {
|
||||||
|
BuildStringChar(c, word);
|
||||||
|
backslash = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (quote) {
|
||||||
|
if (c == '"') {
|
||||||
|
if (quotedBackslash) {
|
||||||
|
BuildStringChar(c, word);
|
||||||
|
quotedBackslash = 0;
|
||||||
|
} else
|
||||||
|
quote = 0;
|
||||||
|
} else {
|
||||||
|
if (quotedBackslash) {
|
||||||
|
BuildStringChar('\\', word);
|
||||||
|
quotedBackslash = 0;
|
||||||
|
}
|
||||||
|
if (c == '\\')
|
||||||
|
quotedBackslash = 1;
|
||||||
|
else
|
||||||
|
BuildStringChar(c, word);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (c == '\\') {
|
||||||
|
backslash = 1;
|
||||||
|
} else if (c == '#') {
|
||||||
|
comment = 1;
|
||||||
|
if (checkInc == -1)
|
||||||
|
checkInc = 0;
|
||||||
|
} else if (c == '"') {
|
||||||
|
quote = 1;
|
||||||
|
sawQuote = 1;
|
||||||
|
} else if (isspace(c)) {
|
||||||
|
if (word->used <= 1)
|
||||||
|
continue;
|
||||||
|
if (spaceok) {
|
||||||
|
BuildStringChar(c, word);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
gotword:
|
||||||
|
while (word->used > 1 &&
|
||||||
|
isspace((int)(word->string[word->used - 2])))
|
||||||
|
word->used--;
|
||||||
|
if (word->used > 0)
|
||||||
|
word->string[word->used - 1] = '\000';
|
||||||
|
return WORD;
|
||||||
|
} else if (c == '{') {
|
||||||
|
if (word->used <= 1 && !sawQuote) {
|
||||||
|
BuildStringChar(c, word);
|
||||||
|
return LEFTBRACE;
|
||||||
|
} else {
|
||||||
|
ungetc(c, fp);
|
||||||
|
goto gotword;
|
||||||
|
}
|
||||||
|
} else if (c == '}') {
|
||||||
|
if (word->used <= 1 && !sawQuote) {
|
||||||
|
BuildStringChar(c, word);
|
||||||
|
return RIGHTBRACE;
|
||||||
|
} else {
|
||||||
|
ungetc(c, fp);
|
||||||
|
goto gotword;
|
||||||
|
}
|
||||||
|
} else if (c == ';') {
|
||||||
|
if (word->used <= 1 && !sawQuote) {
|
||||||
|
BuildStringChar(c, word);
|
||||||
|
return SEMICOLON;
|
||||||
|
} else {
|
||||||
|
ungetc(c, fp);
|
||||||
|
goto gotword;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
BuildStringChar(c, word);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* this should only happen in rare cases */
|
||||||
|
if (quotedBackslash) {
|
||||||
|
BuildStringChar('\\', word);
|
||||||
|
quotedBackslash = 0;
|
||||||
|
}
|
||||||
|
/* if we saw "valid" data, it's a word */
|
||||||
|
if (word->used > 1 || sawQuote)
|
||||||
|
goto gotword;
|
||||||
|
return DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ParseFile(char *filename, FILE *fp, int level)
|
||||||
|
#else
|
||||||
|
ParseFile(filename, fp, level)
|
||||||
|
char *filename;
|
||||||
|
FILE *fp;
|
||||||
|
int level;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/* things that should be used between recursions */
|
||||||
|
static STATES state = START;
|
||||||
|
static STRING *word = (STRING *)0;
|
||||||
|
static short spaceok = 0;
|
||||||
|
static int secIndex = 0;
|
||||||
|
static int keyIndex = 0;
|
||||||
|
|
||||||
|
/* other stuff that's local to each recursion */
|
||||||
|
char *p;
|
||||||
|
TOKEN token = DONE;
|
||||||
|
int nextline = 1; /* "next" line number */
|
||||||
|
|
||||||
|
if (level >= 10) {
|
||||||
|
if (isMaster)
|
||||||
|
Error("ParseFile(): nesting too deep, not parsing `%s'",
|
||||||
|
filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set some globals */
|
||||||
|
line = 1;
|
||||||
|
file = filename;
|
||||||
|
|
||||||
|
/* if we're parsing the base file, set static vars */
|
||||||
|
if (level == 0) {
|
||||||
|
state = START;
|
||||||
|
spaceok = 0;
|
||||||
|
secIndex = 0;
|
||||||
|
keyIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialize local things */
|
||||||
|
if (word == (STRING *)0)
|
||||||
|
word = AllocString();
|
||||||
|
|
||||||
|
while ((token = GetWord(fp, &nextline, spaceok, word)) != DONE) {
|
||||||
|
if (token == INCLUDE) {
|
||||||
|
FILE *lfp;
|
||||||
|
if ((FILE *)0 == (lfp = fopen(word->string, "r"))) {
|
||||||
|
if (isMaster)
|
||||||
|
Error("ParseFile(): fopen(%s): %s", word->string,
|
||||||
|
strerror(errno));
|
||||||
|
} else {
|
||||||
|
char *fname;
|
||||||
|
/* word gets destroyed, so save the name */
|
||||||
|
fname = StrDup(word->string);
|
||||||
|
ParseFile(fname, lfp, level + 1);
|
||||||
|
fclose(lfp);
|
||||||
|
free(fname);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch (state) {
|
||||||
|
case START:
|
||||||
|
switch (token) {
|
||||||
|
case WORD:
|
||||||
|
for (secIndex = 0;
|
||||||
|
(p = sections[secIndex].id) != (char *)0;
|
||||||
|
secIndex++) {
|
||||||
|
if (strcasecmp(word->string, p) == 0) {
|
||||||
|
CONDDEBUG((1,
|
||||||
|
"ReadCfg(): got keyword '%s' [%s:%d]",
|
||||||
|
word->string, file, line));
|
||||||
|
state = NAME;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == START) {
|
||||||
|
if (isMaster)
|
||||||
|
Error("invalid keyword '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LEFTBRACE:
|
||||||
|
case RIGHTBRACE:
|
||||||
|
case SEMICOLON:
|
||||||
|
if (isMaster)
|
||||||
|
Error("invalid token '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
break;
|
||||||
|
case DONE: /* just shutting up gcc */
|
||||||
|
case INCLUDE: /* just shutting up gcc */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case NAME:
|
||||||
|
switch (token) {
|
||||||
|
case WORD:
|
||||||
|
(*sections[secIndex].begin) (word->string);
|
||||||
|
state = LEFTB;
|
||||||
|
break;
|
||||||
|
case RIGHTBRACE:
|
||||||
|
if (isMaster)
|
||||||
|
Error("premature token '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
state = START;
|
||||||
|
break;
|
||||||
|
case LEFTBRACE:
|
||||||
|
case SEMICOLON:
|
||||||
|
if (isMaster)
|
||||||
|
Error("invalid token '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
break;
|
||||||
|
case DONE: /* just shutting up gcc */
|
||||||
|
case INCLUDE: /* just shutting up gcc */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case LEFTB:
|
||||||
|
switch (token) {
|
||||||
|
case LEFTBRACE:
|
||||||
|
state = KEY;
|
||||||
|
break;
|
||||||
|
case RIGHTBRACE:
|
||||||
|
if (isMaster)
|
||||||
|
Error("premature token '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
(*sections[secIndex].abort) ();
|
||||||
|
state = START;
|
||||||
|
break;
|
||||||
|
case SEMICOLON:
|
||||||
|
if (isMaster)
|
||||||
|
Error("invalid token '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
break;
|
||||||
|
case WORD:
|
||||||
|
if (isMaster)
|
||||||
|
Error("invalid word '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
break;
|
||||||
|
case DONE: /* just shutting up gcc */
|
||||||
|
case INCLUDE: /* just shutting up gcc */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case KEY:
|
||||||
|
switch (token) {
|
||||||
|
case WORD:
|
||||||
|
for (keyIndex = 0;
|
||||||
|
(p =
|
||||||
|
sections[secIndex].items[keyIndex].id) !=
|
||||||
|
(char *)0; keyIndex++) {
|
||||||
|
if (strcasecmp(word->string, p) == 0) {
|
||||||
|
CONDDEBUG((1,
|
||||||
|
"got keyword '%s' [%s:%d]",
|
||||||
|
word->string, file, line));
|
||||||
|
state = VALUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (state == KEY) {
|
||||||
|
if (isMaster)
|
||||||
|
Error("invalid keyword '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RIGHTBRACE:
|
||||||
|
(*sections[secIndex].end) ();
|
||||||
|
state = START;
|
||||||
|
break;
|
||||||
|
case LEFTBRACE:
|
||||||
|
if (isMaster)
|
||||||
|
Error("invalid token '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
break;
|
||||||
|
case SEMICOLON:
|
||||||
|
if (isMaster)
|
||||||
|
Error("premature token '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
case DONE: /* just shutting up gcc */
|
||||||
|
case INCLUDE: /* just shutting up gcc */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case VALUE:
|
||||||
|
switch (token) {
|
||||||
|
case WORD:
|
||||||
|
(*sections[secIndex].items[keyIndex].
|
||||||
|
reg) (word->string);
|
||||||
|
state = SEMI;
|
||||||
|
break;
|
||||||
|
case SEMICOLON:
|
||||||
|
if (isMaster)
|
||||||
|
Error("invalid token '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
state = KEY;
|
||||||
|
break;
|
||||||
|
case RIGHTBRACE:
|
||||||
|
if (isMaster)
|
||||||
|
Error("premature token '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
(*sections[secIndex].abort) ();
|
||||||
|
state = START;
|
||||||
|
break;
|
||||||
|
case LEFTBRACE:
|
||||||
|
if (isMaster)
|
||||||
|
Error("invalid token '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
break;
|
||||||
|
case DONE: /* just shutting up gcc */
|
||||||
|
case INCLUDE: /* just shutting up gcc */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SEMI:
|
||||||
|
switch (token) {
|
||||||
|
case SEMICOLON:
|
||||||
|
state = KEY;
|
||||||
|
break;
|
||||||
|
case RIGHTBRACE:
|
||||||
|
if (isMaster)
|
||||||
|
Error("premature token '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
(*sections[secIndex].abort) ();
|
||||||
|
state = START;
|
||||||
|
break;
|
||||||
|
case LEFTBRACE:
|
||||||
|
if (isMaster)
|
||||||
|
Error("invalid token '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
break;
|
||||||
|
case WORD:
|
||||||
|
if (isMaster)
|
||||||
|
Error("invalid word '%s' [%s:%d]",
|
||||||
|
word->string, file, line);
|
||||||
|
break;
|
||||||
|
case DONE: /* just shutting up gcc */
|
||||||
|
case INCLUDE: /* just shutting up gcc */
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (state) {
|
||||||
|
case NAME:
|
||||||
|
case VALUE:
|
||||||
|
spaceok = 1;
|
||||||
|
break;
|
||||||
|
case KEY:
|
||||||
|
case LEFTB:
|
||||||
|
case START:
|
||||||
|
case SEMI:
|
||||||
|
spaceok = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
line = nextline;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (level == 0) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
/* check for proper ending of file and do any cleanup */
|
||||||
|
switch (state) {
|
||||||
|
case START:
|
||||||
|
break;
|
||||||
|
case KEY:
|
||||||
|
case LEFTB:
|
||||||
|
case VALUE:
|
||||||
|
case SEMI:
|
||||||
|
(*sections[secIndex].abort) ();
|
||||||
|
/* fall through */
|
||||||
|
case NAME:
|
||||||
|
if (isMaster)
|
||||||
|
Error("premature EOF seen [%s:%d]", file, line);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* now clean up all the temporary space used */
|
||||||
|
for (i = 0; sections[i].id != (char *)0; i++) {
|
||||||
|
(*sections[i].destroy) ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ProcessSubst(SUBST * s, char **repl, char **str, char *name, char *id)
|
||||||
|
#else
|
||||||
|
ProcessSubst(s, repl, str, name, id)
|
||||||
|
SUBST *s;
|
||||||
|
char **repl;
|
||||||
|
char **str;
|
||||||
|
char *name;
|
||||||
|
char *id;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* (CONSENT *pCE) and (char **repl) are used when a replacement is to
|
||||||
|
* actually happen...repl is the string to munch, pCE holds the data.
|
||||||
|
*
|
||||||
|
* (char **str) is used to store a copy of (char *id), if it passes
|
||||||
|
* the format check.
|
||||||
|
*
|
||||||
|
* the idea is that this is first called when the config file is read,
|
||||||
|
* putting the result in (char **str). then we call it again, near
|
||||||
|
* the end, permuting (char **repl) with values from (CONSENT *pCE) with
|
||||||
|
* the saved string now coming in as (char *id). got it?
|
||||||
|
*
|
||||||
|
* you could pass all arguments in...then both types of actions occur.
|
||||||
|
*/
|
||||||
|
char *p;
|
||||||
|
char *repfmt[255];
|
||||||
|
unsigned short repnum;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
enum repstate {
|
||||||
|
REP_BEGIN,
|
||||||
|
REP_LTR,
|
||||||
|
REP_EQ,
|
||||||
|
REP_INT,
|
||||||
|
REP_END
|
||||||
|
} state;
|
||||||
|
|
||||||
|
if (str != (char **)0) {
|
||||||
|
if (*str != (char *)0) {
|
||||||
|
free(*str);
|
||||||
|
*str = (char *)0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((id == (char *)0) || (*id == '\000'))
|
||||||
|
return;
|
||||||
|
|
||||||
|
repnum = 0;
|
||||||
|
state = REP_BEGIN;
|
||||||
|
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
repfmt[i] = (char *)0;
|
||||||
|
|
||||||
|
for (p = id; *p != '\000'; p++) {
|
||||||
|
switch (state) {
|
||||||
|
case REP_BEGIN:
|
||||||
|
/* must be printable */
|
||||||
|
if (*p == ',' || !isgraph((int)(*p)))
|
||||||
|
goto subst_err;
|
||||||
|
|
||||||
|
/* make sure we haven't seen this replacement char yet */
|
||||||
|
repnum = (unsigned short)(*p);
|
||||||
|
if (repfmt[repnum] != (char *)0) {
|
||||||
|
if (isMaster)
|
||||||
|
Error
|
||||||
|
("substitution characters of `%s' option are the same [%s:%d]",
|
||||||
|
name, file, line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
state = REP_LTR;
|
||||||
|
break;
|
||||||
|
case REP_LTR:
|
||||||
|
if (*p != '=')
|
||||||
|
goto subst_err;
|
||||||
|
state = REP_EQ;
|
||||||
|
break;
|
||||||
|
case REP_EQ:
|
||||||
|
repfmt[repnum] = p;
|
||||||
|
if (s->tokens[(unsigned)(*(repfmt[repnum]))] != ISNOTHING)
|
||||||
|
state = REP_INT;
|
||||||
|
else
|
||||||
|
goto subst_err;
|
||||||
|
break;
|
||||||
|
case REP_INT:
|
||||||
|
if (*p == 'd' || *p == 'x' || *p == 'X') {
|
||||||
|
if (s->tokens[(unsigned)(*(repfmt[repnum]))] !=
|
||||||
|
ISNUMBER)
|
||||||
|
goto subst_err;
|
||||||
|
state = REP_END;
|
||||||
|
} else if (*p == 's') {
|
||||||
|
if (s->tokens[(unsigned)(*(repfmt[repnum]))] !=
|
||||||
|
ISSTRING)
|
||||||
|
goto subst_err;
|
||||||
|
state = REP_END;
|
||||||
|
} else if (!isdigit((int)(*p)))
|
||||||
|
goto subst_err;
|
||||||
|
break;
|
||||||
|
case REP_END:
|
||||||
|
if (*p != ',')
|
||||||
|
goto subst_err;
|
||||||
|
state = REP_BEGIN;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state != REP_END) {
|
||||||
|
subst_err:
|
||||||
|
if (isMaster)
|
||||||
|
Error
|
||||||
|
("invalid `%s' specification `%s' (char #%d: `%c') [%s:%d]",
|
||||||
|
name, id, (p - id) + 1, *p, file, line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (str != (char **)0) {
|
||||||
|
if ((*str = StrDup(id)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (s != (SUBST *) 0 && repl != (char **)0) {
|
||||||
|
static STRING *result = (STRING *)0;
|
||||||
|
|
||||||
|
if (result == (STRING *)0)
|
||||||
|
result = AllocString();
|
||||||
|
BuildString((char *)0, result);
|
||||||
|
|
||||||
|
for (p = *repl; *p != '\000'; p++) {
|
||||||
|
if (repfmt[(unsigned short)(*p)] != (char *)0) {
|
||||||
|
char *r = repfmt[(unsigned short)(*p)];
|
||||||
|
int plen = 0;
|
||||||
|
char *c = (char *)0;
|
||||||
|
int o = 0;
|
||||||
|
|
||||||
|
if (s->tokens[(unsigned)(*r)] == ISSTRING) {
|
||||||
|
/* check the pattern for a length */
|
||||||
|
if (isdigit((int)(*(r + 1))))
|
||||||
|
plen = atoi(r + 1);
|
||||||
|
|
||||||
|
/* this should never return zero, but just in case */
|
||||||
|
if ((*s->callback) (*r, &c, (int *)0) == 0)
|
||||||
|
c = "";
|
||||||
|
plen -= strlen(c);
|
||||||
|
|
||||||
|
/* pad it out, if necessary */
|
||||||
|
for (i = 0; i < plen; i++)
|
||||||
|
BuildStringChar(' ', result);
|
||||||
|
|
||||||
|
/* throw in the string */
|
||||||
|
BuildString(c, result);
|
||||||
|
} else {
|
||||||
|
int i = 0;
|
||||||
|
unsigned short port = 0;
|
||||||
|
unsigned short base = 0;
|
||||||
|
int padzero = 0;
|
||||||
|
static STRING *num = (STRING *)0;
|
||||||
|
|
||||||
|
if (num == (STRING *)0)
|
||||||
|
num = AllocString();
|
||||||
|
BuildString((char *)0, num);
|
||||||
|
|
||||||
|
/* this should never return zero, but just in case */
|
||||||
|
if ((*s->callback) (*r, (char **)0, &i) == 0)
|
||||||
|
port = 0;
|
||||||
|
else
|
||||||
|
port = (unsigned short)i;
|
||||||
|
|
||||||
|
/* check the pattern for a length and padding */
|
||||||
|
for (c = r + 1; *c != '\000'; c++)
|
||||||
|
if (!isdigit((int)(*c)))
|
||||||
|
break;
|
||||||
|
if (c != r + 1) {
|
||||||
|
plen = atoi(r + 1);
|
||||||
|
padzero = (r[1] == '0');
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check for base */
|
||||||
|
switch (*c) {
|
||||||
|
case 'd':
|
||||||
|
base = 10;
|
||||||
|
break;
|
||||||
|
case 'x':
|
||||||
|
case 'X':
|
||||||
|
base = 16;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
while (port >= base) {
|
||||||
|
if (port % base >= 10)
|
||||||
|
BuildStringChar((port % base) - 10 +
|
||||||
|
(*c == 'x' ? 'a' : 'A'), num);
|
||||||
|
else
|
||||||
|
BuildStringChar((port % base) + '0', num);
|
||||||
|
port /= base;
|
||||||
|
}
|
||||||
|
if (port >= 10)
|
||||||
|
BuildStringChar(port - 10 +
|
||||||
|
(*c == 'x' ? 'a' : 'A'), num);
|
||||||
|
else
|
||||||
|
BuildStringChar(port + '0', num);
|
||||||
|
|
||||||
|
/* if we're supposed to be a certain length, pad it */
|
||||||
|
while (num->used - 1 < plen) {
|
||||||
|
if (padzero == 0)
|
||||||
|
BuildStringChar(' ', num);
|
||||||
|
else
|
||||||
|
BuildStringChar('0', num);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* reverse the text to put it in forward order */
|
||||||
|
o = num->used - 1;
|
||||||
|
for (i = 0; i < o / 2; i++) {
|
||||||
|
char temp;
|
||||||
|
|
||||||
|
temp = num->string[i];
|
||||||
|
num->string[i]
|
||||||
|
= num->string[o - i - 1];
|
||||||
|
num->string[o - i - 1] = temp;
|
||||||
|
}
|
||||||
|
BuildStringN(num->string, o, result);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
BuildStringChar(*p, result);
|
||||||
|
}
|
||||||
|
free(*repl);
|
||||||
|
if ((*repl = StrDup(result->string)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: cutil.h,v 1.61 2004/03/10 02:55:45 bryan Exp $
|
* $Id: cutil.h,v 1.63 2004/05/25 00:38:15 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -89,6 +89,37 @@ typedef struct consFile {
|
|||||||
#endif
|
#endif
|
||||||
} CONSFILE;
|
} CONSFILE;
|
||||||
|
|
||||||
|
typedef struct item {
|
||||||
|
char *id;
|
||||||
|
void (*reg) PARAMS((char *));
|
||||||
|
} ITEM;
|
||||||
|
|
||||||
|
typedef struct section {
|
||||||
|
char *id;
|
||||||
|
void (*begin) PARAMS((char *));
|
||||||
|
void (*end) PARAMS((void));
|
||||||
|
void (*abort) PARAMS((void));
|
||||||
|
void (*destroy) PARAMS((void));
|
||||||
|
ITEM *items;
|
||||||
|
} SECTION;
|
||||||
|
|
||||||
|
typedef enum substToken {
|
||||||
|
ISNOTHING = 0,
|
||||||
|
ISNUMBER,
|
||||||
|
ISSTRING
|
||||||
|
} SUBSTTOKEN;
|
||||||
|
|
||||||
|
typedef struct subst {
|
||||||
|
SUBSTTOKEN tokens[255];
|
||||||
|
/* data for callback function
|
||||||
|
*/
|
||||||
|
void *data;
|
||||||
|
/* function to retrieve a value (as a char* or int or both) for
|
||||||
|
* a substitution
|
||||||
|
*/
|
||||||
|
int (*callback) PARAMS((char, char **, int *));
|
||||||
|
} SUBST;
|
||||||
|
|
||||||
extern int isMultiProc, fDebug, fVerbose, fErrorPrinted;
|
extern int isMultiProc, fDebug, fVerbose, fErrorPrinted;
|
||||||
extern char *progname;
|
extern char *progname;
|
||||||
extern pid_t thepid;
|
extern pid_t thepid;
|
||||||
@ -100,6 +131,10 @@ extern fd_set winit;
|
|||||||
extern int maxfd;
|
extern int maxfd;
|
||||||
extern int debugLineNo;
|
extern int debugLineNo;
|
||||||
extern char *debugFileName;
|
extern char *debugFileName;
|
||||||
|
extern int line; /* used by ParseFile */
|
||||||
|
extern char *file; /* used by ParseFile */
|
||||||
|
extern SECTION sections[]; /* used by ParseFile */
|
||||||
|
extern int isMaster;
|
||||||
|
|
||||||
extern const char *StrTime PARAMS((time_t *));
|
extern const char *StrTime PARAMS((time_t *));
|
||||||
extern void Debug PARAMS((int, char *, ...));
|
extern void Debug PARAMS((int, char *, ...));
|
||||||
@ -157,6 +192,10 @@ extern char *StrDup PARAMS((char *));
|
|||||||
extern int ParseIACBuf PARAMS((CONSFILE *, void *, int *));
|
extern int ParseIACBuf PARAMS((CONSFILE *, void *, int *));
|
||||||
extern void *MemMove PARAMS((void *, void *, size_t));
|
extern void *MemMove PARAMS((void *, void *, size_t));
|
||||||
extern char *StringChar PARAMS((STRING *, int, char));
|
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 *));
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
extern SSL *FileGetSSL PARAMS((CONSFILE *));
|
extern SSL *FileGetSSL PARAMS((CONSFILE *));
|
||||||
extern void FileSetSSL PARAMS((CONSFILE *, SSL *));
|
extern void FileSetSSL PARAMS((CONSFILE *, SSL *));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: fallback.c,v 5.60 2003/11/20 13:56:38 bryan Exp $
|
* $Id: fallback.c,v 5.61 2004/04/16 16:58:09 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -210,7 +210,7 @@ GetPseudoTTY(slave, slaveFD)
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 > (fd = open(acMaster, O_RDWR | O_NDELAY, 0))) {
|
if (0 > (fd = open(acMaster, O_RDWR | O_NONBLOCK, 0))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
acSlave[iIndex] = *pcOne;
|
acSlave[iIndex] = *pcOne;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: group.c,v 5.291 2004/03/16 04:17:31 bryan Exp $
|
* $Id: group.c,v 5.301 2004/05/25 00:38:15 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -901,6 +901,75 @@ FlagReUp(sig)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct delay {
|
||||||
|
char *host;
|
||||||
|
time_t last;
|
||||||
|
struct delay *next;
|
||||||
|
} *delays = (struct delay *)0;
|
||||||
|
|
||||||
|
/* returns zero if the delay has been reached, otherwise returns
|
||||||
|
* the time when the next init should happen
|
||||||
|
*/
|
||||||
|
static time_t
|
||||||
|
#if PROTOTYPES
|
||||||
|
InitDelay(CONSENT *pCE)
|
||||||
|
#else
|
||||||
|
InitDelay(pCE)
|
||||||
|
CONSENT *pCE;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
char *l;
|
||||||
|
struct delay *d;
|
||||||
|
|
||||||
|
if (pCE->host != (char *)0)
|
||||||
|
l = pCE->host;
|
||||||
|
else
|
||||||
|
l = "";
|
||||||
|
|
||||||
|
for (d = delays; d != (struct delay *)0; d = d->next) {
|
||||||
|
if (strcmp(l, d->host) == 0) {
|
||||||
|
if ((time((time_t *)0) - d->last) >= config->initdelay) {
|
||||||
|
return (time_t)0;
|
||||||
|
} else
|
||||||
|
return d->last + config->initdelay;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (time_t)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
#if PROTOTYPES
|
||||||
|
UpdateDelay(CONSENT *pCE)
|
||||||
|
#else
|
||||||
|
UpdateDelay(pCE)
|
||||||
|
CONSENT *pCE;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
char *l;
|
||||||
|
struct delay *d;
|
||||||
|
|
||||||
|
if (pCE->host != (char *)0)
|
||||||
|
l = pCE->host;
|
||||||
|
else
|
||||||
|
l = "";
|
||||||
|
|
||||||
|
for (d = delays; d != (struct delay *)0; d = d->next) {
|
||||||
|
if (strcmp(l, d->host) == 0) {
|
||||||
|
d->last = time((time_t *)0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((d =
|
||||||
|
(struct delay *)malloc(sizeof(struct delay))) ==
|
||||||
|
(struct delay *)0)
|
||||||
|
OutOfMem();
|
||||||
|
if ((d->host = StrDup(l)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
d->last = time((time_t *)0);
|
||||||
|
d->next = delays;
|
||||||
|
delays = d;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
#if PROTOTYPES
|
#if PROTOTYPES
|
||||||
ReUp(GRPENT *pGE, short automatic)
|
ReUp(GRPENT *pGE, short automatic)
|
||||||
@ -913,6 +982,9 @@ ReUp(pGE, automatic)
|
|||||||
CONSENT *pCE;
|
CONSENT *pCE;
|
||||||
int autoReUp;
|
int autoReUp;
|
||||||
time_t tyme;
|
time_t tyme;
|
||||||
|
short retry;
|
||||||
|
static short autoup = 0;
|
||||||
|
short wasAuto = 0;
|
||||||
|
|
||||||
if ((GRPENT *)0 == pGE)
|
if ((GRPENT *)0 == pGE)
|
||||||
return;
|
return;
|
||||||
@ -924,19 +996,49 @@ ReUp(pGE, automatic)
|
|||||||
(!config->reinitcheck || (tyme < timers[T_REINIT])))
|
(!config->reinitcheck || (tyme < timers[T_REINIT])))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (pCE = pGE->pCElist; pCE != (CONSENT *)0; pCE = pCE->pCEnext) {
|
if (automatic == -1)
|
||||||
if (pCE->fup || pCE->ondemand == FLAGTRUE ||
|
wasAuto = autoup;
|
||||||
(automatic == 1 && !pCE->autoReUp))
|
autoup = 0;
|
||||||
continue;
|
|
||||||
autoReUp = pCE->autoReUp;
|
/* we loop here 'cause the init process could take a bit of time
|
||||||
if (automatic)
|
* (depending on how many things we init in the run through the
|
||||||
Msg("[%s] automatic reinitialization", pCE->server);
|
* consoles) and we might be able to then initialize more stuff.
|
||||||
ConsInit(pCE);
|
* we'll eventually run through too fast, run out of consoles, or
|
||||||
if (pCE->fup)
|
* have a big enough delay to go back to the main loop.
|
||||||
FindWrite(pCE);
|
*/
|
||||||
else if (automatic)
|
do {
|
||||||
pCE->autoReUp = autoReUp;
|
retry = 0;
|
||||||
}
|
for (pCE = pGE->pCElist; pCE != (CONSENT *)0; pCE = pCE->pCEnext) {
|
||||||
|
short updateDelay = 0;
|
||||||
|
|
||||||
|
if (pCE->fup || pCE->ondemand == FLAGTRUE ||
|
||||||
|
(automatic == 1 && !pCE->autoReUp))
|
||||||
|
continue;
|
||||||
|
if (config->initdelay > 0) {
|
||||||
|
time_t t;
|
||||||
|
if ((t = InitDelay(pCE)) > 0) {
|
||||||
|
if (timers[T_INITDELAY] == (time_t)0 ||
|
||||||
|
timers[T_INITDELAY] > t)
|
||||||
|
timers[T_INITDELAY] = t;
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
updateDelay = retry = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
autoReUp = pCE->autoReUp;
|
||||||
|
if (automatic > 0 || wasAuto) {
|
||||||
|
Msg("[%s] automatic reinitialization", pCE->server);
|
||||||
|
autoup = 1;
|
||||||
|
}
|
||||||
|
ConsInit(pCE);
|
||||||
|
if (updateDelay)
|
||||||
|
UpdateDelay(pCE);
|
||||||
|
if (pCE->fup)
|
||||||
|
FindWrite(pCE);
|
||||||
|
else if (automatic > 0)
|
||||||
|
pCE->autoReUp = autoReUp;
|
||||||
|
}
|
||||||
|
} while (retry);
|
||||||
|
|
||||||
/* update all the timers */
|
/* update all the timers */
|
||||||
if (automatic == 0 || automatic == 2) {
|
if (automatic == 0 || automatic == 2) {
|
||||||
@ -1255,7 +1357,7 @@ FlagReapVirt(sig)
|
|||||||
|
|
||||||
/* on a TERM we have to cleanup utmp entries (ask ptyd to do it) (ksb)
|
/* on a TERM we have to cleanup utmp entries (ask ptyd to do it) (ksb)
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
#if PROTOTYPES
|
#if PROTOTYPES
|
||||||
DeUtmp(GRPENT *pGE, int sfd)
|
DeUtmp(GRPENT *pGE, int sfd)
|
||||||
#else
|
#else
|
||||||
@ -1265,7 +1367,14 @@ DeUtmp(pGE, sfd)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
CONSENT *pCE;
|
CONSENT *pCE;
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
struct sockaddr_un lstn_port;
|
||||||
|
socklen_t so;
|
||||||
|
|
||||||
|
so = sizeof(lstn_port);
|
||||||
|
if (getsockname(sfd, (struct sockaddr *)&lstn_port, &so) != -1)
|
||||||
|
unlink(lstn_port.sun_path);
|
||||||
|
#endif
|
||||||
/* shut down the socket */
|
/* shut down the socket */
|
||||||
close(sfd);
|
close(sfd);
|
||||||
|
|
||||||
@ -1501,8 +1610,8 @@ PutConsole(pCEServing, c, quote)
|
|||||||
* quote == 2, telnet - processed by telnet protocol
|
* quote == 2, telnet - processed by telnet protocol
|
||||||
* if console != telnet, 1 == 2
|
* if console != telnet, 1 == 2
|
||||||
*/
|
*/
|
||||||
if (quote == 1 && pCEServing->type == HOST && !pCEServing->raw &&
|
if (quote == 1 && pCEServing->type == HOST &&
|
||||||
c == IAC) {
|
pCEServing->raw != FLAGTRUE && c == IAC) {
|
||||||
BuildStringChar((char)c, pCEServing->wbuf);
|
BuildStringChar((char)c, pCEServing->wbuf);
|
||||||
if (pCEServing->wbufIAC == 0)
|
if (pCEServing->wbufIAC == 0)
|
||||||
pCEServing->wbufIAC = pCEServing->wbuf->used;
|
pCEServing->wbufIAC = pCEServing->wbuf->used;
|
||||||
@ -1576,11 +1685,11 @@ ExpandString(str, pCE, breaknum)
|
|||||||
++octs;
|
++octs;
|
||||||
oct = oct * 8 + (s - '0');
|
oct = oct * 8 + (s - '0');
|
||||||
continue;
|
continue;
|
||||||
} else if (s == 'd' && pCE != (CONSENT *)0) {
|
} else if (s == 'd') {
|
||||||
PutConsole(pCE, IAC, 0);
|
PutConsole(pCE, IAC, 0);
|
||||||
PutConsole(pCE, '0' + breaknum, 0);
|
PutConsole(pCE, '0' + breaknum, 0);
|
||||||
continue;
|
continue;
|
||||||
} else if (s == 'z' && pCE != (CONSENT *)0) {
|
} else if (s == 'z') {
|
||||||
PutConsole(pCE, IAC, 0);
|
PutConsole(pCE, IAC, 0);
|
||||||
PutConsole(pCE, BREAK, 0);
|
PutConsole(pCE, BREAK, 0);
|
||||||
continue;
|
continue;
|
||||||
@ -2039,7 +2148,7 @@ CommandInfo(pGE, pCLServing, pCEServing, tyme)
|
|||||||
case HOST:
|
case HOST:
|
||||||
FilePrint(pCLServing->fd, FLAGTRUE, "!:%s,%hu,%s",
|
FilePrint(pCLServing->fd, FLAGTRUE, "!:%s,%hu,%s",
|
||||||
pCE->host, pCE->netport,
|
pCE->host, pCE->netport,
|
||||||
(pCE->raw ? "raw" : "telnet"));
|
(pCE->raw == FLAGTRUE ? "raw" : "telnet"));
|
||||||
break;
|
break;
|
||||||
case DEVICE:
|
case DEVICE:
|
||||||
FilePrint(pCLServing->fd, FLAGTRUE, "/:%s,%s%c",
|
FilePrint(pCLServing->fd, FLAGTRUE, "/:%s,%s%c",
|
||||||
@ -2298,7 +2407,7 @@ DoConsoleRead(pCEServing)
|
|||||||
CONDDEBUG((1, "DoConsoleRead(): read %d bytes from fd %d", nr,
|
CONDDEBUG((1, "DoConsoleRead(): read %d bytes from fd %d", nr,
|
||||||
cofile));
|
cofile));
|
||||||
|
|
||||||
if (pCEServing->type == HOST && !pCEServing->raw) {
|
if (pCEServing->type == HOST && pCEServing->raw != FLAGTRUE) {
|
||||||
/* Do a little Telnet Protocol interpretation
|
/* Do a little Telnet Protocol interpretation
|
||||||
* state = 0: normal
|
* state = 0: normal
|
||||||
* = 1: Saw a IAC char
|
* = 1: Saw a IAC char
|
||||||
@ -2703,7 +2812,7 @@ DoClientRead(pGE, pCLServing)
|
|||||||
"help this help message\r\n",
|
"help this help message\r\n",
|
||||||
"hosts show host status and user\r\n",
|
"hosts show host status and user\r\n",
|
||||||
"info show console information\r\n",
|
"info show console information\r\n",
|
||||||
"textmsg send a text message\r\n",
|
"textmsg send a text message\r\n",
|
||||||
"* = requires admin privileges\r\n",
|
"* = requires admin privileges\r\n",
|
||||||
(char *)0
|
(char *)0
|
||||||
};
|
};
|
||||||
@ -3824,11 +3933,19 @@ FlushConsole(pCEServing)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (pCEServing->wbuf->used > 1) {
|
if (pCEServing->wbuf->used > 1) {
|
||||||
|
char *iac = StringChar(pCEServing->wbuf, 0, (char)IAC);
|
||||||
|
CONDDEBUG((1, "Kiddie(): hunting for new IAC for [%s]",
|
||||||
|
pCEServing->server));
|
||||||
|
if (iac == (char *)0)
|
||||||
|
pCEServing->wbufIAC = 0;
|
||||||
|
else
|
||||||
|
pCEServing->wbufIAC = (iac - pCEServing->wbuf->string) + 2;
|
||||||
CONDDEBUG((1,
|
CONDDEBUG((1,
|
||||||
"Kiddie(): watching writability for fd %d 'cause we have buffered data",
|
"Kiddie(): watching writability for fd %d 'cause we have buffered data",
|
||||||
FileFDNum(pCEServing->cofile)));
|
FileFDNum(pCEServing->cofile)));
|
||||||
FD_SET(FileFDNum(pCEServing->cofile), &winit);
|
FD_SET(FileFDNum(pCEServing->cofile), &winit);
|
||||||
} else {
|
} else {
|
||||||
|
pCEServing->wbufIAC = 0;
|
||||||
if (FileBufEmpty(pCEServing->cofile)) {
|
if (FileBufEmpty(pCEServing->cofile)) {
|
||||||
CONDDEBUG((1,
|
CONDDEBUG((1,
|
||||||
"Kiddie(): removing writability for fd %d 'cause we don't have buffered data",
|
"Kiddie(): removing writability for fd %d 'cause we don't have buffered data",
|
||||||
@ -4098,6 +4215,12 @@ Kiddie(pGE, sfd)
|
|||||||
time((time_t *)0) >= timers[T_MARK])
|
time((time_t *)0) >= timers[T_MARK])
|
||||||
Mark(pGE);
|
Mark(pGE);
|
||||||
|
|
||||||
|
if (timers[T_INITDELAY] != (time_t)0 &&
|
||||||
|
time((time_t *)0) >= timers[T_INITDELAY]) {
|
||||||
|
timers[T_INITDELAY] = (time_t)0;
|
||||||
|
ReUp(pGE, -1);
|
||||||
|
}
|
||||||
|
|
||||||
if (timers[T_REINIT] != (time_t)0 &&
|
if (timers[T_REINIT] != (time_t)0 &&
|
||||||
time((time_t *)0) >= timers[T_REINIT])
|
time((time_t *)0) >= timers[T_REINIT])
|
||||||
ReUp(pGE, 2);
|
ReUp(pGE, 2);
|
||||||
@ -4469,18 +4592,53 @@ Spawn(pGE)
|
|||||||
{
|
{
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
int sfd;
|
int sfd;
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
struct sockaddr_un lstn_port;
|
||||||
|
static STRING *portPath = (STRING *)0;
|
||||||
|
#else
|
||||||
socklen_t so;
|
socklen_t so;
|
||||||
struct sockaddr_in lstn_port;
|
|
||||||
int true = 1;
|
int true = 1;
|
||||||
unsigned short portInc = 0;
|
unsigned short portInc = 0;
|
||||||
|
struct sockaddr_in lstn_port;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* get a socket for listening
|
/* get a socket for listening */
|
||||||
*/
|
|
||||||
#if HAVE_MEMSET
|
#if HAVE_MEMSET
|
||||||
memset((void *)&lstn_port, 0, sizeof(lstn_port));
|
memset((void *)&lstn_port, 0, sizeof(lstn_port));
|
||||||
#else
|
#else
|
||||||
bzero((char *)&lstn_port, sizeof(lstn_port));
|
bzero((char *)&lstn_port, sizeof(lstn_port));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
lstn_port.sun_family = AF_UNIX;
|
||||||
|
|
||||||
|
if (portPath == (STRING *)0)
|
||||||
|
portPath = AllocString();
|
||||||
|
BuildStringPrint(portPath, "%s/%u", interface, pGE->id);
|
||||||
|
if (portPath->used > sizeof(lstn_port.sun_path)) {
|
||||||
|
Error("Spawn(): path to socket too long: %s", portPath->string);
|
||||||
|
Bye(EX_OSERR);
|
||||||
|
}
|
||||||
|
strcpy(lstn_port.sun_path, portPath->string);
|
||||||
|
|
||||||
|
/* create a socket to listen on
|
||||||
|
* (prepared by master so he can see the port number of the kid)
|
||||||
|
*/
|
||||||
|
if ((sfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
||||||
|
Error("Spawn(): socket(): %s", strerror(errno));
|
||||||
|
Bye(EX_OSERR);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SetFlags(sfd, O_NONBLOCK, 0))
|
||||||
|
Bye(EX_OSERR);
|
||||||
|
|
||||||
|
if (bind(sfd, (struct sockaddr *)&lstn_port, sizeof(lstn_port)) < 0) {
|
||||||
|
Error("Spawn(): bind(%s): %s", lstn_port.sun_path,
|
||||||
|
strerror(errno));
|
||||||
|
Bye(EX_OSERR);
|
||||||
|
}
|
||||||
|
pGE->port = pGE->id;
|
||||||
|
#else
|
||||||
lstn_port.sin_family = AF_INET;
|
lstn_port.sin_family = AF_INET;
|
||||||
lstn_port.sin_addr.s_addr = bindAddr;
|
lstn_port.sin_addr.s_addr = bindAddr;
|
||||||
lstn_port.sin_port = htons(bindBasePort);
|
lstn_port.sin_port = htons(bindBasePort);
|
||||||
@ -4492,24 +4650,24 @@ Spawn(pGE)
|
|||||||
Error("Spawn(): socket(): %s", strerror(errno));
|
Error("Spawn(): socket(): %s", strerror(errno));
|
||||||
Bye(EX_OSERR);
|
Bye(EX_OSERR);
|
||||||
}
|
}
|
||||||
#if HAVE_SETSOCKOPT
|
# if HAVE_SETSOCKOPT
|
||||||
if (setsockopt
|
if (setsockopt
|
||||||
(sfd, SOL_SOCKET, SO_REUSEADDR, (char *)&true, sizeof(true)) < 0) {
|
(sfd, SOL_SOCKET, SO_REUSEADDR, (char *)&true, sizeof(true)) < 0) {
|
||||||
Error("Spawn(): setsockopt(%u,SO_REUSEADDR): %s", sfd,
|
Error("Spawn(): setsockopt(%u,SO_REUSEADDR): %s", sfd,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
Bye(EX_OSERR);
|
Bye(EX_OSERR);
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
if (!SetFlags(sfd, O_NONBLOCK, 0))
|
if (!SetFlags(sfd, O_NONBLOCK, 0))
|
||||||
Bye(EX_OSERR);
|
Bye(EX_OSERR);
|
||||||
|
|
||||||
while (bind(sfd, (struct sockaddr *)&lstn_port, sizeof(lstn_port)) < 0) {
|
while (bind(sfd, (struct sockaddr *)&lstn_port, sizeof(lstn_port)) < 0) {
|
||||||
if (bindBasePort && (
|
if (bindBasePort && (
|
||||||
#if defined(EADDRINUSE)
|
# if defined(EADDRINUSE)
|
||||||
(errno == EADDRINUSE) ||
|
(errno == EADDRINUSE) ||
|
||||||
#endif
|
# endif
|
||||||
(errno == EACCES)) && portInc++) {
|
(errno == EACCES)) && ++portInc) {
|
||||||
lstn_port.sin_port = htons(bindBasePort + portInc);
|
lstn_port.sin_port = htons(bindBasePort + portInc);
|
||||||
} else {
|
} else {
|
||||||
Error("Spawn(): bind(%hu): %s", ntohs(lstn_port.sin_port),
|
Error("Spawn(): bind(%hu): %s", ntohs(lstn_port.sin_port),
|
||||||
@ -4524,6 +4682,7 @@ Spawn(pGE)
|
|||||||
Bye(EX_OSERR);
|
Bye(EX_OSERR);
|
||||||
}
|
}
|
||||||
pGE->port = ntohs(lstn_port.sin_port);
|
pGE->port = ntohs(lstn_port.sin_port);
|
||||||
|
#endif
|
||||||
|
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
@ -4587,12 +4746,20 @@ Spawn(pGE)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (listen(sfd, SOMAXCONN) < 0) {
|
if (listen(sfd, SOMAXCONN) < 0) {
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
Error("Spawn(): listen(%s): %s", lstn_port.sun_path,
|
||||||
|
strerror(errno));
|
||||||
|
#else
|
||||||
Error("Spawn(): listen(%hu): %s", pGE->port, strerror(errno));
|
Error("Spawn(): listen(%hu): %s", pGE->port, strerror(errno));
|
||||||
|
#endif
|
||||||
Bye(EX_OSERR);
|
Bye(EX_OSERR);
|
||||||
}
|
}
|
||||||
Kiddie(pGE, sfd);
|
Kiddie(pGE, sfd);
|
||||||
|
|
||||||
/* should never get here...but on errors we could */
|
/* should never get here...but on errors we could */
|
||||||
close(sfd);
|
close(sfd);
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
unlink(lstn_port.sun_path);
|
||||||
|
#endif
|
||||||
Bye(EX_SOFTWARE);
|
Bye(EX_SOFTWARE);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: group.h,v 5.43 2003/12/20 06:11:53 bryan Exp $
|
* $Id: group.h,v 5.46 2004/05/25 00:38:15 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -41,7 +41,8 @@
|
|||||||
#define T_REINIT 3
|
#define T_REINIT 3
|
||||||
#define T_AUTOUP 4
|
#define T_AUTOUP 4
|
||||||
#define T_ROLL 5
|
#define T_ROLL 5
|
||||||
#define T_MAX 6 /* T_MAX *must* be last */
|
#define T_INITDELAY 6
|
||||||
|
#define T_MAX 7 /* T_MAX *must* be last */
|
||||||
|
|
||||||
/* return values used by CheckPass()
|
/* return values used by CheckPass()
|
||||||
*/
|
*/
|
||||||
@ -79,7 +80,7 @@ PARAMS((GRPENT *, CONSCLIENT *, char *, FLAG));
|
|||||||
extern int ClientAccess PARAMS((CONSENT *, char *));
|
extern int ClientAccess PARAMS((CONSENT *, char *));
|
||||||
extern void DestroyClient PARAMS((CONSCLIENT *));
|
extern void DestroyClient PARAMS((CONSCLIENT *));
|
||||||
extern int CheckPasswd PARAMS((CONSCLIENT *, char *));
|
extern int CheckPasswd PARAMS((CONSCLIENT *, char *));
|
||||||
extern void ExpandString PARAMS((char *, CONSENT *, short));
|
extern void DeUtmp PARAMS((GRPENT *, int));
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
extern int AttemptSSL PARAMS((CONSCLIENT *));
|
extern int AttemptSSL PARAMS((CONSCLIENT *));
|
||||||
#endif
|
#endif
|
||||||
|
360
conserver/main.c
360
conserver/main.c
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: main.c,v 5.178 2004/03/11 16:23:59 bryan Exp $
|
* $Id: main.c,v 5.185 2004/05/25 23:03:01 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -40,10 +40,7 @@
|
|||||||
#include <readcfg.h>
|
#include <readcfg.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
|
||||||
#include <net/if.h>
|
#include <dirent.h>
|
||||||
#if HAVE_SYS_SOCKIO_H
|
|
||||||
# include <sys/sockio.h>
|
|
||||||
#endif
|
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
# include <openssl/opensslv.h>
|
# include <openssl/opensslv.h>
|
||||||
#endif
|
#endif
|
||||||
@ -53,9 +50,8 @@ int fAll = 0, fNoinit = 0, fVersion = 0, fStrip = 0, fReopen =
|
|||||||
0, fNoautoreup = 0, fSyntaxOnly = 0;
|
0, fNoautoreup = 0, fSyntaxOnly = 0;
|
||||||
|
|
||||||
char *pcConfig = CONFIGFILE;
|
char *pcConfig = CONFIGFILE;
|
||||||
int isMaster = 1;
|
|
||||||
int cMaxMemb = MAXMEMB;
|
int cMaxMemb = MAXMEMB;
|
||||||
in_addr_t bindAddr;
|
in_addr_t bindAddr = INADDR_ANY;
|
||||||
unsigned short bindPort;
|
unsigned short bindPort;
|
||||||
unsigned short bindBasePort;
|
unsigned short bindBasePort;
|
||||||
static STRING *startedMsg = (STRING *)0;
|
static STRING *startedMsg = (STRING *)0;
|
||||||
@ -64,8 +60,7 @@ CONFIG *config = (CONFIG *)0;
|
|||||||
char *interface = (char *)0;
|
char *interface = (char *)0;
|
||||||
CONFIG defConfig =
|
CONFIG defConfig =
|
||||||
{ (STRING *)0, 'r', FLAGFALSE, LOGFILEPATH, PASSWDFILE, DEFPORT,
|
{ (STRING *)0, 'r', FLAGFALSE, LOGFILEPATH, PASSWDFILE, DEFPORT,
|
||||||
FLAGTRUE,
|
FLAGTRUE, FLAGTRUE, 0, DEFBASEPORT, (char *)0, 0
|
||||||
FLAGTRUE, 0, DEFBASEPORT, (char *)0
|
|
||||||
#if HAVE_SETPROCTITLE
|
#if HAVE_SETPROCTITLE
|
||||||
, FLAGFALSE
|
, FLAGFALSE
|
||||||
#endif
|
#endif
|
||||||
@ -523,7 +518,7 @@ Usage(wantfull)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
static char u_terse[] =
|
static char u_terse[] =
|
||||||
"[-7dDEFhinoRSuvV] [-a type] [-m max] [-M addr] [-p port] [-b port] [-c cred] [-C config] [-P passwd] [-L logfile] [-O min] [-U logfile]";
|
"[-7dDEFhinoRSuvV] [-a type] [-m max] [-M master] [-p port] [-b port] [-c cred] [-C config] [-P passwd] [-L logfile] [-O min] [-U logfile]";
|
||||||
static char *full[] = {
|
static char *full[] = {
|
||||||
"7 strip the high bit off all console data",
|
"7 strip the high bit off all console data",
|
||||||
"a type set the default access type",
|
"a type set the default access type",
|
||||||
@ -546,11 +541,19 @@ Usage(wantfull)
|
|||||||
"i initialize console connections on demand",
|
"i initialize console connections on demand",
|
||||||
"L logfile give a new logfile path to the server process",
|
"L logfile give a new logfile path to the server process",
|
||||||
"m max maximum consoles managed per process",
|
"m max maximum consoles managed per process",
|
||||||
"M addr address to listen on (all addresses by default)",
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
"M master directory that holds the Unix domain sockets",
|
||||||
|
#else
|
||||||
|
"M master address to listen on (all addresses by default)",
|
||||||
|
#endif
|
||||||
"n obsolete - see -u",
|
"n obsolete - see -u",
|
||||||
"o reopen downed console on client connect",
|
"o reopen downed console on client connect",
|
||||||
"O min reopen all downed consoles every <min> minutes",
|
"O min reopen all downed consoles every <min> minutes",
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
"p port ignored - Unix domain sockets compiled into code",
|
||||||
|
#else
|
||||||
"p port port to listen on",
|
"p port port to listen on",
|
||||||
|
#endif
|
||||||
"P passwd give a new passwd file to the server process",
|
"P passwd give a new passwd file to the server process",
|
||||||
"R disable automatic client redirection",
|
"R disable automatic client redirection",
|
||||||
"S syntax check of configuration file",
|
"S syntax check of configuration file",
|
||||||
@ -595,6 +598,9 @@ Version()
|
|||||||
#endif
|
#endif
|
||||||
#if TRUST_REVERSE_DNS
|
#if TRUST_REVERSE_DNS
|
||||||
"trustrevdns",
|
"trustrevdns",
|
||||||
|
#endif
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
"uds",
|
||||||
#endif
|
#endif
|
||||||
(char *)0
|
(char *)0
|
||||||
};
|
};
|
||||||
@ -616,9 +622,13 @@ Version()
|
|||||||
Msg("default pidfile is `%s'", PIDFILE);
|
Msg("default pidfile is `%s'", PIDFILE);
|
||||||
Msg("default limit is %d member%s per group", MAXMEMB,
|
Msg("default limit is %d member%s per group", MAXMEMB,
|
||||||
MAXMEMB == 1 ? "" : "s");
|
MAXMEMB == 1 ? "" : "s");
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
Msg("default socket directory `%s'", UDSDIR);
|
||||||
|
#else
|
||||||
Msg("default primary port referenced as `%s'", defConfig.primaryport);
|
Msg("default primary port referenced as `%s'", defConfig.primaryport);
|
||||||
Msg("default secondary base port referenced as `%s'",
|
Msg("default secondary base port referenced as `%s'",
|
||||||
defConfig.secondaryport);
|
defConfig.secondaryport);
|
||||||
|
#endif
|
||||||
|
|
||||||
BuildString((char *)0, acA1);
|
BuildString((char *)0, acA1);
|
||||||
if (optionlist[0] == (char *)0)
|
if (optionlist[0] == (char *)0)
|
||||||
@ -639,10 +649,12 @@ Version()
|
|||||||
BuildStringChar('0' + DMALLOC_VERSION_MINOR, acA1);
|
BuildStringChar('0' + DMALLOC_VERSION_MINOR, acA1);
|
||||||
BuildStringChar('.', acA1);
|
BuildStringChar('.', acA1);
|
||||||
BuildStringChar('0' + DMALLOC_VERSION_PATCH, acA1);
|
BuildStringChar('0' + DMALLOC_VERSION_PATCH, acA1);
|
||||||
|
#if defined(DMALLOC_VERSION_BETA)
|
||||||
if (DMALLOC_VERSION_BETA != 0) {
|
if (DMALLOC_VERSION_BETA != 0) {
|
||||||
BuildString("-b", acA1);
|
BuildString("-b", acA1);
|
||||||
BuildStringChar('0' + DMALLOC_VERSION_BETA, acA1);
|
BuildStringChar('0' + DMALLOC_VERSION_BETA, acA1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
Msg("dmalloc version: %s", acA1->string);
|
Msg("dmalloc version: %s", acA1->string);
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
@ -708,6 +720,8 @@ DestroyDataStructures()
|
|||||||
DestroyBreakList();
|
DestroyBreakList();
|
||||||
DestroyStrings();
|
DestroyStrings();
|
||||||
DestroyUserList();
|
DestroyUserList();
|
||||||
|
if (substData != (SUBST *) 0)
|
||||||
|
free(substData);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -839,13 +853,13 @@ DumpDataStructures()
|
|||||||
GRPENT *pGE;
|
GRPENT *pGE;
|
||||||
CONSENT *pCE;
|
CONSENT *pCE;
|
||||||
REMOTE *pRC;
|
REMOTE *pRC;
|
||||||
char *empty = "<empty>";
|
|
||||||
|
|
||||||
#if HAVE_DMALLOC && DMALLOC_MARK_MAIN
|
#if HAVE_DMALLOC && DMALLOC_MARK_MAIN
|
||||||
CONDDEBUG((1, "DumpDataStructures(): dmalloc / MarkMain"));
|
CONDDEBUG((1, "DumpDataStructures(): dmalloc / MarkMain"));
|
||||||
dmalloc_log_changed(dmallocMarkMain, 1, 0, 1);
|
dmalloc_log_changed(dmallocMarkMain, 1, 0, 1);
|
||||||
#endif
|
#endif
|
||||||
#define EMPTYSTR(x) x == (char *)0 ? empty : x
|
#define EMPTYSTR(x) x == (char *)0 ? "(null)" : x
|
||||||
|
#define FLAGSTR(x) x == FLAGTRUE ? "true" : (x == FLAGFALSE ? "false" : "unset")
|
||||||
if (!fDebug)
|
if (!fDebug)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -884,9 +898,9 @@ DumpDataStructures()
|
|||||||
"DumpDataStructures(): server=%s, type=HOST",
|
"DumpDataStructures(): server=%s, type=HOST",
|
||||||
EMPTYSTR(pCE->server)));
|
EMPTYSTR(pCE->server)));
|
||||||
CONDDEBUG((1,
|
CONDDEBUG((1,
|
||||||
"DumpDataStructures(): host=%s, raw=%hu, netport=%hu, port=%hu, telnetState=%d",
|
"DumpDataStructures(): host=%s, raw=%s, netport=%hu, port=%hu, telnetState=%d",
|
||||||
EMPTYSTR(pCE->host), pCE->raw, pCE->netport,
|
EMPTYSTR(pCE->host), FLAGSTR(pCE->raw),
|
||||||
pCE->port, pCE->telnetState));
|
pCE->netport, pCE->port, pCE->telnetState));
|
||||||
break;
|
break;
|
||||||
case UNKNOWNTYPE:
|
case UNKNOWNTYPE:
|
||||||
CONDDEBUG((1,
|
CONDDEBUG((1,
|
||||||
@ -908,32 +922,27 @@ DumpDataStructures()
|
|||||||
CONDDEBUG((1,
|
CONDDEBUG((1,
|
||||||
"DumpDataStructures(): mark=%d, nextMark=%ld, autoReup=%hu, downHard=%s",
|
"DumpDataStructures(): mark=%d, nextMark=%ld, autoReup=%hu, downHard=%s",
|
||||||
pCE->mark, pCE->nextMark, pCE->autoReUp,
|
pCE->mark, pCE->nextMark, pCE->autoReUp,
|
||||||
pCE->downHard == FLAGTRUE ? "true" : "false"));
|
FLAGSTR(pCE->downHard)));
|
||||||
CONDDEBUG((1,
|
CONDDEBUG((1,
|
||||||
"DumpDataStructures(): nolog=%d, cofile=%d, activitylog=%s, breaklog=%s",
|
"DumpDataStructures(): nolog=%d, cofile=%d, activitylog=%s, breaklog=%s",
|
||||||
pCE->nolog, FileFDNum(pCE->cofile),
|
pCE->nolog, FileFDNum(pCE->cofile),
|
||||||
pCE->activitylog == FLAGTRUE ? "true" : "false",
|
FLAGSTR(pCE->activitylog), FLAGSTR(pCE->breaklog)));
|
||||||
pCE->breaklog == FLAGTRUE ? "true" : "false"));
|
|
||||||
CONDDEBUG((1,
|
CONDDEBUG((1,
|
||||||
"DumpDataStructures(): ixon=%s, ixany=%s, ixoff=%s",
|
"DumpDataStructures(): ixon=%s, ixany=%s, ixoff=%s",
|
||||||
pCE->ixon == FLAGTRUE ? "true" : "false",
|
FLAGSTR(pCE->ixon), FLAGSTR(pCE->ixany),
|
||||||
pCE->ixany == FLAGTRUE ? "true" : "false",
|
FLAGSTR(pCE->ixoff)));
|
||||||
pCE->ixoff == FLAGTRUE ? "true" : "false"));
|
|
||||||
CONDDEBUG((1,
|
CONDDEBUG((1,
|
||||||
"DumpDataStructures(): autoreinit=%s, hupcl=%s, cstopb=%s, ondemand=%s",
|
"DumpDataStructures(): autoreinit=%s, hupcl=%s, cstopb=%s, ondemand=%s",
|
||||||
pCE->autoreinit == FLAGTRUE ? "true" : "false",
|
FLAGSTR(pCE->autoreinit), FLAGSTR(pCE->hupcl),
|
||||||
pCE->hupcl == FLAGTRUE ? "true" : "false",
|
FLAGSTR(pCE->cstopb), FLAGSTR(pCE->ondemand)));
|
||||||
pCE->cstopb == FLAGTRUE ? "true" : "false",
|
|
||||||
pCE->ondemand == FLAGTRUE ? "true" : "false"));
|
|
||||||
#if defined(CRTSCTS)
|
#if defined(CRTSCTS)
|
||||||
CONDDEBUG((1, "DumpDataStructures(): crtscts=%s",
|
CONDDEBUG((1, "DumpDataStructures(): crtscts=%s",
|
||||||
pCE->crtscts == FLAGTRUE ? "true" : "false"));
|
FLAGSTR(pCE->crtscts)));
|
||||||
#endif
|
#endif
|
||||||
CONDDEBUG((1,
|
CONDDEBUG((1,
|
||||||
"DumpDataStructures(): reinitoncc=%s, striphigh=%s, unloved=%s",
|
"DumpDataStructures(): reinitoncc=%s, striphigh=%s, unloved=%s",
|
||||||
pCE->reinitoncc == FLAGTRUE ? "true" : "false",
|
FLAGSTR(pCE->reinitoncc), FLAGSTR(pCE->striphigh),
|
||||||
pCE->striphigh == FLAGTRUE ? "true" : "false",
|
FLAGSTR(pCE->unloved)));
|
||||||
pCE->unloved == FLAGTRUE ? "true" : "false"));
|
|
||||||
CONDDEBUG((1,
|
CONDDEBUG((1,
|
||||||
"DumpDataStructures(): initpid=%lu, initcmd=%s, initfile=%d",
|
"DumpDataStructures(): initpid=%lu, initcmd=%s, initfile=%d",
|
||||||
(unsigned long)pCE->initpid, EMPTYSTR(pCE->initcmd),
|
(unsigned long)pCE->initpid, EMPTYSTR(pCE->initcmd),
|
||||||
@ -971,187 +980,93 @@ DumpDataStructures()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* fills the myAddrs array with host interface addresses */
|
/* This makes sure a directory exists and tries to create it if it
|
||||||
void
|
* doesn't. returns 0 for success, -1 for error
|
||||||
|
*/
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
int
|
||||||
#if PROTOTYPES
|
#if PROTOTYPES
|
||||||
ProbeInterfaces(void)
|
VerifyEmptyDirectory(char *d)
|
||||||
#else
|
#else
|
||||||
ProbeInterfaces()
|
VerifyEmptyDirectory(d)
|
||||||
|
char *d;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef SIOCGIFCONF
|
struct stat dstat;
|
||||||
struct ifconf ifc;
|
DIR *dir;
|
||||||
struct ifreq *ifr;
|
struct dirent *de;
|
||||||
#ifdef SIOCGIFFLAGS
|
STRING *path = (STRING *)0;
|
||||||
struct ifreq ifrcopy;
|
int retval = 0;
|
||||||
#endif
|
|
||||||
int sock;
|
|
||||||
int r = 0, m = 0;
|
|
||||||
int bufsize = 2048;
|
|
||||||
int count = 0;
|
|
||||||
|
|
||||||
/* if we use -M, just fill the array with that interface */
|
while (1) {
|
||||||
if (bindAddr != INADDR_ANY) {
|
if (stat(d, &dstat) == -1) {
|
||||||
myAddrs = (struct in_addr *)calloc(2, sizeof(struct in_addr));
|
if (errno == ENOENT) {
|
||||||
if (myAddrs == (struct in_addr *)0)
|
if (mkdir(d, 0755) == -1) {
|
||||||
OutOfMem();
|
Error("mkdir(%s): %s", d, strerror(errno));
|
||||||
#if HAVE_MEMCPY
|
return -1;
|
||||||
memcpy(&(myAddrs[0].s_addr), &bindAddr, sizeof(in_addr_t));
|
}
|
||||||
#else
|
CONDDEBUG((1, "VerifyEmptyDirectory: created `%s'", d));
|
||||||
bcopy(&bindAddr, &(myAddrs[0].s_addr), sizeof(in_addr_t));
|
|
||||||
#endif
|
|
||||||
Verbose("interface address %s (-M option)", inet_ntoa(myAddrs[0]));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
|
|
||||||
Error("ProbeInterfaces(): socket(): %s", strerror(errno));
|
|
||||||
Bye(EX_OSERR);
|
|
||||||
}
|
|
||||||
|
|
||||||
while (bufsize) {
|
|
||||||
ifc.ifc_len = bufsize;
|
|
||||||
ifc.ifc_req = (struct ifreq *)malloc(ifc.ifc_len);
|
|
||||||
if (ifc.ifc_req == (struct ifreq *)0)
|
|
||||||
OutOfMem();
|
|
||||||
if (ioctl(sock, SIOCGIFCONF, &ifc) != 0) {
|
|
||||||
free(ifc.ifc_req);
|
|
||||||
close(sock);
|
|
||||||
Error("ProbeInterfaces(): ioctl(SIOCGIFCONF): %s",
|
|
||||||
strerror(errno));
|
|
||||||
Bye(EX_OSERR);
|
|
||||||
}
|
|
||||||
/* if the return size plus a 512 byte "buffer zone" is less than
|
|
||||||
* the buffer we passed in (bufsize), we're done. otherwise
|
|
||||||
* allocate a bigger buffer and try again. with a too-small
|
|
||||||
* buffer, some implementations (freebsd) will fill the buffer
|
|
||||||
* best it can (leaving a gap - returning <=bufsize) and others
|
|
||||||
* (linux) will return a buffer length the same size as passed
|
|
||||||
* in (==bufsize). so, we'll assume a 512 byte gap would have
|
|
||||||
* been big enough to put one more record and as long as we have
|
|
||||||
* that "buffer zone", we should have all the interfaces.
|
|
||||||
*/
|
|
||||||
if (ifc.ifc_len + 512 < bufsize)
|
|
||||||
break;
|
|
||||||
free(ifc.ifc_req);
|
|
||||||
bufsize += 2048;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* this is probably way overkill, but better to kill a few bytes
|
|
||||||
* than loop through looking for valid interfaces that are up
|
|
||||||
* twice, huh?
|
|
||||||
*/
|
|
||||||
count = ifc.ifc_len / sizeof(*ifr);
|
|
||||||
CONDDEBUG((1, "ProbeInterfaces(): ifc_len==%d max_count==%d",
|
|
||||||
ifc.ifc_len, count));
|
|
||||||
|
|
||||||
/* set up myAddrs array */
|
|
||||||
if (myAddrs != (struct in_addr *)0)
|
|
||||||
free(myAddrs);
|
|
||||||
myAddrs = (struct in_addr *)0;
|
|
||||||
if (count == 0) {
|
|
||||||
free(ifc.ifc_req);
|
|
||||||
close(sock);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
myAddrs = (struct in_addr *)calloc(count + 1, sizeof(struct in_addr));
|
|
||||||
if (myAddrs == (struct in_addr *)0)
|
|
||||||
OutOfMem();
|
|
||||||
|
|
||||||
for (m = r = 0; r < ifc.ifc_len;) {
|
|
||||||
struct sockaddr *sa;
|
|
||||||
ifr = (struct ifreq *)&ifc.ifc_buf[r];
|
|
||||||
sa = (struct sockaddr *)&ifr->ifr_addr;
|
|
||||||
/* don't use less than a ifreq sized chunk */
|
|
||||||
if ((ifc.ifc_len - r) < sizeof(*ifr))
|
|
||||||
break;
|
|
||||||
#ifdef HAVE_SA_LEN
|
|
||||||
if (sa->sa_len > sizeof(ifr->ifr_addr))
|
|
||||||
r += sizeof(ifr->ifr_name) + sa->sa_len;
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
r += sizeof(*ifr);
|
|
||||||
|
|
||||||
if (sa->sa_family == AF_INET) {
|
|
||||||
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
|
|
||||||
#ifdef SIOCGIFFLAGS
|
|
||||||
/* make sure the interface is up */
|
|
||||||
ifrcopy = *ifr;
|
|
||||||
if ((ioctl(sock, SIOCGIFFLAGS, &ifrcopy) == 0) &&
|
|
||||||
((ifrcopy.ifr_flags & IFF_UP) == 0))
|
|
||||||
continue;
|
continue;
|
||||||
#endif
|
} else {
|
||||||
CONDDEBUG((1, "ProbeInterfaces(): name=%s addr=%s",
|
Error("stat(%s): %s", d, strerror(errno));
|
||||||
ifr->ifr_name, inet_ntoa(sin->sin_addr)));
|
return -1;
|
||||||
#if HAVE_MEMCPY
|
}
|
||||||
memcpy(&myAddrs[m], &(sin->sin_addr), sizeof(struct in_addr));
|
|
||||||
#else
|
|
||||||
bcopy(&(sin->sin_addr), &myAddrs[m], sizeof(struct in_addr));
|
|
||||||
#endif
|
|
||||||
Verbose("interface address %s (%s)", inet_ntoa(myAddrs[m]),
|
|
||||||
ifr->ifr_name);
|
|
||||||
m++;
|
|
||||||
}
|
}
|
||||||
}
|
if (S_ISDIR(dstat.st_mode))
|
||||||
if (m == 0) {
|
break;
|
||||||
free(myAddrs);
|
return -1;
|
||||||
myAddrs = (struct in_addr *)0;
|
|
||||||
}
|
|
||||||
close(sock);
|
|
||||||
free(ifc.ifc_req);
|
|
||||||
#else /* use the hostname like the old code did (but use all addresses!) */
|
|
||||||
int count;
|
|
||||||
struct hostent *he;
|
|
||||||
|
|
||||||
/* if we use -M, just fill the array with that interface */
|
|
||||||
if (bindAddr != INADDR_ANY) {
|
|
||||||
myAddrs = (struct in_addr *)calloc(2, sizeof(struct in_addr));
|
|
||||||
if (myAddrs == (struct in_addr *)0)
|
|
||||||
OutOfMem();
|
|
||||||
#if HAVE_MEMCPY
|
|
||||||
memcpy(&(myAddrs[0].s_addr), &bindAddr, sizeof(in_addr_t));
|
|
||||||
#else
|
|
||||||
bcopy(&bindAddr, &(myAddrs[0].s_addr), sizeof(in_addr_t));
|
|
||||||
#endif
|
|
||||||
Verbose("interface address %s (-M option)", inet_ntoa(myAddrs[0]));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Verbose("using hostname for interface addresses");
|
/* now make sure it's empty...erase anything you see, etc */
|
||||||
if ((struct hostent *)0 == (he = gethostbyname(myHostname))) {
|
if ((dir = opendir(d)) == (DIR *) 0) {
|
||||||
Error("ProbeInterfaces(): gethostbyname(%s): %s", myHostname,
|
Error("opendir(%s): %s", d, strerror(errno));
|
||||||
hstrerror(h_errno));
|
return -1;
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (4 != he->h_length || AF_INET != he->h_addrtype) {
|
|
||||||
Error
|
|
||||||
("ProbeInterfaces(): gethostbyname(%s): wrong address size (4 != %d) or address family (%d != %d)",
|
|
||||||
myHostname, he->h_length, AF_INET, he->h_addrtype);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (count = 0; he->h_addr_list[count] != (char *)0; count++);
|
while ((de = readdir(dir)) != (struct dirent *)0) {
|
||||||
if (myAddrs != (struct in_addr *)0)
|
if ((strcmp(de->d_name, ".") == 0) ||
|
||||||
free(myAddrs);
|
(strcmp(de->d_name, "..") == 0))
|
||||||
myAddrs = (struct in_addr *)0;
|
continue;
|
||||||
if (count == 0)
|
/* we're going to just let the user deal with non-empty directories */
|
||||||
return;
|
Error("non-empty directory `%s'", d);
|
||||||
myAddrs = (struct in_addr *)calloc(count + 1, sizeof(struct in_addr));
|
retval = -1;
|
||||||
if (myAddrs == (struct in_addr *)0)
|
break;
|
||||||
OutOfMem();
|
/* this is probably too extreme. if someone happens to point conserver
|
||||||
for (count--; count >= 0; count--) {
|
* at /etc, for example, it could (if running as root) nuke the password
|
||||||
#if HAVE_MEMCPY
|
* database, config files, etc. too many important files could be
|
||||||
memcpy(&(myAddrs[count].s_addr), he->h_addr_list[count],
|
* shredded with a small typo.
|
||||||
he->h_length);
|
*/
|
||||||
#else
|
#if 0
|
||||||
bcopy(he->h_addr_list[count], &(myAddrs[count].s_addr),
|
if (path == (STRING *)0)
|
||||||
he->h_length);
|
path = AllocString();
|
||||||
|
BuildStringPrint(path, "%s/%s", d, de->d_name);
|
||||||
|
if (stat(path->string, &dstat) == -1) {
|
||||||
|
Error("stat(%s): %s", path->string, strerror(errno));
|
||||||
|
retval = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (S_ISDIR(dstat.st_mode)) {
|
||||||
|
if (rmdir(path->string) != 0) {
|
||||||
|
Error("rmdir(%s): %s", path->string, strerror(errno));
|
||||||
|
retval = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (unlink(path->string) != 0) {
|
||||||
|
Error("unlink(%s): %s", path->string, strerror(errno));
|
||||||
|
retval = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
Verbose("interface address %s (hostname address)",
|
|
||||||
inet_ntoa(myAddrs[count]));
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
if (path != (STRING *)0)
|
||||||
|
DestroyString(path);
|
||||||
|
|
||||||
|
return retval;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* find out where/who we are (ksb)
|
/* find out where/who we are (ksb)
|
||||||
* parse optons
|
* parse optons
|
||||||
@ -1180,17 +1095,19 @@ main(argc, argv)
|
|||||||
char *curuser = (char *)0;
|
char *curuser = (char *)0;
|
||||||
int curuid = 0;
|
int curuid = 0;
|
||||||
GRPENT *pGE = (GRPENT *)0;
|
GRPENT *pGE = (GRPENT *)0;
|
||||||
|
#if !USE_UNIX_DOMAIN_SOCKETS
|
||||||
#if HAVE_INET_ATON
|
#if HAVE_INET_ATON
|
||||||
struct in_addr inetaddr;
|
struct in_addr inetaddr;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
isMultiProc = 1; /* make sure stuff has the pid */
|
isMultiProc = 1; /* make sure stuff has the pid */
|
||||||
|
|
||||||
thepid = getpid();
|
thepid = getpid();
|
||||||
if ((char *)0 == (progname = strrchr(argv[0], '/'))) {
|
if ((char *)0 == (progname = strrchr(argv[0], '/'))) {
|
||||||
progname = StrDup(argv[0]);
|
progname = argv[0];
|
||||||
} else {
|
} else {
|
||||||
progname = StrDup(++progname);
|
++progname;
|
||||||
}
|
}
|
||||||
|
|
||||||
setpwent();
|
setpwent();
|
||||||
@ -1252,7 +1169,7 @@ main(argc, argv)
|
|||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
case 'C':
|
case 'C':
|
||||||
pcConfig = StrDup(optarg);
|
pcConfig = optarg;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
optConf->daemonmode = FLAGTRUE;
|
optConf->daemonmode = FLAGTRUE;
|
||||||
@ -1379,37 +1296,46 @@ main(argc, argv)
|
|||||||
if (fSyntaxOnly)
|
if (fSyntaxOnly)
|
||||||
Msg("performing configuration file syntax check");
|
Msg("performing configuration file syntax check");
|
||||||
|
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
/* Don't do any redirects if we're purely local
|
||||||
|
* (but it allows them to see where remote consoles are)
|
||||||
|
*/
|
||||||
|
optConf->redirect = FLAGFALSE;
|
||||||
|
if (interface == (char *)0)
|
||||||
|
interface = UDSDIR;
|
||||||
|
#else
|
||||||
/* set up the address to bind to */
|
/* set up the address to bind to */
|
||||||
if (interface == (char *)0 ||
|
if (interface == (char *)0 ||
|
||||||
(interface[0] == '*' && interface[1] == '\000'))
|
(interface[0] == '*' && interface[1] == '\000'))
|
||||||
bindAddr = INADDR_ANY;
|
bindAddr = INADDR_ANY;
|
||||||
else {
|
else {
|
||||||
#if HAVE_INET_ATON
|
# if HAVE_INET_ATON
|
||||||
if (inet_aton(interface, &inetaddr) == 0) {
|
if (inet_aton(interface, &inetaddr) == 0) {
|
||||||
Error("inet_aton(%s): %s", interface, "invalid IP address");
|
Error("inet_aton(%s): %s", interface, "invalid IP address");
|
||||||
Bye(EX_OSERR);
|
Bye(EX_OSERR);
|
||||||
}
|
}
|
||||||
bindAddr = inetaddr.s_addr;
|
bindAddr = inetaddr.s_addr;
|
||||||
#else
|
# else
|
||||||
bindAddr = inet_addr(interface);
|
bindAddr = inet_addr(interface);
|
||||||
if (bindAddr == (in_addr_t) (-1)) {
|
if (bindAddr == (in_addr_t) (-1)) {
|
||||||
Error("inet_addr(%s): %s", interface, "invalid IP address");
|
Error("inet_addr(%s): %s", interface, "invalid IP address");
|
||||||
Bye(EX_OSERR);
|
Bye(EX_OSERR);
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
}
|
}
|
||||||
if (fDebug) {
|
if (fDebug) {
|
||||||
struct in_addr ba;
|
struct in_addr ba;
|
||||||
ba.s_addr = bindAddr;
|
ba.s_addr = bindAddr;
|
||||||
CONDDEBUG((1, "main(): bind address set to `%s'", inet_ntoa(ba)));
|
CONDDEBUG((1, "main(): bind address set to `%s'", inet_ntoa(ba)));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* must do all this so IsMe() works right */
|
/* must do all this so IsMe() works right */
|
||||||
if (gethostname(myHostname, MAXHOSTNAME) != 0) {
|
if (gethostname(myHostname, MAXHOSTNAME) != 0) {
|
||||||
Error("gethostname(): %s", interface, strerror(errno));
|
Error("gethostname(): %s", strerror(errno));
|
||||||
Bye(EX_OSERR);
|
Bye(EX_OSERR);
|
||||||
}
|
}
|
||||||
ProbeInterfaces();
|
ProbeInterfaces(bindAddr);
|
||||||
|
|
||||||
/* initialize the timers */
|
/* initialize the timers */
|
||||||
for (i = 0; i < T_MAX; i++)
|
for (i = 0; i < T_MAX; i++)
|
||||||
@ -1423,6 +1349,7 @@ main(argc, argv)
|
|||||||
ReadCfg(pcConfig, fpConfig);
|
ReadCfg(pcConfig, fpConfig);
|
||||||
fclose(fpConfig);
|
fclose(fpConfig);
|
||||||
|
|
||||||
|
#if !USE_UNIX_DOMAIN_SOCKETS
|
||||||
/* set up the port to bind to */
|
/* set up the port to bind to */
|
||||||
if (optConf->primaryport != (char *)0)
|
if (optConf->primaryport != (char *)0)
|
||||||
config->primaryport = StrDup(optConf->primaryport);
|
config->primaryport = StrDup(optConf->primaryport);
|
||||||
@ -1482,6 +1409,7 @@ main(argc, argv)
|
|||||||
bindBasePort = ntohs((unsigned short)pSE->s_port);
|
bindBasePort = ntohs((unsigned short)pSE->s_port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (optConf->passwdfile != (char *)0)
|
if (optConf->passwdfile != (char *)0)
|
||||||
config->passwdfile = StrDup(optConf->passwdfile);
|
config->passwdfile = StrDup(optConf->passwdfile);
|
||||||
@ -1549,6 +1477,14 @@ main(argc, argv)
|
|||||||
if (config->unifiedlog == (char *)0)
|
if (config->unifiedlog == (char *)0)
|
||||||
OutOfMem();
|
OutOfMem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (optConf->initdelay != 0)
|
||||||
|
config->initdelay = optConf->initdelay;
|
||||||
|
else if (pConfig->initdelay != 0)
|
||||||
|
config->initdelay = pConfig->initdelay;
|
||||||
|
else
|
||||||
|
config->initdelay = defConfig.initdelay;
|
||||||
|
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
if (optConf->sslrequired != FLAGUNKNOWN)
|
if (optConf->sslrequired != FLAGUNKNOWN)
|
||||||
config->sslrequired = optConf->sslrequired;
|
config->sslrequired = optConf->sslrequired;
|
||||||
@ -1580,7 +1516,13 @@ main(argc, argv)
|
|||||||
|
|
||||||
if (pGroups == (GRPENT *)0 && pRCList == (REMOTE *)0) {
|
if (pGroups == (GRPENT *)0 && pRCList == (REMOTE *)0) {
|
||||||
Error("no consoles found in configuration file");
|
Error("no consoles found in configuration file");
|
||||||
} else if (!fSyntaxOnly) {
|
} else if (fSyntaxOnly) {
|
||||||
|
/* short-circuit */
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
} else if (VerifyEmptyDirectory(interface) == -1) {
|
||||||
|
Error("Master(): %s: unusable socket directory", interface);
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
/* Prep the SSL layer */
|
/* Prep the SSL layer */
|
||||||
SetupSSL();
|
SetupSSL();
|
||||||
@ -1603,7 +1545,6 @@ main(argc, argv)
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
Spawn(pGE);
|
Spawn(pGE);
|
||||||
|
|
||||||
Verbose("group #%d pid %lu on port %hu", pGE->id,
|
Verbose("group #%d pid %lu on port %hu", pGE->id,
|
||||||
(unsigned long)pGE->pid, pGE->port);
|
(unsigned long)pGE->pid, pGE->port);
|
||||||
}
|
}
|
||||||
@ -1617,8 +1558,13 @@ main(argc, argv)
|
|||||||
local += pGE->imembers;
|
local += pGE->imembers;
|
||||||
for (pRC = pRCList; (REMOTE *)0 != pRC; pRC = pRC->pRCnext)
|
for (pRC = pRCList; (REMOTE *)0 != pRC; pRC = pRC->pRCnext)
|
||||||
remote++;
|
remote++;
|
||||||
|
# if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
setproctitle("master: port 0, %d local, %d remote", local,
|
||||||
|
remote);
|
||||||
|
#else
|
||||||
setproctitle("master: port %hu, %d local, %d remote", bindPort,
|
setproctitle("master: port %hu, %d local, %d remote", bindPort,
|
||||||
local, remote);
|
local, remote);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: main.h,v 5.51 2003/11/10 15:37:24 bryan Exp $
|
* $Id: main.h,v 5.53 2004/05/21 04:15:17 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -44,11 +44,13 @@ extern unsigned short bindPort, bindBasePort;
|
|||||||
extern char *pcConfig;
|
extern char *pcConfig;
|
||||||
extern int cMaxMemb;
|
extern int cMaxMemb;
|
||||||
extern struct sockaddr_in in_port;
|
extern struct sockaddr_in in_port;
|
||||||
extern int isMaster;
|
|
||||||
extern CONFIG *optConf;
|
extern CONFIG *optConf;
|
||||||
extern CONFIG *config;
|
extern CONFIG *config;
|
||||||
extern CONFIG defConfig;
|
extern CONFIG defConfig;
|
||||||
extern CONSFILE *unifiedlog;
|
extern CONSFILE *unifiedlog;
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
extern char *interface;
|
||||||
|
#endif
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
extern SSL_CTX *ctx;
|
extern SSL_CTX *ctx;
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: master.c,v 5.124 2003/12/25 19:22:00 bryan Exp $
|
* $Id: master.c,v 5.126 2004/05/06 02:09:07 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -569,6 +569,10 @@ DoNormalRead(pCLServing)
|
|||||||
int iSep = 1;
|
int iSep = 1;
|
||||||
|
|
||||||
if ((GRPENT *)0 != pGroups) {
|
if ((GRPENT *)0 != pGroups) {
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
FilePrint(pCLServing->fd, FLAGTRUE, "@0");
|
||||||
|
iSep = 0;
|
||||||
|
#else
|
||||||
struct sockaddr_in lcl;
|
struct sockaddr_in lcl;
|
||||||
socklen_t so = sizeof(lcl);
|
socklen_t so = sizeof(lcl);
|
||||||
if (-1 ==
|
if (-1 ==
|
||||||
@ -579,22 +583,26 @@ DoNormalRead(pCLServing)
|
|||||||
-1);
|
-1);
|
||||||
Error("Master(): getsockname(%u): %s",
|
Error("Master(): getsockname(%u): %s",
|
||||||
FileFDNum(pCLServing->fd), strerror(errno));
|
FileFDNum(pCLServing->fd), strerror(errno));
|
||||||
Bye(EX_OSERR);
|
iSep = -1;
|
||||||
}
|
} else {
|
||||||
FilePrint(pCLServing->fd, FLAGTRUE, "@%s",
|
FilePrint(pCLServing->fd, FLAGTRUE, "@%s",
|
||||||
inet_ntoa(lcl.sin_addr));
|
inet_ntoa(lcl.sin_addr));
|
||||||
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;
|
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 &&
|
} else if (pCLServing->iState == S_NORMAL &&
|
||||||
strcmp(pcCmd, "pid") == 0) {
|
strcmp(pcCmd, "pid") == 0) {
|
||||||
FilePrint(pCLServing->fd, FLAGFALSE, "%lu\r\n",
|
FilePrint(pCLServing->fd, FLAGFALSE, "%lu\r\n",
|
||||||
@ -673,8 +681,13 @@ Master()
|
|||||||
int msfd;
|
int msfd;
|
||||||
socklen_t so;
|
socklen_t so;
|
||||||
fd_set rmask, wmask;
|
fd_set rmask, wmask;
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
struct sockaddr_un master_port;
|
||||||
|
static STRING *portPath = (STRING *)0;
|
||||||
|
#else
|
||||||
struct sockaddr_in master_port;
|
struct sockaddr_in master_port;
|
||||||
int true = 1;
|
int true = 1;
|
||||||
|
#endif
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
CONSCLIENT *pCLServing = (CONSCLIENT *)0;
|
CONSCLIENT *pCLServing = (CONSCLIENT *)0;
|
||||||
CONSCLIENT *pCL = (CONSCLIENT *)0;
|
CONSCLIENT *pCL = (CONSCLIENT *)0;
|
||||||
@ -715,6 +728,40 @@ Master()
|
|||||||
#else
|
#else
|
||||||
bzero((char *)&master_port, sizeof(master_port));
|
bzero((char *)&master_port, sizeof(master_port));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
master_port.sun_family = AF_UNIX;
|
||||||
|
|
||||||
|
if (portPath == (STRING *)0)
|
||||||
|
portPath = AllocString();
|
||||||
|
BuildStringPrint(portPath, "%s/0", interface);
|
||||||
|
if (portPath->used > sizeof(master_port.sun_path)) {
|
||||||
|
Error("Master(): path to socket too long: %s", portPath->string);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
strcpy(master_port.sun_path, portPath->string);
|
||||||
|
|
||||||
|
if ((msfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
||||||
|
Error("Master(): socket(AF_UNIX,SOCK_STREAM): %s",
|
||||||
|
strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!SetFlags(msfd, O_NONBLOCK, 0))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (bind(msfd, (struct sockaddr *)&master_port, sizeof(master_port)) <
|
||||||
|
0) {
|
||||||
|
Error("Master(): bind(%s): %s", master_port.sun_path,
|
||||||
|
strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (listen(msfd, SOMAXCONN) < 0) {
|
||||||
|
Error("Master(): listen(%s): %s", master_port.sun_path,
|
||||||
|
strerror(errno));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#else
|
||||||
master_port.sin_family = AF_INET;
|
master_port.sin_family = AF_INET;
|
||||||
master_port.sin_addr.s_addr = bindAddr;
|
master_port.sin_addr.s_addr = bindAddr;
|
||||||
master_port.sin_port = htons(bindPort);
|
master_port.sin_port = htons(bindPort);
|
||||||
@ -724,7 +771,7 @@ Master()
|
|||||||
strerror(errno));
|
strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if HAVE_SETSOCKOPT
|
# if HAVE_SETSOCKOPT
|
||||||
if (setsockopt
|
if (setsockopt
|
||||||
(msfd, SOL_SOCKET, SO_REUSEADDR, (char *)&true,
|
(msfd, SOL_SOCKET, SO_REUSEADDR, (char *)&true,
|
||||||
sizeof(true)) < 0) {
|
sizeof(true)) < 0) {
|
||||||
@ -732,7 +779,7 @@ Master()
|
|||||||
strerror(errno));
|
strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
# endif
|
||||||
|
|
||||||
if (!SetFlags(msfd, O_NONBLOCK, 0))
|
if (!SetFlags(msfd, O_NONBLOCK, 0))
|
||||||
return;
|
return;
|
||||||
@ -748,6 +795,7 @@ Master()
|
|||||||
strerror(errno));
|
strerror(errno));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
fp = fopen(PIDFILE, "w");
|
fp = fopen(PIDFILE, "w");
|
||||||
if (fp) {
|
if (fp) {
|
||||||
@ -943,6 +991,9 @@ Master()
|
|||||||
}
|
}
|
||||||
|
|
||||||
close(msfd);
|
close(msfd);
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
unlink(master_port.sun_path);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* clean up the free list */
|
/* clean up the free list */
|
||||||
while (pCLmfree != (CONSCLIENT *)0) {
|
while (pCLmfree != (CONSCLIENT *)0) {
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: readcfg.h,v 5.38 2003/11/10 15:37:24 bryan Exp $
|
* $Id: readcfg.h,v 5.40 2004/05/25 23:03:01 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -20,6 +20,7 @@ typedef struct config {
|
|||||||
int reinitcheck;
|
int reinitcheck;
|
||||||
char *secondaryport;
|
char *secondaryport;
|
||||||
char *unifiedlog;
|
char *unifiedlog;
|
||||||
|
int initdelay;
|
||||||
#if HAVE_SETPROCTITLE
|
#if HAVE_SETPROCTITLE
|
||||||
FLAG setproctitle;
|
FLAG setproctitle;
|
||||||
#endif
|
#endif
|
||||||
@ -42,6 +43,7 @@ extern ACCESS *pACList; /* `who do you love' (or trust) */
|
|||||||
extern CONSENTUSERS *pADList; /* list of admin users */
|
extern CONSENTUSERS *pADList; /* list of admin users */
|
||||||
extern BREAKS breakList[9]; /* list of break sequences */
|
extern BREAKS breakList[9]; /* list of break sequences */
|
||||||
extern CONFIG *pConfig; /* settings seen by config parser */
|
extern CONFIG *pConfig; /* settings seen by config parser */
|
||||||
|
extern SUBST *substData; /* substitution function data */
|
||||||
|
|
||||||
extern void ReadCfg PARAMS((char *, FILE *));
|
extern void ReadCfg PARAMS((char *, FILE *));
|
||||||
extern void ReReadCfg PARAMS((int));
|
extern void ReReadCfg PARAMS((int));
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: version.h,v 1.59 2004/03/16 04:17:31 bryan Exp $
|
* $Id: version.h,v 1.62 2004/05/23 16:44:45 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -14,4 +14,4 @@
|
|||||||
@(#) Copyright 2000 conserver.com.\n\
|
@(#) Copyright 2000 conserver.com.\n\
|
||||||
All rights reserved.\n"
|
All rights reserved.\n"
|
||||||
|
|
||||||
#define THIS_VERSION "conserver.com version 8.1.3"
|
#define THIS_VERSION "conserver.com version 8.1.6"
|
||||||
|
@ -25,11 +25,11 @@ LIBS = @LIBS@
|
|||||||
|
|
||||||
### Makefile rules - no user-servicable parts below
|
### Makefile rules - no user-servicable parts below
|
||||||
|
|
||||||
CONSOLE_OBJS = console.o getpassword.o ../conserver/cutil.o
|
CONSOLE_OBJS = console.o getpassword.o readconf.o ../conserver/cutil.o
|
||||||
CONSOLE_HDRS = ../config.h $(top_srcdir)/compat.h \
|
CONSOLE_HDRS = ../config.h $(top_srcdir)/compat.h \
|
||||||
$(top_srcdir)/conserver/cutil.h \
|
$(top_srcdir)/conserver/cutil.h \
|
||||||
$(top_srcdir)/conserver/version.h \
|
$(top_srcdir)/conserver/version.h \
|
||||||
$(srcdir)/getpassword.h
|
$(srcdir)/getpassword.h $(srcdir)/readconf.h
|
||||||
ALL = console
|
ALL = console
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* $Id: console.c,v 5.161 2004/03/20 14:40:42 bryan Exp $
|
* $Id: console.c,v 5.167 2004/05/25 23:03:25 bryan Exp $
|
||||||
*
|
*
|
||||||
* Copyright conserver.com, 2000
|
* Copyright conserver.com, 2000
|
||||||
*
|
*
|
||||||
@ -34,6 +34,7 @@
|
|||||||
#include <getpassword.h>
|
#include <getpassword.h>
|
||||||
#include <cutil.h>
|
#include <cutil.h>
|
||||||
#include <version.h>
|
#include <version.h>
|
||||||
|
#include <readconf.h>
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
#include <openssl/ssl.h>
|
#include <openssl/ssl.h>
|
||||||
#include <openssl/err.h>
|
#include <openssl/err.h>
|
||||||
@ -41,18 +42,11 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
int fReplay = 0, fVersion = 0, fStrip = 0;
|
int fReplay = 0, fVersion = 0;
|
||||||
#if HAVE_OPENSSL
|
int showExecData = 1;
|
||||||
int fReqEncryption = 1;
|
|
||||||
char *pcCredFile = (char *)0;
|
|
||||||
#endif
|
|
||||||
int chAttn = -1, chEsc = -1;
|
int chAttn = -1, chEsc = -1;
|
||||||
char *pcInMaster = /* which machine is current */
|
|
||||||
MASTERHOST;
|
|
||||||
char *pcPort = DEFPORT;
|
|
||||||
unsigned short bindPort;
|
unsigned short bindPort;
|
||||||
CONSFILE *cfstdout;
|
CONSFILE *cfstdout;
|
||||||
char *pcUser = (char *)0;
|
|
||||||
int disconnectCount = 0;
|
int disconnectCount = 0;
|
||||||
STRING *execCmd = (STRING *)0;
|
STRING *execCmd = (STRING *)0;
|
||||||
CONSFILE *execCmdFile = (CONSFILE *)0;
|
CONSFILE *execCmdFile = (CONSFILE *)0;
|
||||||
@ -61,6 +55,8 @@ CONSFILE *gotoConsole = (CONSFILE *)0;
|
|||||||
CONSFILE *prevConsole = (CONSFILE *)0;
|
CONSFILE *prevConsole = (CONSFILE *)0;
|
||||||
char *gotoName = (char *)0;
|
char *gotoName = (char *)0;
|
||||||
char *prevName = (char *)0;
|
char *prevName = (char *)0;
|
||||||
|
CONFIG *optConf = (CONFIG *)0;
|
||||||
|
CONFIG *config = (CONFIG *)0;
|
||||||
|
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
SSL_CTX *ctx = (SSL_CTX *)0;
|
SSL_CTX *ctx = (SSL_CTX *)0;
|
||||||
@ -86,15 +82,17 @@ SetupSSL()
|
|||||||
Error("Could not load SSL default CA file and/or directory");
|
Error("Could not load SSL default CA file and/or directory");
|
||||||
Bye(EX_UNAVAILABLE);
|
Bye(EX_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
if (pcCredFile != (char *)0) {
|
if (config->sslcredentials != (char *)0) {
|
||||||
if (SSL_CTX_use_certificate_chain_file(ctx, pcCredFile) != 1) {
|
if (SSL_CTX_use_certificate_chain_file
|
||||||
|
(ctx, config->sslcredentials) != 1) {
|
||||||
Error("Could not load SSL certificate from '%s'",
|
Error("Could not load SSL certificate from '%s'",
|
||||||
pcCredFile);
|
config->sslcredentials);
|
||||||
Bye(EX_UNAVAILABLE);
|
Bye(EX_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
if (SSL_CTX_use_PrivateKey_file
|
if (SSL_CTX_use_PrivateKey_file
|
||||||
(ctx, pcCredFile, SSL_FILETYPE_PEM) != 1) {
|
(ctx, config->sslcredentials, SSL_FILETYPE_PEM) != 1) {
|
||||||
Error("Could not SSL private key from '%s'", pcCredFile);
|
Error("Could not SSL private key from '%s'",
|
||||||
|
config->sslcredentials);
|
||||||
Bye(EX_UNAVAILABLE);
|
Bye(EX_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,48 +183,56 @@ Usage(wantfull)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
static char *full[] = {
|
static char *full[] = {
|
||||||
"7 strip the high bit off all console data",
|
"7 strip the high bit off all console data",
|
||||||
"a(A) attach politely (and replay last 20 lines)",
|
"a(A) attach politely (and replay last 20 lines)",
|
||||||
"b(B) send broadcast message to all users (on master)",
|
"b(B) send broadcast message to all users (on master)",
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
"c cred load an SSL certificate and key from the PEM encoded file",
|
"c cred load an SSL certificate and key from the PEM encoded file",
|
||||||
#else
|
#else
|
||||||
"c cred ignored - encryption not compiled into code",
|
"c cred ignored - encryption not compiled into code",
|
||||||
#endif
|
#endif
|
||||||
"d disconnect [user][@console]",
|
"C config override per-user config file",
|
||||||
"D enable debug output, sent to stderr",
|
"d disconnect [user][@console]",
|
||||||
"e esc set the initial escape characters",
|
"D enable debug output, sent to stderr",
|
||||||
|
"e esc set the initial escape characters",
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
"E don't attempt encrypted connections",
|
"E don't attempt encrypted connections",
|
||||||
#else
|
#else
|
||||||
"E ignored - encryption not compiled into code",
|
"E ignored - encryption not compiled into code",
|
||||||
#endif
|
#endif
|
||||||
"f(F) force read/write connection (and replay)",
|
"f(F) force read/write connection (and replay)",
|
||||||
"h output this message",
|
"h output this message",
|
||||||
"i(I) display information in machine-parseable form (on master)",
|
"i(I) display information in machine-parseable form (on master)",
|
||||||
"l user use username instead of current username",
|
"l user use username instead of current username",
|
||||||
"M mach master server to poll first",
|
"M master master server to poll first",
|
||||||
"p port port to connect to",
|
"n do not read system-wide config file",
|
||||||
"P display pids of daemon(s)",
|
"p port port to connect to",
|
||||||
"q(Q) send a quit command to the (master) server",
|
"P display pids of daemon(s)",
|
||||||
"r(R) display (master) daemon version (think 'r'emote version)",
|
"q(Q) send a quit command to the (master) server",
|
||||||
"s(S) spy on a console (and replay)",
|
"r(R) display (master) daemon version (think 'r'emote version)",
|
||||||
"t send a text message to [user][@console]",
|
"s(S) spy on a console (and replay)",
|
||||||
"u show users on the various consoles",
|
"t send a text message to [user][@console]",
|
||||||
"v be more verbose",
|
"u show users on the various consoles",
|
||||||
"V show version information",
|
#if HAVE_OPENSSL
|
||||||
"w(W) show who is on which console (on master)",
|
"U allow unencrypted connections if SSL not available",
|
||||||
"x examine ports and baud rates",
|
#else
|
||||||
|
"U ignored - encryption not compiled into code",
|
||||||
|
#endif
|
||||||
|
"v be more verbose",
|
||||||
|
"V show version information",
|
||||||
|
"w(W) show who is on which console (on master)",
|
||||||
|
"x examine ports and baud rates",
|
||||||
(char *)0
|
(char *)0
|
||||||
};
|
};
|
||||||
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s [-aAEfFsS] [-7Dv] [-c cred] [-M mach] [-p port] [-e esc] [-l username] console\n",
|
"usage: %s [-aAfFsS] [-7DEnUv] [-c cred] [-C config] [-M master] [-p port] [-e esc] [-l username] console\n",
|
||||||
progname);
|
progname);
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"usage: %s [-hiIPrRuVwWx] [-7Dv] [-M mach] [-p port] [-d [user][@console]] [-[bB] message] [-t [user][@console] message]\n",
|
" %s [-hiIPrRuVwWx] [-7DEnUv] [-c cred] [-C config] [-M master] [-p port] [-d [user][@console]] [-[bB] message] [-t [user][@console] message]\n",
|
||||||
progname);
|
progname);
|
||||||
fprintf(stderr, "usage: %s [-qQ] [-7Dv] [-M mach] [-p port]\n",
|
fprintf(stderr,
|
||||||
|
" %s [-qQ] [-7DEnUv] [-c cred] [-C config] [-M master] [-p port]\n",
|
||||||
progname);
|
progname);
|
||||||
|
|
||||||
if (wantfull) {
|
if (wantfull) {
|
||||||
@ -260,6 +266,9 @@ Version()
|
|||||||
#endif
|
#endif
|
||||||
#if HAVE_PAM
|
#if HAVE_PAM
|
||||||
"pam",
|
"pam",
|
||||||
|
#endif
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
"uds",
|
||||||
#endif
|
#endif
|
||||||
(char *)0
|
(char *)0
|
||||||
};
|
};
|
||||||
@ -270,10 +279,16 @@ Version()
|
|||||||
acA2 = AllocString();
|
acA2 = AllocString();
|
||||||
|
|
||||||
Msg("%s", THIS_VERSION);
|
Msg("%s", THIS_VERSION);
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
Msg("default socket directory `%s\'", UDSDIR);
|
||||||
|
#else
|
||||||
Msg("default initial master server `%s\'", MASTERHOST);
|
Msg("default initial master server `%s\'", MASTERHOST);
|
||||||
|
Msg("default port referenced as `%s'", DEFPORT);
|
||||||
|
#endif
|
||||||
Msg("default escape sequence `%s%s\'", FmtCtl(DEFATTN, acA1),
|
Msg("default escape sequence `%s%s\'", FmtCtl(DEFATTN, acA1),
|
||||||
FmtCtl(DEFESC, acA2));
|
FmtCtl(DEFESC, acA2));
|
||||||
Msg("default port referenced as `%s'", DEFPORT);
|
Msg("default site-wide configuration in `%s'", CLIENTCONFIGFILE);
|
||||||
|
Msg("default per-user configuration in `%s'", "$HOME/.consolerc");
|
||||||
|
|
||||||
BuildString((char *)0, acA1);
|
BuildString((char *)0, acA1);
|
||||||
if (optionlist[0] == (char *)0)
|
if (optionlist[0] == (char *)0)
|
||||||
@ -294,10 +309,12 @@ Version()
|
|||||||
BuildStringChar('0' + DMALLOC_VERSION_MINOR, acA1);
|
BuildStringChar('0' + DMALLOC_VERSION_MINOR, acA1);
|
||||||
BuildStringChar('.', acA1);
|
BuildStringChar('.', acA1);
|
||||||
BuildStringChar('0' + DMALLOC_VERSION_PATCH, acA1);
|
BuildStringChar('0' + DMALLOC_VERSION_PATCH, acA1);
|
||||||
|
#if defined(DMALLOC_VERSION_BETA)
|
||||||
if (DMALLOC_VERSION_BETA != 0) {
|
if (DMALLOC_VERSION_BETA != 0) {
|
||||||
BuildString("-b", acA1);
|
BuildString("-b", acA1);
|
||||||
BuildStringChar('0' + DMALLOC_VERSION_BETA, acA1);
|
BuildStringChar('0' + DMALLOC_VERSION_BETA, acA1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
Msg("dmalloc version: %s", acA1->string);
|
Msg("dmalloc version: %s", acA1->string);
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
@ -372,7 +389,7 @@ ValidateEsc()
|
|||||||
{
|
{
|
||||||
unsigned char c1, c2;
|
unsigned char c1, c2;
|
||||||
|
|
||||||
if (!fStrip)
|
if (config->striphigh != FLAGTRUE)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (chAttn == -1 || chEsc == -1) {
|
if (chAttn == -1 || chEsc == -1) {
|
||||||
@ -430,8 +447,13 @@ GetPort(pcToHost, sPort)
|
|||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
int s;
|
int s;
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
struct sockaddr_un port;
|
||||||
|
static STRING *portPath = (STRING *)0;
|
||||||
|
#else
|
||||||
struct hostent *hp = (struct hostent *)0;
|
struct hostent *hp = (struct hostent *)0;
|
||||||
struct sockaddr_in port;
|
struct sockaddr_in port;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAVE_MEMSET
|
#if HAVE_MEMSET
|
||||||
memset((void *)(&port), '\000', sizeof(port));
|
memset((void *)(&port), '\000', sizeof(port));
|
||||||
@ -439,21 +461,47 @@ GetPort(pcToHost, sPort)
|
|||||||
bzero((char *)(&port), sizeof(port));
|
bzero((char *)(&port), sizeof(port));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if HAVE_INET_ATON
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
if (inet_aton(pcToHost, &(port.sin_addr)) == 0)
|
if (portPath == (STRING *)0)
|
||||||
|
portPath = AllocString();
|
||||||
|
BuildStringPrint(portPath, "%s/%hu", config->master, sPort);
|
||||||
|
port.sun_family = AF_UNIX;
|
||||||
|
if (portPath->used > sizeof(port.sun_path)) {
|
||||||
|
Error("GetPort: path to socket too long: %s", portPath->string);
|
||||||
|
return (CONSFILE *)0;
|
||||||
|
}
|
||||||
|
strcpy(port.sun_path, portPath->string);
|
||||||
|
|
||||||
|
CONDDEBUG((1, "GetPort: socket=%s", port.sun_path));
|
||||||
|
|
||||||
|
/* set up the socket to talk to the server for all consoles
|
||||||
|
* (it will tell us who to talk to to get a real connection)
|
||||||
|
*/
|
||||||
|
if ((s = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
|
||||||
|
Error("socket(AF_UNIX,SOCK_STREAM): %s", strerror(errno));
|
||||||
|
return (CONSFILE *)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (connect(s, (struct sockaddr *)(&port), sizeof(port)) < 0) {
|
||||||
|
Error("connect(): %s: %s", port.sun_path, strerror(errno));
|
||||||
|
return (CONSFILE *)0;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
|
# if HAVE_INET_ATON
|
||||||
|
if (inet_aton(pcToHost, &(port.sin_addr)) == 0)
|
||||||
|
# else
|
||||||
port.sin_addr.s_addr = inet_addr(pcToHost);
|
port.sin_addr.s_addr = inet_addr(pcToHost);
|
||||||
if ((in_addr_t) (-1) == port.sin_addr.s_addr)
|
if ((in_addr_t) (-1) == port.sin_addr.s_addr)
|
||||||
#endif
|
# endif
|
||||||
{
|
{
|
||||||
if ((struct hostent *)0 != (hp = gethostbyname(pcToHost))) {
|
if ((struct hostent *)0 != (hp = gethostbyname(pcToHost))) {
|
||||||
#if HAVE_MEMCPY
|
# if HAVE_MEMCPY
|
||||||
memcpy((char *)&port.sin_addr.s_addr, (char *)hp->h_addr,
|
memcpy((char *)&port.sin_addr.s_addr, (char *)hp->h_addr,
|
||||||
hp->h_length);
|
hp->h_length);
|
||||||
#else
|
# else
|
||||||
bcopy((char *)hp->h_addr, (char *)&port.sin_addr.s_addr,
|
bcopy((char *)hp->h_addr, (char *)&port.sin_addr.s_addr,
|
||||||
hp->h_length);
|
hp->h_length);
|
||||||
#endif
|
# endif
|
||||||
} else {
|
} else {
|
||||||
Error("gethostbyname(%s): %s", pcToHost, hstrerror(h_errno));
|
Error("gethostbyname(%s): %s", pcToHost, hstrerror(h_errno));
|
||||||
return (CONSFILE *)0;
|
return (CONSFILE *)0;
|
||||||
@ -481,11 +529,13 @@ GetPort(pcToHost, sPort)
|
|||||||
Error("socket(AF_INET,SOCK_STREAM): %s", strerror(errno));
|
Error("socket(AF_INET,SOCK_STREAM): %s", strerror(errno));
|
||||||
return (CONSFILE *)0;
|
return (CONSFILE *)0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (connect(s, (struct sockaddr *)(&port), sizeof(port)) < 0) {
|
if (connect(s, (struct sockaddr *)(&port), sizeof(port)) < 0) {
|
||||||
Error("connect(): %hu@%s: %s", ntohs(port.sin_port), pcToHost,
|
Error("connect(): %hu@%s: %s", ntohs(port.sin_port), pcToHost,
|
||||||
strerror(errno));
|
strerror(errno));
|
||||||
return (CONSFILE *)0;
|
return (CONSFILE *)0;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return FileOpenFD(s, simpleSocket);
|
return FileOpenFD(s, simpleSocket);
|
||||||
}
|
}
|
||||||
@ -558,7 +608,15 @@ DestroyDataStructures()
|
|||||||
C2Cooked();
|
C2Cooked();
|
||||||
if (cfstdout != (CONSFILE *)0)
|
if (cfstdout != (CONSFILE *)0)
|
||||||
FileUnopen(cfstdout);
|
FileUnopen(cfstdout);
|
||||||
|
DestroyConfig(pConfig);
|
||||||
|
DestroyConfig(optConf);
|
||||||
|
DestroyConfig(config);
|
||||||
|
DestroyTerminal(pTerm);
|
||||||
|
if (myAddrs != (struct in_addr *)0)
|
||||||
|
free(myAddrs);
|
||||||
DestroyStrings();
|
DestroyStrings();
|
||||||
|
if (substData != (SUBST *) 0)
|
||||||
|
free(substData);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
@ -848,6 +906,7 @@ DoExec(pcf)
|
|||||||
CONSFILE *pcf;
|
CONSFILE *pcf;
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
|
showExecData = 1;
|
||||||
FileWrite(cfstdout, FLAGFALSE, "exec: ", 6);
|
FileWrite(cfstdout, FLAGFALSE, "exec: ", 6);
|
||||||
|
|
||||||
GetUserInput(execCmd);
|
GetUserInput(execCmd);
|
||||||
@ -894,6 +953,129 @@ DoExec(pcf)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ExpandString(char *str, CONSFILE *c)
|
||||||
|
#else
|
||||||
|
ExpandString(str, c)
|
||||||
|
char *str;
|
||||||
|
CONSFILE *c;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
char s;
|
||||||
|
short backslash = 0;
|
||||||
|
short cntrl = 0;
|
||||||
|
char oct = '\000';
|
||||||
|
short octs = 0;
|
||||||
|
static STRING *exp = (STRING *)0;
|
||||||
|
|
||||||
|
if (str == (char *)0 || c == (CONSFILE *)0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (exp == (STRING *)0)
|
||||||
|
exp = AllocString();
|
||||||
|
|
||||||
|
BuildString((char *)0, exp);
|
||||||
|
|
||||||
|
backslash = 0;
|
||||||
|
cntrl = 0;
|
||||||
|
while ((s = (*str++)) != '\000') {
|
||||||
|
if (octs > 0 && octs < 3 && s >= '0' && s <= '7') {
|
||||||
|
++octs;
|
||||||
|
oct = oct * 8 + (s - '0');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (octs != 0) {
|
||||||
|
BuildStringChar(oct, exp);
|
||||||
|
octs = 0;
|
||||||
|
oct = '\000';
|
||||||
|
}
|
||||||
|
if (backslash) {
|
||||||
|
backslash = 0;
|
||||||
|
if (s == 'a')
|
||||||
|
s = '\a';
|
||||||
|
else if (s == 'b')
|
||||||
|
s = '\b';
|
||||||
|
else if (s == 'f')
|
||||||
|
s = '\f';
|
||||||
|
else if (s == 'n')
|
||||||
|
s = '\n';
|
||||||
|
else if (s == 'r')
|
||||||
|
s = '\r';
|
||||||
|
else if (s == 't')
|
||||||
|
s = '\t';
|
||||||
|
else if (s == 'v')
|
||||||
|
s = '\v';
|
||||||
|
else if (s == '^')
|
||||||
|
s = '^';
|
||||||
|
else if (s >= '0' && s <= '7') {
|
||||||
|
++octs;
|
||||||
|
oct = oct * 8 + (s - '0');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
BuildStringChar(s, exp);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (cntrl) {
|
||||||
|
cntrl = 0;
|
||||||
|
if (s == '?')
|
||||||
|
s = 0x7f; /* delete */
|
||||||
|
else
|
||||||
|
s = s & 0x1f;
|
||||||
|
BuildStringChar(s, exp);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (s == '\\') {
|
||||||
|
backslash = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (s == '^') {
|
||||||
|
cntrl = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
BuildStringChar(s, exp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (octs != 0)
|
||||||
|
BuildStringChar(oct, exp);
|
||||||
|
|
||||||
|
if (backslash)
|
||||||
|
BuildStringChar('\\', exp);
|
||||||
|
|
||||||
|
if (cntrl)
|
||||||
|
BuildStringChar('^', exp);
|
||||||
|
|
||||||
|
if (exp->used > 1)
|
||||||
|
FileWrite(c, FLAGFALSE, exp->string, exp->used - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
PrintSubst(CONSFILE *pcf, char *pcMach, char *string, char *subst)
|
||||||
|
#else
|
||||||
|
PrintSubst(pcf, pcMach, string, subst)
|
||||||
|
CONSFILE *pcf;
|
||||||
|
char *pcMach;
|
||||||
|
char *string;
|
||||||
|
char *subst;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (string == (char *)0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (subst != (char *)0) {
|
||||||
|
char *str;
|
||||||
|
if ((str = StrDup(string)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
substData->data = (void *)config;
|
||||||
|
config->console = pcMach;
|
||||||
|
ProcessSubst(substData, &str, (char **)0, (char *)0, subst);
|
||||||
|
ExpandString(str, pcf);
|
||||||
|
free(str);
|
||||||
|
} else
|
||||||
|
ExpandString(string, pcf);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
#if PROTOTYPES
|
#if PROTOTYPES
|
||||||
Interact(CONSFILE *pcf, char *pcMach)
|
Interact(CONSFILE *pcf, char *pcMach)
|
||||||
@ -912,8 +1094,10 @@ Interact(pcf, pcMach)
|
|||||||
/* if this is true, it means we successfully moved to a new console
|
/* if this is true, it means we successfully moved to a new console
|
||||||
* so we need to close the old one.
|
* so we need to close the old one.
|
||||||
*/
|
*/
|
||||||
if (prevConsole != (CONSFILE *)0)
|
if (prevConsole != (CONSFILE *)0) {
|
||||||
FileClose(&prevConsole);
|
FileClose(&prevConsole);
|
||||||
|
PrintSubst(cfstdout, prevName, pTerm->detach, pTerm->detachsubst);
|
||||||
|
}
|
||||||
if (prevName != (char *)0) {
|
if (prevName != (char *)0) {
|
||||||
free(prevName);
|
free(prevName);
|
||||||
prevName = (char *)0;
|
prevName = (char *)0;
|
||||||
@ -926,6 +1110,8 @@ Interact(pcf, pcMach)
|
|||||||
FileWrite(pcf, FLAGFALSE, "\n", 1);
|
FileWrite(pcf, FLAGFALSE, "\n", 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PrintSubst(cfstdout, pcMach, pTerm->attach, pTerm->attachsubst);
|
||||||
|
|
||||||
C2Raw();
|
C2Raw();
|
||||||
|
|
||||||
/* set socket to non-blocking */
|
/* set socket to non-blocking */
|
||||||
@ -974,7 +1160,7 @@ Interact(pcf, pcMach)
|
|||||||
FilePrint(pcf, FLAGFALSE, "%c%c", OB_IAC, OB_ABRT);
|
FilePrint(pcf, FLAGFALSE, "%c%c", OB_IAC, OB_ABRT);
|
||||||
FileSetQuoteIAC(pcf, FLAGTRUE);
|
FileSetQuoteIAC(pcf, FLAGTRUE);
|
||||||
} else {
|
} else {
|
||||||
if (fStrip) {
|
if (config->striphigh == FLAGTRUE) {
|
||||||
for (i = 0; i < nc; ++i)
|
for (i = 0; i < nc; ++i)
|
||||||
acMesg[i] &= 127;
|
acMesg[i] &= 127;
|
||||||
}
|
}
|
||||||
@ -1041,14 +1227,16 @@ Interact(pcf, pcMach)
|
|||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (fStrip) {
|
if (config->striphigh == FLAGTRUE) {
|
||||||
for (i = 0; i < l; ++i)
|
for (i = 0; i < l; ++i)
|
||||||
acMesg[i] &= 127;
|
acMesg[i] &= 127;
|
||||||
}
|
}
|
||||||
FileWrite(cfstdout, FLAGFALSE, acMesg, l);
|
|
||||||
if (execCmdFile != (CONSFILE *)0) {
|
if (execCmdFile != (CONSFILE *)0) {
|
||||||
FileWrite(execCmdFile, FLAGFALSE, acMesg, l);
|
FileWrite(execCmdFile, FLAGFALSE, acMesg, l);
|
||||||
}
|
if (showExecData)
|
||||||
|
FileWrite(cfstdout, FLAGFALSE, acMesg, l);
|
||||||
|
} else
|
||||||
|
FileWrite(cfstdout, FLAGFALSE, acMesg, l);
|
||||||
nc -= l;
|
nc -= l;
|
||||||
MemMove(acMesg, acMesg + l, nc);
|
MemMove(acMesg, acMesg + l, nc);
|
||||||
}
|
}
|
||||||
@ -1071,7 +1259,7 @@ Interact(pcf, pcMach)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (execCmdFile == (CONSFILE *)0) {
|
if (execCmdFile == (CONSFILE *)0) {
|
||||||
if (fStrip) {
|
if (config->striphigh == FLAGTRUE) {
|
||||||
for (i = 0; i < nc; ++i)
|
for (i = 0; i < nc; ++i)
|
||||||
acMesg[i] &= 127;
|
acMesg[i] &= 127;
|
||||||
}
|
}
|
||||||
@ -1092,12 +1280,21 @@ Interact(pcf, pcMach)
|
|||||||
FilePrint(cfstdout, FLAGFALSE,
|
FilePrint(cfstdout, FLAGFALSE,
|
||||||
"[local command sent SIGKILL - pid %lu]\r\n",
|
"[local command sent SIGKILL - pid %lu]\r\n",
|
||||||
execCmdPid);
|
execCmdPid);
|
||||||
|
} else if (acMesg[i] == 'o' || acMesg[i] == 'O') {
|
||||||
|
showExecData = !showExecData;
|
||||||
|
FilePrint(cfstdout, FLAGFALSE,
|
||||||
|
"[local command data %s]\r\n",
|
||||||
|
showExecData ? "on" : "off");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
C2Cooked();
|
C2Cooked();
|
||||||
|
|
||||||
|
PrintSubst(cfstdout, pcMach, pTerm->detach, pTerm->detachsubst);
|
||||||
|
|
||||||
if (fVerbose)
|
if (fVerbose)
|
||||||
printf("Console %s closed.\n", pcMach);
|
printf("Console %s closed.\n", pcMach);
|
||||||
}
|
}
|
||||||
@ -1270,6 +1467,7 @@ DoCmds(master, pports, cmdi)
|
|||||||
int len;
|
int len;
|
||||||
char *ports;
|
char *ports;
|
||||||
char *pcopy;
|
char *pcopy;
|
||||||
|
char *serverName;
|
||||||
|
|
||||||
if ((pcopy = ports = StrDup(pports)) == (char *)0)
|
if ((pcopy = ports = StrDup(pports)) == (char *)0)
|
||||||
OutOfMem();
|
OutOfMem();
|
||||||
@ -1292,13 +1490,27 @@ DoCmds(master, pports, cmdi)
|
|||||||
} else
|
} else
|
||||||
server = master;
|
server = master;
|
||||||
|
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
serverName = "localhost";
|
||||||
|
#else
|
||||||
|
serverName = server;
|
||||||
|
#endif
|
||||||
|
|
||||||
if (*ports == '\000') {
|
if (*ports == '\000') {
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
port = 0;
|
||||||
|
#else
|
||||||
port = htons(bindPort);
|
port = htons(bindPort);
|
||||||
|
#endif
|
||||||
} else if (!isdigit((int)(ports[0]))) {
|
} else if (!isdigit((int)(ports[0]))) {
|
||||||
Error("invalid port spec for %s: `%s'", server, ports);
|
Error("invalid port spec for %s: `%s'", serverName, ports);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
port = (short)atoi(ports);
|
||||||
|
#else
|
||||||
port = htons((short)atoi(ports));
|
port = htons((short)atoi(ports));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
attemptLogin:
|
attemptLogin:
|
||||||
@ -1310,25 +1522,31 @@ DoCmds(master, pports, cmdi)
|
|||||||
t = ReadReply(pcf, 0);
|
t = ReadReply(pcf, 0);
|
||||||
if (strcmp(t, "ok\r\n") != 0) {
|
if (strcmp(t, "ok\r\n") != 0) {
|
||||||
FileClose(&pcf);
|
FileClose(&pcf);
|
||||||
FilePrint(cfstdout, FLAGFALSE, "%s: %s", server, t);
|
FilePrint(cfstdout, FLAGFALSE, "%s: %s", serverName, t);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
if (fReqEncryption) {
|
if (config->sslenabled == FLAGTRUE) {
|
||||||
FileWrite(pcf, FLAGFALSE, "ssl\r\n", 5);
|
FileWrite(pcf, FLAGFALSE, "ssl\r\n", 5);
|
||||||
t = ReadReply(pcf, 0);
|
t = ReadReply(pcf, 0);
|
||||||
if (strcmp(t, "ok\r\n") == 0) {
|
if (strcmp(t, "ok\r\n") == 0) {
|
||||||
AttemptSSL(pcf);
|
AttemptSSL(pcf);
|
||||||
}
|
if (FileGetType(pcf) != SSLSocket) {
|
||||||
if (FileGetType(pcf) != SSLSocket) {
|
Error("Encryption not supported by server `%s'",
|
||||||
Error("Encryption not supported by server `%s'", server);
|
serverName);
|
||||||
|
FileClose(&pcf);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
} else if (config->sslrequired == FLAGTRUE) {
|
||||||
|
Error("Encryption not supported by server `%s'",
|
||||||
|
serverName);
|
||||||
FileClose(&pcf);
|
FileClose(&pcf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
FilePrint(pcf, FLAGFALSE, "login %s\r\n", pcUser);
|
FilePrint(pcf, FLAGFALSE, "login %s\r\n", config->username);
|
||||||
|
|
||||||
t = ReadReply(pcf, 0);
|
t = ReadReply(pcf, 0);
|
||||||
if (strncmp(t, "passwd?", 7) == 0) {
|
if (strncmp(t, "passwd?", 7) == 0) {
|
||||||
@ -1339,19 +1557,19 @@ DoCmds(master, pports, cmdi)
|
|||||||
if (t[7] == ' ') {
|
if (t[7] == ' ') {
|
||||||
hostname = PruneSpace(t + 7);
|
hostname = PruneSpace(t + 7);
|
||||||
if (*hostname == '\000')
|
if (*hostname == '\000')
|
||||||
hostname = server;
|
hostname = serverName;
|
||||||
} else
|
} else
|
||||||
hostname = server;
|
hostname = serverName;
|
||||||
if (tmpString == (STRING *)0)
|
if (tmpString == (STRING *)0)
|
||||||
tmpString = AllocString();
|
tmpString = AllocString();
|
||||||
if (tmpString->used <= 1) {
|
if (tmpString->used <= 1) {
|
||||||
char *pass;
|
char *pass;
|
||||||
BuildStringPrint(tmpString, "Enter %s@%s's password: ",
|
BuildStringPrint(tmpString, "Enter %s@%s's password: ",
|
||||||
pcUser, hostname);
|
config->username, hostname);
|
||||||
pass = GetPassword(tmpString->string);
|
pass = GetPassword(tmpString->string);
|
||||||
if (pass == (char *)0) {
|
if (pass == (char *)0) {
|
||||||
Error("could not get password from tty for `%s'",
|
Error("could not get password from tty for `%s'",
|
||||||
server);
|
serverName);
|
||||||
FileClose(&pcf);
|
FileClose(&pcf);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -1363,12 +1581,12 @@ DoCmds(master, pports, cmdi)
|
|||||||
tmpString->used - 1);
|
tmpString->used - 1);
|
||||||
t = ReadReply(pcf, 0);
|
t = ReadReply(pcf, 0);
|
||||||
if (strcmp(t, "ok\r\n") != 0) {
|
if (strcmp(t, "ok\r\n") != 0) {
|
||||||
FilePrint(cfstdout, FLAGFALSE, "%s: %s", server, t);
|
FilePrint(cfstdout, FLAGFALSE, "%s: %s", serverName, t);
|
||||||
if (++count < 3) {
|
if (++count < 3) {
|
||||||
BuildString((char *)0, tmpString);
|
BuildString((char *)0, tmpString);
|
||||||
goto attemptLogin;
|
goto attemptLogin;
|
||||||
}
|
}
|
||||||
Error("too many bad passwords for `%s'", server);
|
Error("too many bad passwords for `%s'", serverName);
|
||||||
count = 0;
|
count = 0;
|
||||||
FileClose(&pcf);
|
FileClose(&pcf);
|
||||||
continue;
|
continue;
|
||||||
@ -1376,7 +1594,7 @@ DoCmds(master, pports, cmdi)
|
|||||||
count = 0;
|
count = 0;
|
||||||
} else if (strcmp(t, "ok\r\n") != 0) {
|
} else if (strcmp(t, "ok\r\n") != 0) {
|
||||||
FileClose(&pcf);
|
FileClose(&pcf);
|
||||||
FilePrint(cfstdout, FLAGFALSE, "%s: %s", server, t);
|
FilePrint(cfstdout, FLAGFALSE, "%s: %s", serverName, t);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1412,7 +1630,8 @@ DoCmds(master, pports, cmdi)
|
|||||||
Bye(EX_SOFTWARE);
|
Bye(EX_SOFTWARE);
|
||||||
}
|
}
|
||||||
} else if (result[0] != '[') { /* did we not get a connection? */
|
} else if (result[0] != '[') { /* did we not get a connection? */
|
||||||
FilePrint(cfstdout, FLAGFALSE, "%s: %s", server, result);
|
FilePrint(cfstdout, FLAGFALSE, "%s: %s", serverName,
|
||||||
|
result);
|
||||||
FileClose(&pcf);
|
FileClose(&pcf);
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
@ -1452,7 +1671,7 @@ DoCmds(master, pports, cmdi)
|
|||||||
*/
|
*/
|
||||||
if (cmds[0][0] == 'd') {
|
if (cmds[0][0] == 'd') {
|
||||||
if (result[0] != 'o' || result[1] != 'k') {
|
if (result[0] != 'o' || result[1] != 'k') {
|
||||||
FileWrite(cfstdout, FLAGTRUE, server, -1);
|
FileWrite(cfstdout, FLAGTRUE, serverName, -1);
|
||||||
FileWrite(cfstdout, FLAGTRUE, ": ", 2);
|
FileWrite(cfstdout, FLAGTRUE, ": ", 2);
|
||||||
FileWrite(cfstdout, FLAGFALSE, result, len);
|
FileWrite(cfstdout, FLAGFALSE, result, len);
|
||||||
} else {
|
} else {
|
||||||
@ -1461,8 +1680,9 @@ DoCmds(master, pports, cmdi)
|
|||||||
} else if ((cmds[0][0] != 'b' && cmds[0][0] != 't') ||
|
} else if ((cmds[0][0] != 'b' && cmds[0][0] != 't') ||
|
||||||
(result[0] != 'o' || result[1] != 'k')) {
|
(result[0] != 'o' || result[1] != 'k')) {
|
||||||
/* did a 'master' before this or doing a 'disconnect' */
|
/* did a 'master' before this or doing a 'disconnect' */
|
||||||
if (cmds[1][0] == 'm' || cmds[0][0] == 'd') {
|
if ((cmds[1] != (char *)0 && cmds[1][0] == 'm') ||
|
||||||
FileWrite(cfstdout, FLAGTRUE, server, -1);
|
cmds[0][0] == 'd') {
|
||||||
|
FileWrite(cfstdout, FLAGTRUE, serverName, -1);
|
||||||
FileWrite(cfstdout, FLAGTRUE, ": ", 2);
|
FileWrite(cfstdout, FLAGTRUE, ": ", 2);
|
||||||
}
|
}
|
||||||
FileWrite(cfstdout, FLAGFALSE, result, len);
|
FileWrite(cfstdout, FLAGFALSE, result, len);
|
||||||
@ -1510,14 +1730,15 @@ main(argc, argv)
|
|||||||
int opt;
|
int opt;
|
||||||
int fLocal;
|
int fLocal;
|
||||||
static STRING *acPorts = (STRING *)0;
|
static STRING *acPorts = (STRING *)0;
|
||||||
static char acOpts[] = "7aAb:B:c:d:De:EfFhiIl:M:p:PqQrRsSt:uvVwWx";
|
static char acOpts[] = "7aAb:B:c:C:d:De:EfFhiIl:M:np:PqQrRsSt:uUvVwWx";
|
||||||
extern int optind;
|
extern int optind;
|
||||||
extern int optopt;
|
extern int optopt;
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
int i;
|
|
||||||
static STRING *textMsg = (STRING *)0;
|
static STRING *textMsg = (STRING *)0;
|
||||||
int cmdi;
|
int cmdi;
|
||||||
static STRING *consoleName = (STRING *)0;
|
static STRING *consoleName = (STRING *)0;
|
||||||
|
short readSystemConf = 1;
|
||||||
|
char *userConf = (char *)0;
|
||||||
|
|
||||||
isMultiProc = 0; /* make sure stuff DOESN'T have the pid */
|
isMultiProc = 0; /* make sure stuff DOESN'T have the pid */
|
||||||
|
|
||||||
@ -1534,6 +1755,17 @@ main(argc, argv)
|
|||||||
++progname;
|
++progname;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* prep the config options */
|
||||||
|
if ((optConf = (CONFIG *)calloc(1, sizeof(CONFIG))) == (CONFIG *)0)
|
||||||
|
OutOfMem();
|
||||||
|
if ((config = (CONFIG *)calloc(1, sizeof(CONFIG))) == (CONFIG *)0)
|
||||||
|
OutOfMem();
|
||||||
|
if ((pConfig = (CONFIG *)calloc(1, sizeof(CONFIG))) == (CONFIG *)0)
|
||||||
|
OutOfMem();
|
||||||
|
/* and the terminal options */
|
||||||
|
if ((pTerm = (TERM *)calloc(1, sizeof(TERM))) == (TERM *)0)
|
||||||
|
OutOfMem();
|
||||||
|
|
||||||
/* command line parsing
|
/* command line parsing
|
||||||
*/
|
*/
|
||||||
pcCmd = (char *)0;
|
pcCmd = (char *)0;
|
||||||
@ -1541,7 +1773,7 @@ main(argc, argv)
|
|||||||
while ((opt = getopt(argc, argv, acOpts)) != EOF) {
|
while ((opt = getopt(argc, argv, acOpts)) != EOF) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case '7': /* strip high-bit */
|
case '7': /* strip high-bit */
|
||||||
fStrip = 1;
|
optConf->striphigh = FLAGTRUE;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'A': /* attach with log replay */
|
case 'A': /* attach with log replay */
|
||||||
@ -1556,12 +1788,21 @@ main(argc, argv)
|
|||||||
/* fall through */
|
/* fall through */
|
||||||
case 'b':
|
case 'b':
|
||||||
pcCmd = "broadcast";
|
pcCmd = "broadcast";
|
||||||
cmdarg = optarg;
|
if (cmdarg != (char *)0)
|
||||||
|
free(cmdarg);
|
||||||
|
if ((cmdarg = StrDup(optarg)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'C':
|
||||||
|
userConf = optarg;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'c':
|
case 'c':
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
pcCredFile = optarg;
|
if ((optConf->sslcredentials =
|
||||||
|
StrDup(optarg)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -1571,17 +1812,21 @@ main(argc, argv)
|
|||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
pcCmd = "disconnect";
|
pcCmd = "disconnect";
|
||||||
cmdarg = optarg;
|
if (cmdarg != (char *)0)
|
||||||
|
free(cmdarg);
|
||||||
|
if ((cmdarg = StrDup(optarg)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'E':
|
case 'E':
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
fReqEncryption = 0;
|
optConf->sslenabled = FLAGFALSE;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'e': /* set escape chars */
|
case 'e': /* set escape chars */
|
||||||
ParseEsc(optarg);
|
if ((optConf->escape = StrDup(optarg)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'F': /* force attach with log replay */
|
case 'F': /* force attach with log replay */
|
||||||
@ -1599,15 +1844,22 @@ main(argc, argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
pcUser = optarg;
|
if ((optConf->username = StrDup(optarg)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'M':
|
case 'M':
|
||||||
pcInMaster = optarg;
|
if ((optConf->master = StrDup(optarg)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'n':
|
||||||
|
readSystemConf = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
pcPort = optarg;
|
if ((optConf->port = StrDup(optarg)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'P': /* send a pid command to the server */
|
case 'P': /* send a pid command to the server */
|
||||||
@ -1650,6 +1902,12 @@ main(argc, argv)
|
|||||||
pcCmd = textMsg->string;
|
pcCmd = textMsg->string;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'U':
|
||||||
|
#if HAVE_OPENSSL
|
||||||
|
optConf->sslrequired = FLAGFALSE;
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
case 'u':
|
case 'u':
|
||||||
pcCmd = "hosts";
|
pcCmd = "hosts";
|
||||||
break;
|
break;
|
||||||
@ -1692,6 +1950,109 @@ main(argc, argv)
|
|||||||
Bye(EX_OK);
|
Bye(EX_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProbeInterfaces(INADDR_ANY);
|
||||||
|
|
||||||
|
if (readSystemConf)
|
||||||
|
ReadConf(CLIENTCONFIGFILE, FLAGFALSE);
|
||||||
|
|
||||||
|
if (userConf == (char *)0) {
|
||||||
|
/* read the config files */
|
||||||
|
char *h = (char *)0;
|
||||||
|
|
||||||
|
if (((h = getenv("HOME")) == (char *)0) &&
|
||||||
|
((pwdMe = getpwuid(getuid())) == (struct passwd *)0)) {
|
||||||
|
Error("$HOME does not exist and getpwuid fails: %d: %s",
|
||||||
|
(int)(getuid()), strerror(errno));
|
||||||
|
} else {
|
||||||
|
if (h == (char *)0) {
|
||||||
|
if (pwdMe->pw_dir == (char *)0 ||
|
||||||
|
pwdMe->pw_dir[0] == '\000') {
|
||||||
|
Error("Home directory for uid %d is not defined",
|
||||||
|
(int)(getuid()));
|
||||||
|
Bye(EX_UNAVAILABLE);
|
||||||
|
} else {
|
||||||
|
h = pwdMe->pw_dir;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (h != (char *)0) {
|
||||||
|
BuildTmpString((char *)0);
|
||||||
|
BuildTmpString(h);
|
||||||
|
h = BuildTmpString("/.consolerc");
|
||||||
|
ReadConf(h, FLAGFALSE);
|
||||||
|
BuildTmpString((char *)0);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
ReadConf(userConf, FLAGTRUE);
|
||||||
|
|
||||||
|
if (optConf->striphigh != FLAGUNKNOWN)
|
||||||
|
config->striphigh = optConf->striphigh;
|
||||||
|
else if (pConfig->striphigh != FLAGUNKNOWN)
|
||||||
|
config->striphigh = pConfig->striphigh;
|
||||||
|
else
|
||||||
|
config->striphigh = FLAGFALSE;
|
||||||
|
|
||||||
|
if (optConf->escape != (char *)0)
|
||||||
|
ParseEsc(optConf->escape);
|
||||||
|
else if (pConfig->escape != (char *)0)
|
||||||
|
ParseEsc(pConfig->escape);
|
||||||
|
|
||||||
|
if (optConf->username != (char *)0)
|
||||||
|
config->username = StrDup(optConf->username);
|
||||||
|
else if (pConfig->username != (char *)0)
|
||||||
|
config->username = StrDup(pConfig->username);
|
||||||
|
else
|
||||||
|
config->username = (char *)0;
|
||||||
|
|
||||||
|
if (optConf->master != (char *)0 && optConf->master[0] != '\000')
|
||||||
|
config->master = StrDup(optConf->master);
|
||||||
|
else if (pConfig->master != (char *)0 && pConfig->master[0] != '\000')
|
||||||
|
config->master = StrDup(pConfig->master);
|
||||||
|
else
|
||||||
|
config->master = StrDup(
|
||||||
|
#if USE_UNIX_DOMAIN_SOCKETS
|
||||||
|
UDSDIR
|
||||||
|
#else
|
||||||
|
MASTERHOST /* which machine is current */
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
if (config->master == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
|
||||||
|
if (optConf->port != (char *)0 && optConf->port[0] != '\000')
|
||||||
|
config->port = StrDup(optConf->port);
|
||||||
|
else if (pConfig->port != (char *)0 && pConfig->port[0] != '\000')
|
||||||
|
config->port = StrDup(pConfig->port);
|
||||||
|
else
|
||||||
|
config->port = StrDup(DEFPORT);
|
||||||
|
if (config->port == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
|
||||||
|
#if HAVE_OPENSSL
|
||||||
|
if (optConf->sslcredentials != (char *)0 &&
|
||||||
|
optConf->sslcredentials[0] != '\000')
|
||||||
|
config->sslcredentials = StrDup(optConf->sslcredentials);
|
||||||
|
else if (pConfig->sslcredentials != (char *)0 &&
|
||||||
|
pConfig->sslcredentials[0] != '\000')
|
||||||
|
config->sslcredentials = StrDup(pConfig->sslcredentials);
|
||||||
|
else
|
||||||
|
config->sslcredentials = (char *)0;
|
||||||
|
|
||||||
|
if (optConf->sslenabled != FLAGUNKNOWN)
|
||||||
|
config->sslenabled = optConf->sslenabled;
|
||||||
|
else if (pConfig->sslenabled != FLAGUNKNOWN)
|
||||||
|
config->sslenabled = pConfig->sslenabled;
|
||||||
|
else
|
||||||
|
config->sslenabled = FLAGTRUE;
|
||||||
|
|
||||||
|
if (optConf->sslrequired != FLAGUNKNOWN)
|
||||||
|
config->sslrequired = optConf->sslrequired;
|
||||||
|
else if (pConfig->sslrequired != FLAGUNKNOWN)
|
||||||
|
config->sslrequired = pConfig->sslrequired;
|
||||||
|
else
|
||||||
|
config->sslrequired = FLAGTRUE;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* finish resolving the command to do */
|
/* finish resolving the command to do */
|
||||||
if (pcCmd == (char *)0) {
|
if (pcCmd == (char *)0) {
|
||||||
pcCmd = "attach";
|
pcCmd = "attach";
|
||||||
@ -1702,6 +2063,8 @@ main(argc, argv)
|
|||||||
Error("missing console name");
|
Error("missing console name");
|
||||||
Bye(EX_UNAVAILABLE);
|
Bye(EX_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
|
if (cmdarg != (char *)0)
|
||||||
|
free(cmdarg);
|
||||||
if ((cmdarg = StrDup(argv[optind++])) == (char *)0)
|
if ((cmdarg = StrDup(argv[optind++])) == (char *)0)
|
||||||
OutOfMem();
|
OutOfMem();
|
||||||
} else if (*pcCmd == 't') {
|
} else if (*pcCmd == 't') {
|
||||||
@ -1709,55 +2072,60 @@ main(argc, argv)
|
|||||||
Error("missing message text");
|
Error("missing message text");
|
||||||
Bye(EX_UNAVAILABLE);
|
Bye(EX_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
cmdarg = argv[optind++];
|
if (cmdarg != (char *)0)
|
||||||
|
free(cmdarg);
|
||||||
|
if ((cmdarg = StrDup(argv[optind++])) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (optind < argc) {
|
if (optind < argc) {
|
||||||
Error("extra garbage on command line? (%s...)", argv[optind]);
|
Error("extra garbage on command line? (%s...)", argv[optind]);
|
||||||
Bye(EX_UNAVAILABLE);
|
Bye(EX_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
|
#if !USE_UNIX_DOMAIN_SOCKETS
|
||||||
/* if we somehow lost the port (or got an empty string), reset */
|
|
||||||
if (pcPort == (char *)0 || pcPort[0] == '\000')
|
|
||||||
pcPort = DEFPORT;
|
|
||||||
|
|
||||||
/* Look for non-numeric characters */
|
/* Look for non-numeric characters */
|
||||||
for (i = 0; pcPort[i] != '\000'; i++)
|
for (opt = 0; config->port[opt] != '\000'; opt++)
|
||||||
if (!isdigit((int)pcPort[i]))
|
if (!isdigit((int)config->port[opt]))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (pcPort[i] == '\000') {
|
if (config->port[opt] == '\000') {
|
||||||
/* numeric only */
|
/* numeric only */
|
||||||
bindPort = atoi(pcPort);
|
bindPort = atoi(config->port);
|
||||||
} else {
|
} else {
|
||||||
/* non-numeric only */
|
/* non-numeric only */
|
||||||
struct servent *pSE;
|
struct servent *pSE;
|
||||||
if ((pSE = getservbyname(pcPort, "tcp")) == (struct servent *)0) {
|
if ((pSE =
|
||||||
Error("getservbyname(%s) failed", pcPort);
|
getservbyname(config->port, "tcp")) == (struct servent *)0) {
|
||||||
|
Error("getservbyname(%s) failed", config->port);
|
||||||
Bye(EX_UNAVAILABLE);
|
Bye(EX_UNAVAILABLE);
|
||||||
} else {
|
} else {
|
||||||
bindPort = ntohs((u_short) pSE->s_port);
|
bindPort = ntohs((u_short) pSE->s_port);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (pcUser == (char *)0 || pcUser[0] == '\000') {
|
if (config->username == (char *)0 || config->username[0] == '\000') {
|
||||||
if (((pcUser = getenv("LOGNAME")) == (char *)0) &&
|
if (config->username != (char *)0)
|
||||||
((pcUser = getenv("USER")) == (char *)0) &&
|
free(config->username);
|
||||||
|
if (((config->username = getenv("LOGNAME")) == (char *)0) &&
|
||||||
|
((config->username = getenv("USER")) == (char *)0) &&
|
||||||
((pwdMe = getpwuid(getuid())) == (struct passwd *)0)) {
|
((pwdMe = getpwuid(getuid())) == (struct passwd *)0)) {
|
||||||
Error
|
Error
|
||||||
("$LOGNAME and $USER do not exist and getpwuid fails: %d: %s",
|
("$LOGNAME and $USER do not exist and getpwuid fails: %d: %s",
|
||||||
(int)(getuid()), strerror(errno));
|
(int)(getuid()), strerror(errno));
|
||||||
Bye(EX_UNAVAILABLE);
|
Bye(EX_UNAVAILABLE);
|
||||||
}
|
}
|
||||||
if (pcUser == (char *)0) {
|
if (config->username == (char *)0) {
|
||||||
if (pwdMe->pw_name == (char *)0 || pwdMe->pw_name[0] == '\000') {
|
if (pwdMe->pw_name == (char *)0 || pwdMe->pw_name[0] == '\000') {
|
||||||
Error("Username for uid %d does not exist",
|
Error("Username for uid %d does not exist",
|
||||||
(int)(getuid()));
|
(int)(getuid()));
|
||||||
Bye(EX_UNAVAILABLE);
|
Bye(EX_UNAVAILABLE);
|
||||||
} else {
|
} else {
|
||||||
pcUser = pwdMe->pw_name;
|
config->username = pwdMe->pw_name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ((config->username = StrDup(config->username)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (execCmd == (STRING *)0)
|
if (execCmd == (STRING *)0)
|
||||||
@ -1769,7 +2137,7 @@ main(argc, argv)
|
|||||||
|
|
||||||
BuildString((char *)0, acPorts);
|
BuildString((char *)0, acPorts);
|
||||||
BuildStringChar('@', acPorts);
|
BuildStringChar('@', acPorts);
|
||||||
BuildString(pcInMaster, acPorts);
|
BuildString(config->master, acPorts);
|
||||||
|
|
||||||
#if HAVE_OPENSSL
|
#if HAVE_OPENSSL
|
||||||
SetupSSL(); /* should only do if we want ssl - provide flag! */
|
SetupSSL(); /* should only do if we want ssl - provide flag! */
|
||||||
@ -1793,7 +2161,7 @@ main(argc, argv)
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
if (gotoConsole == (CONSFILE *)0)
|
if (gotoConsole == (CONSFILE *)0)
|
||||||
DoCmds(pcInMaster, acPorts->string, cmdi);
|
DoCmds(config->master, acPorts->string, cmdi);
|
||||||
else
|
else
|
||||||
Interact(gotoConsole, gotoName);
|
Interact(gotoConsole, gotoName);
|
||||||
|
|
||||||
@ -1836,8 +2204,9 @@ main(argc, argv)
|
|||||||
free(cmdarg);
|
free(cmdarg);
|
||||||
|
|
||||||
if (*pcCmd == 'd')
|
if (*pcCmd == 'd')
|
||||||
FilePrint(cfstdout, FLAGFALSE, "Disconnected %d users\n",
|
FilePrint(cfstdout, FLAGFALSE, "disconnected %d %s\n",
|
||||||
disconnectCount);
|
disconnectCount,
|
||||||
|
disconnectCount == 1 ? "user" : "users");
|
||||||
|
|
||||||
Bye(0);
|
Bye(0);
|
||||||
return 0; /* noop - Bye() terminates us */
|
return 0; /* noop - Bye() terminates us */
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
.\" $Id: console.man,v 1.45 2004/03/20 14:40:42 bryan Exp $
|
.\" $Id: console.man,v 1.51 2004/05/25 00:38:15 bryan Exp $
|
||||||
.TH CONSOLE 1 "2004/03/20" "conserver-8.1.3" "conserver"
|
.TH CONSOLE 1 "2004/05/25" "conserver-8.1.6" "conserver"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
console \- console server client program
|
console \- console server client program
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B console
|
.B console
|
||||||
.RB [ \-aAEfFsS ]
|
.RB [ \-aAfFsS ]
|
||||||
.RB [ \-7Dv ]
|
.RB [ \-7DEnUv ]
|
||||||
.RB [ \-c
|
.RB [ \-c
|
||||||
.IR cred ]
|
.IR cred ]
|
||||||
|
.RB [ \-C
|
||||||
|
.IR config ]
|
||||||
.BR [ \-M
|
.BR [ \-M
|
||||||
.IR mach ]
|
.IR master ]
|
||||||
.BR [ \-p
|
.BR [ \-p
|
||||||
.IR port ]
|
.IR port ]
|
||||||
.BR [ \-e
|
.BR [ \-e
|
||||||
@ -20,24 +22,32 @@ console \- console server client program
|
|||||||
.br
|
.br
|
||||||
.B console
|
.B console
|
||||||
.RB [ \-hiIPrRuVwWx ]
|
.RB [ \-hiIPrRuVwWx ]
|
||||||
.RB [ \-7Dv ]
|
.RB [ \-7DEnUv ]
|
||||||
|
.RB [ \-c
|
||||||
|
.IR cred ]
|
||||||
|
.RB [ \-C
|
||||||
|
.IR config ]
|
||||||
.RB [ \-M
|
.RB [ \-M
|
||||||
.IR mach ]
|
.IR master ]
|
||||||
.RB [ \-p
|
.RB [ \-p
|
||||||
.IR port ]
|
.IR port ]
|
||||||
.RB [ \-d
|
.RB [ \-d
|
||||||
.RI [ user ][\fB@\fP console ]]
|
.RI [ user ][\f3@\fP console ]]
|
||||||
.RB [ \- [ bB ]
|
.RB [ \- [ bB ]
|
||||||
.IR message ]
|
.IR message ]
|
||||||
.RB [ \-t
|
.RB [ \-t
|
||||||
.RI [ user ][\fB@\fP console ]
|
.RI [ user ][\f3@\fP console ]
|
||||||
.IR message ]
|
.IR message ]
|
||||||
.br
|
.br
|
||||||
.B console
|
.B console
|
||||||
.RB [ \-qQ ]
|
.RB [ \-qQ ]
|
||||||
.RB [ \-7Dv ]
|
.RB [ \-7DEnUv ]
|
||||||
|
.RB [ \-c
|
||||||
|
.IR cred ]
|
||||||
|
.RB [ \-C
|
||||||
|
.IR config ]
|
||||||
.RB [ \-M
|
.RB [ \-M
|
||||||
.IR mach ]
|
.IR master ]
|
||||||
.RB [ \-p
|
.RB [ \-p
|
||||||
.IR port ]
|
.IR port ]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
@ -116,6 +126,10 @@ to users on the primary server.
|
|||||||
Load an SSL certificate and key from the PEM encoded file
|
Load an SSL certificate and key from the PEM encoded file
|
||||||
.IR cred .
|
.IR cred .
|
||||||
.TP
|
.TP
|
||||||
|
.BI \-C config
|
||||||
|
Use the per-user configuration file
|
||||||
|
.IR conf .
|
||||||
|
.TP
|
||||||
.B \-d
|
.B \-d
|
||||||
Disconnect the users specified by
|
Disconnect the users specified by
|
||||||
.IR user @ console .
|
.IR user @ console .
|
||||||
@ -150,9 +164,13 @@ The default value is
|
|||||||
.B \-E
|
.B \-E
|
||||||
If encryption has been built into the code
|
If encryption has been built into the code
|
||||||
.RB ( --with-openssl ),
|
.RB ( --with-openssl ),
|
||||||
encrypted client connections are a requirement.
|
encrypted client connections are, by default, a requirement.
|
||||||
This option allows the client to connect to a console
|
This option disables any attempt at creating an
|
||||||
over a non-encrypted connection.
|
encrypted connection.
|
||||||
|
If you'd like to use encrypted connections when your server
|
||||||
|
supports it, but fallback to non-encrypted otherwise, the
|
||||||
|
.B \-U
|
||||||
|
option is what you want.
|
||||||
.TP
|
.TP
|
||||||
.B \-f
|
.B \-f
|
||||||
Same as
|
Same as
|
||||||
@ -179,19 +197,34 @@ uses $USER if its uid matches the user's real uid,
|
|||||||
or $LOGNAME if its uid matches the user's real uid,
|
or $LOGNAME if its uid matches the user's real uid,
|
||||||
or else the name associated with the user's real uid.
|
or else the name associated with the user's real uid.
|
||||||
.TP
|
.TP
|
||||||
.BI \-M mach
|
.BI \-M master
|
||||||
The
|
The
|
||||||
.B console
|
.B console
|
||||||
client program polls
|
client program polls
|
||||||
.I mach
|
.I master
|
||||||
as the primary server,
|
as the primary server,
|
||||||
rather than the default set at compile time (typically
|
rather than the default set at compile time (typically
|
||||||
.RB `` console '').
|
.RB `` console '').
|
||||||
The default
|
The default
|
||||||
.I mach
|
.I master
|
||||||
may be changed at compile time using the
|
may be changed at compile time using the
|
||||||
.B --with-master
|
.B --with-master
|
||||||
option.
|
option.
|
||||||
|
If
|
||||||
|
.B --with-uds
|
||||||
|
is used to enable Unix domain sockets, however, this option points
|
||||||
|
.B console
|
||||||
|
to the directory which holds those sockets.
|
||||||
|
The default
|
||||||
|
.I master
|
||||||
|
directory
|
||||||
|
.RB (`` /tmp/conserver '')
|
||||||
|
may be changed at compile time using the
|
||||||
|
.B --with-uds
|
||||||
|
option.
|
||||||
|
.TP
|
||||||
|
.BI \-n
|
||||||
|
Do not read the system-wide configuration file.
|
||||||
.TP
|
.TP
|
||||||
.BI \-p port
|
.BI \-p port
|
||||||
Set the port to connect to.
|
Set the port to connect to.
|
||||||
@ -203,6 +236,9 @@ may be changed at compile time
|
|||||||
using the
|
using the
|
||||||
.B --with-port
|
.B --with-port
|
||||||
option.
|
option.
|
||||||
|
If the
|
||||||
|
.B --with-uds
|
||||||
|
option was used, this option is ignored.
|
||||||
.TP
|
.TP
|
||||||
.B \-P
|
.B \-P
|
||||||
Display the pid of the master daemon process on each server.
|
Display the pid of the master daemon process on each server.
|
||||||
@ -264,6 +300,18 @@ and attached users
|
|||||||
.RI ( user @ host
|
.RI ( user @ host
|
||||||
if attached read-write, `<spies>' if only users in spy mode, or `<none>').
|
if attached read-write, `<spies>' if only users in spy mode, or `<none>').
|
||||||
.TP
|
.TP
|
||||||
|
.B \-U
|
||||||
|
If encryption has been built into the code
|
||||||
|
.RB ( --with-openssl ),
|
||||||
|
encrypted client connections are, by default, a requirement.
|
||||||
|
This option allows the client to attempt an encrypted connection
|
||||||
|
but fall back to a non-encrypted connection if the server doesn't
|
||||||
|
support encryption.
|
||||||
|
If the encryption handshake is failing, disabling encryption on the
|
||||||
|
client with the
|
||||||
|
.B \-E
|
||||||
|
option is probably what you want.
|
||||||
|
.TP
|
||||||
.B \-v
|
.B \-v
|
||||||
Be more verbose when building the connection(s).
|
Be more verbose when building the connection(s).
|
||||||
Use this option in combination with any of `show' options (below)
|
Use this option in combination with any of `show' options (below)
|
||||||
@ -297,7 +345,7 @@ The
|
|||||||
options have the same effect as their lower-case variants.
|
options have the same effect as their lower-case variants.
|
||||||
In addition, they each request the last 20 lines of the console output after
|
In addition, they each request the last 20 lines of the console output after
|
||||||
making the connection (as if
|
making the connection (as if
|
||||||
.RB ` ^Ecr '
|
.RB `` ^Ecr ''
|
||||||
were typed).
|
were typed).
|
||||||
.PP
|
.PP
|
||||||
The
|
The
|
||||||
@ -349,7 +397,7 @@ that the server can open the file for read, but not write.
|
|||||||
The details regarding the logging for the console.
|
The details regarding the logging for the console.
|
||||||
The comma-separated
|
The comma-separated
|
||||||
values will be the logfile, ``log'' or ``nolog'' (if logging is on
|
values will be the logfile, ``log'' or ``nolog'' (if logging is on
|
||||||
or not - toggled via ^EcL), ``act'' or ``noact'' (if activity logging is
|
or not - toggled via ``^EcL''), ``act'' or ``noact'' (if activity logging is
|
||||||
enabled or not - the `a' timestamp option), the timestamp interval, and
|
enabled or not - the `a' timestamp option), the timestamp interval, and
|
||||||
the file descriptor of the logfile.
|
the file descriptor of the logfile.
|
||||||
.TP
|
.TP
|
||||||
@ -375,6 +423,311 @@ The idletimeout configuration option for the console.
|
|||||||
.TP
|
.TP
|
||||||
.I idlestring
|
.I idlestring
|
||||||
The idlestring configuration option for the console.
|
The idlestring configuration option for the console.
|
||||||
|
.SH CONFIGURATION
|
||||||
|
.B Console
|
||||||
|
reads configuration information from the system-wide configuration file
|
||||||
|
.RB ( console.cf ),
|
||||||
|
then the per-user configuration file
|
||||||
|
.RB ( .consolerc ),
|
||||||
|
and then applies command-line arguments.
|
||||||
|
Each configuration location can override the previous.
|
||||||
|
The same happens when parsing an individual file - the later entries
|
||||||
|
always override the earlier entries.
|
||||||
|
Because of that, you should put ``global'' defaults first and
|
||||||
|
more specific defaults second.
|
||||||
|
.PP
|
||||||
|
The configuration file is read using the same parser as
|
||||||
|
.BR conserver.cf (5),
|
||||||
|
and you should check that manpage for parser details.
|
||||||
|
.B Console
|
||||||
|
recognizes the following configuration blocks.
|
||||||
|
.TP 8
|
||||||
|
.B config
|
||||||
|
.RI [ " hostname " | " ipaddr " ]
|
||||||
|
.br
|
||||||
|
Define a configuration block for the host named
|
||||||
|
.I hostname
|
||||||
|
or using the address
|
||||||
|
.IR ipaddr .
|
||||||
|
If the value of ``*'' is used, the configuration block will be applied to
|
||||||
|
all hosts.
|
||||||
|
.RS
|
||||||
|
.TP 15
|
||||||
|
.B escape
|
||||||
|
.I esc
|
||||||
|
.br
|
||||||
|
Set the escape sequence (see the
|
||||||
|
.B \-e
|
||||||
|
command-line flag).
|
||||||
|
.TP
|
||||||
|
.B master
|
||||||
|
.I master
|
||||||
|
.br
|
||||||
|
Set the default master to
|
||||||
|
.I master
|
||||||
|
(see the
|
||||||
|
.B \-M
|
||||||
|
command-line flag).
|
||||||
|
.TP
|
||||||
|
.B port
|
||||||
|
.I port
|
||||||
|
.br
|
||||||
|
Set the default port to
|
||||||
|
.I port
|
||||||
|
(see the
|
||||||
|
.B \-p
|
||||||
|
command-line flag).
|
||||||
|
.TP
|
||||||
|
.B sslcredentials
|
||||||
|
.I filename
|
||||||
|
.br
|
||||||
|
Set the
|
||||||
|
.SM SSL
|
||||||
|
credentials file location (see the
|
||||||
|
.B \-c
|
||||||
|
command-line flag).
|
||||||
|
.TP
|
||||||
|
.B sslenabled
|
||||||
|
.RB [ " yes " | " true "
|
||||||
|
.RB | " on " | " no "
|
||||||
|
.RB | " false " | " off " ]
|
||||||
|
.br
|
||||||
|
Set whether or not encryption is attempted when talking to servers (see the
|
||||||
|
.B \-E
|
||||||
|
command-line flag).
|
||||||
|
.TP
|
||||||
|
.B sslrequired
|
||||||
|
.RB [ " yes " | " true "
|
||||||
|
.RB | " on " | " no "
|
||||||
|
.RB | " false " | " off " ]
|
||||||
|
.br
|
||||||
|
Set whether or not encryption is required when talking to servers (see the
|
||||||
|
.B \-U
|
||||||
|
command-line flag).
|
||||||
|
.TP
|
||||||
|
.B striphigh
|
||||||
|
.RB [ " yes " | " true "
|
||||||
|
.RB | " on " | " no "
|
||||||
|
.RB | " false " | " off " ]
|
||||||
|
.br
|
||||||
|
Set whether or not to strip the high bit off all data received
|
||||||
|
(see the
|
||||||
|
.B \-7
|
||||||
|
command-line flag).
|
||||||
|
.TP
|
||||||
|
.B username
|
||||||
|
.I user
|
||||||
|
.br
|
||||||
|
Set the username passed to the server to
|
||||||
|
.I user
|
||||||
|
(see the
|
||||||
|
.B \-l
|
||||||
|
command-line flag).
|
||||||
|
.RE
|
||||||
|
.TP 8
|
||||||
|
.B terminal
|
||||||
|
.I type
|
||||||
|
.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 15
|
||||||
|
.B attach
|
||||||
|
.RI [ " string "
|
||||||
|
| "" ]
|
||||||
|
.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 (``""'') 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
|
||||||
|
.B attachsubst
|
||||||
|
[\f2c\fP=\f2t\fP[\f2n\fP]\f2f\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=\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 (``""'') is used, no replacements will be done.
|
||||||
|
.TP 15
|
||||||
|
.B detach
|
||||||
|
.RI [ " string "
|
||||||
|
| "" ]
|
||||||
|
.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 (``""'') is used, no string will be printed.
|
||||||
|
.TP
|
||||||
|
.B detachsubst
|
||||||
|
[\f2c\fP=\f2t\fP[\f2n\fP]\f2f\fP[,...]
|
||||||
|
| "" ]
|
||||||
|
.br
|
||||||
|
Perform character substitutions on the
|
||||||
|
.B detach
|
||||||
|
value.
|
||||||
|
See the
|
||||||
|
.B attachsubst
|
||||||
|
option for an explanation of the format string.
|
||||||
|
.RE
|
||||||
|
.PP
|
||||||
|
A simple configuration to set a new default escape sequence and override
|
||||||
|
the master location would be:
|
||||||
|
.IP
|
||||||
|
.ft CR
|
||||||
|
.nf
|
||||||
|
# override options for all hosts
|
||||||
|
config * {
|
||||||
|
master localhost;
|
||||||
|
escape ^Ee;
|
||||||
|
}
|
||||||
|
# set things more specific to host1
|
||||||
|
# note: if the entries were reversed, host1
|
||||||
|
# would also use localhost.
|
||||||
|
config host1 {
|
||||||
|
master console1;
|
||||||
|
}
|
||||||
|
.fi
|
||||||
|
.ft
|
||||||
.SH "ESCAPE SEQUENCES"
|
.SH "ESCAPE SEQUENCES"
|
||||||
The connection can be controlled by a two-character escape sequence, followed
|
The connection can be controlled by a two-character escape sequence, followed
|
||||||
by a command.
|
by a command.
|
||||||
@ -493,12 +846,16 @@ In the
|
|||||||
output, the login ``<none>'' indicates no one is
|
output, the login ``<none>'' indicates no one is
|
||||||
viewing that console, and the login ``<spies>'' indicates that
|
viewing that console, and the login ``<spies>'' indicates that
|
||||||
no one has a full two-way attachment.
|
no one has a full two-way attachment.
|
||||||
When no one is attached to
|
.PP
|
||||||
a console its output is cloned to the stdout of the server process if
|
When running a local command via
|
||||||
.B conserver
|
.RB `` ^Ec| '',
|
||||||
was started with the
|
you can type
|
||||||
.B \-u
|
.B ^C
|
||||||
option.
|
to send the command a SIGHUP,
|
||||||
|
.B ^\e
|
||||||
|
to send the command a SIGKILL, and
|
||||||
|
.B o
|
||||||
|
to toggle the display of the console data.
|
||||||
.SH EXAMPLES
|
.SH EXAMPLES
|
||||||
.TP 15
|
.TP 15
|
||||||
console \-u
|
console \-u
|
||||||
@ -550,6 +907,22 @@ or number of days is displayed.
|
|||||||
console \-e "^[1" lv426
|
console \-e "^[1" lv426
|
||||||
Requests a connection to the host ``lv426'' with the escape characters
|
Requests a connection to the host ``lv426'' with the escape characters
|
||||||
set to ``escape one''.
|
set to ``escape one''.
|
||||||
|
.SH FILES
|
||||||
|
.PP
|
||||||
|
The following default file locations may be overridden
|
||||||
|
at compile time or by the command-line options described above.
|
||||||
|
Run
|
||||||
|
.B console \-V
|
||||||
|
to see the defaults set at compile time.
|
||||||
|
.PP
|
||||||
|
.PD 0
|
||||||
|
.TP 25
|
||||||
|
.B /etc/console.cf
|
||||||
|
system-wide configuration file
|
||||||
|
.TP
|
||||||
|
.B $HOME/.consolerc
|
||||||
|
per-user configuration file
|
||||||
|
.PD
|
||||||
.SH BUGS
|
.SH BUGS
|
||||||
It is possible to create a loop of console connections, with ugly results.
|
It is possible to create a loop of console connections, with ugly results.
|
||||||
Never run
|
Never run
|
||||||
|
720
console/readconf.c
Normal file
720
console/readconf.c
Normal file
@ -0,0 +1,720 @@
|
|||||||
|
/*
|
||||||
|
* $Id: readconf.c,v 5.2 2004/05/25 00:38:15 bryan Exp $
|
||||||
|
*
|
||||||
|
* Copyright conserver.com, 2000
|
||||||
|
*
|
||||||
|
* Maintainer/Enhancer: Bryan Stansell (bryan@conserver.com)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <compat.h>
|
||||||
|
|
||||||
|
#include <cutil.h>
|
||||||
|
#include <readconf.h>
|
||||||
|
|
||||||
|
CONFIG *parserConfigTemp = (CONFIG *)0;
|
||||||
|
CONFIG *parserConfigDefault = (CONFIG *)0;
|
||||||
|
CONFIG *pConfig = (CONFIG *)0;
|
||||||
|
TERM *parserTermTemp = (TERM *)0;
|
||||||
|
TERM *parserTermDefault = (TERM *)0;
|
||||||
|
TERM *pTerm = (TERM *)0;
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
DestroyConfig(CONFIG *c)
|
||||||
|
#else
|
||||||
|
DestroyConfig(c)
|
||||||
|
CONFIG *c;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (c == (CONFIG *)0)
|
||||||
|
return;
|
||||||
|
if (c->username != (char *)0)
|
||||||
|
free(c->username);
|
||||||
|
if (c->master != (char *)0)
|
||||||
|
free(c->master);
|
||||||
|
if (c->port != (char *)0)
|
||||||
|
free(c->port);
|
||||||
|
if (c->escape != (char *)0)
|
||||||
|
free(c->escape);
|
||||||
|
#if HAVE_OPENSSL
|
||||||
|
if (c->sslcredentials != (char *)0)
|
||||||
|
free(c->sslcredentials);
|
||||||
|
#endif
|
||||||
|
free(c);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ApplyConfigDefault(CONFIG *c)
|
||||||
|
#else
|
||||||
|
ApplyConfigDefault(c)
|
||||||
|
CONFIG *c;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (parserConfigDefault == (CONFIG *)0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (parserConfigDefault->username != (char *)0) {
|
||||||
|
if (c->username != (char *)0)
|
||||||
|
free(c->username);
|
||||||
|
if ((c->username =
|
||||||
|
StrDup(parserConfigDefault->username)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
if (parserConfigDefault->master != (char *)0) {
|
||||||
|
if (c->master != (char *)0)
|
||||||
|
free(c->master);
|
||||||
|
if ((c->master = StrDup(parserConfigDefault->master)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
if (parserConfigDefault->port != (char *)0) {
|
||||||
|
if (c->port != (char *)0)
|
||||||
|
free(c->port);
|
||||||
|
if ((c->port = StrDup(parserConfigDefault->port)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
if (parserConfigDefault->escape != (char *)0) {
|
||||||
|
if (c->escape != (char *)0)
|
||||||
|
free(c->escape);
|
||||||
|
if ((c->escape = StrDup(parserConfigDefault->escape)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
if (parserConfigDefault->striphigh != FLAGUNKNOWN)
|
||||||
|
c->striphigh = parserConfigDefault->striphigh;
|
||||||
|
#if HAVE_OPENSSL
|
||||||
|
if (parserConfigDefault->sslcredentials != (char *)0) {
|
||||||
|
if (c->sslcredentials != (char *)0)
|
||||||
|
free(c->sslcredentials);
|
||||||
|
if ((c->sslcredentials =
|
||||||
|
StrDup(parserConfigDefault->sslcredentials)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
if (parserConfigDefault->sslrequired != FLAGUNKNOWN)
|
||||||
|
c->sslrequired = parserConfigDefault->sslrequired;
|
||||||
|
if (parserConfigDefault->sslenabled != FLAGUNKNOWN)
|
||||||
|
c->sslenabled = parserConfigDefault->sslenabled;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ConfigBegin(char *id)
|
||||||
|
#else
|
||||||
|
ConfigBegin(id)
|
||||||
|
char *id;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "ConfigBegin(%s) [%s:%d]", id, file, line));
|
||||||
|
if (id == (char *)0 || id[0] == '\000') {
|
||||||
|
Error("empty config name [%s:%d]", file, line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (parserConfigTemp != (CONFIG *)0)
|
||||||
|
DestroyConfig(parserConfigTemp);
|
||||||
|
if ((parserConfigTemp = (CONFIG *)calloc(1, sizeof(CONFIG)))
|
||||||
|
== (CONFIG *)0)
|
||||||
|
OutOfMem();
|
||||||
|
ApplyConfigDefault(parserConfigTemp);
|
||||||
|
parserConfigTemp->name = AllocString();
|
||||||
|
BuildString(id, parserConfigTemp->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ConfigEnd(void)
|
||||||
|
#else
|
||||||
|
ConfigEnd()
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "ConfigEnd() [%s:%d]", file, line));
|
||||||
|
|
||||||
|
if (parserConfigTemp == (CONFIG *)0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (parserConfigTemp->name->used > 1) {
|
||||||
|
if ((parserConfigTemp->name->string[0] == '*' &&
|
||||||
|
parserConfigTemp->name->string[1] == '\000') ||
|
||||||
|
IsMe(parserConfigTemp->name->string)) {
|
||||||
|
DestroyConfig(parserConfigDefault);
|
||||||
|
parserConfigDefault = parserConfigTemp;
|
||||||
|
parserConfigTemp = (CONFIG *)0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DestroyConfig(parserConfigTemp);
|
||||||
|
parserConfigTemp = (CONFIG *)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ConfigAbort(void)
|
||||||
|
#else
|
||||||
|
ConfigAbort()
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "ConfigAbort() [%s:%d]", file, line));
|
||||||
|
if (parserConfigTemp == (CONFIG *)0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DestroyConfig(parserConfigTemp);
|
||||||
|
parserConfigTemp = (CONFIG *)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ConfigDestroy(void)
|
||||||
|
#else
|
||||||
|
ConfigDestroy()
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "ConfigDestroy() [%s:%d]", file, line));
|
||||||
|
|
||||||
|
if (parserConfigTemp != (CONFIG *)0) {
|
||||||
|
DestroyConfig(parserConfigTemp);
|
||||||
|
parserConfigTemp = (CONFIG *)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parserConfigDefault != (CONFIG *)0) {
|
||||||
|
DestroyConfig(pConfig);
|
||||||
|
pConfig = parserConfigDefault;
|
||||||
|
parserConfigDefault = (CONFIG *)0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
DestroyTerminal(TERM *t)
|
||||||
|
#else
|
||||||
|
DestroyTerminal(t)
|
||||||
|
TERM *t;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (t == (TERM *)0)
|
||||||
|
return;
|
||||||
|
if (t->attach != (char *)0)
|
||||||
|
free(t->attach);
|
||||||
|
if (t->attachsubst != (char *)0)
|
||||||
|
free(t->attachsubst);
|
||||||
|
if (t->detach != (char *)0)
|
||||||
|
free(t->detach);
|
||||||
|
if (t->detachsubst != (char *)0)
|
||||||
|
free(t->detachsubst);
|
||||||
|
free(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ApplyTermDefault(TERM *t)
|
||||||
|
#else
|
||||||
|
ApplyTermDefault(t)
|
||||||
|
TERM *t;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (parserTermDefault == (TERM *)0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (parserTermDefault->attach != (char *)0) {
|
||||||
|
if (t->attach != (char *)0)
|
||||||
|
free(t->attach);
|
||||||
|
if ((t->attach = StrDup(parserTermDefault->attach)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
if (parserTermDefault->attachsubst != (char *)0) {
|
||||||
|
if (t->attachsubst != (char *)0)
|
||||||
|
free(t->attachsubst);
|
||||||
|
if ((t->attachsubst =
|
||||||
|
StrDup(parserTermDefault->attachsubst)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
if (parserTermDefault->detach != (char *)0) {
|
||||||
|
if (t->detach != (char *)0)
|
||||||
|
free(t->detach);
|
||||||
|
if ((t->detach = StrDup(parserTermDefault->detach)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
if (parserTermDefault->detachsubst != (char *)0) {
|
||||||
|
if (t->detachsubst != (char *)0)
|
||||||
|
free(t->detachsubst);
|
||||||
|
if ((t->detachsubst =
|
||||||
|
StrDup(parserTermDefault->detachsubst)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
TerminalBegin(char *id)
|
||||||
|
#else
|
||||||
|
TerminalBegin(id)
|
||||||
|
char *id;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "TerminalBegin(%s) [%s:%d]", id, file, line));
|
||||||
|
if (id == (char *)0 || id[0] == '\000') {
|
||||||
|
Error("empty terminal name [%s:%d]", file, line);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (parserTermTemp != (TERM *)0)
|
||||||
|
DestroyTerminal(parserTermTemp);
|
||||||
|
if ((parserTermTemp = (TERM *)calloc(1, sizeof(TERM)))
|
||||||
|
== (TERM *)0)
|
||||||
|
OutOfMem();
|
||||||
|
ApplyTermDefault(parserTermTemp);
|
||||||
|
parserTermTemp->name = AllocString();
|
||||||
|
BuildString(id, parserTermTemp->name);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
TerminalEnd(void)
|
||||||
|
#else
|
||||||
|
TerminalEnd()
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
static char *term = (char *)0;
|
||||||
|
|
||||||
|
CONDDEBUG((1, "TerminalEnd() [%s:%d]", file, line));
|
||||||
|
|
||||||
|
if (parserTermTemp == (TERM *)0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (term == (char *)0) {
|
||||||
|
if ((term = getenv("TERM")) == (char *)0) {
|
||||||
|
term = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parserTermTemp->name->used > 1) {
|
||||||
|
if ((parserTermTemp->name->string[0] == '*' &&
|
||||||
|
parserTermTemp->name->string[1] == '\000') ||
|
||||||
|
strcmp(parserTermTemp->name->string, term) == 0) {
|
||||||
|
DestroyTerminal(parserTermDefault);
|
||||||
|
parserTermDefault = parserTermTemp;
|
||||||
|
parserTermTemp = (TERM *)0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
DestroyTerminal(parserTermTemp);
|
||||||
|
parserTermTemp = (TERM *)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
TerminalAbort(void)
|
||||||
|
#else
|
||||||
|
TerminalAbort()
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "TerminalAbort() [%s:%d]", file, line));
|
||||||
|
if (parserTermTemp == (TERM *)0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DestroyTerminal(parserTermTemp);
|
||||||
|
parserTermTemp = (TERM *)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
TerminalDestroy(void)
|
||||||
|
#else
|
||||||
|
TerminalDestroy()
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "TerminalDestroy() [%s:%d]", file, line));
|
||||||
|
|
||||||
|
if (parserTermTemp != (TERM *)0) {
|
||||||
|
DestroyTerminal(parserTermTemp);
|
||||||
|
parserTermTemp = (TERM *)0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parserTermDefault != (TERM *)0) {
|
||||||
|
DestroyTerminal(pTerm);
|
||||||
|
pTerm = parserTermDefault;
|
||||||
|
parserTermDefault = (TERM *)0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ProcessYesNo(char *id, FLAG *flag)
|
||||||
|
#else
|
||||||
|
ProcessYesNo(id, flag)
|
||||||
|
char *id;
|
||||||
|
FLAG *flag;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
if (id == (char *)0 || id[0] == '\000')
|
||||||
|
*flag = FLAGFALSE;
|
||||||
|
else if (strcasecmp("yes", id) == 0 || strcasecmp("true", id) == 0 ||
|
||||||
|
strcasecmp("on", id) == 0)
|
||||||
|
*flag = FLAGTRUE;
|
||||||
|
else if (strcasecmp("no", id) == 0 || strcasecmp("false", id) == 0 ||
|
||||||
|
strcasecmp("off", id) == 0)
|
||||||
|
*flag = FLAGFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ConfigItemEscape(char *id)
|
||||||
|
#else
|
||||||
|
ConfigItemEscape(id)
|
||||||
|
char *id;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "ConfigItemEscape(%s) [%s:%d]", id, file, line));
|
||||||
|
|
||||||
|
if (parserConfigTemp->escape != (char *)0)
|
||||||
|
free(parserConfigTemp->escape);
|
||||||
|
|
||||||
|
if ((id == (char *)0) || (*id == '\000')) {
|
||||||
|
parserConfigTemp->escape = (char *)0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((parserConfigTemp->escape = StrDup(id)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ConfigItemMaster(char *id)
|
||||||
|
#else
|
||||||
|
ConfigItemMaster(id)
|
||||||
|
char *id;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "ConfigItemMaster(%s) [%s:%d]", id, file, line));
|
||||||
|
|
||||||
|
if (parserConfigTemp->master != (char *)0)
|
||||||
|
free(parserConfigTemp->master);
|
||||||
|
|
||||||
|
if ((id == (char *)0) || (*id == '\000')) {
|
||||||
|
parserConfigTemp->master = (char *)0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((parserConfigTemp->master = StrDup(id)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
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
|
||||||
|
ConfigItemSslcredentials(char *id)
|
||||||
|
#else
|
||||||
|
ConfigItemSslcredentials(id)
|
||||||
|
char *id;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "ConfigItemSslcredentials(%s) [%s:%d]", id, file, line));
|
||||||
|
#if HAVE_OPENSSL
|
||||||
|
if (parserConfigTemp->sslcredentials != (char *)0)
|
||||||
|
free(parserConfigTemp->sslcredentials);
|
||||||
|
|
||||||
|
if ((id == (char *)0) || (*id == '\000')) {
|
||||||
|
parserConfigTemp->sslcredentials = (char *)0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((parserConfigTemp->sslcredentials = StrDup(id)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
#else
|
||||||
|
Error
|
||||||
|
("sslcredentials ignored - encryption not compiled into code [%s:%d]",
|
||||||
|
file, line);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ConfigItemSslrequired(char *id)
|
||||||
|
#else
|
||||||
|
ConfigItemSslrequired(id)
|
||||||
|
char *id;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "ConfigItemSslrequired(%s) [%s:%d]", id, file, line));
|
||||||
|
#if HAVE_OPENSSL
|
||||||
|
ProcessYesNo(id, &(parserConfigTemp->sslrequired));
|
||||||
|
#else
|
||||||
|
Error
|
||||||
|
("sslrequired ignored - encryption not compiled into code [%s:%d]",
|
||||||
|
file, line);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ConfigItemSslenabled(char *id)
|
||||||
|
#else
|
||||||
|
ConfigItemSslenabled(id)
|
||||||
|
char *id;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "ConfigItemSslenabled(%s) [%s:%d]", id, file, line));
|
||||||
|
#if HAVE_OPENSSL
|
||||||
|
ProcessYesNo(id, &(parserConfigTemp->sslenabled));
|
||||||
|
#else
|
||||||
|
Error("sslenabled ignored - encryption not compiled into code [%s:%d]",
|
||||||
|
file, line);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ConfigItemStriphigh(char *id)
|
||||||
|
#else
|
||||||
|
ConfigItemStriphigh(id)
|
||||||
|
char *id;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "ConfigItemStriphigh(%s) [%s:%d]", id, file, line));
|
||||||
|
ProcessYesNo(id, &(parserConfigTemp->striphigh));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ConfigItemUsername(char *id)
|
||||||
|
#else
|
||||||
|
ConfigItemUsername(id)
|
||||||
|
char *id;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
CONDDEBUG((1, "ConfigItemUsername(%s) [%s:%d]", id, file, line));
|
||||||
|
|
||||||
|
if (parserConfigTemp->username != (char *)0)
|
||||||
|
free(parserConfigTemp->username);
|
||||||
|
|
||||||
|
if ((id == (char *)0) || (*id == '\000')) {
|
||||||
|
parserConfigTemp->username = (char *)0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if ((parserConfigTemp->username = StrDup(id)) == (char *)0)
|
||||||
|
OutOfMem();
|
||||||
|
}
|
||||||
|
|
||||||
|
SUBST *substData = (SUBST *) 0;
|
||||||
|
|
||||||
|
int
|
||||||
|
#if PROTOTYPES
|
||||||
|
SubstCallback(char c, char **s, int *i)
|
||||||
|
#else
|
||||||
|
SubstCallback(c, s, i)
|
||||||
|
char c;
|
||||||
|
char **s;
|
||||||
|
int *i;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
int retval = 0;
|
||||||
|
|
||||||
|
if (substData == (SUBST *) 0) {
|
||||||
|
if ((substData =
|
||||||
|
(SUBST *) calloc(1, sizeof(SUBST))) == (SUBST *) 0)
|
||||||
|
OutOfMem();
|
||||||
|
substData->callback = &SubstCallback;
|
||||||
|
substData->tokens['u'] = ISSTRING;
|
||||||
|
substData->tokens['c'] = ISSTRING;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
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},
|
||||||
|
{"port", ConfigItemPort},
|
||||||
|
{"sslcredentials", ConfigItemSslcredentials},
|
||||||
|
{"sslrequired", ConfigItemSslrequired},
|
||||||
|
{"sslenabled", ConfigItemSslenabled},
|
||||||
|
{"striphigh", ConfigItemStriphigh},
|
||||||
|
{"username", ConfigItemUsername},
|
||||||
|
{(char *)0, (void *)0}
|
||||||
|
};
|
||||||
|
|
||||||
|
ITEM keyTerminal[] = {
|
||||||
|
{"attach", TerminalItemAttach},
|
||||||
|
{"attachsubst", TerminalItemAttachsubst},
|
||||||
|
{"detach", TerminalItemDetach},
|
||||||
|
{"detachsubst", TerminalItemDetachsubst},
|
||||||
|
{(char *)0, (void *)0}
|
||||||
|
};
|
||||||
|
|
||||||
|
SECTION sections[] = {
|
||||||
|
{"config", ConfigBegin, ConfigEnd, ConfigAbort, ConfigDestroy,
|
||||||
|
keyConfig},
|
||||||
|
{"terminal", TerminalBegin, TerminalEnd, TerminalAbort,
|
||||||
|
TerminalDestroy, keyTerminal},
|
||||||
|
{(char *)0, (void *)0, (void *)0, (void *)0, (void *)0}
|
||||||
|
};
|
||||||
|
|
||||||
|
void
|
||||||
|
#if PROTOTYPES
|
||||||
|
ReadConf(char *filename, FLAG verbose)
|
||||||
|
#else
|
||||||
|
ReadConf(filename, verbose)
|
||||||
|
char *filename;
|
||||||
|
FLAG verbose;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
FILE *fp;
|
||||||
|
|
||||||
|
if ((FILE *)0 == (fp = fopen(filename, "r"))) {
|
||||||
|
if (verbose == FLAGTRUE)
|
||||||
|
Error("could not open `%s'", filename);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* initialize the substition bits */
|
||||||
|
SubstCallback('\000', (char **)0, (int *)0);
|
||||||
|
|
||||||
|
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)));
|
||||||
|
#if HAVE_OPENSSL
|
||||||
|
CONDDEBUG((1, "pConfig->sslcredentials = %s",
|
||||||
|
EMPTYSTR(pConfig->sslcredentials)));
|
||||||
|
CONDDEBUG((1, "pConfig->sslrequired = %s",
|
||||||
|
FLAGSTR(pConfig->sslrequired)));
|
||||||
|
CONDDEBUG((1, "pConfig->sslenabled = %s",
|
||||||
|
FLAGSTR(pConfig->sslenabled)));
|
||||||
|
#endif
|
||||||
|
CONDDEBUG((1, "pTerm->attach = %s", EMPTYSTR(pTerm->attach)));
|
||||||
|
CONDDEBUG((1, "pTerm->attachsubst = %s",
|
||||||
|
EMPTYSTR(pTerm->attachsubst)));
|
||||||
|
CONDDEBUG((1, "pTerm->detach = %s", EMPTYSTR(pTerm->detach)));
|
||||||
|
CONDDEBUG((1, "pTerm->detachsubst = %s",
|
||||||
|
EMPTYSTR(pTerm->detachsubst)));
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(fp);
|
||||||
|
}
|
38
console/readconf.h
Normal file
38
console/readconf.h
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* $Id: readconf.h,v 5.3 2004/05/25 23:03:25 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;
|
||||||
|
#if HAVE_OPENSSL
|
||||||
|
char *sslcredentials;
|
||||||
|
FLAG sslrequired;
|
||||||
|
FLAG sslenabled;
|
||||||
|
#endif
|
||||||
|
} CONFIG;
|
||||||
|
|
||||||
|
typedef struct term {
|
||||||
|
STRING *name;
|
||||||
|
char *attach;
|
||||||
|
char *attachsubst;
|
||||||
|
char *detach;
|
||||||
|
char *detachsubst;
|
||||||
|
} TERM;
|
||||||
|
|
||||||
|
extern CONFIG *pConfig;
|
||||||
|
extern TERM *pTerm;
|
||||||
|
extern SUBST *substData;
|
||||||
|
|
||||||
|
extern void ReadConf PARAMS((char *, FLAG));
|
||||||
|
extern void DestroyConfig PARAMS((CONFIG *));
|
||||||
|
extern void DestroyTerminal PARAMS((TERM *));
|
@ -4,7 +4,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
%define pkg conserver
|
%define pkg conserver
|
||||||
%define ver 8.1.3
|
%define ver 8.1.6
|
||||||
|
|
||||||
# define the name of the machine on which the main conserver
|
# define the name of the machine on which the main conserver
|
||||||
# daemon will be running if you don't want to use the default
|
# daemon will be running if you don't want to use the default
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
PKG="conserver"
|
PKG="conserver"
|
||||||
NAME="Console server and client"
|
NAME="Console server and client"
|
||||||
CATEGORY="system"
|
CATEGORY="system"
|
||||||
VERSION="8.1.3"
|
VERSION="8.1.6"
|
||||||
DESC="Console server and client"
|
DESC="Console server and client"
|
||||||
CLASSES=none
|
CLASSES=none
|
||||||
ARCH=sparc
|
ARCH=sparc
|
||||||
|
13
test/dotest
13
test/dotest
@ -14,6 +14,7 @@ cleanup()
|
|||||||
[ "$i" != "conserver.log" ] && [ -f "$i" ] && rm -f "$i";
|
[ "$i" != "conserver.log" ] && [ -f "$i" ] && rm -f "$i";
|
||||||
done
|
done
|
||||||
[ "$exitval" = 0 ] && rm -f conserver.log
|
[ "$exitval" = 0 ] && rm -f conserver.log
|
||||||
|
[ -d 127.0.0.1 ] && sleep 1 && rm -rf 127.0.0.1
|
||||||
exit $exitval
|
exit $exitval
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -25,7 +26,7 @@ dotest()
|
|||||||
eval "$2" > test.out 2>&1
|
eval "$2" > test.out 2>&1
|
||||||
else
|
else
|
||||||
echo "$1" | \
|
echo "$1" | \
|
||||||
../console/console -M 127.0.0.1 -p 7777 shell > test.out 2>&1
|
../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 shell > test.out 2>&1
|
||||||
fi
|
fi
|
||||||
if [ "$record" ]; then
|
if [ "$record" ]; then
|
||||||
echo "recorded"
|
echo "recorded"
|
||||||
@ -72,7 +73,7 @@ sleep 3
|
|||||||
|
|
||||||
[ ! -d results ] && mkdir results
|
[ ! -d results ] && mkdir results
|
||||||
|
|
||||||
dotest EVAL "../console/console -M 127.0.0.1 -p 7777 -u | sed -e 's/[0-9][0-9]*//g' -e 's/[ ][ ]*/ /g'"
|
dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -u | sed -e 's/[0-9][0-9]*//g' -e 's/[ ][ ]*/ /g'"
|
||||||
dotest 'c?c.'
|
dotest 'c?c.'
|
||||||
dotest 'cl?c.'
|
dotest 'cl?c.'
|
||||||
dotest 'cdc.'
|
dotest 'cdc.'
|
||||||
@ -84,14 +85,14 @@ cp test2.cf c.cf
|
|||||||
kill -1 $pid
|
kill -1 $pid
|
||||||
sleep 3
|
sleep 3
|
||||||
|
|
||||||
dotest EVAL "../console/console -M 127.0.0.1 -p 7777 -u | sed -e 's/[0-9][0-9]*//g' -e 's/[ ][ ]*/ /g'"
|
dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -u | sed -e 's/[0-9][0-9]*//g' -e 's/[ ][ ]*/ /g'"
|
||||||
dotest 'c?c.'
|
dotest 'c?c.'
|
||||||
dotest 'cl?c.'
|
dotest 'cl?c.'
|
||||||
dotest 'cdc.'
|
dotest 'cdc.'
|
||||||
dotest 'coc.'
|
dotest 'coc.'
|
||||||
|
|
||||||
dotest EVAL "echo 'tu.' | ../console/console -M 127.0.0.1 -p 7777 -e 'tu' shell"
|
dotest EVAL "echo 'tu.' | ../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -e 'tu' shell"
|
||||||
dotest EVAL "../console/console -M 127.0.0.1 -p 7777 -P | sed -e 's/:.*//'"
|
dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -R | sed -e 's/ [^ ]*$//'"
|
||||||
dotest EVAL "../console/console -M 127.0.0.1 -p 7777 -x | sed -e 's/ on [^ ]* */ on /'"
|
dotest EVAL "../console/console -n -C /dev/null -M 127.0.0.1 -p 7777 -x | sed -e 's/ on [^ ]* */ on /'"
|
||||||
|
|
||||||
cleanup
|
cleanup
|
||||||
|
@ -1 +1 @@
|
|||||||
127.0.0.1
|
version `conserver.com version
|
||||||
|
Reference in New Issue
Block a user