mirror of
https://github.com/bstansell/conserver.git
synced 2025-06-24 09:46:39 +00:00
Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
75cfd02f7a | |||
ad7a90dd69 | |||
691c3102c9 | |||
eafae7c27d | |||
92cf41a9f2 | |||
1c188a41d6 | |||
aeb8ac0057 | |||
66e0902358 | |||
de2e2fd33c |
128
CHANGES
128
CHANGES
@ -1,6 +1,132 @@
|
||||
CHANGES
|
||||
=======
|
||||
|
||||
version 8.0.9 (Dec 10, 2003):
|
||||
- fixed major bug in connect() handling which causes most
|
||||
socket-based consoles to timeout after 10 seconds - reported
|
||||
by Tom Rataski <trataski@intlsteel.com>
|
||||
- added a couple details to the 'logfilemax' manpage entry
|
||||
|
||||
version 8.0.8 (Dec 2, 2003):
|
||||
- added client ^Ec| sequence for running a command on the client
|
||||
and having it's I/O directed to the console - inspired by
|
||||
discussions with David Williamson
|
||||
<david+conserver@williamsons.net> years ago ;-)
|
||||
- touched up Makefiles to test against .h files
|
||||
- fixed inability to replay the console log while the console is
|
||||
down - reported by Matt Selsky <selsky@columbia.edu>
|
||||
- added a console 'logfilemax' option for rotating the console
|
||||
logfile once the file is greater than the specified size
|
||||
- added sample configuration files to conserver.cf/samples
|
||||
- tweaked some failure messages and initcmd notifications
|
||||
|
||||
version 8.0.7 (Nov 20, 2003):
|
||||
- renamed util.[ch] to cutil.[ch] to prevent name conflict with
|
||||
system util.h, reordered some #includes, and fixed a configure
|
||||
test for sys/proc.h to build on OpenBSD 3.4 (and probably
|
||||
others) - reported by Kurt Raschke <kurt@raschke.net>
|
||||
- fixed missing semi-colon for cygwin build - reported by
|
||||
Raymond Richmond <raymond.richmond@ualberta.ca>
|
||||
|
||||
version 8.0.6 (Nov 16, 2003):
|
||||
- code was missing regarding the 'setproctitle' option - patch
|
||||
by Dmitry Morozovsky <marck@rinet.ru>
|
||||
- fixed the order of access list checking when
|
||||
--with-trustrevdns is used
|
||||
- fixed various spelling errors - patches by Matt Selsky
|
||||
<selsky@columbia.edu>
|
||||
- added console 'idletimeout' and 'idlestring' options to
|
||||
trigger the sending of 'idlestring' after a lack of activity
|
||||
for 'idletimeout' seconds - suggested by Ian Potts
|
||||
<ian.potts@db.com>
|
||||
- added console 'portbase' and 'portinc' options to allow
|
||||
specifying a formula for referencing ports - inspired by Todd
|
||||
Stansell <todd@stansell.org>
|
||||
- fixed problem where console 'port' option didn't take port
|
||||
names (manpage said it did)
|
||||
- added server -U option and configuration option 'unifiedlog'
|
||||
to allow a copy of all console activity to go to a single file
|
||||
- removed all sprintf() calls
|
||||
- added 'devicesubst' and 'execsubst' console options for doing
|
||||
replacements with calculated port numbers on the 'device' and
|
||||
'exec' values
|
||||
- NULL characters in console data caused data loss because of
|
||||
strlen() usage - reported by Toby Gerhart <toby.gerhart@eds.com>
|
||||
- fixed a couple errors in contrib/redhat-rpm/conserver.spec -
|
||||
reported by Martin Evans <m.d.t.evans@qmul.ac.uk>
|
||||
- added capability to use '!' in user access lists to prevent a
|
||||
user from having access - suggested by Matt Selsky
|
||||
<selsky@columbia.edu>
|
||||
|
||||
version 8.0.5 (Oct 31, 2003):
|
||||
- added 'loghostnames' config option (default is on) to log
|
||||
client hostnames instead of ip addresses (like pre-8.0.0) -
|
||||
suggested by Han Pilmeyer <han@zk3.dec.com>
|
||||
- fixed bug where 'daemonmode' config file option wasn't being
|
||||
used
|
||||
- fixed potential logfile (-L) opening problem processing SIGHUP
|
||||
- fixed various potential conserver.cf issues with 'config'
|
||||
block values processing SIGHUP
|
||||
- added 'setproctitle' config option (default is off) to enable
|
||||
changing the process title to contain runtime information -
|
||||
patch by Dmitry Morozovsky <marck@rinet.ru>
|
||||
|
||||
version 8.0.4 (Oct 10, 2003):
|
||||
- fixed client rejection bug that can nearly never happen -
|
||||
reported by Han Pilmeyer <han@zk3.dec.com>
|
||||
- fixed bug where client is reconnected to the previous console
|
||||
when non-exact console names are used - reported by Rolf
|
||||
Petter Halle <rph@online.no>
|
||||
- fixed bug where exact matchs on a remote console name never
|
||||
happened - reported by Toby Gerhart <toby.gerhart@eds.com>
|
||||
- fixed bug where SIGHUP fails to update console aliases -
|
||||
reported by Han Pilmeyer <han@zk3.dec.com>
|
||||
|
||||
version 8.0.3 (Oct 6, 2003):
|
||||
- the SIGHUP process fails to pick up changes to certain fields
|
||||
because of a horribly broken SwapStr() function [broken in
|
||||
all previous 8.0.x versions] - reported by Toby Gerhart
|
||||
<toby.gerhart@eds.com>
|
||||
|
||||
version 8.0.2 (Oct 5, 2003):
|
||||
- reworked the i/o calls to better buffer data
|
||||
- added console 'motd' option for holding a "message of the
|
||||
day", displayed to the client on attachment to console -
|
||||
suggested by Toby Gerhart <toby.gerhart@eds.com>
|
||||
- added ^Ecm client command for displaying MOTD and integrated
|
||||
it into the client console attachment sequence
|
||||
- now unallocate client lists when forking new child conserver
|
||||
processes
|
||||
- changed strdup() to local StrDup() so dmalloc can gracefully
|
||||
track changes
|
||||
- added a ^Ec; sequence to let client signal server when it's
|
||||
ready to see console data, otherwise a chatty console can
|
||||
cause the login sequence to fail and you can never attach to
|
||||
the console
|
||||
|
||||
version 8.0.1 (Sep 29, 2003):
|
||||
- fixed bug in access list parsing where multiple addresses per
|
||||
line can cause errors - reported by Jay McCanta
|
||||
<mccantaj@amgen.com>
|
||||
- changed client password prompt to show hostname passed down by
|
||||
the server - suggested by Toby Gerhart <toby.gerhart@eds.com>
|
||||
- fixed bug where remote console names were only search for
|
||||
substring matches - reported by Toby Gerhart
|
||||
<toby.gerhart@eds.com>
|
||||
- the server -M option wasn't being used properly to limit the
|
||||
consoles managed by the host
|
||||
- added 'initcmd' console option which allows a command to
|
||||
interact with a console right after a console is opened -
|
||||
suggested by Greg Woods <woods@weird.com>
|
||||
- added the chat program contributed by Greg Woods
|
||||
<woods@weird.com> to the contrib/chat directory
|
||||
- added WUNTRACED to waitpid() for catching suspended processes
|
||||
- reworded some client/server messages to be clearer
|
||||
- embedded non-printable characters in break lists now display
|
||||
correctly when '^Ecl?' is used
|
||||
- in case client aborts unexpectedly, terminal state should
|
||||
now be restored to normal
|
||||
|
||||
version 8.0.0 (Sep 22, 2003):
|
||||
- better error messages and management of the user's password
|
||||
- 8.0.0-beta4 mistakenly lost conserver.passwd usage
|
||||
@ -517,5 +643,5 @@ before version 6.05:
|
||||
and enhancements of various types were applied.
|
||||
|
||||
#
|
||||
# $Id: CHANGES,v 1.103 2003-09-22 10:42:00-07 bryan Exp $
|
||||
# $Id: CHANGES,v 1.141 2003/12/10 18:33:40 bryan Exp $
|
||||
#
|
||||
|
2
FAQ
2
FAQ
@ -186,5 +186,5 @@ directed to faq@conserver.com. The FAQ answers the following questions:
|
||||
through the same problem?
|
||||
|
||||
#
|
||||
# $Id: FAQ,v 1.9 2003-08-23 12:27:10-07 bryan Exp $
|
||||
# $Id: FAQ,v 1.9 2003/08/23 19:27:10 bryan Exp $
|
||||
#
|
||||
|
18
INSTALL
18
INSTALL
@ -10,6 +10,22 @@ Upgrading?
|
||||
new features added to the client if you're considering *not*
|
||||
upgrading.
|
||||
|
||||
Version 8.0.2
|
||||
|
||||
- I've added a '^Ec;' sequence to allow the client to signal the
|
||||
server as to when it's ready to see console data. Without
|
||||
this, verbose consoles will prevent clients from attaching
|
||||
(the client sees unexpected data). An 8.0.2 client should be
|
||||
compatible with an 8.0.1 server, but an 8.0.1 client is not
|
||||
compatible with an 8.0.2 server.
|
||||
|
||||
Version 8.0.1
|
||||
|
||||
- There's a slight client/server protocol change to implement
|
||||
the new 'initcmd' console option. If you use this
|
||||
functionality with an 8.0.0 client, you'll run into a
|
||||
compatibility problem while the 'initcmd' command is running.
|
||||
|
||||
Version 8.0.0
|
||||
|
||||
- The client/server protocol has been rearchitected. You *MUST*
|
||||
@ -239,5 +255,5 @@ Other Information And Gotchas
|
||||
|
||||
|
||||
#
|
||||
# $Id: INSTALL,v 1.32 2003-08-23 11:20:55-07 bryan Exp $
|
||||
# $Id: INSTALL,v 1.34 2003/10/03 17:52:31 bryan Exp $
|
||||
#
|
||||
|
@ -25,6 +25,12 @@ autologin:
|
||||
autologin.install:
|
||||
( cd autologin && $(MAKE) install $(MAKE_FLAGS) ) || exit 1;
|
||||
|
||||
chat:
|
||||
( cd contrib/chat && $(MAKE) $@ $(MAKE_FLAGS) ) || exit 1;
|
||||
|
||||
chat.install:
|
||||
( cd contrib/chat && $(MAKE) install $(MAKE_FLAGS) ) || exit 1;
|
||||
|
||||
test:
|
||||
( cd test && ./dotest ) || exit 1
|
||||
|
||||
|
2
README
2
README
@ -55,5 +55,5 @@ Contributions
|
||||
http://www.columbia.edu/acis/sy/unixdev/zinc
|
||||
|
||||
#
|
||||
# $Id: README,v 1.22 2003-08-23 12:34:24-07 bryan Exp $
|
||||
# $Id: README,v 1.22 2003/08/23 19:34:24 bryan Exp $
|
||||
#
|
||||
|
21
TODO
21
TODO
@ -10,9 +10,6 @@ Bryan Stansell
|
||||
|
||||
---------------------------------------------------------------------------
|
||||
|
||||
- Singular logging so that swatch/logsurfer can watch for errors across
|
||||
the board - unloved output comes close
|
||||
|
||||
- Telnet protocol should be improved
|
||||
- Not even RFC 854 compliant
|
||||
- Option negotiation ignored - should we negotiate anything?
|
||||
@ -36,6 +33,7 @@ Bryan Stansell
|
||||
|
||||
- pipe input/output (console <-> program) via 'console'
|
||||
- some apps (net-ups thing, gdb) might need to talk to user
|
||||
- ^Ec| does this, but the interact with user bits might not work
|
||||
|
||||
- autologout? setting per console? gack, would have to interpret data.
|
||||
|
||||
@ -62,8 +60,6 @@ Bryan Stansell
|
||||
- server -M flag should accept multiple addresses (comma separated)
|
||||
- should client as well?
|
||||
|
||||
- logfile rotation based on size
|
||||
|
||||
- automatic log rotation in general : Egan Ford <egan@us.ibm.com>
|
||||
|
||||
- website docs on serial port configs
|
||||
@ -74,16 +70,21 @@ Bryan Stansell
|
||||
- suggestions by Trevor Fiatal <trevor@seven.com>
|
||||
- include server hostname on 'console -x' output
|
||||
|
||||
- ability to configure strings to be sent to a console whenever it is
|
||||
(re)opened (eg. a termserver login) : Greg A. Woods
|
||||
<woods@planix.com>
|
||||
|
||||
- ability to configure strings to be sent to a console periodically :
|
||||
Greg A. Woods <woods@planix.com>
|
||||
|
||||
- show attach/detach events to/of spy console clients : Greg A. Woods
|
||||
<woods@planix.com>
|
||||
|
||||
- redefine client escape sequence in conserver.cf : Toby Gerhart
|
||||
<toby.gerhart@eds.com>
|
||||
|
||||
- send a string when connected to a console, so you can set the
|
||||
xterm title, for example : Richard Threadgill <richardt@tellme.com>
|
||||
|
||||
- allow for very long replays (hundres of lines) : John Stoffel
|
||||
<stoffel@lucent.com>
|
||||
|
||||
#
|
||||
# $Id: TODO,v 1.36 2003-08-24 15:11:03-07 bryan Exp $
|
||||
# $Id: TODO,v 1.44 2003/11/29 14:10:47 bryan Exp $
|
||||
#
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: INSTALL,v 1.3 94/07/11 12:38:19 ksb Exp $
|
||||
# $Id: INSTALL.old,v 1.1 2003/11/04 02:36:24 bryan Exp $
|
||||
|
||||
To install this program you need root access and access to the physical
|
||||
console of the machine (either through the console server or via the physical
|
||||
|
@ -31,6 +31,8 @@ ALL = autologin
|
||||
|
||||
all: $(ALL)
|
||||
|
||||
$(AUTOLOGIN_OBJS): $(AUTOLOGIN_HDRS)
|
||||
|
||||
autologin: $(AUTOLOGIN_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o autologin $(AUTOLOGIN_OBJS) $(LIBS)
|
||||
|
||||
|
@ -17,5 +17,5 @@ Good luck.
|
||||
Bryan Stansell
|
||||
|
||||
#
|
||||
# $Id: README,v 1.2 2002-09-23 14:08:42-07 bryan Exp $
|
||||
# $Id: README,v 1.2 2002/09/23 21:08:42 bryan Exp $
|
||||
#
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: README,v 1.3 93/04/21 16:13:37 ksb Exp $
|
||||
# $Id: README.old,v 1.1 2003/11/04 02:36:24 bryan Exp $
|
||||
|
||||
This program can be used to put a root shell on the console at boot time.
|
||||
See the manual page.
|
||||
|
@ -69,7 +69,7 @@
|
||||
*/
|
||||
|
||||
#ifndef lint
|
||||
char *rcsid = "$Id: autologin.c,v 1.23 2002-09-20 23:29:39-07 bryan Exp $";
|
||||
char *rcsid = "$Id: autologin.c,v 1.23 2002/09/21 06:29:39 bryan Exp $";
|
||||
#endif /* not lint */
|
||||
extern char *progname;
|
||||
gid_t awGrps[NGROUPS_MAX];
|
||||
|
@ -1,7 +1,7 @@
|
||||
# mkcmd parser for autologin program
|
||||
%%
|
||||
static char *rcsid =
|
||||
"$Id: autologin.m,v 1.2 92/07/28 13:18:34 ksb Exp $";
|
||||
"$Id: autologin.m,v 1.1 2003/11/04 02:36:24 bryan Exp $";
|
||||
%%
|
||||
|
||||
integer variable "iErrs" {
|
||||
|
@ -1,4 +1,4 @@
|
||||
.\" $Id: autologin.man,v 1.3 93/03/16 16:41:45 ksb Exp $
|
||||
.\" $Id: autologin.man,v 1.1 2003/11/04 02:36:24 bryan Exp $
|
||||
.TH AUTOLOGIN 8L PUCC
|
||||
.SH NAME
|
||||
autologin \- create an automatic login session from /etc/inittab
|
||||
|
@ -80,7 +80,7 @@ char **nargv, *ostr;
|
||||
#endif /* ! HAVE_GETOPT */
|
||||
|
||||
char
|
||||
*progname = "$Id$",
|
||||
*progname = "$Id: main.c,v 1.1 2003/11/04 02:36:24 bryan Exp $",
|
||||
*au_terse[] = {
|
||||
" [-u] [-c cmd] [-e env=value] [-g group] [-l login] [-t tty]",
|
||||
" -h",
|
||||
@ -111,7 +111,7 @@ int
|
||||
#endif
|
||||
|
||||
static char *rcsid =
|
||||
"$Id: autologin.m,v 1.2 92/07/28 13:18:34 ksb Exp $";
|
||||
"$Id: main.c,v 1.1 2003/11/04 02:36:24 bryan Exp $";
|
||||
|
||||
/*
|
||||
* parser
|
||||
|
6
compat.h
6
compat.h
@ -7,8 +7,8 @@
|
||||
#include <sys/file.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
#include <ctype.h>
|
||||
#include <signal.h>
|
||||
@ -287,6 +287,10 @@ typedef int socklen_t;
|
||||
#define ONLRET 0
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET L_SET
|
||||
#endif
|
||||
|
||||
#ifndef PARAMS
|
||||
# if PROTOTYPES
|
||||
# define PARAMS(protos) protos
|
||||
|
32
config.guess
vendored
32
config.guess
vendored
@ -3,7 +3,7 @@
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2003-08-18'
|
||||
timestamp='2003-10-20'
|
||||
|
||||
# This file is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License as published by
|
||||
@ -221,6 +221,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
mvmeppc:OpenBSD:*:*)
|
||||
echo powerpc-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
pegasos:OpenBSD:*:*)
|
||||
echo powerpc-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
pmax:OpenBSD:*:*)
|
||||
echo mipsel-unknown-openbsd${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
@ -307,6 +310,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
|
||||
*:OS/390:*:*)
|
||||
echo i370-ibm-openedition
|
||||
exit 0 ;;
|
||||
*:OS400:*:*)
|
||||
echo powerpc-ibm-os400
|
||||
exit 0 ;;
|
||||
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
|
||||
echo arm-acorn-riscix${UNAME_RELEASE}
|
||||
exit 0;;
|
||||
@ -742,6 +748,11 @@ EOF
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
|
||||
echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit 0 ;;
|
||||
5000:UNIX_System_V:4.*:*)
|
||||
FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
|
||||
FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
|
||||
echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
|
||||
exit 0 ;;
|
||||
i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
@ -751,7 +762,7 @@ EOF
|
||||
*:BSD/OS:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:FreeBSD:*:*|*:GNU/FreeBSD:*:*)
|
||||
*:FreeBSD:*:*)
|
||||
# Determine whether the default compiler uses glibc.
|
||||
eval $set_cc_for_build
|
||||
sed 's/^ //' << EOF >$dummy.c
|
||||
@ -763,7 +774,7 @@ EOF
|
||||
#endif
|
||||
EOF
|
||||
eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
|
||||
# GNU/FreeBSD systems have a "k" prefix to indicate we are using
|
||||
# GNU/KFreeBSD systems have a "k" prefix to indicate we are using
|
||||
# FreeBSD's kernel, but not the complete OS.
|
||||
case ${LIBC} in gnu) kernel_only='k' ;; esac
|
||||
echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
|
||||
@ -799,8 +810,13 @@ EOF
|
||||
echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
|
||||
exit 0 ;;
|
||||
*:GNU:*:*)
|
||||
# the GNU system
|
||||
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
|
||||
exit 0 ;;
|
||||
*:GNU/*:*:*)
|
||||
# other systems with GNU libc and userland
|
||||
echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
|
||||
exit 0 ;;
|
||||
i*86:Minix:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-minix
|
||||
exit 0 ;;
|
||||
@ -981,6 +997,9 @@ EOF
|
||||
i*86:atheos:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-atheos
|
||||
exit 0 ;;
|
||||
i*86:syllable:*:*)
|
||||
echo ${UNAME_MACHINE}-pc-syllable
|
||||
exit 0 ;;
|
||||
i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
|
||||
echo i386-unknown-lynxos${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
@ -1052,7 +1071,7 @@ EOF
|
||||
exit 0 ;;
|
||||
M68*:*:R3V[567]*:*)
|
||||
test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
|
||||
3[34]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
|
||||
3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0)
|
||||
OS_REL=''
|
||||
test -r /etc/.relid \
|
||||
&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
|
||||
@ -1167,7 +1186,7 @@ EOF
|
||||
*:QNX:*:4*)
|
||||
echo i386-pc-qnx
|
||||
exit 0 ;;
|
||||
NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*)
|
||||
NSR-[DGKLNPTVWY]:NONSTOP_KERNEL:*:*)
|
||||
echo nsr-tandem-nsk${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:NonStop-UX:*:*)
|
||||
@ -1211,6 +1230,9 @@ EOF
|
||||
SEI:*:*:SEIUX)
|
||||
echo mips-sei-seiux${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
*:DRAGONFLY:*:*)
|
||||
echo ${UNAME_MACHINE}-unknown-dragonfly${UNAME_RELEASE}
|
||||
exit 0 ;;
|
||||
esac
|
||||
|
||||
#echo '(No uname command or uname output not recognized.)' 1>&2
|
||||
|
@ -144,6 +144,9 @@
|
||||
/* Define to 1 if you have the `setpgrp' function. */
|
||||
#undef HAVE_SETPGRP
|
||||
|
||||
/* Define to 1 if you have the `setproctitle' function. */
|
||||
#undef HAVE_SETPROCTITLE
|
||||
|
||||
/* Define to 1 if you have the `setsid' function. */
|
||||
#undef HAVE_SETSID
|
||||
|
||||
@ -204,6 +207,9 @@
|
||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
||||
#undef HAVE_SYS_IOCTL_H
|
||||
|
||||
/* Define to 1 if you have the <sys/param.h> header file. */
|
||||
#undef HAVE_SYS_PARAM_H
|
||||
|
||||
/* Define to 1 if you have the <sys/proc.h> header file. */
|
||||
#undef HAVE_SYS_PROC_H
|
||||
|
||||
|
36
config.sub
vendored
36
config.sub
vendored
@ -3,7 +3,7 @@
|
||||
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
# 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
|
||||
timestamp='2003-08-18'
|
||||
timestamp='2003-11-20'
|
||||
|
||||
# This file is (in principle) common to ALL GNU software.
|
||||
# The presence of a machine in this file suggests that SOME GNU software
|
||||
@ -118,7 +118,8 @@ esac
|
||||
# Here we must recognize all the valid KERNEL-OS combinations.
|
||||
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
|
||||
case $maybe_os in
|
||||
nto-qnx* | linux-gnu* | linux-dietlibc | kfreebsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
|
||||
nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
|
||||
kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
|
||||
os=-$maybe_os
|
||||
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
|
||||
;;
|
||||
@ -248,6 +249,7 @@ case $basic_machine in
|
||||
| mipsisa32 | mipsisa32el \
|
||||
| mipsisa32r2 | mipsisa32r2el \
|
||||
| mipsisa64 | mipsisa64el \
|
||||
| mipsisa64r2 | mipsisa64r2el \
|
||||
| mipsisa64sb1 | mipsisa64sb1el \
|
||||
| mipsisa64sr71k | mipsisa64sr71kel \
|
||||
| mipstx39 | mipstx39el \
|
||||
@ -320,6 +322,7 @@ case $basic_machine in
|
||||
| mipsisa32-* | mipsisa32el-* \
|
||||
| mipsisa32r2-* | mipsisa32r2el-* \
|
||||
| mipsisa64-* | mipsisa64el-* \
|
||||
| mipsisa64r2-* | mipsisa64r2el-* \
|
||||
| mipsisa64sb1-* | mipsisa64sb1el-* \
|
||||
| mipsisa64sr71k-* | mipsisa64sr71kel-* \
|
||||
| mipstx39-* | mipstx39el-* \
|
||||
@ -741,6 +744,10 @@ case $basic_machine in
|
||||
basic_machine=or32-unknown
|
||||
os=-coff
|
||||
;;
|
||||
os400)
|
||||
basic_machine=powerpc-ibm
|
||||
os=-os400
|
||||
;;
|
||||
OSE68000 | ose68000)
|
||||
basic_machine=m68000-ericsson
|
||||
os=-ose
|
||||
@ -961,6 +968,10 @@ case $basic_machine in
|
||||
tower | tower-32)
|
||||
basic_machine=m68k-ncr
|
||||
;;
|
||||
tpf)
|
||||
basic_machine=s390x-ibm
|
||||
os=-tpf
|
||||
;;
|
||||
udi29k)
|
||||
basic_machine=a29k-amd
|
||||
os=-udi
|
||||
@ -1129,19 +1140,19 @@ case $os in
|
||||
| -aos* \
|
||||
| -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
|
||||
| -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
|
||||
| -hiux* | -386bsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \
|
||||
| -hiux* | -386bsd* | -knetbsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \
|
||||
| -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
|
||||
| -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
|
||||
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
|
||||
| -chorusos* | -chorusrdb* \
|
||||
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
|
||||
| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
|
||||
| -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
|
||||
| -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
|
||||
| -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
|
||||
| -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
|
||||
| -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
|
||||
| -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
|
||||
| -powermax* | -dnix* | -nx6 | -nx7 | -sei*)
|
||||
| -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly*)
|
||||
# Remember, each alternative MUST END IN *, to match a version number.
|
||||
;;
|
||||
-qnx*)
|
||||
@ -1180,6 +1191,9 @@ case $os in
|
||||
-opened*)
|
||||
os=-openedition
|
||||
;;
|
||||
-os400*)
|
||||
os=-os400
|
||||
;;
|
||||
-wince*)
|
||||
os=-wince
|
||||
;;
|
||||
@ -1201,6 +1215,9 @@ case $os in
|
||||
-atheos*)
|
||||
os=-atheos
|
||||
;;
|
||||
-syllable*)
|
||||
os=-syllable
|
||||
;;
|
||||
-386bsd)
|
||||
os=-bsd
|
||||
;;
|
||||
@ -1223,6 +1240,9 @@ case $os in
|
||||
-sinix*)
|
||||
os=-sysv4
|
||||
;;
|
||||
-tpf*)
|
||||
os=-tpf
|
||||
;;
|
||||
-triton*)
|
||||
os=-sysv3
|
||||
;;
|
||||
@ -1471,9 +1491,15 @@ case $basic_machine in
|
||||
-mvs* | -opened*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-os400*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-ptx*)
|
||||
vendor=sequent
|
||||
;;
|
||||
-tpf*)
|
||||
vendor=ibm
|
||||
;;
|
||||
-vxsim* | -vxworks* | -windiss*)
|
||||
vendor=wrs
|
||||
;;
|
||||
|
63
configure
vendored
63
configure
vendored
@ -3485,7 +3485,7 @@ fi
|
||||
|
||||
|
||||
|
||||
for ac_header in unistd.h getopt.h sys/vlimit.h sys/resource.h ttyent.h sys/ttold.h sys/uio.h sys/proc.h sys/ioctl_compat.h usersec.h sys/select.h stropts.h sys/audit.h shadow.h sys/time.h crypt.h sysexits.h types.h sys/sockio.h
|
||||
for ac_header in unistd.h getopt.h sys/vlimit.h sys/resource.h ttyent.h sys/ttold.h sys/uio.h sys/ioctl_compat.h usersec.h sys/select.h stropts.h sys/audit.h shadow.h sys/time.h crypt.h sysexits.h types.h sys/sockio.h sys/param.h
|
||||
do
|
||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||
if eval "test \"\${$as_ac_Header+set}\" = set"; then
|
||||
@ -3626,6 +3626,61 @@ fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
for ac_header in sys/proc.h
|
||||
do
|
||||
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
|
||||
echo "$as_me:$LINENO: checking for $ac_header" >&5
|
||||
echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
|
||||
if eval "test \"\${$as_ac_Header+set}\" = set"; then
|
||||
echo $ECHO_N "(cached) $ECHO_C" >&6
|
||||
else
|
||||
cat >conftest.$ac_ext <<_ACEOF
|
||||
#line $LINENO "configure"
|
||||
/* confdefs.h. */
|
||||
_ACEOF
|
||||
cat confdefs.h >>conftest.$ac_ext
|
||||
cat >>conftest.$ac_ext <<_ACEOF
|
||||
/* end confdefs.h. */
|
||||
#if HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <$ac_header>
|
||||
_ACEOF
|
||||
rm -f conftest.$ac_objext
|
||||
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
|
||||
(eval $ac_compile) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); } &&
|
||||
{ ac_try='test -s conftest.$ac_objext'
|
||||
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
|
||||
(eval $ac_try) 2>&5
|
||||
ac_status=$?
|
||||
echo "$as_me:$LINENO: \$? = $ac_status" >&5
|
||||
(exit $ac_status); }; }; then
|
||||
eval "$as_ac_Header=yes"
|
||||
else
|
||||
echo "$as_me: failed program was:" >&5
|
||||
sed 's/^/| /' conftest.$ac_ext >&5
|
||||
|
||||
eval "$as_ac_Header=no"
|
||||
fi
|
||||
rm -f conftest.$ac_objext conftest.$ac_ext
|
||||
fi
|
||||
echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
|
||||
echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
|
||||
if test `eval echo '${'$as_ac_Header'}'` = yes; then
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
|
||||
_ACEOF
|
||||
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5
|
||||
echo $ECHO_N "checking whether time.h and sys/time.h may both be included... $ECHO_C" >&6
|
||||
if test "${ac_cv_header_time+set}" = set; then
|
||||
@ -6155,7 +6210,8 @@ done
|
||||
|
||||
|
||||
|
||||
for ac_func in getopt strerror getrlimit getsid setsid getuserattr setgroups tcgetpgrp tcsetpgrp tcgetattr tcsetattr tcsendbreak setpgrp getutent setttyent getspnam setlinebuf setvbuf ptsname grantpt unlockpt sigaction setsockopt getdtablesize putenv memset memcpy memcmp memmove sysconf getlogin inet_aton
|
||||
|
||||
for ac_func in getopt strerror getrlimit getsid setsid getuserattr setgroups tcgetpgrp tcsetpgrp tcgetattr tcsetattr tcsendbreak setpgrp getutent setttyent getspnam setlinebuf setvbuf ptsname grantpt unlockpt sigaction setsockopt getdtablesize putenv memset memcpy memcmp memmove sysconf getlogin inet_aton setproctitle
|
||||
do
|
||||
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
|
||||
echo "$as_me:$LINENO: checking for $ac_func" >&5
|
||||
@ -6762,7 +6818,7 @@ done
|
||||
|
||||
|
||||
|
||||
ac_config_files="$ac_config_files Makefile conserver/Makefile conserver.cf/Makefile console/Makefile autologin/Makefile"
|
||||
ac_config_files="$ac_config_files Makefile conserver/Makefile conserver.cf/Makefile console/Makefile autologin/Makefile contrib/chat/Makefile"
|
||||
|
||||
ac_config_files="$ac_config_files conserver/conserver.rc"
|
||||
|
||||
@ -7295,6 +7351,7 @@ do
|
||||
"conserver.cf/Makefile" ) CONFIG_FILES="$CONFIG_FILES conserver.cf/Makefile" ;;
|
||||
"console/Makefile" ) CONFIG_FILES="$CONFIG_FILES console/Makefile" ;;
|
||||
"autologin/Makefile" ) CONFIG_FILES="$CONFIG_FILES autologin/Makefile" ;;
|
||||
"contrib/chat/Makefile" ) CONFIG_FILES="$CONFIG_FILES contrib/chat/Makefile" ;;
|
||||
"conserver/conserver.rc" ) CONFIG_FILES="$CONFIG_FILES conserver/conserver.rc" ;;
|
||||
"config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
|
||||
*) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5
|
||||
|
12
configure.in
12
configure.in
@ -244,7 +244,13 @@ if test "$ac_cv_sys_posix_termios" != "yes"; then
|
||||
AC_MSG_ERROR([POSIX termios interface required])
|
||||
fi
|
||||
|
||||
AC_CHECK_HEADERS(unistd.h getopt.h sys/vlimit.h sys/resource.h ttyent.h sys/ttold.h sys/uio.h sys/proc.h sys/ioctl_compat.h usersec.h sys/select.h stropts.h sys/audit.h shadow.h sys/time.h crypt.h sysexits.h types.h sys/sockio.h)
|
||||
AC_CHECK_HEADERS(unistd.h getopt.h sys/vlimit.h sys/resource.h ttyent.h sys/ttold.h sys/uio.h sys/ioctl_compat.h usersec.h sys/select.h stropts.h sys/audit.h shadow.h sys/time.h crypt.h sysexits.h types.h sys/sockio.h sys/param.h)
|
||||
dnl sys/proc.h needs sys/param.h on openbsd, apparently
|
||||
AC_CHECK_HEADERS(sys/proc.h, [], [],
|
||||
[#if HAVE_SYS_PARAM_H
|
||||
#include <sys/param.h>
|
||||
#endif
|
||||
])
|
||||
AC_HEADER_TIME
|
||||
AC_HEADER_SYS_WAIT
|
||||
AC_TYPE_MODE_T
|
||||
@ -498,7 +504,7 @@ AC_CHECK_HEADERS(pty.h libutil.h util.h)
|
||||
AC_CHECK_LIB(util, openpty)
|
||||
AC_CHECK_FUNCS(openpty)
|
||||
|
||||
AC_CHECK_FUNCS(getopt strerror getrlimit getsid setsid getuserattr setgroups tcgetpgrp tcsetpgrp tcgetattr tcsetattr tcsendbreak setpgrp getutent setttyent getspnam setlinebuf setvbuf ptsname grantpt unlockpt sigaction setsockopt getdtablesize putenv memset memcpy memcmp memmove sysconf getlogin inet_aton)
|
||||
AC_CHECK_FUNCS(getopt strerror getrlimit getsid setsid getuserattr setgroups tcgetpgrp tcsetpgrp tcgetattr tcsetattr tcsendbreak setpgrp getutent setttyent getspnam setlinebuf setvbuf ptsname grantpt unlockpt sigaction setsockopt getdtablesize putenv memset memcpy memcmp memmove sysconf getlogin inet_aton setproctitle)
|
||||
AC_FUNC_SETPGRP
|
||||
AC_CHECK_FUNC(strcasecmp,
|
||||
[AC_DEFINE(HAVE_STRCASECMP, 1, [Define if strcasecmp is available])],
|
||||
@ -513,6 +519,6 @@ AC_CHECK_FUNCS(getaudit getaudit_addr)
|
||||
|
||||
|
||||
dnl ### Create output files. #######################################
|
||||
AC_CONFIG_FILES([Makefile conserver/Makefile conserver.cf/Makefile console/Makefile autologin/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_OUTPUT
|
||||
|
@ -7,5 +7,5 @@ files with enough detail to get you going.
|
||||
That's about it. Good luck.
|
||||
|
||||
#
|
||||
# $Id: INSTALL,v 1.3 2003-07-04 11:21:21-07 bryan Exp $
|
||||
# $Id: INSTALL,v 1.3 2003/07/04 18:21:21 bryan Exp $
|
||||
#
|
||||
|
@ -1,54 +1,113 @@
|
||||
#
|
||||
# $Id: conserver.cf,v 1.5 2003-07-04 11:05:04-07 bryan Exp $
|
||||
# Sample conserver.cf file, to give you ideas of what you can do with
|
||||
# the various configuration items.
|
||||
#
|
||||
# The character '&' in logfile names are substituted with the console
|
||||
# name.
|
||||
#
|
||||
default full {
|
||||
rw *;
|
||||
}
|
||||
|
||||
### set up global access
|
||||
default full { rw *; }
|
||||
|
||||
### define some terminal server specifics
|
||||
# we set portbase and portinc so we can reference the ports in a
|
||||
# physical representation and let conserver do the math to figure
|
||||
# out the actual socket address
|
||||
default cisco { type host; portbase 2000; portinc 1; }
|
||||
default xyplex { type host; portbase 2000; portinc 100; }
|
||||
default iolan { type host; portbase 10000; portinc 1; }
|
||||
|
||||
### set up some custom break sequences
|
||||
break 4 { string "+\d+\d+"; delay 300; }
|
||||
break 5 { string "\033c"; }
|
||||
|
||||
### set the defaults for all the consoles
|
||||
# these get applied before anything else
|
||||
default * {
|
||||
# The '&' character is substituted with the console name
|
||||
logfile /var/consoles/&;
|
||||
timestamp "";
|
||||
# timestamps every hour with activity and break logging
|
||||
timestamp 1hab;
|
||||
# include the 'full' default
|
||||
include full;
|
||||
}
|
||||
#
|
||||
# list of consoles we serve
|
||||
#
|
||||
console tweety {
|
||||
# master server is localhost
|
||||
master localhost;
|
||||
type host;
|
||||
host ts1;
|
||||
port 2002;
|
||||
}
|
||||
console bambam {
|
||||
master localhost;
|
||||
type host;
|
||||
host ts1;
|
||||
port 2003;
|
||||
|
||||
### define the first terminal server
|
||||
default ts1.conserver.com {
|
||||
# use the xyplex defaults
|
||||
include xyplex;
|
||||
# host to connect to is ts1.conserver.com
|
||||
host ts1.conserver.com;
|
||||
# run login-xyplex when connecting to the term server
|
||||
initcmd /usr/local/sbin/login-xyplex;
|
||||
}
|
||||
console shell {
|
||||
master localhost;
|
||||
logfile /dev/null;
|
||||
|
||||
# now define the consoles on ts1.conserver.com
|
||||
# bryan isn't allowed on web1.conserver.com
|
||||
console web1.conserver.com { include ts1.conserver.com; port 2; rw !bryan; }
|
||||
console ns1.conserver.com { include ts1.conserver.com; port 10; }
|
||||
console ns2.conserver.com { include ts1.conserver.com; port 8; }
|
||||
|
||||
### define the second terminal server
|
||||
# this one is a cisco, with simple socket connections
|
||||
default ts2.conserver.com { include cisco; host ts2.conserver.com; }
|
||||
|
||||
# and the consoles on ts2.conserver.com
|
||||
console ldap1.conserver.com { include ts2.conserver.com; port 7; }
|
||||
|
||||
### and now some one-off consoles
|
||||
# we still inherit the '*' default set
|
||||
# a simple ssh invocation
|
||||
console ssh {
|
||||
type exec;
|
||||
exec "";
|
||||
}
|
||||
console telnet {
|
||||
master localhost;
|
||||
logfile /dev/null;
|
||||
type exec;
|
||||
exec telnet host;
|
||||
exec ssh localhost;
|
||||
# provide a 'message-of-the-day'
|
||||
motd "just a simple ssh to localhost";
|
||||
}
|
||||
|
||||
# connect to /dev/ttya
|
||||
console ttya {
|
||||
master localhost;
|
||||
type device;
|
||||
device /dev/ttya;
|
||||
device /dev/ttya; parity none; baud 9600;
|
||||
idlestring "#";
|
||||
idletimeout 5m; # send a '#' every 5 minutes of idle
|
||||
timestamp ""; # no timestamps on this console
|
||||
}
|
||||
|
||||
### define a group of users
|
||||
group sysadmin {
|
||||
users bryan, todd;
|
||||
users dave;
|
||||
}
|
||||
|
||||
### reset the defaults for the next set of consoles
|
||||
# again, these get applied before anything else
|
||||
default * {
|
||||
# The '&' character is substituted with the console name
|
||||
logfile /var/consoles/&;
|
||||
timestamp 5m;
|
||||
rw sysadmin; # use the group defined above
|
||||
master localhost;
|
||||
}
|
||||
|
||||
default cyclades {
|
||||
# sets up /dev/ttyC0 through /dev/ttyC31, for a 32 port card
|
||||
type device;
|
||||
device /dev/ttyC.;
|
||||
devicesubst ,.d;
|
||||
portbase -1;
|
||||
portinc 1;
|
||||
host none; # not really used, since devicesubst doesn't use it
|
||||
baud 9600;
|
||||
parity none;
|
||||
}
|
||||
#
|
||||
# list of clients we allow
|
||||
#
|
||||
|
||||
console modem1.conserver.com { include cyclades; port 2; break 4; }
|
||||
# todd isn't allowed on modem2.conserver.com
|
||||
console modem2.conserver.com { include cyclades; port 6; rw !todd; }
|
||||
|
||||
### list of clients we allow
|
||||
access * {
|
||||
allowed 127.0.0.1 gnac.com;
|
||||
allowed 10.0.0.0/8 192.168.0.0/16;
|
||||
allowed cs1.conserver.com cs2.conserver.com cs3.conserver.com;
|
||||
trusted 127.0.0.1;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" $Id: conserver.cf.man,v 1.41 2003-09-21 15:05:48-07 bryan Exp $
|
||||
.TH CONSERVER.CF 5 "2003-09-21" "conserver-8.0.0" "conserver"
|
||||
.\" $Id: conserver.cf.man,v 1.54 2003/12/10 18:33:56 bryan Exp $
|
||||
.TH CONSERVER.CF 5 "2003/12/10" "conserver-8.0.9" "conserver"
|
||||
.SH NAME
|
||||
conserver.cf \- console configuration file for
|
||||
.BR conserver (8)
|
||||
@ -65,12 +65,12 @@ The parser has six characters that it considers special.
|
||||
These are: ``{'', ``}'', ``;'', ``#'', ``\e'', and ``"''.
|
||||
The first three (hereby called tokens) define the format of the
|
||||
configuration blocks and are used as word
|
||||
seperators, the next is the comment character, and the last two are
|
||||
separators, the next is the comment character, and the last two are
|
||||
quoting characters.
|
||||
.PP
|
||||
Word seperation occurs when the parser encounters an unquoted token
|
||||
Word separation occurs when the parser encounters an unquoted token
|
||||
and, in certain cases, whitespace.
|
||||
Whitespace is only used as a word seperator when the parser is
|
||||
Whitespace is only used as a word separator when the parser is
|
||||
looking for a block-type or keyword.
|
||||
When it's looking for a block-name or value, whitespace is like any
|
||||
other character, which allows you to embed whitespace in a block-name
|
||||
@ -123,14 +123,16 @@ fashion (top down), so order is important.
|
||||
.RS
|
||||
.TP 15
|
||||
.B admin
|
||||
.RI [ " username" ,...
|
||||
.RI "[ [\fB!\fP]" username ,...
|
||||
| "" ]
|
||||
.br
|
||||
Define a list of users making up the admin list for the console server.
|
||||
If
|
||||
.I username
|
||||
matches a previously defined group name, all members of the previous
|
||||
group are added to the admin list.
|
||||
group are applied to the admin list (with access reversed if prefixed
|
||||
with a `!').
|
||||
Otherwise, users will be granted (or denied if prefixed with `!') access.
|
||||
If the null string (``""'') is used, any
|
||||
users previously defined for the console servers's admin list are removed.
|
||||
.TP
|
||||
@ -202,7 +204,9 @@ alert
|
||||
backspace
|
||||
.TP
|
||||
.B \ed
|
||||
0.33 second delay
|
||||
delay specified by the
|
||||
.B delay
|
||||
option.
|
||||
.TP
|
||||
.B \ef
|
||||
form-feed
|
||||
@ -316,6 +320,16 @@ Set the base port number used by child processes (see the
|
||||
.B \-b
|
||||
command-line flag).
|
||||
.TP
|
||||
.B setproctitle
|
||||
.RB [ " yes " | " true " | " on " | " no " | " false " | " off " ]
|
||||
.br
|
||||
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
|
||||
consoles it is managing.
|
||||
The operating system must support the
|
||||
.BR setproctitle ()
|
||||
call.
|
||||
.TP
|
||||
.B sslcredentials
|
||||
.I filename
|
||||
.br
|
||||
@ -331,6 +345,15 @@ command-line flag).
|
||||
Set whether or not encryption is required when talking to clients (see the
|
||||
.B \-E
|
||||
command-line flag).
|
||||
.TP
|
||||
.B unifiedlog
|
||||
.I filename
|
||||
.br
|
||||
Set the location of the unified log to
|
||||
.IR filename .
|
||||
See the
|
||||
.B \-U
|
||||
command-line flag for details.
|
||||
.RE
|
||||
.TP 8
|
||||
.B console
|
||||
@ -360,7 +383,7 @@ Define a block of defaults identified as
|
||||
If
|
||||
.I name
|
||||
is ``*'', the automatically applied default block is defined (basically
|
||||
all consoles have an implicit ``include "*";'' at the begining
|
||||
all consoles have an implicit ``include "*";'' at the beginning
|
||||
of their definition).
|
||||
.RS
|
||||
.TP 15
|
||||
@ -387,6 +410,36 @@ Assign the serial device
|
||||
as the access to the console.
|
||||
Only consoles of type ``device'' will use this value.
|
||||
.TP
|
||||
.B devicesubst
|
||||
.RI [ " hp" [ n ] "f "
|
||||
| "" ]
|
||||
.br
|
||||
Perform string substitutions on the
|
||||
.B device
|
||||
value.
|
||||
.I h
|
||||
is the character in
|
||||
.B device
|
||||
to replace with the
|
||||
.B host
|
||||
value and
|
||||
.I p
|
||||
is the character to replace with the
|
||||
.B port
|
||||
value.
|
||||
The
|
||||
.B port
|
||||
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' or `x' or `X', specifying a decimal, lower-case
|
||||
hexdecimal, or uppercase hexdecimal representation of
|
||||
.BR port .
|
||||
If the null string (``""'') is used, no replacements will be done.
|
||||
.TP
|
||||
.B exec
|
||||
.RI [ " command "
|
||||
| "" ]
|
||||
@ -399,7 +452,37 @@ invoking ``/bin/sh -ce "\fIcommand\fP"''.
|
||||
If the null string (``""'') is used or no
|
||||
.B exec
|
||||
keyword is specified, conserver will use the command ``/bin/sh -i''.
|
||||
Only consoles of type ``device'' will use this value.
|
||||
Only consoles of type ``exec'' will use this value.
|
||||
.TP
|
||||
.B execsubst
|
||||
.RI [ " hp" [ n ] "f "
|
||||
| "" ]
|
||||
.br
|
||||
Perform string substitutions on the
|
||||
.B exec
|
||||
value.
|
||||
.I h
|
||||
is the character in
|
||||
.B exec
|
||||
to replace with the
|
||||
.B host
|
||||
value and
|
||||
.I p
|
||||
is the character to replace with the
|
||||
.B port
|
||||
value.
|
||||
The
|
||||
.B port
|
||||
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' or `x' or `X', specifying a decimal, lower-case
|
||||
hexdecimal, or uppercase hexdecimal representation of
|
||||
.BR port .
|
||||
If the null string (``""'') is used, no replacements will be done.
|
||||
.TP
|
||||
.B host
|
||||
.I hostname
|
||||
@ -410,7 +493,41 @@ as the host to connect to for accessing the console.
|
||||
You must also set the
|
||||
.B port
|
||||
option as well.
|
||||
Only consoles of type ``host'' will use this value.
|
||||
Normally, only consoles of type ``host'' will use this value.
|
||||
If the
|
||||
.B devicesubst
|
||||
or
|
||||
.B execsubst
|
||||
keywords are used in ``device'' and ``exec'' types, this value is used.
|
||||
.TP
|
||||
.B idlestring
|
||||
.RI [ " string "
|
||||
| "" ]
|
||||
.br
|
||||
Assign the
|
||||
.I string
|
||||
that is sent to the console once the console is idle for an
|
||||
.I idletimeout
|
||||
amount of time.
|
||||
If the null string (``""'') is used, the string is unset and
|
||||
the default is used.
|
||||
The string is interpreted just as a
|
||||
.B break
|
||||
string is interpreted (see the
|
||||
.B break
|
||||
configuration items for details) where all delays specified (via ``\ed'')
|
||||
use the default delay time.
|
||||
The default string is ``\en''.
|
||||
.TP
|
||||
.B idletimeout
|
||||
.BR \fInumber\fP [ s | m | h ]
|
||||
.br
|
||||
Set the idle timeout of the console to
|
||||
.I number
|
||||
seconds. If an `s', `m', or `h' is used after
|
||||
.IR number ,
|
||||
the specified time is interpreted as seconds, minutes, or hours.
|
||||
Set the timeout to zero to disable the idle timeout (the default).
|
||||
.TP
|
||||
.B include
|
||||
.I default
|
||||
@ -420,18 +537,67 @@ The default block defined using the name
|
||||
is applied to the current console or default block.
|
||||
The included default block must be previously defined.
|
||||
.TP
|
||||
.B initcmd
|
||||
.RI [ " command "
|
||||
| "" ]
|
||||
.br
|
||||
Invoke
|
||||
.I command
|
||||
as soon as the console is brought up, redirecting the console
|
||||
to stdin, stdout, and stderr of
|
||||
.IR command .
|
||||
The
|
||||
.I command
|
||||
is passed as an argument to ``/bin/sh -ce''.
|
||||
If the null string (``""'') is used, the command is unset and
|
||||
nothing is invoked.
|
||||
.TP
|
||||
.B logfile
|
||||
.RI [ " filename "
|
||||
| "" ]
|
||||
.br
|
||||
Assign the logfile specified by
|
||||
.I filename
|
||||
to the console. Any occurance of ``&'' in
|
||||
to the console. Any occurrence of ``&'' in
|
||||
.I filename
|
||||
will be replaced with the name of the console.
|
||||
If the null string (``""'') is used, the logfile name is unset and
|
||||
no logging will occur.
|
||||
.TP
|
||||
.B logfilemax
|
||||
.BR \fInumber\fP [ k | m ]
|
||||
.br
|
||||
Enable automatic rotation of
|
||||
.B logfile
|
||||
once it's size exceeds
|
||||
.I number
|
||||
bytes.
|
||||
Specifying
|
||||
.B k
|
||||
or
|
||||
.B m
|
||||
interpret
|
||||
.I number
|
||||
as kilobytes and megabytes.
|
||||
.I number
|
||||
must be at least 2048 bytes.
|
||||
A value of zero will turn off automatic rotation of
|
||||
.BR logfile .
|
||||
The
|
||||
.B logfile
|
||||
.I filename
|
||||
will be renamed
|
||||
.IR filename -\s-1YYYYMMDD\s0-\s-1HHMMSS\s0,
|
||||
where the extension is the current GMT year, month, day, hour,
|
||||
minute, and second (to prevent issues with clock rollbacks).
|
||||
File sizes are checked every 5 minutes with an additional initial
|
||||
pseudo-random delay of up to one minute (to help prevent all processes
|
||||
checking all consoles simultaneously).
|
||||
2.5% (minimum 100 bytes, maximum 4000 bytes) of the old
|
||||
logfile is read from the end of the file.
|
||||
All data past the first newline is moved (not copied) to the new logfile
|
||||
so that a replay of the console works and starts on a line boundary.
|
||||
.TP
|
||||
.B master
|
||||
.RI [ " hostname " | " ipaddr " ]
|
||||
.br
|
||||
@ -441,6 +607,16 @@ The host may be specified by
|
||||
or using the address
|
||||
.IR ipaddr .
|
||||
.TP
|
||||
.B motd
|
||||
.RI [ " message "
|
||||
| "" ]
|
||||
.br
|
||||
Set the "message of the day" for the console to
|
||||
.IR message ,
|
||||
which gets displayed when a client attaches to the console.
|
||||
If the null string (``""'') is used, the MOTD is unset and
|
||||
no message will occur.
|
||||
.TP
|
||||
.B options
|
||||
.RI [ " option" ,...
|
||||
| "" ]
|
||||
@ -571,17 +747,59 @@ Set the port used to access the console.
|
||||
The port may be specified as a
|
||||
.I number
|
||||
or a
|
||||
.IR name ,
|
||||
in which case it will use
|
||||
.IR name .
|
||||
A
|
||||
.I name
|
||||
will cause a
|
||||
.BR getservbyname (3)
|
||||
to look up a port number.
|
||||
call to look up the port number.
|
||||
The
|
||||
.BR port ,
|
||||
.BR portbase ,
|
||||
and
|
||||
.B portinc
|
||||
values are all used to calculate the final port number to connect to.
|
||||
The formula used is
|
||||
.IR finalport " = "
|
||||
.BR portbase " + "
|
||||
.BR portinc " * " port .
|
||||
By using proper values in the formula, you can reference ports on a
|
||||
terminal server by their physical numbering of 1 through
|
||||
.IR n .
|
||||
You must also set the
|
||||
.B host
|
||||
option as well.
|
||||
Only consoles of type ``host'' will use this value.
|
||||
Normally, only consoles of type ``host'' will use this value.
|
||||
If the
|
||||
.B devicesubst
|
||||
or
|
||||
.B execsubst
|
||||
keywords are used in ``device'' and ``exec'' types, this value is used.
|
||||
.TP
|
||||
.B portbase
|
||||
.I number
|
||||
.br
|
||||
Set the base value for the port calculation formula.
|
||||
.I number
|
||||
must be -1 or greater.
|
||||
The default is zero.
|
||||
See
|
||||
.B port
|
||||
for the details of the formula.
|
||||
.TP
|
||||
.B portinc
|
||||
.I number
|
||||
.br
|
||||
Set the increment value for the port calculation formula.
|
||||
.I number
|
||||
must be 1 or greater.
|
||||
The default is one.
|
||||
See
|
||||
.B port
|
||||
for the details of the formula.
|
||||
.TP
|
||||
.B ro
|
||||
.RI [ " username" ,...
|
||||
.RI "[ [\fB!\fP]" username ,...
|
||||
| "" ]
|
||||
.br
|
||||
Define a list of users making up the read-only access list
|
||||
@ -589,12 +807,15 @@ for the console.
|
||||
If
|
||||
.I username
|
||||
matches a previously defined group name, all members of the previous
|
||||
group are added to the read-only access list.
|
||||
group are applied to the read-only access list (with access reversed
|
||||
if prefixed with a `!').
|
||||
Otherwise, users will be granted (or denied if prefixed with `!')
|
||||
read-only access.
|
||||
If the null string (``""'') is used, any
|
||||
users previously defined for the console's read-only list are removed.
|
||||
.TP
|
||||
.B rw
|
||||
.RI [ " username" ,...
|
||||
.RI "[ [\fB!\fP]" username ,...
|
||||
| "" ]
|
||||
.br
|
||||
Define a list of users making up the read-write access list
|
||||
@ -602,7 +823,10 @@ for the console.
|
||||
If
|
||||
.I username
|
||||
matches a previously defined group name, all members of the previous
|
||||
group are added to the read-write access list.
|
||||
group are applied to the read-write access list (with access reversed
|
||||
if prefixed with a `!').
|
||||
Otherwise, users will be granted (or denied if prefixed with `!')
|
||||
read-write access.
|
||||
If the null string (``""'') is used, any
|
||||
users previously defined for the console's read-write list are removed.
|
||||
.TP
|
||||
@ -667,7 +891,7 @@ Define a user group identified as
|
||||
.RS
|
||||
.TP 15
|
||||
.B users
|
||||
.RI [ " username" ,...
|
||||
.RI "[ [\fB!\fP]" username ,...
|
||||
| "" ]
|
||||
.br
|
||||
Define a list of users making up the group
|
||||
@ -675,7 +899,10 @@ Define a list of users making up the group
|
||||
If
|
||||
.I username
|
||||
matches a previously defined group name, all members of the previous
|
||||
group are added to the current group.
|
||||
group are applied to the current group (with access reversed
|
||||
if prefixed with a `!').
|
||||
Otherwise, users will be recorded with (or without if prefixed with `!')
|
||||
access.
|
||||
If the null string (``""'') is used, any
|
||||
users previously defined for this group are removed.
|
||||
.RE
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" $Id: conserver.passwd.man,v 1.9 2003-07-04 13:20:52-07 bryan Exp $
|
||||
.TH CONSERVER.PASSWD 5 "2003-07-04" "conserver-8.0.0" "conserver"
|
||||
.\" $Id: conserver.passwd.man,v 1.9 2003/07/04 20:20:52 bryan Exp $
|
||||
.TH CONSERVER.PASSWD 5 "2003/07/04" "conserver-8.0.9" "conserver"
|
||||
.SH NAME
|
||||
conserver.passwd \- user access information for
|
||||
.BR conserver (8)
|
||||
|
@ -1,5 +1,5 @@
|
||||
%!PS-Adobe-2.0 EPSF-1.2
|
||||
%%$Id: label.ps,v 1.8 94/01/21 09:37:42 ksb Exp $
|
||||
%%$Id: label.ps,v 1.1 2003/11/04 02:36:26 bryan Exp $
|
||||
%%Title: RJ-11
|
||||
%%Creator: A Braunsdorf
|
||||
%%CreationDate:
|
||||
|
21
conserver.cf/samples/README
Normal file
21
conserver.cf/samples/README
Normal file
@ -0,0 +1,21 @@
|
||||
I put together the sample configuration files in this directory in hopes
|
||||
that it would help folks see some of the possibilities of the
|
||||
configuration file format. Each of the files are syntatically correct,
|
||||
but have never actually been used.
|
||||
|
||||
Each file is basically built upon the previous...theoretically, if not
|
||||
actually. Hopefully they'll help show some of the cool things you can
|
||||
do with the configuration file and help those trying to figure out how
|
||||
they should even start.
|
||||
|
||||
simple.cf - A very simple, one console config file
|
||||
|
||||
basic.cf - A config with a couple consoles, mostly using defaults
|
||||
|
||||
average.cf - A config for many consoles, using breaks, user lists,
|
||||
etc...bascially customizing each area
|
||||
|
||||
average-distributed.cf - Taking average.cf to multiple conserver
|
||||
hosts with overrides on those hosts
|
||||
|
||||
Bryan Stansell
|
108
conserver.cf/samples/average-distributed.cf
Normal file
108
conserver.cf/samples/average-distributed.cf
Normal file
@ -0,0 +1,108 @@
|
||||
#
|
||||
# I took the average.cf file and expanded it to use a distributed
|
||||
# conserver setup...two conserver hosts (conserver1 and conserver2), but
|
||||
# the basic philosophy would hold for many more console and/or conserver
|
||||
# hosts.
|
||||
#
|
||||
|
||||
# ------ define a user group ------
|
||||
group sysadmin {
|
||||
users bryan, todd, dave;
|
||||
}
|
||||
# helpers is everyone but the sysadmin group
|
||||
group helpers {
|
||||
users *, !sysadmin;
|
||||
}
|
||||
|
||||
|
||||
# ------ make sure breaks are the way we want --------
|
||||
break 1 { string "\z"; }
|
||||
break 2 { string "\r\d~\d^b"; delay 600; }
|
||||
break 3 { string "#."; }
|
||||
|
||||
|
||||
# ----- define some console types ------
|
||||
# yeah, just setting a break doesn't quite seem worth it, but perhaps,
|
||||
# some day, there will be more host-specific stuff.
|
||||
default sun-std { break 1; }
|
||||
default sun-alt { break 2; }
|
||||
default sun-lom { break 3; }
|
||||
|
||||
|
||||
# ------ defaults ------
|
||||
# we set a 'global' default so we can reuse the bits below. we're going
|
||||
# to set the '*' default, then define consoles, reset the '*' default,
|
||||
# define more consoles, etc.
|
||||
default global {
|
||||
logfile /var/consoles/&; # '&' is replaced with console name
|
||||
timestamp 1hab; # write timestamps
|
||||
rw sysadmin; # allow sysadmins full access
|
||||
ro helpers; # allow helpers to watch
|
||||
include sun-std;
|
||||
}
|
||||
|
||||
|
||||
# --------- define our terminal attributes ----------
|
||||
# simple tcp connections are "easy"
|
||||
default cisco { type host; portbase 2000; portinc 1; }
|
||||
default xyplex { type host; portbase 2000; portinc 100; }
|
||||
|
||||
# this is a cyclades card referenced with /dev/ttyC0 through /dev/ttyC31
|
||||
# we set the various port calculation bits and pattern substitution to
|
||||
# come up with a generic definition
|
||||
default cyclades { type device; device /dev/ttyC&; baud 9600; parity none;
|
||||
devicesubst .&d; portbase -1; portinc 1; host unused; }
|
||||
|
||||
## this is a term server accessed with an ssh command
|
||||
# it too uses pattern substitution and such to get the job done
|
||||
default ciscossh { type exec; portbase 2000; portinc 1;
|
||||
exec /usr/local/bin/ssh -p P -l tsuser H;
|
||||
execsubst HPd; }
|
||||
|
||||
|
||||
# ------- set the global default for the first conserver host -------
|
||||
# the consoles below (until the default is reset) are managed
|
||||
# by conserver1.conserver.com
|
||||
default * { include global; master conserver1.conserver.com; }
|
||||
|
||||
# ------- define the consoles on ts1.conserver.com --------
|
||||
default ts1.conserver.com { include cisco; host ts1.conserver.com; }
|
||||
console web1.conserver.com { include ts1.conserver.com; port 2; }
|
||||
console ns1.conserver.com { include ts1.conserver.com; port 10; }
|
||||
|
||||
# ------- define the consoles on ts2.conserver.com --------
|
||||
default ts2.conserver.com { include xyplex; host ts2.conserver.com; }
|
||||
console web2.conserver.com { include ts2.conserver.com; port 4; }
|
||||
console ns2.conserver.com { include ts2.conserver.com; port 22; }
|
||||
|
||||
# ------- set the global default for the second conserver host -------
|
||||
# the following consoles are managed by conserver2.conserver.com
|
||||
default * { include global; master conserver2.conserver.com; }
|
||||
|
||||
# ------- define the consoles on ts3.conserver.com --------
|
||||
default ts3.conserver.com { include ciscossh; host ts3.conserver.com; }
|
||||
console ftp1.conserver.com { include ts3.conserver.com; include sun-lom;
|
||||
port 7; }
|
||||
|
||||
# ------- set up the an access list to avoid the default -------
|
||||
# anything *not* matched here will fallback to the default access mode
|
||||
access * {
|
||||
trusted 127.0.0.1;
|
||||
allowed 10.0.0.0/8;
|
||||
}
|
||||
|
||||
# conserver2 has an extra leg that is trusted
|
||||
access conserver2.conserver.com { trusted 192.168.0.0/16; }
|
||||
|
||||
# ------- do some server configuration ---------
|
||||
# both conserver1.conserver.com and conserver2.conserver.com use the same
|
||||
# set of defaults
|
||||
config * {
|
||||
defaultaccess rejected;
|
||||
daemonmode on;
|
||||
logfile /var/log/conserver;
|
||||
}
|
||||
|
||||
# we're going to set the default access on conserver2 to allowed, because
|
||||
# it's in a higher-trust network
|
||||
config conserver2.conserver.com { defaultaccess allowed; }
|
90
conserver.cf/samples/average.cf
Normal file
90
conserver.cf/samples/average.cf
Normal file
@ -0,0 +1,90 @@
|
||||
#
|
||||
# This would be what i'd expect a more common configuration file would
|
||||
# look like. There are consoles attached to multiple devices, simple
|
||||
# access lists, etc.
|
||||
#
|
||||
|
||||
# ------ define a user group ------
|
||||
group sysadmin {
|
||||
users bryan, todd, dave;
|
||||
}
|
||||
# helpers is everyone but the sysadmin group
|
||||
group helpers {
|
||||
users *, !sysadmin;
|
||||
}
|
||||
|
||||
|
||||
# ------ make sure breaks are the way we want --------
|
||||
break 1 { string "\z"; }
|
||||
break 2 { string "\r\d~\d^b"; delay 600; }
|
||||
break 3 { string "#."; }
|
||||
|
||||
|
||||
# ----- define some console types ------
|
||||
# yeah, just setting a break doesn't quite seem worth it, but perhaps,
|
||||
# some day, there will be more host-specific stuff.
|
||||
default sun-std { break 1; }
|
||||
default sun-alt { break 2; }
|
||||
default sun-lom { break 3; }
|
||||
|
||||
|
||||
# ------ defaults ------
|
||||
# now for some generic console defaults so that we don't have to
|
||||
# duplicate them for each console.
|
||||
default * {
|
||||
logfile /var/consoles/&; # '&' is replaced with console name
|
||||
timestamp 1hab; # write timestamps
|
||||
rw sysadmin; # allow sysadmins full access
|
||||
ro helpers; # allow helpers to watch
|
||||
master localhost;
|
||||
include sun-std;
|
||||
}
|
||||
|
||||
|
||||
# --------- define our terminal attributes ----------
|
||||
# simple tcp connections are "easy"
|
||||
default cisco { type host; portbase 2000; portinc 1; }
|
||||
default xyplex { type host; portbase 2000; portinc 100; }
|
||||
|
||||
# this is a cyclades card referenced with /dev/ttyC0 through /dev/ttyC31
|
||||
# we set the various port calculation bits and pattern substitution to
|
||||
# come up with a generic definition
|
||||
default cyclades { type device; device /dev/ttyC&; baud 9600; parity none;
|
||||
devicesubst .&d; portbase -1; portinc 1; host unused; }
|
||||
|
||||
## this is a term server accessed with an ssh command
|
||||
# it too uses pattern substitution and such to get the job done
|
||||
default ciscossh { type exec; portbase 2000; portinc 1;
|
||||
exec /usr/local/bin/ssh -p P -l tsuser H;
|
||||
execsubst HPd; }
|
||||
|
||||
|
||||
# ------- define the consoles on ts1.conserver.com --------
|
||||
default ts1.conserver.com { include cisco; host ts1.conserver.com; }
|
||||
console web1.conserver.com { include ts1.conserver.com; port 2; }
|
||||
console ns1.conserver.com { include ts1.conserver.com; port 10; }
|
||||
|
||||
# ------- define the consoles on ts2.conserver.com --------
|
||||
default ts2.conserver.com { include xyplex; host ts2.conserver.com; }
|
||||
console web2.conserver.com { include ts2.conserver.com; port 4; }
|
||||
console ns2.conserver.com { include ts2.conserver.com; port 22; }
|
||||
|
||||
# ------- define the consoles on ts3.conserver.com --------
|
||||
default ts3.conserver.com { include ciscossh; host ts3.conserver.com; }
|
||||
console ftp1.conserver.com { include ts3.conserver.com; include sun-lom;
|
||||
port 7; }
|
||||
|
||||
|
||||
# ------- set up the an access list to avoid the default -------
|
||||
# anything *not* matched here will fallback to the default access mode
|
||||
access * {
|
||||
trusted 127.0.0.1;
|
||||
allowed 10.0.0.0/8;
|
||||
}
|
||||
|
||||
# ------- do some server configuration ---------
|
||||
config * {
|
||||
defaultaccess rejected;
|
||||
daemonmode on;
|
||||
logfile /var/log/conserver;
|
||||
}
|
28
conserver.cf/samples/basic.cf
Normal file
28
conserver.cf/samples/basic.cf
Normal file
@ -0,0 +1,28 @@
|
||||
#
|
||||
# This is a fairly basic configuration file that interacts with one
|
||||
# terminal server.
|
||||
#
|
||||
|
||||
# first, we're going to set some generic console defaults so that we
|
||||
# don't have to duplicate them for each console.
|
||||
default * {
|
||||
logfile /var/consoles/&; # '&' is replaced with console name
|
||||
timestamp 1hab; # write timestamps
|
||||
rw *; # allow all users
|
||||
master localhost;
|
||||
type host;
|
||||
host ts1.conserver.com; # consoles on ts1.conserver.co
|
||||
portbase 2000; # port numbers start at 2001 and
|
||||
portinc 1; # go up by 1 (port #1 == 2001, etc)
|
||||
}
|
||||
|
||||
# define two consoles on the terminal server
|
||||
console web1.conserver.com { port 2; } # calculates to tcp port 2002
|
||||
console ns1.conserver.com { port 10; } # calculates to tcp port 2010
|
||||
|
||||
# set up the an access list to avoid the default
|
||||
# anything *not* matched here will fallback to the default access (-a)
|
||||
# mode
|
||||
access * {
|
||||
trusted 127.0.0.1;
|
||||
}
|
11
conserver.cf/samples/simple.cf
Normal file
11
conserver.cf/samples/simple.cf
Normal file
@ -0,0 +1,11 @@
|
||||
#
|
||||
# I believe this is the smallest configuration file that is also fully
|
||||
# functional. You have to be happy with the default access type (-a)
|
||||
# as well as the default access list that gets used.
|
||||
#
|
||||
|
||||
console simple {
|
||||
master localhost;
|
||||
type exec;
|
||||
rw *;
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
# dummy conserver config file
|
||||
#
|
||||
# $Id: test.cf,v 1.2 2003-07-04 11:04:05-07 bryan Exp $
|
||||
# $Id: test.cf,v 1.2 2003/07/04 18:04:05 bryan Exp $
|
||||
#
|
||||
default full {
|
||||
rw *;
|
||||
|
@ -183,11 +183,11 @@
|
||||
|
||||
<H3>Downloading</H3>
|
||||
|
||||
<P>The current version, released on Sep 22, 2003, is <A
|
||||
href="8.0.0.tar.gz">8.0.0.tar.gz</A>. You can get it via
|
||||
<P>The current version, released on Dec 10, 2003, is <A
|
||||
href="8.0.9.tar.gz">8.0.9.tar.gz</A>. You can get it via
|
||||
<A href=
|
||||
"ftp://ftp.conserver.com/conserver/8.0.0.tar.gz">FTP</A>
|
||||
or <A href="8.0.0.tar.gz">HTTP</A>. See the <A href=
|
||||
"ftp://ftp.conserver.com/conserver/8.0.9.tar.gz">FTP</A>
|
||||
or <A href="8.0.9.tar.gz">HTTP</A>. See the <A href=
|
||||
"CHANGES">CHANGES</A> file for information on the latest
|
||||
updates.</P>
|
||||
|
||||
|
@ -27,21 +27,24 @@ LIBS = @LIBS@ @CONSLIBS@
|
||||
### Makefile rules - no user-servicable parts below
|
||||
|
||||
CONSERVER_OBJS = access.o client.o consent.o group.o main.o master.o \
|
||||
readcfg.o fallback.o util.o
|
||||
readcfg.o fallback.o cutil.o
|
||||
CONSERVER_HDRS = ../config.h $(top_srcdir)/compat.h $(srcdir)/access.h \
|
||||
$(srcdir)/client.h $(srcdir)/consent.h $(srcdir)/group.h \
|
||||
$(srcdir)/main.h $(srcdir)/master.h $(srcdir)/readcfg.h \
|
||||
$(srcdir)/util.h
|
||||
$(srcdir)/client.h $(srcdir)/consent.h $(srcdir)/cutil.h \
|
||||
$(srcdir)/group.h $(srcdir)/main.h $(srcdir)/master.h \
|
||||
$(srcdir)/readcfg.h $(srcdir)/version.h
|
||||
|
||||
ALL = conserver convert
|
||||
|
||||
|
||||
all: $(ALL)
|
||||
|
||||
$(CONSERVER_OBJS): $(CONSERVER_HDRS)
|
||||
|
||||
conserver: $(CONSERVER_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o conserver $(CONSERVER_OBJS) $(LIBS)
|
||||
|
||||
convert: convert.o util.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o convert convert.o util.o $(LIBS)
|
||||
convert: convert.o cutil.o
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o convert convert.o cutil.o $(LIBS)
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
||||
|
@ -1,4 +1,4 @@
|
||||
# $Id: Sun-serial,v 2.1 93/02/09 11:45:12 ldv Exp $
|
||||
# $Id: Sun-serial,v 1.1 2003/11/04 02:36:25 bryan Exp $
|
||||
|
||||
If you are going to be hooking Sun consoles to your console server, you
|
||||
will run into a problem: The sun will halt whenever the cable is unplugged.
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: access.c,v 5.66 2003-08-15 14:24:39-07 bryan Exp $
|
||||
* $Id: access.c,v 5.71 2003/11/20 13:56:38 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
#include <compat.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <cutil.h>
|
||||
#include <access.h>
|
||||
#include <consent.h>
|
||||
#include <client.h>
|
||||
@ -137,91 +137,138 @@ AccType(addr, peername)
|
||||
socklen_t so;
|
||||
struct hostent *he = (struct hostent *)0;
|
||||
int a;
|
||||
char ret;
|
||||
#if TRUST_REVERSE_DNS
|
||||
char *pcName;
|
||||
int wlen;
|
||||
char *hname;
|
||||
int len;
|
||||
char **revNames = (char **)0;
|
||||
#endif
|
||||
|
||||
CONDDEBUG((1, "AccType(): ip=%s", inet_ntoa(*addr)));
|
||||
|
||||
ret = config->defaultaccess;
|
||||
so = sizeof(*addr);
|
||||
for (pACtmp = pACList; pACtmp != (ACCESS *)0; pACtmp = pACtmp->pACnext) {
|
||||
CONDDEBUG((1, "AccType(): who=%s, trust=%c", pACtmp->pcwho,
|
||||
pACtmp->ctrust));
|
||||
if (pACtmp->isCIDR != 0) {
|
||||
if (AddrCmp(addr, pACtmp->pcwho) == 0)
|
||||
return pACtmp->ctrust;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((he = gethostbyname(pACtmp->pcwho)) == (struct hostent *)0) {
|
||||
Error("AccType(): gethostbyname(%s): %s", pACtmp->pcwho,
|
||||
hstrerror(h_errno));
|
||||
continue;
|
||||
}
|
||||
if (4 != he->h_length || AF_INET != he->h_addrtype) {
|
||||
Error
|
||||
("AccType(): gethostbyname(%s): wrong address size (4 != %d) or address family (%d != %d)",
|
||||
pACtmp->pcwho, he->h_length, AF_INET, he->h_addrtype);
|
||||
continue;
|
||||
}
|
||||
for (a = 0; he->h_addr_list[a] != (char *)0; a++) {
|
||||
CONDDEBUG((1, "AccType(): addr=%s",
|
||||
inet_ntoa(*(struct in_addr *)
|
||||
(he->h_addr_list[a]))));
|
||||
if (
|
||||
#if HAVE_MEMCMP
|
||||
memcmp(&(addr->s_addr), he->h_addr_list[a],
|
||||
he->h_length)
|
||||
#else
|
||||
bcmp(&(addr->s_addr), he->h_addr_list[a], he->h_length)
|
||||
#endif
|
||||
== 0)
|
||||
return pACtmp->ctrust;
|
||||
}
|
||||
}
|
||||
|
||||
#if TRUST_REVERSE_DNS
|
||||
/* if we trust reverse dns, we get the names associated with
|
||||
* the address we're checking and then check each of those
|
||||
* against the access list entries.
|
||||
* we chop bits off client names so that we can put domain
|
||||
* names in access lists or even top-level domains.
|
||||
* allowed conserver.com, net;
|
||||
* this allows anything from conserver.com and anything in
|
||||
* the .net top-level. without TRUST_REVERSE_DNS, those names
|
||||
* better map to ip addresses for them to take effect.
|
||||
* against the access list entries (below).
|
||||
*/
|
||||
if ((he =
|
||||
gethostbyaddr((char *)addr, so,
|
||||
AF_INET)) == (struct hostent *)0) {
|
||||
Error("AccType(): gethostbyaddr(%s): %s", inet_ntoa(*addr),
|
||||
hstrerror(h_errno));
|
||||
return config->defaultaccess;
|
||||
}
|
||||
for (pACtmp = pACList; pACtmp != (ACCESS *)0; pACtmp = pACtmp->pACnext) {
|
||||
if (pACtmp->isCIDR != 0)
|
||||
continue;
|
||||
wlen = strlen(pACtmp->pcwho);
|
||||
for (hname = he->h_name, a = 0; hname != (char *)0;
|
||||
hname = he->h_aliases[a++]) {
|
||||
for (pcName = hname, len = strlen(pcName); len >= wlen;
|
||||
len = strlen(++pcName)) {
|
||||
CONDDEBUG((1, "AccType(): name=%s", pcName));
|
||||
if (strcasecmp(pcName, pACtmp->pcwho) == 0) {
|
||||
*peername = hname;
|
||||
return pACtmp->ctrust;
|
||||
} else {
|
||||
char *hname;
|
||||
if (he->h_name != (char *)0) {
|
||||
/* count up the number of names */
|
||||
for (a = 0, hname = he->h_aliases[a]; hname != (char *)0;
|
||||
hname = he->h_aliases[++a]);
|
||||
a += 2; /* h_name + (char *)0 */
|
||||
/* now duplicate them */
|
||||
if ((revNames =
|
||||
(char **)calloc(a, sizeof(char *))) != (char **)0) {
|
||||
for (hname = he->h_name, a = 0; hname != (char *)0;
|
||||
hname = he->h_aliases[a++]) {
|
||||
if ((revNames[a] = StrDup(hname)) == (char *)0)
|
||||
break;
|
||||
CONDDEBUG((1,"AccType(): revNames[%d]='%s'", a, hname));
|
||||
}
|
||||
pcName = strchr(pcName, '.');
|
||||
if (pcName == (char *)0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return config->defaultaccess;
|
||||
|
||||
for (pACtmp = pACList; pACtmp != (ACCESS *)0; pACtmp = pACtmp->pACnext) {
|
||||
CONDDEBUG((1, "AccType(): who=%s, trust=%c", pACtmp->pcwho,
|
||||
pACtmp->ctrust));
|
||||
if (pACtmp->isCIDR != 0) {
|
||||
if (AddrCmp(addr, pACtmp->pcwho) == 0) {
|
||||
ret = pACtmp->ctrust;
|
||||
goto common_ret;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((he = gethostbyname(pACtmp->pcwho)) == (struct hostent *)0) {
|
||||
Error("AccType(): gethostbyname(%s): %s", pACtmp->pcwho,
|
||||
hstrerror(h_errno));
|
||||
} else if (4 != he->h_length || AF_INET != he->h_addrtype) {
|
||||
Error
|
||||
("AccType(): gethostbyname(%s): wrong address size (4 != %d) or address family (%d != %d)",
|
||||
pACtmp->pcwho, he->h_length, AF_INET, he->h_addrtype);
|
||||
} else {
|
||||
for (a = 0; he->h_addr_list[a] != (char *)0; a++) {
|
||||
CONDDEBUG((1, "AccType(): addr=%s",
|
||||
inet_ntoa(*(struct in_addr *)
|
||||
(he->h_addr_list[a]))));
|
||||
if (
|
||||
#if HAVE_MEMCMP
|
||||
memcmp(&(addr->s_addr), he->h_addr_list[a],
|
||||
he->h_length)
|
||||
#else
|
||||
bcmp(&(addr->s_addr), he->h_addr_list[a],
|
||||
he->h_length)
|
||||
#endif
|
||||
== 0) {
|
||||
ret = pACtmp->ctrust;
|
||||
goto common_ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if TRUST_REVERSE_DNS
|
||||
/* we chop bits off client names so that we can put domain
|
||||
* names in access lists or even top-level domains.
|
||||
* allowed conserver.com, net;
|
||||
* this allows anything from conserver.com and anything in
|
||||
* the .net top-level. without TRUST_REVERSE_DNS, those names
|
||||
* better map to ip addresses for them to take effect.
|
||||
*/
|
||||
if (revNames != (char **)0) {
|
||||
char *pcName;
|
||||
int wlen;
|
||||
int len;
|
||||
wlen = strlen(pACtmp->pcwho);
|
||||
for (a = 0; revNames[a] != (char *)0; a++) {
|
||||
for (pcName = revNames[a], len = strlen(pcName);
|
||||
len >= wlen; len = strlen(++pcName)) {
|
||||
CONDDEBUG((1, "AccType(): name=%s", pcName));
|
||||
if (strcasecmp(pcName, pACtmp->pcwho) == 0) {
|
||||
if (peername != (char **)0)
|
||||
*peername = StrDup(revNames[a]);
|
||||
ret = pACtmp->ctrust;
|
||||
goto common_ret2;
|
||||
}
|
||||
pcName = strchr(pcName, '.');
|
||||
if (pcName == (char *)0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
common_ret:
|
||||
if (config->loghostnames == FLAGTRUE && peername != (char **)0) {
|
||||
#if TRUST_REVERSE_DNS
|
||||
if (revNames != (char **)0 && revNames[0] != (char *)0)
|
||||
*peername = StrDup(revNames[0]);
|
||||
#else
|
||||
if ((he =
|
||||
gethostbyaddr((char *)addr, so,
|
||||
AF_INET)) != (struct hostent *)0) {
|
||||
*peername = StrDup(he->h_name);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#if TRUST_REVERSE_DNS
|
||||
common_ret2:
|
||||
if (revNames != (char **)0) {
|
||||
for (a = 0; revNames[a] != (char *)0; a++)
|
||||
free(revNames[a]);
|
||||
free(revNames);
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
@ -241,7 +288,7 @@ SetDefAccess(pAddr, pHost)
|
||||
addr = inet_ntoa(*pAddr);
|
||||
if ((a = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0)
|
||||
OutOfMem();
|
||||
if ((a->pcwho = strdup(addr)) == (char *)0)
|
||||
if ((a->pcwho = StrDup(addr)) == (char *)0)
|
||||
OutOfMem();
|
||||
a->ctrust = 'a';
|
||||
a->pACnext = pACList;
|
||||
@ -258,7 +305,7 @@ SetDefAccess(pAddr, pHost)
|
||||
|
||||
if ((a = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0)
|
||||
OutOfMem();
|
||||
if ((a->pcwho = strdup(pcDomain)) == (char *)0)
|
||||
if ((a->pcwho = StrDup(pcDomain)) == (char *)0)
|
||||
OutOfMem();
|
||||
a->ctrust = 'a';
|
||||
a->pACnext = pACList;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: access.h,v 5.26 2003-08-10 11:11:20-07 bryan Exp $
|
||||
* $Id: access.h,v 5.26 2003/08/10 18:11:20 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: client.c,v 5.69 2003-08-15 14:24:39-07 bryan Exp $
|
||||
* $Id: client.c,v 5.79 2003/11/28 23:36:02 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -36,7 +36,7 @@
|
||||
|
||||
#include <compat.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <cutil.h>
|
||||
#include <consent.h>
|
||||
#include <access.h>
|
||||
#include <client.h>
|
||||
@ -52,36 +52,41 @@ int deny_severity = LOG_WARNING;
|
||||
|
||||
/* find the next guy who wants to write on the console (ksb)
|
||||
*/
|
||||
CONSCLIENT *
|
||||
void
|
||||
#if PROTOTYPES
|
||||
FindWrite(CONSCLIENT *pCL)
|
||||
FindWrite(CONSENT *pCE)
|
||||
#else
|
||||
FindWrite(pCL)
|
||||
CONSCLIENT *pCL;
|
||||
FindWrite(pCE)
|
||||
CONSENT *pCE;
|
||||
#endif
|
||||
{
|
||||
/* return the first guy to have the `want write' bit set
|
||||
CONSCLIENT *pCL;
|
||||
|
||||
/* make the first guy to have the `want write' bit set the writer
|
||||
* (tell him of the promotion, too) we could look for the
|
||||
* most recent or some such... I guess it doesn't matter that
|
||||
* much.
|
||||
*/
|
||||
for ( /*passed in */ ; (CONSCLIENT *)0 != pCL; pCL = pCL->pCLnext) {
|
||||
if (pCE->pCLwr != (CONSCLIENT *)0 || pCE->fronly ||
|
||||
!(pCE->fup && pCE->ioState == ISNORMAL &&
|
||||
pCE->initfile == (CONSFILE *)0))
|
||||
return;
|
||||
|
||||
for (pCL = pCE->pCLon; (CONSCLIENT *)0 != pCL; pCL = pCL->pCLnext) {
|
||||
if (!pCL->fwantwr || pCL->fro)
|
||||
continue;
|
||||
if (!(pCL->pCEto->fup && pCL->pCEto->ioState == ISNORMAL) ||
|
||||
pCL->pCEto->fronly)
|
||||
break;
|
||||
pCL->fwantwr = 0;
|
||||
pCL->fwr = 1;
|
||||
if (pCL->pCEto->nolog) {
|
||||
FileWrite(pCL->fd, "\r\n[attached (nologging)]\r\n", -1);
|
||||
if (pCE->nolog) {
|
||||
FileWrite(pCL->fd, FLAGFALSE, "\r\n[attached (nologging)]\r\n",
|
||||
-1);
|
||||
} else {
|
||||
FileWrite(pCL->fd, "\r\n[attached]\r\n", -1);
|
||||
FileWrite(pCL->fd, FLAGFALSE, "\r\n[attached]\r\n", -1);
|
||||
}
|
||||
TagLogfileAct(pCL->pCEto, "%s attached", pCL->acid->string);
|
||||
return pCL;
|
||||
TagLogfileAct(pCE, "%s attached", pCL->acid->string);
|
||||
pCE->pCLwr = pCL;
|
||||
return;
|
||||
}
|
||||
return (CONSCLIENT *)0;
|
||||
}
|
||||
|
||||
/* replay last iBack lines of the log file upon connect to console (ksb)
|
||||
@ -92,15 +97,15 @@ FindWrite(pCL)
|
||||
*/
|
||||
void
|
||||
#if PROTOTYPES
|
||||
Replay(CONSFILE *fdLog, CONSFILE *fdOut, int iBack)
|
||||
Replay(CONSENT *pCE, CONSFILE *fdOut, int iBack)
|
||||
#else
|
||||
Replay(fdLog, fdOut, iBack)
|
||||
CONSFILE *fdLog;
|
||||
Replay(pCE, fdOut, iBack)
|
||||
CONSENT *pCE;
|
||||
CONSFILE *fdOut;
|
||||
int iBack;
|
||||
#endif
|
||||
{
|
||||
|
||||
CONSFILE *fdLog = (CONSFILE *)0;
|
||||
off_t file_pos;
|
||||
off_t buf_pos;
|
||||
char *buf;
|
||||
@ -125,8 +130,18 @@ Replay(fdLog, fdOut, iBack)
|
||||
unsigned long dmallocMarkReplay = 0;
|
||||
#endif
|
||||
|
||||
if ((CONSFILE *)0 == fdLog) {
|
||||
FileWrite(fdOut, "[no log file on this console]\r\n", -1);
|
||||
if (pCE != (CONSENT *)0) {
|
||||
fdLog = pCE->fdlog;
|
||||
|
||||
/* no logfile and down and logfile defined? try and open it */
|
||||
if (fdLog == (CONSFILE *)0 && !pCE->fup &&
|
||||
pCE->logfile != (char *)0)
|
||||
fdLog = FileOpen(pCE->logfile, O_RDONLY, 0644);
|
||||
}
|
||||
|
||||
if (fdLog == (CONSFILE *)0) {
|
||||
FileWrite(fdOut, FLAGFALSE, "[no log file on this console]\r\n",
|
||||
-1);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -173,17 +188,9 @@ Replay(fdLog, fdOut, iBack)
|
||||
* the rest (as we work our way back in the file) should be
|
||||
*/
|
||||
buf_pos = (file_pos / BUFSIZ) * BUFSIZ;
|
||||
#if defined(SEEK_SET)
|
||||
/* PTX and maybe other Posix systems
|
||||
*/
|
||||
if (FileSeek(fdLog, buf_pos, SEEK_SET) < 0) {
|
||||
goto common_exit;
|
||||
}
|
||||
#else
|
||||
if (FileSeek(fdLog, buf_pos, L_SET) < 0) {
|
||||
goto common_exit;
|
||||
}
|
||||
#endif
|
||||
if ((r = FileRead(fdLog, buf, BUFSIZ)) < 0) {
|
||||
goto common_exit;
|
||||
}
|
||||
@ -240,8 +247,9 @@ Replay(fdLog, fdOut, iBack)
|
||||
InitString(lines[ln].line);
|
||||
} else {
|
||||
BuildString((char *)0, lines[ln - 1].line);
|
||||
BuildString(lines[ln].line->string,
|
||||
lines[ln - 1].line);
|
||||
BuildStringN(lines[ln].line->string,
|
||||
lines[ln].line->used - 1,
|
||||
lines[ln - 1].line);
|
||||
BuildString((char *)0, lines[ln].line);
|
||||
}
|
||||
ln--;
|
||||
@ -307,8 +315,9 @@ Replay(fdLog, fdOut, iBack)
|
||||
if ((char *)0 != s) {
|
||||
*s = '\000';
|
||||
}
|
||||
FileWrite(fdOut, lines[i].line->string, -1);
|
||||
FileWrite(fdOut, " .. ", -1);
|
||||
FileWrite(fdOut, FLAGTRUE, lines[i].line->string,
|
||||
lines[i].line->used - 1);
|
||||
FileWrite(fdOut, FLAGTRUE, " .. ", 4);
|
||||
|
||||
/* build the end string by removing the leading "[-- MARK -- "
|
||||
* and replacing "]\r\n" on the end with " -- MARK --]\r\n"
|
||||
@ -319,16 +328,22 @@ Replay(fdLog, fdOut, iBack)
|
||||
if ((char *)0 != s) {
|
||||
*s = '\000';
|
||||
}
|
||||
FileWrite(fdOut, lines[i].mark_end->string + mark_len, -1);
|
||||
FileWrite(fdOut, " -- MARK --]\r\n", -1);
|
||||
FileWrite(fdOut, FLAGTRUE,
|
||||
lines[i].mark_end->string + mark_len, -1);
|
||||
FileWrite(fdOut, FLAGFALSE, " -- MARK --]\r\n", -1);
|
||||
u = lines[i].mark_end->used;
|
||||
s = lines[i].mark_end->string;
|
||||
} else
|
||||
FileWrite(fdOut, lines[i].line->string, -1);
|
||||
FileWrite(fdOut, FLAGFALSE, lines[i].line->string,
|
||||
lines[i].line->used - 1);
|
||||
}
|
||||
|
||||
common_exit:
|
||||
|
||||
/* if we opened the logfile, close it */
|
||||
if (fdLog != pCE->fdlog)
|
||||
FileClose(&fdLog);
|
||||
|
||||
if ((struct lines *)0 != lines) {
|
||||
for (i = 0; i < n_lines; i++) {
|
||||
DestroyString(lines[i].mark_end);
|
||||
@ -377,6 +392,7 @@ static HELP aHLTable[] = {
|
||||
{WHEN_ATTACH, "l? break sequence list"},
|
||||
{WHEN_ATTACH, "l0 send break per config file"},
|
||||
{WHEN_ATTACH, "l1-9 send specific break sequence"},
|
||||
{WHEN_ALWAYS, "m display the message of the day"},
|
||||
{WHEN_ALWAYS, "o (re)open the tty and log file"},
|
||||
{WHEN_ALWAYS, "p replay the last 60 lines"},
|
||||
{WHEN_ALWAYS, "r replay the last 20 lines"},
|
||||
@ -386,12 +402,12 @@ static HELP aHLTable[] = {
|
||||
{WHEN_ALWAYS, "w who is on this console"},
|
||||
{WHEN_ALWAYS, "x show console baud info"},
|
||||
{WHEN_ALWAYS, "z suspend the connection"},
|
||||
{WHEN_ATTACH, "| attach local command"},
|
||||
{WHEN_ALWAYS, "<cr> ignore/abort command"},
|
||||
{WHEN_ALWAYS, "? print this message"},
|
||||
{WHEN_ALWAYS, "^R replay the last line"},
|
||||
{WHEN_ATTACH, "\\ooo send character by octal code"},
|
||||
{WHEN_EXPERT, "^I toggle tab expansion"},
|
||||
{WHEN_EXPERT, "; change to another console"},
|
||||
{WHEN_EXPERT, "+(-) do (not) drop line"},
|
||||
{WHEN_VT100, "PF1 print this message"},
|
||||
{WHEN_VT100, "PF2 disconnect"},
|
||||
@ -420,10 +436,10 @@ HelpUser(pCL)
|
||||
|
||||
iCmp = WHEN_ALWAYS | WHEN_SPY;
|
||||
if (pCL->fwr) {
|
||||
FileWrite(pCL->fd, acH1, sizeof(acH1) - 1);
|
||||
FileWrite(pCL->fd, FLAGTRUE, acH1, sizeof(acH1) - 1);
|
||||
iCmp |= WHEN_ATTACH;
|
||||
} else {
|
||||
FileWrite(pCL->fd, acH2, sizeof(acH2) - 1);
|
||||
FileWrite(pCL->fd, FLAGTRUE, acH2, sizeof(acH2) - 1);
|
||||
}
|
||||
if ('\033' == pCL->ic[0] && 'O' == pCL->ic[1]) {
|
||||
iCmp |= WHEN_VT100;
|
||||
@ -441,12 +457,14 @@ HelpUser(pCL)
|
||||
}
|
||||
BuildString(aHLTable[i].actext, acLine);
|
||||
BuildString(acEoln, acLine);
|
||||
FileWrite(pCL->fd, acLine->string, -1);
|
||||
FileWrite(pCL->fd, FLAGTRUE, acLine->string,
|
||||
acLine->used - 1);
|
||||
BuildString((char *)0, acLine);
|
||||
continue;
|
||||
} else {
|
||||
BuildString(acEoln, acLine);
|
||||
FileWrite(pCL->fd, acLine->string, -1);
|
||||
FileWrite(pCL->fd, FLAGTRUE, acLine->string,
|
||||
acLine->used - 1);
|
||||
BuildString((char *)0, acLine);
|
||||
}
|
||||
}
|
||||
@ -455,15 +473,17 @@ HelpUser(pCL)
|
||||
BuildString(aHLTable[i].actext, acLine);
|
||||
if (acLine->used > HALFLINE) {
|
||||
BuildString(acEoln, acLine);
|
||||
FileWrite(pCL->fd, acLine->string, -1);
|
||||
FileWrite(pCL->fd, FLAGTRUE, acLine->string,
|
||||
acLine->used - 1);
|
||||
BuildString((char *)0, acLine);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (acLine->used != 0) {
|
||||
BuildString(acEoln, acLine);
|
||||
FileWrite(pCL->fd, acLine->string, -1);
|
||||
FileWrite(pCL->fd, FLAGTRUE, acLine->string, acLine->used - 1);
|
||||
}
|
||||
FileWrite(pCL->fd, FLAGFALSE, (char *)0, 0);
|
||||
}
|
||||
|
||||
int
|
||||
@ -489,7 +509,8 @@ ClientAccessOk(pCL)
|
||||
request_init(&request, RQ_DAEMON, progname, RQ_FILE, cfd, 0);
|
||||
fromhost(&request);
|
||||
if (!hosts_access(&request)) {
|
||||
FileWrite(pCL->fd, "access from your host refused\r\n", -1);
|
||||
FileWrite(pCL->fd, FLAGFALSE,
|
||||
"access from your host refused\r\n", -1);
|
||||
retval = 0;
|
||||
goto setpeer;
|
||||
}
|
||||
@ -499,13 +520,14 @@ ClientAccessOk(pCL)
|
||||
so = sizeof(in_port);
|
||||
if (-1 ==
|
||||
(getpeer = getpeername(cfd, (struct sockaddr *)&in_port, &so))) {
|
||||
FileWrite(pCL->fd, "getpeername failed\r\n", -1);
|
||||
FileWrite(pCL->fd, FLAGFALSE, "getpeername failed\r\n", -1);
|
||||
retval = 0;
|
||||
goto setpeer;
|
||||
}
|
||||
pCL->caccess = AccType(&in_port.sin_addr, &peername);
|
||||
if (pCL->caccess == 'r') {
|
||||
FileWrite(pCL->fd, "access from your host refused\r\n", -1);
|
||||
FileWrite(pCL->fd, FLAGFALSE, "access from your host refused\r\n",
|
||||
-1);
|
||||
retval = 0;
|
||||
}
|
||||
|
||||
@ -519,5 +541,7 @@ ClientAccessOk(pCL)
|
||||
else
|
||||
BuildString("<unknown>", pCL->peername);
|
||||
}
|
||||
if (peername != (char *)0)
|
||||
free(peername);
|
||||
return retval;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: client.h,v 5.31 2003-08-24 13:00:50-07 bryan Exp $
|
||||
* $Id: client.h,v 5.35 2003/11/28 15:55:34 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -46,7 +46,8 @@ typedef enum clientState {
|
||||
S_IDENT, /* probational connection (who is this) */
|
||||
S_PASSWD, /* still needs a passwd to connect */
|
||||
S_QUOTE, /* send any character we can spell */
|
||||
S_BCAST /* send a broadcast message to all clients */
|
||||
S_BCAST, /* send a broadcast message to all clients */
|
||||
S_CWAIT /* wait for client */
|
||||
} CLIENTSTATE;
|
||||
|
||||
typedef struct client { /* Connection Information: */
|
||||
@ -63,7 +64,6 @@ typedef struct client { /* Connection Information: */
|
||||
time_t typetym; /* time of last keystroke */
|
||||
char actym[32]; /* pre-formatted time */
|
||||
struct consent
|
||||
*pCEwant, /* what machine we would like to be on */
|
||||
*pCEto; /* host a client gets output from */
|
||||
struct client
|
||||
**ppCLbscan, /* back link for scan ptr */
|
||||
@ -83,7 +83,7 @@ typedef struct client { /* Connection Information: */
|
||||
cnct_port; /* where from */
|
||||
} CONSCLIENT;
|
||||
|
||||
extern void Replay PARAMS((CONSFILE *, CONSFILE *, int));
|
||||
extern void Replay PARAMS((CONSENT *, CONSFILE *, int));
|
||||
extern void HelpUser PARAMS((CONSCLIENT *));
|
||||
extern CONSCLIENT *FindWrite PARAMS((CONSCLIENT *));
|
||||
extern void FindWrite PARAMS((CONSENT *));
|
||||
extern int ClientAccessOk PARAMS((CONSCLIENT *));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: consent.c,v 5.125 2003-08-15 14:24:39-07 bryan Exp $
|
||||
* $Id: consent.c,v 5.133 2003/12/10 18:33:47 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -42,7 +42,7 @@
|
||||
|
||||
#include <pwd.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <cutil.h>
|
||||
#include <consent.h>
|
||||
#include <client.h>
|
||||
#include <group.h>
|
||||
@ -248,6 +248,189 @@ TtyDev(pCE)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
#if PROTOTYPES
|
||||
StopInit(CONSENT *pCE)
|
||||
#else
|
||||
StopInit(pCE)
|
||||
CONSENT *pCE;
|
||||
#endif
|
||||
{
|
||||
if (pCE->initcmd == (char *)0)
|
||||
return;
|
||||
|
||||
if (pCE->initpid != 0) {
|
||||
kill(pCE->initpid, SIGHUP);
|
||||
CONDDEBUG((1, "StopInit(): sending initcmd pid %lu signal %d",
|
||||
(unsigned long)pCE->initpid, SIGHUP));
|
||||
Msg("[%s] initcmd terminated: pid %lu", pCE->server,
|
||||
(unsigned long)pCE->initpid);
|
||||
TagLogfileAct(pCE, "initcmd terminated");
|
||||
pCE->initpid = 0;
|
||||
}
|
||||
|
||||
if (pCE->initfile != (CONSFILE *)0) {
|
||||
int initfile = FileFDNum(pCE->initfile);
|
||||
FD_CLR(initfile, &rinit);
|
||||
initfile = FileFDOutNum(pCE->initfile);
|
||||
FD_CLR(initfile, &winit);
|
||||
FileClose(&pCE->initfile);
|
||||
pCE->initfile = (CONSFILE *)0;
|
||||
}
|
||||
}
|
||||
|
||||
/* invoke the initcmd command */
|
||||
void
|
||||
#if PROTOTYPES
|
||||
StartInit(CONSENT *pCE)
|
||||
#else
|
||||
StartInit(pCE)
|
||||
CONSENT *pCE;
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
pid_t iNewGrp;
|
||||
extern char **environ;
|
||||
int pin[2];
|
||||
int pout[2];
|
||||
static char *apcArgv[] = {
|
||||
"/bin/sh", "-ce", (char *)0, (char *)0
|
||||
};
|
||||
|
||||
if (pCE->initcmd == (char *)0)
|
||||
return;
|
||||
|
||||
/* this should never happen, but hey, just in case */
|
||||
if (pCE->initfile != (CONSFILE *)0 || pCE->initpid != 0) {
|
||||
Error("[%s] StartInit(): initpid/initfile sync error",
|
||||
pCE->server);
|
||||
StopInit(pCE);
|
||||
}
|
||||
|
||||
if (pCE->pCLwr != (CONSCLIENT *)0) {
|
||||
CONSCLIENT *pCL = pCE->pCLwr;
|
||||
pCL->fwr = 0;
|
||||
pCL->fwantwr = 1;
|
||||
/*
|
||||
FileWrite(pCL->fd,
|
||||
"[forced to `spy' mode by initialization command]\r\n",
|
||||
-1);
|
||||
TagLogfileAct(pCE, "initialization command bumped %s",
|
||||
pCL->acid->string);
|
||||
*/
|
||||
pCE->pCLwr = (CONSCLIENT *)0;
|
||||
}
|
||||
|
||||
/* pin[0] = parent read, pin[1] = child write */
|
||||
if (pipe(pin) != 0) {
|
||||
Error("[%s] StartInit(): pipe(): %s", pCE->server,
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
/* pout[0] = child read, pout[l] = parent write */
|
||||
if (pipe(pout) != 0) {
|
||||
close(pin[0]);
|
||||
close(pin[1]);
|
||||
Error("[%s] StartInit(): pipe(): %s", pCE->server,
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
switch (pCE->initpid = fork()) {
|
||||
case -1:
|
||||
pCE->initpid = 0;
|
||||
return;
|
||||
case 0:
|
||||
thepid = getpid();
|
||||
break;
|
||||
default:
|
||||
close(pout[0]);
|
||||
close(pin[1]);
|
||||
if ((pCE->initfile =
|
||||
FileOpenPipe(pin[0], pout[1])) == (CONSFILE *)0) {
|
||||
Error("[%s] FileOpenPipe(%d,%d) failed: forcing down",
|
||||
pCE->server, pin[0], pout[1]);
|
||||
close(pin[0]);
|
||||
close(pout[1]);
|
||||
kill(pCE->initpid, SIGHUP);
|
||||
pCE->initpid = 0;
|
||||
return;
|
||||
}
|
||||
Msg("[%s] initcmd started: pid %lu", pCE->server,
|
||||
(unsigned long)pCE->initpid);
|
||||
TagLogfileAct(pCE, "initcmd started");
|
||||
FD_SET(pin[0], &rinit);
|
||||
if (maxfd < pin[0] + 1)
|
||||
maxfd = pin[0] + 1;
|
||||
fflush(stderr);
|
||||
return;
|
||||
}
|
||||
|
||||
close(pin[0]);
|
||||
close(pout[1]);
|
||||
|
||||
/* put the signals back that we ignore (trapped auto-reset to default)
|
||||
*/
|
||||
SimpleSignal(SIGQUIT, SIG_DFL);
|
||||
SimpleSignal(SIGINT, SIG_DFL);
|
||||
SimpleSignal(SIGPIPE, SIG_DFL);
|
||||
#if defined(SIGTTOU)
|
||||
SimpleSignal(SIGTTOU, SIG_DFL);
|
||||
#endif
|
||||
#if defined(SIGTTIN)
|
||||
SimpleSignal(SIGTTIN, SIG_DFL);
|
||||
#endif
|
||||
#if defined(SIGTSTP)
|
||||
SimpleSignal(SIGTSTP, SIG_DFL);
|
||||
#endif
|
||||
#if defined(SIGPOLL)
|
||||
SimpleSignal(SIGPOLL, SIG_DFL);
|
||||
#endif
|
||||
|
||||
/* setup new process with clean file descriptors
|
||||
*/
|
||||
i = GetMaxFiles();
|
||||
for ( /* i above */ ; --i > 2;) {
|
||||
if (i != pout[0] && i != pin[1])
|
||||
close(i);
|
||||
}
|
||||
/* leave 2 until we have to close it */
|
||||
close(1);
|
||||
close(0);
|
||||
|
||||
# if HAVE_SETSID
|
||||
iNewGrp = setsid();
|
||||
if (-1 == iNewGrp) {
|
||||
Error("[%s] setsid(): %s", pCE->server, strerror(errno));
|
||||
iNewGrp = getpid();
|
||||
}
|
||||
# else
|
||||
iNewGrp = getpid();
|
||||
# endif
|
||||
|
||||
if (dup(pout[0]) != 0 || dup(pin[1]) != 1) {
|
||||
Error("[%s] StartInit(): fd sync error", pCE->server);
|
||||
Bye(EX_OSERR);
|
||||
}
|
||||
close(pout[0]);
|
||||
close(pin[1]);
|
||||
|
||||
tcsetpgrp(0, iNewGrp);
|
||||
|
||||
apcArgv[2] = pCE->initcmd;
|
||||
|
||||
close(2);
|
||||
dup(1); /* better be 2, but it is too late now */
|
||||
|
||||
execve(apcArgv[0], apcArgv, environ);
|
||||
Error("[%s] execve(%s): %s", pCE->server, apcArgv[2], strerror(errno));
|
||||
Bye(EX_OSERR);
|
||||
return;
|
||||
}
|
||||
|
||||
/* setup a virtual device (ksb)
|
||||
*/
|
||||
static int
|
||||
@ -424,11 +607,13 @@ ConsDown(pCE, downHard, force)
|
||||
#endif
|
||||
{
|
||||
if (force != FLAGTRUE &&
|
||||
!(FileBufEmpty(pCE->fdlog) && FileBufEmpty(pCE->cofile))) {
|
||||
!(FileBufEmpty(pCE->fdlog) && FileBufEmpty(pCE->cofile) &&
|
||||
FileBufEmpty(pCE->initfile))) {
|
||||
pCE->ioState = ISFLUSHING;
|
||||
return;
|
||||
}
|
||||
|
||||
StopInit(pCE);
|
||||
if (pCE->ipid != 0) {
|
||||
CONDDEBUG((1, "ConsDown(): sending pid %lu signal %d",
|
||||
(unsigned long)pCE->ipid, SIGHUP));
|
||||
@ -607,6 +792,9 @@ ConsInit(pCE)
|
||||
} else {
|
||||
pCE->ioState = INCONNECT;
|
||||
pCE->stateTimer = time((time_t *)0) + CONNECTTIMEOUT;
|
||||
if (timers[T_STATE] == (time_t)0 ||
|
||||
timers[T_STATE] > pCE->stateTimer)
|
||||
timers[T_STATE] = pCE->stateTimer;
|
||||
pCE->fup = 1;
|
||||
}
|
||||
break;
|
||||
@ -654,13 +842,28 @@ ConsInit(pCE)
|
||||
break;
|
||||
}
|
||||
|
||||
FD_SET(cofile, &rinit);
|
||||
/* if we're waiting for connect() to finish, watch the
|
||||
* write bit, otherwise watch for the read bit
|
||||
*/
|
||||
if (pCE->ioState == INCONNECT)
|
||||
FD_SET(cofile, &winit);
|
||||
else
|
||||
FD_SET(cofile, &rinit);
|
||||
if (maxfd < cofile + 1)
|
||||
maxfd = cofile + 1;
|
||||
|
||||
tyme = time((time_t *)0);
|
||||
|
||||
if (pCE->ioState == ISNORMAL) {
|
||||
pCE->lastWrite = tyme;
|
||||
if (pCE->idletimeout != (time_t)0 &&
|
||||
(timers[T_IDLE] == (time_t)0 ||
|
||||
timers[T_IDLE] > pCE->lastWrite + pCE->idletimeout))
|
||||
timers[T_IDLE] = pCE->lastWrite + pCE->idletimeout;
|
||||
}
|
||||
|
||||
/* If we have marks, adjust the next one so that it's in the future */
|
||||
if (pCE->nextMark > 0) {
|
||||
tyme = time((time_t *)0);
|
||||
if (tyme >= pCE->nextMark) {
|
||||
/* Add as many pCE->mark values as necessary so that we move
|
||||
* beyond the current time.
|
||||
@ -671,9 +874,15 @@ ConsInit(pCE)
|
||||
}
|
||||
|
||||
if (pCE->downHard == FLAGTRUE) {
|
||||
Msg("[%s] console up", pCE->server);
|
||||
if (pCE->ioState == ISNORMAL)
|
||||
Msg("[%s] console up", pCE->server);
|
||||
else
|
||||
Msg("[%s] console inititalizing", pCE->server);
|
||||
pCE->downHard = FLAGFALSE;
|
||||
}
|
||||
|
||||
if (pCE->ioState == ISNORMAL)
|
||||
StartInit(pCE);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: consent.h,v 5.46 2003-08-18 20:01:16-07 bryan Exp $
|
||||
* $Id: consent.h,v 5.53 2003/11/28 23:36:02 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -65,6 +65,7 @@ typedef struct names {
|
||||
|
||||
typedef struct consentUsers {
|
||||
NAMES *user;
|
||||
short not;
|
||||
struct consentUsers *next;
|
||||
} CONSENTUSERS;
|
||||
|
||||
@ -78,6 +79,7 @@ typedef struct consent { /* console information */
|
||||
NAMES *aliases; /* aliases for server name */
|
||||
/* type == DEVICE */
|
||||
char *device; /* device file */
|
||||
char *devicesubst; /* device substitution pattern */
|
||||
BAUD *baud; /* the baud on this console port */
|
||||
PARITY *parity; /* the parity on this line */
|
||||
FLAG hupcl; /* use HUPCL */
|
||||
@ -90,15 +92,21 @@ typedef struct consent { /* console information */
|
||||
#endif
|
||||
/* type == HOST */
|
||||
char *host; /* hostname */
|
||||
unsigned short port; /* port number */
|
||||
unsigned short port; /* port number socket = portbase + */
|
||||
unsigned short portbase; /* port base portinc * port */
|
||||
unsigned short portinc; /* port increment */
|
||||
/* type == EXEC */
|
||||
char *exec; /* exec command */
|
||||
/* */
|
||||
char *execsubst; /* exec substitution pattern */
|
||||
/* global stuff */
|
||||
char *master; /* master hostname */
|
||||
/* */
|
||||
unsigned short breakNum; /* break type [1-9] */
|
||||
/* */
|
||||
char *logfile; /* logfile */
|
||||
off_t logfilemax; /* size limit for rolling logfile */
|
||||
char *initcmd; /* initcmd command */
|
||||
char *motd; /* motd */
|
||||
time_t idletimeout; /* idle timeout */
|
||||
char *idlestring; /* string to print when idle */
|
||||
/* timestamp stuff */
|
||||
int mark; /* Mark (chime) interval */
|
||||
long nextMark; /* Next mark (chime) time */
|
||||
@ -117,10 +125,13 @@ typedef struct consent { /* console information */
|
||||
char *execSlave; /* pseudo-device slave side */
|
||||
int execSlaveFD; /* fd of slave side */
|
||||
pid_t ipid; /* pid of virtual command */
|
||||
pid_t initpid; /* pid of initcmd command */
|
||||
CONSFILE *initfile; /* the command run on init */
|
||||
STRING *wbuf; /* write() buffer */
|
||||
int wbufIAC; /* next IAC location in wbuf */
|
||||
IOSTATE ioState; /* state of the socket */
|
||||
time_t stateTimer; /* timer for ioState states */
|
||||
time_t lastWrite; /* time of last data sent to console */
|
||||
|
||||
/*** state information ***/
|
||||
char acline[132 * 2 + 2]; /* max chars we will call a line */
|
||||
@ -154,3 +165,5 @@ extern void ConsInit PARAMS((CONSENT *));
|
||||
extern void ConsDown PARAMS((CONSENT *, FLAG, FLAG));
|
||||
extern REMOTE *FindUniq PARAMS((REMOTE *));
|
||||
extern void DestroyRemoteConsole PARAMS((REMOTE *));
|
||||
extern void StartInit PARAMS((CONSENT *));
|
||||
extern void StopInit PARAMS((CONSENT *));
|
||||
|
@ -1,6 +1,6 @@
|
||||
.\" @(#)conserver.8 01/06/91 OSU CIS; Thomas A. Fine
|
||||
.\" $Id: conserver.man,v 1.38 2003-09-22 08:33:41-07 bryan Exp $
|
||||
.TH CONSERVER 8 "2003-09-22" "conserver-8.0.0" "conserver"
|
||||
.\" $Id: conserver.man,v 1.40 2003/11/10 15:37:24 bryan Exp $
|
||||
.TH CONSERVER 8 "2003/11/10" "conserver-8.0.9" "conserver"
|
||||
.SH NAME
|
||||
conserver \- console server daemon
|
||||
.SH SYNOPSIS
|
||||
@ -26,6 +26,8 @@ conserver \- console server daemon
|
||||
.IR logfile ]
|
||||
.RB [ \-O
|
||||
.IR min ]
|
||||
.RB [ \-U
|
||||
.IR logfile ]
|
||||
.SH DESCRIPTION
|
||||
.B Conserver
|
||||
is the daemon that manages
|
||||
@ -93,7 +95,7 @@ Close all connections and exit.
|
||||
.TP
|
||||
SIGHUP
|
||||
Reread the configuration file.
|
||||
New consoles are managed by forking off new childen, deleted
|
||||
New consoles are managed by forking off new children, deleted
|
||||
consoles (and their clients) are dropped,
|
||||
and changes to consoles are done "in place", resetting the console
|
||||
port (bringing it down and up) only when necessary.
|
||||
@ -147,7 +149,7 @@ the signing certificate must be properly trusted, which usually means
|
||||
the public portion is in
|
||||
.IB OPENSSL_ROOT /ssl/certs
|
||||
(on both the client and server sides).
|
||||
See the sample self-signing certficate making script
|
||||
See the sample self-signing certificate making script
|
||||
.B contrib/maketestcerts
|
||||
for further clues.
|
||||
To allow
|
||||
@ -332,6 +334,17 @@ independent of whether logging of individual consoles is enabled via
|
||||
.B conserver.cf
|
||||
entries.
|
||||
.TP
|
||||
.BI \-U logfile
|
||||
Copy all console data to the ``unified''
|
||||
.IR logfile .
|
||||
The output is the same as the
|
||||
.B \-u
|
||||
output, but all consoles, not
|
||||
just those without a user, are logged.
|
||||
Each line of output is prefixed with the console name.
|
||||
If a user is attached read/write, a `*' is appended to the console name,
|
||||
to allow log watching utilites to ignore potential user-introduced alarms.
|
||||
.TP
|
||||
.B \-v
|
||||
Echo the configuration as it is being read (be verbose).
|
||||
.TP
|
||||
|
@ -1,4 +0,0 @@
|
||||
bryan:r71mXjfALB5Ak:any
|
||||
djs:r71mXjfALB5Ak:login
|
||||
chogan:*passwd*:foobar,login,shell
|
||||
hogan:*passwd*:any
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: convert.c,v 1.7 2003-08-15 14:24:39-07 bryan Exp $
|
||||
* $Id: convert.c,v 1.8 2003/11/20 13:56:38 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -32,7 +32,7 @@
|
||||
|
||||
#include <compat.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <cutil.h>
|
||||
#include <consent.h>
|
||||
#include <client.h>
|
||||
#include <group.h>
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: util.c,v 1.98 2003-08-24 10:40:10-07 bryan Exp $
|
||||
* $Id: cutil.c,v 1.109 2003/12/02 16:21:43 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
#include <compat.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <cutil.h>
|
||||
|
||||
#if HAVE_OPENSSL
|
||||
#include <openssl/ssl.h>
|
||||
@ -75,12 +75,12 @@ StrTime(ltime)
|
||||
time_t *ltime;
|
||||
#endif
|
||||
{
|
||||
static char curtime[25];
|
||||
static char curtime[40]; /* just in case ctime() varies */
|
||||
time_t tyme;
|
||||
|
||||
tyme = time((time_t *)0);
|
||||
strcpy(curtime, ctime(&tyme));
|
||||
curtime[24] = '\000';
|
||||
curtime[24] = '\000'; /* might need to adjust this at some point */
|
||||
if (ltime != NULL)
|
||||
*ltime = tyme;
|
||||
return (const char *)curtime;
|
||||
@ -143,7 +143,10 @@ BuildString(str, msg)
|
||||
CONDDEBUG((3, "BuildString(): 0x%lx reset", (void *)msg));
|
||||
return msg->string;
|
||||
}
|
||||
len = strlen(str) + 1;
|
||||
if (msg->used) /* string or string + null? */
|
||||
len = strlen(str);
|
||||
else
|
||||
len = strlen(str) + 1;
|
||||
if (msg->used + len >= msg->allocated) {
|
||||
if (0 == msg->allocated) {
|
||||
msg->allocated =
|
||||
@ -161,13 +164,19 @@ BuildString(str, msg)
|
||||
if (msg->string == (char *)0)
|
||||
OutOfMem();
|
||||
}
|
||||
/* if msg->used, then len = strlen(), so we need to copy len + 1 to
|
||||
* get the NULL which we overwrote with the copy */
|
||||
#if HAVE_MEMCPY
|
||||
memcpy(msg->string + (msg->used ? msg->used - 1 : 0), str, len);
|
||||
#else
|
||||
bcopy(str, msg->string + (msg->used ? msg->used - 1 : 0), len);
|
||||
#endif
|
||||
if (msg->used)
|
||||
len--;
|
||||
memcpy(msg->string + msg->used - 1, str, len + 1);
|
||||
else
|
||||
memcpy(msg->string, str, len);
|
||||
#else
|
||||
if (msg->used)
|
||||
bcopy(str, msg->string + msg->used - 1, len + 1);
|
||||
else
|
||||
bcopy(str, msg->string, len);
|
||||
#endif
|
||||
msg->used += len;
|
||||
CONDDEBUG((3, "BuildString(): 0x%lx added %d chars (%d/%d now)",
|
||||
(void *)msg, len, msg->used, msg->allocated));
|
||||
@ -195,12 +204,10 @@ BuildStringN(str, n, msg)
|
||||
}
|
||||
if (n <= 0)
|
||||
return msg->string;
|
||||
len = strlen(str) + 1;
|
||||
if (len > n) { /* if we're a substring */
|
||||
if (msg->used)
|
||||
len = n;
|
||||
if (str[n - 1] != '\000') /* if we aren't copying a '\000', */
|
||||
len++; /* we need to add one at the end */
|
||||
}
|
||||
else
|
||||
len = n + 1;
|
||||
if (msg->used + len >= msg->allocated) {
|
||||
if (0 == msg->allocated) {
|
||||
msg->allocated =
|
||||
@ -219,14 +226,12 @@ BuildStringN(str, n, msg)
|
||||
OutOfMem();
|
||||
}
|
||||
#if HAVE_MEMCPY
|
||||
memcpy(msg->string + (msg->used ? msg->used - 1 : 0), str, len);
|
||||
memcpy(msg->string + (msg->used ? msg->used - 1 : 0), str, n);
|
||||
#else
|
||||
bcopy(str, msg->string + (msg->used ? msg->used - 1 : 0), len);
|
||||
bcopy(str, msg->string + (msg->used ? msg->used - 1 : 0), n);
|
||||
#endif
|
||||
if (len > n) /* we need to terminate the string */
|
||||
msg->string[(msg->used ? msg->used - 1 : 0) + len - 1] = '\000';
|
||||
if (msg->used)
|
||||
len--;
|
||||
/* add a NULL */
|
||||
msg->string[(msg->used ? msg->used - 1 : 0) + n] = '\000';
|
||||
msg->used += len;
|
||||
CONDDEBUG((3, "BuildStringN(): 0x%lx added %d chars (%d/%d now)",
|
||||
(void *)msg, len, msg->used, msg->allocated));
|
||||
@ -730,6 +735,37 @@ FileOpenFD(fd, type)
|
||||
return cfp;
|
||||
}
|
||||
|
||||
/* This encapsulates a pipe pair in a CONSFILE
|
||||
* object. Returns a CONSFILE pointer to that object.
|
||||
*/
|
||||
CONSFILE *
|
||||
#if PROTOTYPES
|
||||
FileOpenPipe(int fd, int fdout)
|
||||
#else
|
||||
FileOpenPipe(fd, fdout)
|
||||
int fd;
|
||||
int fdout;
|
||||
#endif
|
||||
{
|
||||
CONSFILE *cfp;
|
||||
|
||||
if ((cfp = (CONSFILE *)calloc(1, sizeof(CONSFILE)))
|
||||
== (CONSFILE *)0)
|
||||
OutOfMem();
|
||||
cfp->ftype = simplePipe;
|
||||
cfp->fd = fd;
|
||||
cfp->fdout = fdout;
|
||||
cfp->wbuf = AllocString();
|
||||
#if HAVE_OPENSSL
|
||||
cfp->ssl = (SSL *)0;
|
||||
cfp->waitForRead = cfp->waitForWrite = FLAGFALSE;
|
||||
#endif
|
||||
|
||||
CONDDEBUG((2, "FileOpenPipe(): encapsulated pipe pair fd %d and fd %d",
|
||||
fd, fdout));
|
||||
return cfp;
|
||||
}
|
||||
|
||||
/* This is to "unencapsulate" the file descriptor */
|
||||
int
|
||||
#if PROTOTYPES
|
||||
@ -745,6 +781,9 @@ FileUnopen(cfp)
|
||||
case simpleFile:
|
||||
retval = cfp->fd;
|
||||
break;
|
||||
case simplePipe:
|
||||
retval = cfp->fd;
|
||||
break;
|
||||
case simpleSocket:
|
||||
retval = cfp->fd;
|
||||
break;
|
||||
@ -758,6 +797,7 @@ FileUnopen(cfp)
|
||||
break;
|
||||
}
|
||||
CONDDEBUG((2, "FileUnopen(): unopened fd %d", cfp->fd));
|
||||
DestroyString(cfp->wbuf);
|
||||
free(cfp);
|
||||
|
||||
return retval;
|
||||
@ -826,20 +866,28 @@ FileClose(pcfp)
|
||||
retval = close(cfp->fd);
|
||||
} while (retval == -1 && errno == EINTR);
|
||||
break;
|
||||
case simplePipe:
|
||||
do {
|
||||
retval = close(cfp->fd);
|
||||
} while (retval == -1 && errno == EINTR);
|
||||
do {
|
||||
retval = close(cfp->fdout);
|
||||
} while (retval == -1 && errno == EINTR);
|
||||
break;
|
||||
case simpleSocket:
|
||||
#if defined(__CYGWIN__)
|
||||
/* flush out the client socket - set it to blocking,
|
||||
* then write to it
|
||||
*/
|
||||
SetFlags(cfp->fd, 0, O_NONBLOCK)
|
||||
SetFlags(cfp->fd, 0, O_NONBLOCK);
|
||||
|
||||
/* sent it a byte - guaranteed to block - ensure delivery
|
||||
* of prior data yeah - this is a bit paranoid - try
|
||||
* without this at first
|
||||
*/
|
||||
/* write(cfp->fd, "\n", 1); */
|
||||
/* this is the guts of the workaround for Winsock close bug */
|
||||
shutdown(cfp->fd, 1);
|
||||
/* sent it a byte - guaranteed to block - ensure delivery
|
||||
* of prior data yeah - this is a bit paranoid - try
|
||||
* without this at first
|
||||
*/
|
||||
/* write(cfp->fd, "\n", 1); */
|
||||
/* this is the guts of the workaround for Winsock close bug */
|
||||
shutdown(cfp->fd, 1);
|
||||
|
||||
/* enable lingering */
|
||||
lingeropt.l_onoff = 1;
|
||||
@ -873,7 +921,12 @@ FileClose(pcfp)
|
||||
break;
|
||||
}
|
||||
|
||||
CONDDEBUG((2, "FileClose(): closed fd %d", cfp->fd));
|
||||
if (cfp->ftype == simplePipe) {
|
||||
CONDDEBUG((2, "FileClose(): closed fd %d/%d", cfp->fd,
|
||||
cfp->fdout));
|
||||
} else {
|
||||
CONDDEBUG((2, "FileClose(): closed fd %d", cfp->fd));
|
||||
}
|
||||
DestroyString(cfp->wbuf);
|
||||
free(cfp);
|
||||
*pcfp = (CONSFILE *)0;
|
||||
@ -896,6 +949,7 @@ FileRead(cfp, buf, len)
|
||||
|
||||
switch (cfp->ftype) {
|
||||
case simpleFile:
|
||||
case simplePipe:
|
||||
case simpleSocket:
|
||||
while (retval < 0) {
|
||||
if ((retval = read(cfp->fd, buf, len)) <= 0) {
|
||||
@ -968,9 +1022,15 @@ FileRead(cfp, buf, len)
|
||||
if (tmpString == (STRING *)0)
|
||||
tmpString = AllocString();
|
||||
BuildString((char *)0, tmpString);
|
||||
FmtCtlStr(buf, retval > 30 ? 30 : retval, tmpString);
|
||||
CONDDEBUG((2, "FileRead(): read `%s' from fd %d",
|
||||
tmpString->string, cfp->fd));
|
||||
if (retval > 30) {
|
||||
FmtCtlStr(buf, 30, tmpString);
|
||||
CONDDEBUG((2, "FileRead(): read `%s'... from fd %d",
|
||||
tmpString->string, cfp->fd));
|
||||
} else {
|
||||
FmtCtlStr(buf, retval, tmpString);
|
||||
CONDDEBUG((2, "FileRead(): read `%s' from fd %d",
|
||||
tmpString->string, cfp->fd));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
CONDDEBUG((2,
|
||||
@ -983,10 +1043,11 @@ FileRead(cfp, buf, len)
|
||||
/* returns: -1 on error or eof, >= 0 for valid reads */
|
||||
int
|
||||
#if PROTOTYPES
|
||||
FileWrite(CONSFILE *cfp, char *buf, int len)
|
||||
FileWrite(CONSFILE *cfp, FLAG bufferonly, char *buf, int len)
|
||||
#else
|
||||
FileWrite(cfp, buf, len)
|
||||
FileWrite(cfp, bufferonly, buf, len)
|
||||
CONSFILE *cfp;
|
||||
FLAG bufferonly;
|
||||
char *buf;
|
||||
int len;
|
||||
#endif
|
||||
@ -994,23 +1055,38 @@ FileWrite(cfp, buf, len)
|
||||
int len_orig = len;
|
||||
int len_out = 0;
|
||||
int retval = 0;
|
||||
int fdout = 0;
|
||||
|
||||
if (len < 0 && buf != (char *)0)
|
||||
len = strlen(buf);
|
||||
|
||||
if (cfp->ftype == simplePipe)
|
||||
fdout = cfp->fdout;
|
||||
else
|
||||
fdout = cfp->fd;
|
||||
|
||||
if (fDebug && len > 0 && buf != (char *)0) {
|
||||
static STRING *tmpString = (STRING *)0;
|
||||
if (tmpString == (STRING *)0)
|
||||
tmpString = AllocString();
|
||||
BuildString((char *)0, tmpString);
|
||||
FmtCtlStr(buf, len > 30 ? 30 : len, tmpString);
|
||||
CONDDEBUG((2, "FileWrite(): sending `%s' to fd %d",
|
||||
tmpString->string, cfp->fd));
|
||||
if (len > 30) {
|
||||
FmtCtlStr(buf, 30, tmpString);
|
||||
CONDDEBUG((2, "FileWrite(): sending `%s'... to fd %d",
|
||||
tmpString->string, fdout));
|
||||
} else {
|
||||
FmtCtlStr(buf, len, tmpString);
|
||||
CONDDEBUG((2, "FileWrite(): sending `%s' to fd %d",
|
||||
tmpString->string, fdout));
|
||||
}
|
||||
}
|
||||
/* save the data */
|
||||
if (len > 0 && buf != (char *)0)
|
||||
BuildStringN(buf, len, cfp->wbuf);
|
||||
|
||||
if (bufferonly == FLAGTRUE)
|
||||
return 0;
|
||||
|
||||
/* point at the local data */
|
||||
buf = cfp->wbuf->string;
|
||||
len = cfp->wbuf->used - 1;
|
||||
@ -1024,10 +1100,11 @@ FileWrite(cfp, buf, len)
|
||||
* stop when we hit an error or flush all the data.
|
||||
*/
|
||||
switch (cfp->ftype) {
|
||||
case simplePipe:
|
||||
case simpleFile:
|
||||
case simpleSocket:
|
||||
while (len > 0) {
|
||||
if ((retval = write(cfp->fd, buf, len)) < 0) {
|
||||
if ((retval = write(fdout, buf, len)) < 0) {
|
||||
if (errno == EINTR)
|
||||
continue;
|
||||
if (errno == EAGAIN) {
|
||||
@ -1036,9 +1113,22 @@ FileWrite(cfp, buf, len)
|
||||
break;
|
||||
}
|
||||
retval = -1;
|
||||
/* i believe, as of 8.0.8, we need to just ignore
|
||||
* this and actually produce the error message
|
||||
* below. perhaps we'll have a lot of extra
|
||||
* FileWrite() errors, perhaps not. things shouldn't
|
||||
* just close down and cause errors in normal cases,
|
||||
* right?!? -bryan
|
||||
* maybe not right now, actually. i'm going to check
|
||||
* the return code of FileWrite() on the "important"
|
||||
* things and let the others silently fail and have
|
||||
* the FileRead() catch problems - like it has been
|
||||
* doing. i really should be checking all the return
|
||||
* codes...and i'm sure i'll get there eventually.
|
||||
*/
|
||||
if (errno == EPIPE)
|
||||
break;
|
||||
Error("FileWrite(): fd %d: %s", cfp->fd,
|
||||
Error("FileWrite(): fd %d: %s", fdout,
|
||||
strerror(errno));
|
||||
break;
|
||||
}
|
||||
@ -1110,20 +1200,20 @@ FileWrite(cfp, buf, len)
|
||||
}
|
||||
}
|
||||
if (cfp->wbuf->used <= 1)
|
||||
FD_CLR(cfp->fd, &winit);
|
||||
FD_CLR(fdout, &winit);
|
||||
else {
|
||||
FD_SET(cfp->fd, &winit);
|
||||
FD_SET(fdout, &winit);
|
||||
CONDDEBUG((2, "FileWrite(): buffered %d byte%s for fd %d",
|
||||
(cfp->wbuf->used <= 1) ? 0 : cfp->wbuf->used,
|
||||
(cfp->wbuf->used <= 1) ? "" : "s", cfp->fd));
|
||||
(cfp->wbuf->used <= 1) ? "" : "s", fdout));
|
||||
}
|
||||
|
||||
if (len_out >= 0) {
|
||||
CONDDEBUG((2, "FileWrite(): wrote %d byte%s to fd %d", len_out,
|
||||
(len_out == 1) ? "" : "s", cfp->fd));
|
||||
(len_out == 1) ? "" : "s", fdout));
|
||||
} else {
|
||||
CONDDEBUG((2, "FileWrite(): write of %d byte%s to fd %d: %s",
|
||||
len_orig, (len_out == -1) ? "" : "s", cfp->fd,
|
||||
len_orig, (len_out == -1) ? "" : "s", fdout,
|
||||
strerror(errno)));
|
||||
}
|
||||
return len_out;
|
||||
@ -1139,12 +1229,19 @@ FileCanRead(cfp, prfd, pwfd)
|
||||
fd_set *pwfd;
|
||||
#endif
|
||||
{
|
||||
int fdout;
|
||||
|
||||
if (cfp == (CONSFILE *)0)
|
||||
return 0;
|
||||
|
||||
if (cfp->ftype == simplePipe)
|
||||
fdout = cfp->fdout;
|
||||
else
|
||||
fdout = cfp->fd;
|
||||
|
||||
return ((FD_ISSET(cfp->fd, prfd)
|
||||
#if HAVE_OPENSSL
|
||||
&& cfp->waitForRead != FLAGTRUE) || (FD_ISSET(cfp->fd, pwfd)
|
||||
&& cfp->waitForRead != FLAGTRUE) || (FD_ISSET(fdout, pwfd)
|
||||
&& cfp->waitForWrite ==
|
||||
FLAGTRUE
|
||||
#endif
|
||||
@ -1161,10 +1258,17 @@ FileCanWrite(cfp, prfd, pwfd)
|
||||
fd_set *pwfd;
|
||||
#endif
|
||||
{
|
||||
int fdout;
|
||||
|
||||
if (cfp == (CONSFILE *)0)
|
||||
return 0;
|
||||
|
||||
return ((FD_ISSET(cfp->fd, pwfd)
|
||||
if (cfp->ftype == simplePipe)
|
||||
fdout = cfp->fdout;
|
||||
else
|
||||
fdout = cfp->fd;
|
||||
|
||||
return ((FD_ISSET(fdout, pwfd)
|
||||
#if HAVE_OPENSSL
|
||||
&& cfp->waitForWrite != FLAGTRUE) || (FD_ISSET(cfp->fd, prfd)
|
||||
&& cfp->waitForRead ==
|
||||
@ -1188,57 +1292,42 @@ FileBufEmpty(cfp)
|
||||
|
||||
void
|
||||
#if PROTOTYPES
|
||||
VWrite(CONSFILE *cfp, STRING *str, unsigned which, char *fmt, va_list ap)
|
||||
VWrite(CONSFILE *cfp, FLAG bufferonly, STRING *str, char *fmt, va_list ap)
|
||||
#else
|
||||
VWrite(cfp, str, which, fmt, ap)
|
||||
VWrite(cfp, bufferonly, str, fmt, ap)
|
||||
CONSFILE *cfp;
|
||||
FLAG bufferonly;
|
||||
STRING *str;
|
||||
unsigned which;
|
||||
char *fmt;
|
||||
va_list ap;
|
||||
#endif
|
||||
{
|
||||
int s, l, e;
|
||||
char c;
|
||||
int fmtlen = 0;
|
||||
int fmtpre = 0;
|
||||
short padzero = 0;
|
||||
short sawdot = 0;
|
||||
static STRING *msg = (STRING *)0;
|
||||
static short flong, fneg;
|
||||
static STRING *output = (STRING *)0;
|
||||
short flong = 0, fneg = 0, fminus = 0;
|
||||
|
||||
if (fmt == (char *)0)
|
||||
if (fmt == (char *)0 || (cfp == (CONSFILE *)0 && str == (STRING *)0))
|
||||
return;
|
||||
switch (which) {
|
||||
case 0:
|
||||
if (cfp == (CONSFILE *)0)
|
||||
return;
|
||||
break;
|
||||
case 1:
|
||||
if (str == (STRING *)0)
|
||||
return;
|
||||
BuildString((char *)0, str);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
if (msg == (STRING *)0)
|
||||
msg = AllocString();
|
||||
fneg = flong = 0;
|
||||
if (output == (STRING *)0)
|
||||
output = AllocString();
|
||||
|
||||
BuildString((char *)0, output);
|
||||
|
||||
for (e = s = l = 0; (c = fmt[s + l]) != '\000'; l++) {
|
||||
if (c == '%') {
|
||||
if (e) {
|
||||
e = 0;
|
||||
if (which == 0)
|
||||
FileWrite(cfp, "%", 1);
|
||||
else if (which == 1)
|
||||
BuildStringChar('%', str);
|
||||
} else {
|
||||
e = 1;
|
||||
if (which == 0)
|
||||
FileWrite(cfp, fmt + s, l);
|
||||
else if (which == 1)
|
||||
BuildStringN(fmt + s, l, str);
|
||||
s += l;
|
||||
l = 0;
|
||||
}
|
||||
if (e == 0 && c == '%') {
|
||||
e = 1;
|
||||
BuildStringN(fmt + s, l, output);
|
||||
s += l;
|
||||
l = 0;
|
||||
continue;
|
||||
}
|
||||
if (e) {
|
||||
@ -1246,83 +1335,183 @@ VWrite(cfp, str, which, fmt, ap)
|
||||
int u;
|
||||
char *p;
|
||||
char cc;
|
||||
switch (c) {
|
||||
case 'h':
|
||||
/* noop since shorts are promoted to int in va_arg */
|
||||
continue;
|
||||
case 'l':
|
||||
flong = 1;
|
||||
continue;
|
||||
case 'c':
|
||||
cc = (char)va_arg(ap, int);
|
||||
if (which == 0)
|
||||
FileWrite(cfp, &cc, 1);
|
||||
else if (which == 1)
|
||||
BuildStringChar(cc, str);
|
||||
break;
|
||||
case 's':
|
||||
p = va_arg(ap, char *);
|
||||
if (which == 0)
|
||||
FileWrite(cfp, p, -1);
|
||||
else if (which == 1)
|
||||
BuildString(p, str);
|
||||
break;
|
||||
case 'd':
|
||||
i = (flong ? va_arg(ap, long) : (long)va_arg(ap, int));
|
||||
if ((long)i < 0) {
|
||||
fneg = 1;
|
||||
i = -i;
|
||||
}
|
||||
goto number;
|
||||
case 'u':
|
||||
i = (flong ? va_arg(ap, unsigned long)
|
||||
: (unsigned long)va_arg(ap, unsigned int));
|
||||
number:
|
||||
BuildString((char *)0, msg);
|
||||
while (i >= 10) {
|
||||
BuildStringChar((i % 10) + '0', msg);
|
||||
i /= 10;
|
||||
}
|
||||
BuildStringChar(i + '0', msg);
|
||||
/* reverse the text to put it in forward order
|
||||
*/
|
||||
u = msg->used - 1;
|
||||
for (i = 0; i < u / 2; i++) {
|
||||
char temp;
|
||||
if (c >= '0' && c <= '9') {
|
||||
if (sawdot == 0) {
|
||||
if (c == '0' && fmtlen == 0)
|
||||
padzero = 1;
|
||||
fmtlen = fmtlen * 10 + (c - '0');
|
||||
} else {
|
||||
fmtpre = fmtpre * 10 + (c - '0');
|
||||
}
|
||||
} else {
|
||||
switch (c) {
|
||||
case '.':
|
||||
sawdot = 1;
|
||||
continue;
|
||||
case '-':
|
||||
fminus = 1;
|
||||
continue;
|
||||
case 'h':
|
||||
/* noop since shorts are promoted to int in va_arg */
|
||||
continue;
|
||||
case 'l':
|
||||
flong = 1;
|
||||
continue;
|
||||
case '%':
|
||||
BuildStringChar('%', output);
|
||||
break;
|
||||
case 'c':
|
||||
cc = (char)va_arg(ap, int);
|
||||
BuildStringChar(cc, output);
|
||||
break;
|
||||
case 's':
|
||||
p = va_arg(ap, char *);
|
||||
{
|
||||
int l = strlen(p);
|
||||
int c;
|
||||
if (fmtpre > 0 && fmtpre < l)
|
||||
l = fmtpre;
|
||||
if (fminus != 0)
|
||||
BuildStringN(p, l, output);
|
||||
for (c = l; c < fmtlen; c++)
|
||||
BuildStringChar(' ', output);
|
||||
if (fminus == 0)
|
||||
BuildStringN(p, l, output);
|
||||
}
|
||||
break;
|
||||
case 'd':
|
||||
i = (flong ? va_arg(ap, long) : (long)
|
||||
va_arg(ap, int));
|
||||
if ((long)i < 0) {
|
||||
fneg = 1;
|
||||
i = -i;
|
||||
}
|
||||
goto number;
|
||||
case 'u':
|
||||
i = (flong ? va_arg(ap, unsigned long)
|
||||
: (unsigned long)va_arg(ap, unsigned int));
|
||||
number:
|
||||
BuildString((char *)0, msg);
|
||||
while (i >= 10) {
|
||||
BuildStringChar((i % 10) + '0', msg);
|
||||
i /= 10;
|
||||
}
|
||||
BuildStringChar(i + '0', msg);
|
||||
if (fneg)
|
||||
BuildStringChar('-', msg);
|
||||
|
||||
temp = msg->string[i];
|
||||
msg->string[i]
|
||||
= msg->string[u - i - 1];
|
||||
msg->string[u - i - 1] = temp;
|
||||
}
|
||||
if (fneg) {
|
||||
if (which == 0)
|
||||
FileWrite(cfp, "-", 1);
|
||||
else if (which == 1)
|
||||
BuildStringChar('-', str);
|
||||
fneg = 0;
|
||||
}
|
||||
if (which == 0)
|
||||
FileWrite(cfp, msg->string, msg->used - 1);
|
||||
else if (which == 1)
|
||||
BuildString(msg->string, str);
|
||||
break;
|
||||
default:
|
||||
Error
|
||||
("VWrite(): unknown conversion character `%c' in `%s'",
|
||||
c, fmt);
|
||||
break;
|
||||
if (fmtpre > 0) {
|
||||
padzero = 0;
|
||||
if (fmtpre > fmtlen)
|
||||
fmtlen = fmtpre;
|
||||
while (msg->used - 1 < fmtpre)
|
||||
BuildStringChar('0', msg);
|
||||
}
|
||||
|
||||
/* reverse the text to put it in forward order
|
||||
*/
|
||||
u = msg->used - 1;
|
||||
for (i = 0; i < u / 2; i++) {
|
||||
char temp;
|
||||
|
||||
temp = msg->string[i];
|
||||
msg->string[i]
|
||||
= msg->string[u - i - 1];
|
||||
msg->string[u - i - 1] = temp;
|
||||
}
|
||||
|
||||
{
|
||||
int l = msg->used - 1;
|
||||
if (fminus != 0)
|
||||
BuildString(msg->string, output);
|
||||
for (; l < fmtlen; l++) {
|
||||
if (padzero == 0 || fminus != 0)
|
||||
BuildStringChar(' ', output);
|
||||
else
|
||||
BuildStringChar('0', output);
|
||||
}
|
||||
if (fminus == 0)
|
||||
BuildString(msg->string, output);
|
||||
}
|
||||
break;
|
||||
case 'X':
|
||||
case 'x':
|
||||
i = (flong ? va_arg(ap, unsigned long)
|
||||
: (unsigned long)va_arg(ap, unsigned int));
|
||||
BuildString((char *)0, msg);
|
||||
while (i >= 16) {
|
||||
if (i % 16 >= 10)
|
||||
BuildStringChar((i % 16) - 10 +
|
||||
(c == 'x' ? 'a' : 'A'),
|
||||
msg);
|
||||
else
|
||||
BuildStringChar((i % 16) + '0', msg);
|
||||
i /= 16;
|
||||
}
|
||||
if (i >= 10)
|
||||
BuildStringChar(i - 10 +
|
||||
(c == 'x' ? 'a' : 'A'), msg);
|
||||
else
|
||||
BuildStringChar(i + '0', msg);
|
||||
|
||||
if (fmtpre > 0) {
|
||||
padzero = 0;
|
||||
if (fmtpre > fmtlen)
|
||||
fmtlen = fmtpre;
|
||||
while (msg->used - 1 < fmtpre)
|
||||
BuildStringChar('0', msg);
|
||||
}
|
||||
|
||||
/* reverse the text to put it in forward order
|
||||
*/
|
||||
u = msg->used - 1;
|
||||
for (i = 0; i < u / 2; i++) {
|
||||
char temp;
|
||||
|
||||
temp = msg->string[i];
|
||||
msg->string[i]
|
||||
= msg->string[u - i - 1];
|
||||
msg->string[u - i - 1] = temp;
|
||||
}
|
||||
|
||||
{
|
||||
int l = msg->used - 1;
|
||||
if (fminus != 0)
|
||||
BuildString(msg->string, output);
|
||||
for (; l < fmtlen; l++) {
|
||||
if (padzero == 0 || fminus != 0)
|
||||
BuildStringChar(' ', output);
|
||||
else
|
||||
BuildStringChar('0', output);
|
||||
}
|
||||
if (fminus == 0)
|
||||
BuildString(msg->string, output);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
Error
|
||||
("VWrite(): unknown conversion character `%c' in `%s'",
|
||||
c, fmt);
|
||||
break;
|
||||
}
|
||||
s += l + 1;
|
||||
l = -1;
|
||||
e = flong = fneg = fminus = 0;
|
||||
fmtlen = fmtpre = sawdot = padzero = 0;
|
||||
}
|
||||
s += l + 1;
|
||||
l = -1;
|
||||
e = flong = 0;
|
||||
}
|
||||
}
|
||||
if (l) {
|
||||
if (which == 0)
|
||||
FileWrite(cfp, fmt + s, l);
|
||||
else if (which == 1)
|
||||
BuildStringN(fmt + s, l, str);
|
||||
if (l)
|
||||
BuildStringN(fmt + s, l, output);
|
||||
|
||||
if (str != (STRING *)0)
|
||||
BuildString((char *)0, str);
|
||||
|
||||
if (output->used > 1) {
|
||||
if (str != (STRING *)0)
|
||||
BuildStringN(output->string, output->used - 1, str);
|
||||
if (cfp != (CONSFILE *)0)
|
||||
FileWrite(cfp, bufferonly, output->string, output->used - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1342,7 +1531,7 @@ BuildStringPrint(str, fmt, va_alist)
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
VWrite((CONSFILE *)0, str, 1, fmt, ap);
|
||||
VWrite((CONSFILE *)0, FLAGFALSE, str, fmt, ap);
|
||||
va_end(ap);
|
||||
if (str == (STRING *)0)
|
||||
return (char *)0;
|
||||
@ -1350,25 +1539,11 @@ BuildStringPrint(str, fmt, va_alist)
|
||||
return str->string;
|
||||
}
|
||||
|
||||
void
|
||||
char *
|
||||
#if PROTOTYPES
|
||||
FileVWrite(CONSFILE *cfp, char *fmt, va_list ap)
|
||||
BuildTmpStringPrint(char *fmt, ...)
|
||||
#else
|
||||
FileVWrite(cfp, fmt, ap)
|
||||
CONSFILE *cfp;
|
||||
char *fmt;
|
||||
va_list ap;
|
||||
#endif
|
||||
{
|
||||
VWrite(cfp, (STRING *)0, 0, fmt, ap);
|
||||
}
|
||||
|
||||
void
|
||||
#if PROTOTYPES
|
||||
FilePrint(CONSFILE *cfp, char *fmt, ...)
|
||||
#else
|
||||
FilePrint(cfp, fmt, va_alist)
|
||||
CONSFILE *cfp;
|
||||
BuildTmpStringPrint(fmt, va_alist)
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
@ -1379,7 +1554,45 @@ FilePrint(cfp, fmt, va_alist)
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
FileVWrite(cfp, fmt, ap);
|
||||
if (mymsg == (STRING *)0)
|
||||
mymsg = AllocString();
|
||||
VWrite((CONSFILE *)0, FLAGFALSE, mymsg, fmt, ap);
|
||||
va_end(ap);
|
||||
return mymsg->string;
|
||||
}
|
||||
|
||||
void
|
||||
#if PROTOTYPES
|
||||
FileVWrite(CONSFILE *cfp, FLAG bufferonly, char *fmt, va_list ap)
|
||||
#else
|
||||
FileVWrite(cfp, bufferonly, fmt, ap)
|
||||
CONSFILE *cfp;
|
||||
FLAG bufferonly;
|
||||
char *fmt;
|
||||
va_list ap;
|
||||
#endif
|
||||
{
|
||||
VWrite(cfp, bufferonly, (STRING *)0, fmt, ap);
|
||||
}
|
||||
|
||||
void
|
||||
#if PROTOTYPES
|
||||
FilePrint(CONSFILE *cfp, FLAG bufferonly, char *fmt, ...)
|
||||
#else
|
||||
FilePrint(cfp, bufferonly, fmt, va_alist)
|
||||
CONSFILE *cfp;
|
||||
FLAG bufferonly;
|
||||
char *fmt;
|
||||
va_dcl
|
||||
#endif
|
||||
{
|
||||
va_list ap;
|
||||
#if PROTOTYPES
|
||||
va_start(ap, fmt);
|
||||
#else
|
||||
va_start(ap);
|
||||
#endif
|
||||
FileVWrite(cfp, bufferonly, fmt, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
@ -1399,6 +1612,9 @@ FileStat(cfp, buf)
|
||||
case simpleFile:
|
||||
retval = fstat(cfp->fd, buf);
|
||||
break;
|
||||
case simplePipe:
|
||||
retval = -1;
|
||||
break;
|
||||
case simpleSocket:
|
||||
retval = fstat(cfp->fd, buf);
|
||||
break;
|
||||
@ -1432,6 +1648,9 @@ FileSeek(cfp, offset, whence)
|
||||
case simpleFile:
|
||||
retval = lseek(cfp->fd, offset, whence);
|
||||
break;
|
||||
case simplePipe:
|
||||
retval = -1;
|
||||
break;
|
||||
case simpleSocket:
|
||||
retval = lseek(cfp->fd, offset, whence);
|
||||
break;
|
||||
@ -1466,6 +1685,9 @@ FileFDNum(cfp)
|
||||
case simpleFile:
|
||||
retval = cfp->fd;
|
||||
break;
|
||||
case simplePipe:
|
||||
retval = cfp->fd;
|
||||
break;
|
||||
case simpleSocket:
|
||||
retval = cfp->fd;
|
||||
break;
|
||||
@ -1482,6 +1704,21 @@ FileFDNum(cfp)
|
||||
return retval;
|
||||
}
|
||||
|
||||
/* Returns the file descriptor number of the underlying file */
|
||||
int
|
||||
#if PROTOTYPES
|
||||
FileFDOutNum(CONSFILE *cfp)
|
||||
#else
|
||||
FileFDOutNum(cfp)
|
||||
CONSFILE *cfp;
|
||||
#endif
|
||||
{
|
||||
if (cfp == (CONSFILE *)0 || cfp->ftype != simplePipe)
|
||||
return -1;
|
||||
|
||||
return cfp->fdout;
|
||||
}
|
||||
|
||||
/* Returns the file type */
|
||||
enum consFileType
|
||||
#if PROTOTYPES
|
||||
@ -1494,6 +1731,8 @@ FileGetType(cfp)
|
||||
switch (cfp->ftype) {
|
||||
case simpleFile:
|
||||
return simpleFile;
|
||||
case simplePipe:
|
||||
return simplePipe;
|
||||
case simpleSocket:
|
||||
return simpleSocket;
|
||||
#if HAVE_OPENSSL
|
||||
@ -1629,6 +1868,9 @@ FileSend(cfp, msg, len, flags)
|
||||
case simpleFile:
|
||||
retval = send(cfp->fd, msg, len, flags);
|
||||
break;
|
||||
case simplePipe:
|
||||
retval = send(cfp->fdout, msg, len, flags);
|
||||
break;
|
||||
case simpleSocket:
|
||||
retval = send(cfp->fd, msg, len, flags);
|
||||
break;
|
||||
@ -1821,3 +2063,28 @@ SetFlags(fd, s, c)
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
char *
|
||||
#if PROTOTYPES
|
||||
StrDup(char *msg)
|
||||
#else
|
||||
StrDup(msg)
|
||||
char *msg;
|
||||
#endif
|
||||
{
|
||||
int len;
|
||||
char *buf;
|
||||
|
||||
if (msg == (char *)0)
|
||||
return (char *)0;
|
||||
len = strlen(msg) + 1;
|
||||
buf = malloc(len);
|
||||
if (buf == (char *)0)
|
||||
return (char *)0;
|
||||
#if HAVE_MEMCPY
|
||||
memcpy(buf, msg, len);
|
||||
#else
|
||||
bcopy(msg, buf, len);
|
||||
#endif
|
||||
return buf;
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: util.h,v 1.52 2003-08-23 11:06:35-07 bryan Exp $
|
||||
* $Id: cutil.h,v 1.57 2003/11/28 00:47:29 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -18,6 +18,7 @@
|
||||
|
||||
/* communication constants
|
||||
*/
|
||||
#define OB_EXEC 'E' /* exec a command on the client */
|
||||
#define OB_SUSP 'Z' /* suspended by server */
|
||||
#define OB_DROP '.' /* dropped by server */
|
||||
|
||||
@ -28,6 +29,7 @@
|
||||
enum consFileType {
|
||||
simpleFile,
|
||||
simpleSocket,
|
||||
simplePipe,
|
||||
#if HAVE_OPENSSL
|
||||
SSLSocket,
|
||||
#endif
|
||||
@ -64,6 +66,7 @@ typedef struct consFile {
|
||||
/* Standard socket type stuff */
|
||||
enum consFileType ftype;
|
||||
int fd;
|
||||
int fdout; /* only used when a simplePipe */
|
||||
STRING *wbuf;
|
||||
#if HAVE_OPENSSL
|
||||
/* SSL stuff */
|
||||
@ -96,20 +99,23 @@ extern int GetMaxFiles PARAMS(());
|
||||
extern char *FmtCtl PARAMS((int, STRING *));
|
||||
extern void FmtCtlStr PARAMS((char *, int, STRING *));
|
||||
extern CONSFILE *FileOpenFD PARAMS((int, enum consFileType));
|
||||
extern CONSFILE *FileOpenPipe PARAMS((int, int));
|
||||
extern CONSFILE *FileOpen PARAMS((const char *, int, int));
|
||||
extern int FileClose PARAMS((CONSFILE **));
|
||||
extern int FileRead PARAMS((CONSFILE *, void *, int));
|
||||
extern int FileWrite PARAMS((CONSFILE *, char *, int));
|
||||
extern void FileVWrite PARAMS((CONSFILE *, char *, va_list));
|
||||
extern void FilePrint PARAMS((CONSFILE *, char *, ...));
|
||||
extern int FileWrite PARAMS((CONSFILE *, FLAG, char *, int));
|
||||
extern void FileVWrite PARAMS((CONSFILE *, FLAG, char *, va_list));
|
||||
extern void FilePrint PARAMS((CONSFILE *, FLAG, char *, ...));
|
||||
extern int FileStat PARAMS((CONSFILE *, struct stat *));
|
||||
extern int FileSeek PARAMS((CONSFILE *, off_t, int));
|
||||
extern int FileSend PARAMS((CONSFILE *, const void *, size_t, int));
|
||||
extern int FileFDNum PARAMS((CONSFILE *));
|
||||
extern int FileFDOutNum PARAMS((CONSFILE *));
|
||||
extern int FileUnopen PARAMS((CONSFILE *));
|
||||
extern void OutOfMem PARAMS(());
|
||||
extern char *BuildTmpString PARAMS((const char *));
|
||||
extern char *BuildTmpStringChar PARAMS((const char));
|
||||
extern char *BuildTmpStringPrint PARAMS((char *, ...));
|
||||
extern char *BuildString PARAMS((const char *, STRING *));
|
||||
extern char *BuildStringChar PARAMS((const char, STRING *));
|
||||
extern char *BuildStringPrint PARAMS((STRING *, char *, ...));
|
||||
@ -130,6 +136,7 @@ extern int FileCanRead PARAMS((CONSFILE *, fd_set *, fd_set *));
|
||||
extern int FileCanWrite PARAMS((CONSFILE *, fd_set *, fd_set *));
|
||||
extern int FileBufEmpty PARAMS((CONSFILE *));
|
||||
extern int SetFlags PARAMS((int, int, int));
|
||||
extern char *StrDup PARAMS((char *));
|
||||
#if HAVE_OPENSSL
|
||||
extern SSL *FileGetSSL PARAMS((CONSFILE *));
|
||||
extern void FileSetSSL PARAMS((CONSFILE *, SSL *));
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: fallback.c,v 5.58 2003-08-15 08:18:26-07 bryan Exp $
|
||||
* $Id: fallback.c,v 5.60 2003/11/20 13:56:38 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -16,7 +16,7 @@
|
||||
|
||||
#include <compat.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <cutil.h>
|
||||
|
||||
/*
|
||||
* get a pty for the user
|
||||
@ -261,7 +261,7 @@ FallBack(slave, sfd)
|
||||
}
|
||||
if ((*slave) != (char *)0)
|
||||
free(*slave);
|
||||
if (((*slave) = strdup(pcTSlave->string))
|
||||
if (((*slave) = StrDup(pcTSlave->string))
|
||||
== (char *)0)
|
||||
OutOfMem();
|
||||
return fd;
|
||||
|
2068
conserver/group.c
2068
conserver/group.c
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: group.h,v 5.38 2003-09-19 08:58:18-07 bryan Exp $
|
||||
* $Id: group.h,v 5.42 2003/11/28 23:36:02 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -34,6 +34,15 @@
|
||||
* 4. This notice may not be removed or altered.
|
||||
*/
|
||||
|
||||
/* timers used to have various things happen */
|
||||
#define T_STATE 0
|
||||
#define T_IDLE 1
|
||||
#define T_MARK 2
|
||||
#define T_REINIT 3
|
||||
#define T_AUTOUP 4
|
||||
#define T_ROLL 5
|
||||
#define T_MAX 6 /* T_MAX *must* be last */
|
||||
|
||||
/* return values used by CheckPass()
|
||||
*/
|
||||
#define AUTH_SUCCESS 0 /* ok */
|
||||
@ -52,22 +61,25 @@ typedef struct grpent { /* group info */
|
||||
struct grpent *pGEnext; /* next group entry */
|
||||
} GRPENT;
|
||||
|
||||
extern time_t timers[];
|
||||
|
||||
extern void Spawn PARAMS((GRPENT *));
|
||||
extern int CheckPass PARAMS((char *, char *));
|
||||
extern void TagLogfile PARAMS((const CONSENT *, char *, ...));
|
||||
extern void TagLogfileAct PARAMS((const CONSENT *, char *, ...));
|
||||
extern void CleanupBreak PARAMS((short));
|
||||
extern void DestroyGroup PARAMS((GRPENT *));
|
||||
extern void DestroyConsent PARAMS((GRPENT *, CONSENT *));
|
||||
extern void SendClientsMsg PARAMS((CONSENT *, char *));
|
||||
extern void ResetMark PARAMS((void));
|
||||
extern void DestroyConsentUsers PARAMS((CONSENTUSERS **));
|
||||
extern CONSENTUSERS *ConsentFindUser PARAMS((CONSENTUSERS *, char *));
|
||||
extern int ConsentUserOk PARAMS((CONSENTUSERS *, char *));
|
||||
extern void DisconnectClient
|
||||
PARAMS((GRPENT *, CONSCLIENT *, char *, FLAG));
|
||||
extern int ClientAccess PARAMS((CONSENT *, char *));
|
||||
extern void DestroyClient PARAMS((CONSCLIENT *));
|
||||
extern int CheckPasswd PARAMS((CONSCLIENT *, char *));
|
||||
extern void ExpandString PARAMS((char *, CONSENT *, short));
|
||||
#if HAVE_OPENSSL
|
||||
extern int AttemptSSL PARAMS((CONSCLIENT *));
|
||||
#endif
|
||||
|
285
conserver/main.c
285
conserver/main.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: main.c,v 5.157 2003-09-22 08:33:58-07 bryan Exp $
|
||||
* $Id: main.c,v 5.172 2003/11/20 13:56:39 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -31,7 +31,7 @@
|
||||
|
||||
#include <pwd.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <cutil.h>
|
||||
#include <consent.h>
|
||||
#include <client.h>
|
||||
#include <group.h>
|
||||
@ -49,11 +49,9 @@
|
||||
#endif
|
||||
|
||||
|
||||
int fAll = 0, fNoinit = 0, fVersion = 0, fStrip = 0, fDaemon = 0, fReopen =
|
||||
int fAll = 0, fNoinit = 0, fVersion = 0, fStrip = 0, fReopen =
|
||||
0, fNoautoreup = 0, fSyntaxOnly = 0;
|
||||
|
||||
char chDefAcc = 'r';
|
||||
|
||||
char *pcConfig = CONFIGFILE;
|
||||
int isMaster = 1;
|
||||
int cMaxMemb = MAXMEMB;
|
||||
@ -64,8 +62,24 @@ static STRING *startedMsg = (STRING *)0;
|
||||
CONFIG *optConf = (CONFIG *)0;
|
||||
CONFIG *config = (CONFIG *)0;
|
||||
char *interface = (char *)0;
|
||||
CONFIG defConfig =
|
||||
{ (STRING *)0, 'r', FLAGFALSE, LOGFILEPATH, PASSWDFILE, DEFPORT,
|
||||
FLAGTRUE,
|
||||
FLAGTRUE, 0, DEFBASEPORT, (char *)0
|
||||
#if HAVE_SETPROCTITLE
|
||||
, FLAGFALSE
|
||||
#endif
|
||||
#if HAVE_OPENSSL
|
||||
, (char *)0, FLAGTRUE
|
||||
#endif
|
||||
};
|
||||
|
||||
struct sockaddr_in in_port;
|
||||
CONSFILE *unifiedlog = (CONSFILE *)0;
|
||||
|
||||
#if HAVE_DMALLOC && DMALLOC_MARK_MAIN
|
||||
unsigned long dmallocMarkMain = 0;
|
||||
#endif
|
||||
|
||||
#if HAVE_OPENSSL
|
||||
SSL_CTX *ctx = (SSL_CTX *)0;
|
||||
@ -379,10 +393,23 @@ ReopenLogfile()
|
||||
* after that, all bets are off...probably not see the errors (well,
|
||||
* aside from the tail of the old logfile, if it was rolled).
|
||||
*/
|
||||
if (!fDaemon || config->logfile == (char *)0)
|
||||
if (config->daemonmode != FLAGTRUE)
|
||||
return;
|
||||
|
||||
close(1);
|
||||
|
||||
/* so, if we aren't in daemon mode, we just return before closing
|
||||
* anything. if we are, there are two possibilities. first, if
|
||||
* logfile is set, we close fd 1, open a file, etc. all should be
|
||||
* well. if logfile isn't set, we end up closing fd 1 and 2 and
|
||||
* returning (in case the logfile was set and then unset [config
|
||||
* file change]).
|
||||
*/
|
||||
if (config->logfile == (char *)0) {
|
||||
close(2);
|
||||
return;
|
||||
}
|
||||
|
||||
if (1 != open(config->logfile, O_WRONLY | O_CREAT | O_APPEND, 0644)) {
|
||||
tag = 0;
|
||||
Error("ReopenLogfile(): open(%s): %s", config->logfile,
|
||||
@ -398,6 +425,31 @@ ReopenLogfile()
|
||||
tag = 0;
|
||||
}
|
||||
|
||||
void
|
||||
#if PROTOTYPES
|
||||
ReopenUnifiedlog(void)
|
||||
#else
|
||||
ReopenUnifiedlog()
|
||||
#endif
|
||||
{
|
||||
/* close any existing */
|
||||
if (unifiedlog != (CONSFILE *)0)
|
||||
FileClose(&unifiedlog);
|
||||
|
||||
/* return if we aren't opening again */
|
||||
if (config->unifiedlog == (char *)0)
|
||||
return;
|
||||
|
||||
/* open a new one */
|
||||
if ((unifiedlog =
|
||||
FileOpen(config->unifiedlog, O_WRONLY | O_CREAT | O_APPEND,
|
||||
0644)) == (CONSFILE *)0) {
|
||||
Error("ReopenUnifiedlog(): open(%s): %s", config->unifiedlog,
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* become a daemon (ksb)
|
||||
*/
|
||||
static void
|
||||
@ -471,9 +523,9 @@ Usage(wantfull)
|
||||
#endif
|
||||
{
|
||||
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]";
|
||||
"[-7dDEFhinoRSuvV] [-a type] [-m max] [-M addr] [-p port] [-b port] [-c cred] [-C config] [-P passwd] [-L logfile] [-O min] [-U logfile]";
|
||||
static char *full[] = {
|
||||
"7 strip the high bit of all console data",
|
||||
"7 strip the high bit off all console data",
|
||||
"a type set the default access type",
|
||||
"b port base port for secondary channel (any by default)",
|
||||
#if HAVE_OPENSSL
|
||||
@ -503,6 +555,7 @@ Usage(wantfull)
|
||||
"R disable automatic client redirection",
|
||||
"S syntax check of configuration file",
|
||||
"u copy \"unloved\" console data to stdout",
|
||||
"U logfile copy all console data to the \"unified\" logfile",
|
||||
"v be verbose on startup",
|
||||
"V output version info",
|
||||
(char *)0
|
||||
@ -539,6 +592,9 @@ Version()
|
||||
#endif
|
||||
#if HAVE_PAM
|
||||
"pam",
|
||||
#endif
|
||||
#if TRUST_REVERSE_DNS
|
||||
"trustrevdns",
|
||||
#endif
|
||||
(char *)0
|
||||
};
|
||||
@ -551,17 +607,18 @@ Version()
|
||||
isMultiProc = 0;
|
||||
|
||||
Msg("%s", THIS_VERSION);
|
||||
Msg("default access type `%c'", chDefAcc);
|
||||
Msg("default access type `%c'", defConfig.defaultaccess);
|
||||
Msg("default escape sequence `%s%s'", FmtCtl(DEFATTN, acA1),
|
||||
FmtCtl(DEFESC, acA2));
|
||||
Msg("default configuration in `%s'", CONFIGFILE);
|
||||
Msg("default password in `%s'", PASSWDFILE);
|
||||
Msg("default logfile is `%s'", LOGFILEPATH);
|
||||
Msg("default password in `%s'", defConfig.passwdfile);
|
||||
Msg("default logfile is `%s'", defConfig.logfile);
|
||||
Msg("default pidfile is `%s'", PIDFILE);
|
||||
Msg("default limit is %d member%s per group", MAXMEMB,
|
||||
MAXMEMB == 1 ? "" : "s");
|
||||
Msg("default primary port referenced as `%s'", DEFPORT);
|
||||
Msg("default secondary base port referenced as `%s'", DEFBASEPORT);
|
||||
Msg("default primary port referenced as `%s'", defConfig.primaryport);
|
||||
Msg("default secondary base port referenced as `%s'",
|
||||
defConfig.secondaryport);
|
||||
|
||||
BuildString((char *)0, acA1);
|
||||
if (optionlist[0] == (char *)0)
|
||||
@ -696,12 +753,20 @@ SummarizeDataStructures()
|
||||
size += strlen(pCE->master);
|
||||
if (pCE->logfile != (char *)0)
|
||||
size += strlen(pCE->logfile);
|
||||
if (pCE->initcmd != (char *)0)
|
||||
size += strlen(pCE->initcmd);
|
||||
if (pCE->execSlave != (char *)0)
|
||||
size += strlen(pCE->execSlave);
|
||||
if (pCE->motd != (char *)0)
|
||||
size += strlen(pCE->motd);
|
||||
if (pCE->idlestring != (char *)0)
|
||||
size += strlen(pCE->idlestring);
|
||||
if (pCE->fdlog != (CONSFILE *)0)
|
||||
size += sizeof(CONSFILE);
|
||||
if (pCE->cofile != (CONSFILE *)0)
|
||||
size += sizeof(CONSFILE);
|
||||
if (pCE->initfile != (CONSFILE *)0)
|
||||
size += sizeof(CONSFILE);
|
||||
if (pCE->aliases != (NAMES *)0) {
|
||||
NAMES *n;
|
||||
for (n = pCE->aliases; n != (NAMES *)0; n = n->next) {
|
||||
@ -776,6 +841,10 @@ DumpDataStructures()
|
||||
REMOTE *pRC;
|
||||
char *empty = "<empty>";
|
||||
|
||||
#if HAVE_DMALLOC && DMALLOC_MARK_MAIN
|
||||
CONDDEBUG((1, "DumpDataStructures(): dmalloc / MarkMain"));
|
||||
dmalloc_log_changed(dmallocMarkMain, 1, 0, 1);
|
||||
#endif
|
||||
#define EMPTYSTR(x) x == (char *)0 ? empty : x
|
||||
if (!fDebug)
|
||||
return;
|
||||
@ -864,18 +933,26 @@ DumpDataStructures()
|
||||
pCE->reinitoncc == FLAGTRUE ? "true" : "false",
|
||||
pCE->striphigh == FLAGTRUE ? "true" : "false",
|
||||
pCE->unloved == FLAGTRUE ? "true" : "false"));
|
||||
CONDDEBUG((1,
|
||||
"DumpDataStructures(): initpid=%lu, initcmd=%s, initfile=%d",
|
||||
(unsigned long)pCE->initpid, EMPTYSTR(pCE->initcmd),
|
||||
FileFDNum(pCE->initfile)));
|
||||
CONDDEBUG((1,
|
||||
"DumpDataStructures(): motd=%s, idletimeout=%d, idlestring=%s",
|
||||
EMPTYSTR(pCE->motd), pCE->idletimeout,
|
||||
EMPTYSTR(pCE->idlestring)));
|
||||
if (pCE->ro) {
|
||||
CONSENTUSERS *u;
|
||||
for (u = pCE->ro; u != (CONSENTUSERS *)0; u = u->next) {
|
||||
CONDDEBUG((1, "DumpDataStructures(): ro=%s",
|
||||
u->user->name));
|
||||
CONDDEBUG((1, "DumpDataStructures(): ro=%s%s",
|
||||
(u->not ? "!" : ""), u->user->name));
|
||||
}
|
||||
}
|
||||
if (pCE->rw) {
|
||||
CONSENTUSERS *u;
|
||||
for (u = pCE->rw; u != (CONSENTUSERS *)0; u = u->next) {
|
||||
CONDDEBUG((1, "DumpDataStructures(): rw=%s",
|
||||
u->user->name));
|
||||
CONDDEBUG((1, "DumpDataStructures(): rw=%s%s",
|
||||
(u->not ? "!" : ""), u->user->name));
|
||||
}
|
||||
}
|
||||
CONDDEBUG((1, "DumpDataStructures(): ------"));
|
||||
@ -912,6 +989,20 @@ ProbeInterfaces()
|
||||
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);
|
||||
@ -1011,6 +1102,20 @@ ProbeInterfaces()
|
||||
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,
|
||||
@ -1028,23 +1133,11 @@ ProbeInterfaces()
|
||||
if (myAddrs != (struct in_addr *)0)
|
||||
free(myAddrs);
|
||||
myAddrs = (struct in_addr *)0;
|
||||
if (bindAddr != INADDR_ANY)
|
||||
count++;
|
||||
if (count == 0)
|
||||
return;
|
||||
myAddrs = (struct in_addr *)calloc(count + 1, sizeof(struct in_addr));
|
||||
if (myAddrs == (struct in_addr *)0)
|
||||
OutOfMem();
|
||||
if (bindAddr != INADDR_ANY) {
|
||||
count--;
|
||||
#if HAVE_MEMCPY
|
||||
memcpy(&(myAddrs[count].s_addr), &bindAddr, sizeof(in_addr_t));
|
||||
#else
|
||||
bcopy(&bindAddr, &(myAddrs[count].s_addr), sizeof(in_addr_t));
|
||||
#endif
|
||||
Verbose("interface address %s (-M option)",
|
||||
inet_ntoa(myAddrs[count]));
|
||||
}
|
||||
for (count--; count >= 0; count--) {
|
||||
#if HAVE_MEMCPY
|
||||
memcpy(&(myAddrs[count].s_addr), he->h_addr_list[count],
|
||||
@ -1078,7 +1171,7 @@ main(argc, argv)
|
||||
{
|
||||
int i;
|
||||
FILE *fpConfig = (FILE *)0;
|
||||
static char acOpts[] = "7a:b:c:C:dDEFhiL:m:M:noO:p:P:RSuVv";
|
||||
static char acOpts[] = "7a:b:c:C:dDEFhiL:m:M:noO:p:P:RSuU:Vv";
|
||||
extern int optopt;
|
||||
extern char *optarg;
|
||||
struct passwd *pwd;
|
||||
@ -1094,9 +1187,9 @@ main(argc, argv)
|
||||
|
||||
thepid = getpid();
|
||||
if ((char *)0 == (progname = strrchr(argv[0], '/'))) {
|
||||
progname = argv[0];
|
||||
progname = StrDup(argv[0]);
|
||||
} else {
|
||||
++progname;
|
||||
progname = StrDup(++progname);
|
||||
}
|
||||
|
||||
setpwent();
|
||||
@ -1147,21 +1240,21 @@ main(argc, argv)
|
||||
}
|
||||
break;
|
||||
case 'b':
|
||||
if ((optConf->secondaryport = strdup(optarg)) == (char *)0)
|
||||
if ((optConf->secondaryport = StrDup(optarg)) == (char *)0)
|
||||
OutOfMem();
|
||||
break;
|
||||
case 'c':
|
||||
#if HAVE_OPENSSL
|
||||
if ((optConf->sslcredentials =
|
||||
strdup(optarg)) == (char *)0)
|
||||
StrDup(optarg)) == (char *)0)
|
||||
OutOfMem();
|
||||
#endif
|
||||
break;
|
||||
case 'C':
|
||||
pcConfig = optarg;
|
||||
pcConfig = StrDup(optarg);
|
||||
break;
|
||||
case 'd':
|
||||
fDaemon = 1;
|
||||
optConf->daemonmode = FLAGTRUE;
|
||||
break;
|
||||
case 'D':
|
||||
fDebug++;
|
||||
@ -1181,7 +1274,7 @@ main(argc, argv)
|
||||
fNoinit = 1;
|
||||
break;
|
||||
case 'L':
|
||||
if ((optConf->logfile = strdup(optarg)) == (char *)0)
|
||||
if ((optConf->logfile = StrDup(optarg)) == (char *)0)
|
||||
OutOfMem();
|
||||
break;
|
||||
case 'm':
|
||||
@ -1193,7 +1286,7 @@ main(argc, argv)
|
||||
}
|
||||
break;
|
||||
case 'M':
|
||||
interface = optarg;
|
||||
interface = StrDup(optarg);
|
||||
break;
|
||||
case 'n':
|
||||
/* noop now */
|
||||
@ -1207,11 +1300,11 @@ main(argc, argv)
|
||||
optConf->reinitcheck = atoi(optarg);
|
||||
break;
|
||||
case 'p':
|
||||
if ((optConf->primaryport = strdup(optarg)) == (char *)0)
|
||||
if ((optConf->primaryport = StrDup(optarg)) == (char *)0)
|
||||
OutOfMem();
|
||||
break;
|
||||
case 'P':
|
||||
if ((optConf->passwdfile = strdup(optarg)) == (char *)0)
|
||||
if ((optConf->passwdfile = StrDup(optarg)) == (char *)0)
|
||||
OutOfMem();
|
||||
break;
|
||||
case 'R':
|
||||
@ -1223,6 +1316,10 @@ main(argc, argv)
|
||||
case 'u':
|
||||
fAll = 1;
|
||||
break;
|
||||
case 'U':
|
||||
if ((optConf->unifiedlog = StrDup(optarg)) == (char *)0)
|
||||
OutOfMem();
|
||||
break;
|
||||
case 'V':
|
||||
fVersion = 1;
|
||||
break;
|
||||
@ -1313,6 +1410,9 @@ main(argc, argv)
|
||||
}
|
||||
ProbeInterfaces();
|
||||
|
||||
/* initialize the timers */
|
||||
for (i = 0; i < T_MAX; i++)
|
||||
timers[i] = (time_t)0;
|
||||
|
||||
/* read the config file */
|
||||
if ((FILE *)0 == (fpConfig = fopen(pcConfig, "r"))) {
|
||||
@ -1324,11 +1424,11 @@ main(argc, argv)
|
||||
|
||||
/* set up the port to bind to */
|
||||
if (optConf->primaryport != (char *)0)
|
||||
config->primaryport = strdup(optConf->primaryport);
|
||||
config->primaryport = StrDup(optConf->primaryport);
|
||||
else if (pConfig->primaryport != (char *)0)
|
||||
config->primaryport = strdup(pConfig->primaryport);
|
||||
config->primaryport = StrDup(pConfig->primaryport);
|
||||
else
|
||||
config->primaryport = strdup(DEFPORT);
|
||||
config->primaryport = StrDup(defConfig.primaryport);
|
||||
if (config->primaryport == (char *)0)
|
||||
OutOfMem();
|
||||
|
||||
@ -1345,8 +1445,7 @@ main(argc, argv)
|
||||
struct servent *pSE;
|
||||
if ((struct servent *)0 ==
|
||||
(pSE = getservbyname(config->primaryport, "tcp"))) {
|
||||
Error("getservbyname(%s): %s", config->primaryport,
|
||||
strerror(errno));
|
||||
Error("getservbyname(%s) failed", config->primaryport);
|
||||
Bye(EX_OSERR);
|
||||
} else {
|
||||
bindPort = ntohs((unsigned short)pSE->s_port);
|
||||
@ -1355,11 +1454,11 @@ main(argc, argv)
|
||||
|
||||
/* set up the secondary port to bind to */
|
||||
if (optConf->secondaryport != (char *)0)
|
||||
config->secondaryport = strdup(optConf->secondaryport);
|
||||
config->secondaryport = StrDup(optConf->secondaryport);
|
||||
else if (pConfig->secondaryport != (char *)0)
|
||||
config->secondaryport = strdup(pConfig->secondaryport);
|
||||
config->secondaryport = StrDup(pConfig->secondaryport);
|
||||
else
|
||||
config->secondaryport = strdup(DEFBASEPORT);
|
||||
config->secondaryport = StrDup(defConfig.secondaryport);
|
||||
if (config->secondaryport == (char *)0)
|
||||
OutOfMem();
|
||||
|
||||
@ -1376,8 +1475,7 @@ main(argc, argv)
|
||||
struct servent *pSE;
|
||||
if ((struct servent *)0 ==
|
||||
(pSE = getservbyname(config->secondaryport, "tcp"))) {
|
||||
Error("getservbyname(%s): %s", config->secondaryport,
|
||||
strerror(errno));
|
||||
Error("getservbyname(%s) failed", config->secondaryport);
|
||||
Bye(EX_OSERR);
|
||||
} else {
|
||||
bindBasePort = ntohs((unsigned short)pSE->s_port);
|
||||
@ -1385,20 +1483,20 @@ main(argc, argv)
|
||||
}
|
||||
|
||||
if (optConf->passwdfile != (char *)0)
|
||||
config->passwdfile = strdup(optConf->passwdfile);
|
||||
config->passwdfile = StrDup(optConf->passwdfile);
|
||||
else if (pConfig->passwdfile != (char *)0)
|
||||
config->passwdfile = strdup(pConfig->passwdfile);
|
||||
config->passwdfile = StrDup(pConfig->passwdfile);
|
||||
else
|
||||
config->passwdfile = strdup(PASSWDFILE);
|
||||
config->passwdfile = StrDup(defConfig.passwdfile);
|
||||
if (config->passwdfile == (char *)0)
|
||||
OutOfMem();
|
||||
|
||||
if (optConf->logfile != (char *)0)
|
||||
config->logfile = strdup(optConf->logfile);
|
||||
config->logfile = StrDup(optConf->logfile);
|
||||
else if (pConfig->logfile != (char *)0)
|
||||
config->logfile = strdup(pConfig->logfile);
|
||||
config->logfile = StrDup(pConfig->logfile);
|
||||
else
|
||||
config->logfile = strdup(LOGFILEPATH);
|
||||
config->logfile = StrDup(defConfig.logfile);
|
||||
if (config->logfile == (char *)0)
|
||||
OutOfMem();
|
||||
|
||||
@ -1407,36 +1505,76 @@ main(argc, argv)
|
||||
else if (pConfig->reinitcheck != 0)
|
||||
config->reinitcheck = pConfig->reinitcheck;
|
||||
else
|
||||
config->reinitcheck = 0;
|
||||
config->reinitcheck = defConfig.reinitcheck;
|
||||
|
||||
if (optConf->defaultaccess != '\000')
|
||||
config->defaultaccess = optConf->defaultaccess;
|
||||
else if (pConfig->defaultaccess != '\000')
|
||||
config->defaultaccess = pConfig->defaultaccess;
|
||||
else
|
||||
config->defaultaccess = chDefAcc;
|
||||
config->defaultaccess = defConfig.defaultaccess;
|
||||
|
||||
if (optConf->daemonmode != FLAGUNKNOWN)
|
||||
config->daemonmode = optConf->daemonmode;
|
||||
else if (pConfig->daemonmode != FLAGUNKNOWN)
|
||||
config->daemonmode = pConfig->daemonmode;
|
||||
else
|
||||
config->daemonmode = defConfig.daemonmode;
|
||||
|
||||
if (optConf->redirect != FLAGUNKNOWN)
|
||||
config->redirect = optConf->redirect;
|
||||
else if (pConfig->redirect != FLAGUNKNOWN)
|
||||
config->redirect = pConfig->redirect;
|
||||
else
|
||||
config->redirect = FLAGTRUE;
|
||||
config->redirect = defConfig.redirect;
|
||||
|
||||
if (optConf->loghostnames != FLAGUNKNOWN)
|
||||
config->loghostnames = optConf->loghostnames;
|
||||
else if (pConfig->loghostnames != FLAGUNKNOWN)
|
||||
config->loghostnames = pConfig->loghostnames;
|
||||
else
|
||||
config->loghostnames = defConfig.loghostnames;
|
||||
|
||||
if (optConf->unifiedlog != (char *)0) {
|
||||
config->unifiedlog = StrDup(optConf->unifiedlog);
|
||||
if (config->unifiedlog == (char *)0)
|
||||
OutOfMem();
|
||||
} else if (pConfig->unifiedlog != (char *)0) {
|
||||
config->unifiedlog = StrDup(pConfig->unifiedlog);
|
||||
if (config->unifiedlog == (char *)0)
|
||||
OutOfMem();
|
||||
} else if (defConfig.unifiedlog != (char *)0) {
|
||||
config->unifiedlog = StrDup(defConfig.unifiedlog);
|
||||
if (config->unifiedlog == (char *)0)
|
||||
OutOfMem();
|
||||
}
|
||||
#if HAVE_OPENSSL
|
||||
if (optConf->sslrequired != FLAGUNKNOWN)
|
||||
config->sslrequired = optConf->sslrequired;
|
||||
else if (pConfig->sslrequired != FLAGUNKNOWN)
|
||||
config->sslrequired = pConfig->sslrequired;
|
||||
else
|
||||
config->sslrequired = FLAGTRUE;
|
||||
config->sslrequired = defConfig.sslrequired;
|
||||
|
||||
if (optConf->sslcredentials != (char *)0)
|
||||
config->sslcredentials = optConf->sslcredentials;
|
||||
config->sslcredentials = StrDup(optConf->sslcredentials);
|
||||
else if (pConfig->sslcredentials != (char *)0)
|
||||
config->sslcredentials = pConfig->sslcredentials;
|
||||
config->sslcredentials = StrDup(pConfig->sslcredentials);
|
||||
else
|
||||
config->sslcredentials = (char *)0;
|
||||
config->sslcredentials = StrDup(defConfig.sslcredentials);
|
||||
#endif
|
||||
|
||||
#if HAVE_SETPROCTITLE
|
||||
if (optConf->setproctitle != FLAGUNKNOWN)
|
||||
config->setproctitle = optConf->setproctitle;
|
||||
else if (pConfig->setproctitle != FLAGUNKNOWN)
|
||||
config->setproctitle = pConfig->setproctitle;
|
||||
else
|
||||
config->setproctitle = defConfig.setproctitle;
|
||||
#endif
|
||||
|
||||
#if HAVE_DMALLOC && DMALLOC_MARK_MAIN
|
||||
dmallocMarkMain = dmalloc_mark();
|
||||
#endif
|
||||
|
||||
if (pGroups == (GRPENT *)0 && pRCList == (REMOTE *)0) {
|
||||
@ -1447,9 +1585,11 @@ main(argc, argv)
|
||||
SetupSSL();
|
||||
#endif
|
||||
|
||||
if (fDaemon)
|
||||
if (config->daemonmode == FLAGTRUE)
|
||||
Daemonize();
|
||||
|
||||
ReopenUnifiedlog();
|
||||
|
||||
/* if no one can use us we need to come up with a default
|
||||
*/
|
||||
if (pACList == (ACCESS *)0)
|
||||
@ -1467,6 +1607,20 @@ main(argc, argv)
|
||||
(unsigned long)pGE->pid, pGE->port);
|
||||
}
|
||||
|
||||
#if HAVE_SETPROCTITLE
|
||||
if (config->setproctitle == FLAGTRUE) {
|
||||
REMOTE *pRC;
|
||||
GRPENT *pGE;
|
||||
int local = 0, remote = 0;
|
||||
for (pGE = pGroups; pGE != (GRPENT *)0; pGE = pGE->pGEnext)
|
||||
local += pGE->imembers;
|
||||
for (pRC = pRCList; (REMOTE *)0 != pRC; pRC = pRC->pRCnext)
|
||||
remote++;
|
||||
setproctitle("master: port %hu, %d local, %d remote", bindPort,
|
||||
local, remote);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (fVerbose) {
|
||||
ACCESS *pACtmp;
|
||||
for (pACtmp = pACList; pACtmp != (ACCESS *)0;
|
||||
@ -1497,6 +1651,9 @@ main(argc, argv)
|
||||
SignalKids(SIGTERM);
|
||||
}
|
||||
|
||||
if (unifiedlog != (CONSFILE *)0)
|
||||
FileClose(&unifiedlog);
|
||||
|
||||
DumpDataStructures();
|
||||
|
||||
Msg("terminated");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: main.h,v 5.49 2003-06-15 19:50:28-07 bryan Exp $
|
||||
* $Id: main.h,v 5.51 2003/11/10 15:37:24 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -47,8 +47,11 @@ extern struct sockaddr_in in_port;
|
||||
extern int isMaster;
|
||||
extern CONFIG *optConf;
|
||||
extern CONFIG *config;
|
||||
extern CONFIG defConfig;
|
||||
extern CONSFILE *unifiedlog;
|
||||
#if HAVE_OPENSSL
|
||||
extern SSL_CTX *ctx;
|
||||
#endif
|
||||
extern void ReopenLogfile PARAMS((void));
|
||||
extern void ReopenUnifiedlog PARAMS((void));
|
||||
extern void DumpDataStructures PARAMS((void));
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: master.c,v 5.113 2003-09-19 08:58:18-07 bryan Exp $
|
||||
* $Id: master.c,v 5.123 2003/11/20 13:56:39 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -29,7 +29,7 @@
|
||||
|
||||
#include <compat.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <cutil.h>
|
||||
#include <consent.h>
|
||||
#include <client.h>
|
||||
#include <group.h>
|
||||
@ -42,7 +42,8 @@
|
||||
|
||||
static sig_atomic_t fSawQuit = 0, fSawHUP = 0, fSawUSR2 = 0, fSawUSR1 =
|
||||
0, fSawCHLD = 0;
|
||||
static CONSCLIENT *pCLfree = (CONSCLIENT *)0;
|
||||
CONSCLIENT *pCLmfree = (CONSCLIENT *)0;
|
||||
CONSCLIENT *pCLmall = (CONSCLIENT *)0;
|
||||
#if HAVE_DMALLOC && DMALLOC_MARK_CLIENT_CONNECTION
|
||||
static unsigned long dmallocMarkClientConnection = 0;
|
||||
#endif
|
||||
@ -76,13 +77,15 @@ FixKids()
|
||||
int UWbuf;
|
||||
GRPENT *pGE;
|
||||
|
||||
while (-1 != (pid = waitpid(-1, &UWbuf, WNOHANG))) {
|
||||
while (-1 != (pid = waitpid(-1, &UWbuf, WNOHANG | WUNTRACED))) {
|
||||
if (0 == pid) {
|
||||
break;
|
||||
}
|
||||
/* stopped child is just continuted
|
||||
*/
|
||||
if (WIFSTOPPED(UWbuf) && 0 == kill(pid, SIGCONT)) {
|
||||
Msg("child pid %lu: stopped, sending SIGCONT",
|
||||
(unsigned long)pid);
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -228,6 +231,28 @@ SignalKids(arg)
|
||||
}
|
||||
}
|
||||
|
||||
REMOTE *
|
||||
#if PROTOTYPES
|
||||
FindRemoteConsole(char *args)
|
||||
#else
|
||||
FindRemoteConsole(args)
|
||||
char *args;
|
||||
#endif
|
||||
{
|
||||
REMOTE *pRC;
|
||||
NAMES *name;
|
||||
|
||||
for (pRC = pRCList; (REMOTE *)0 != pRC; pRC = pRC->pRCnext) {
|
||||
if (strcasecmp(args, pRC->rserver) == 0)
|
||||
return pRC;
|
||||
for (name = pRC->aliases; name != (NAMES *)0; name = name->next) {
|
||||
if (strcasecmp(args, name->name) == 0)
|
||||
return pRC;
|
||||
}
|
||||
}
|
||||
return pRC;
|
||||
}
|
||||
|
||||
void
|
||||
#if PROTOTYPES
|
||||
CommandCall(CONSCLIENT *pCL, char *args)
|
||||
@ -258,6 +283,15 @@ CommandCall(pCL, args)
|
||||
++found;
|
||||
}
|
||||
}
|
||||
if (config->redirect == FLAGTRUE ||
|
||||
(config->redirect != FLAGTRUE && found == 0)) {
|
||||
if ((pRC = FindRemoteConsole(args)) != (REMOTE *)0) {
|
||||
ambiguous = BuildTmpString(pRC->rserver);
|
||||
ambiguous = BuildTmpString(", ");
|
||||
++found;
|
||||
pRCFound = pRC;
|
||||
}
|
||||
}
|
||||
if (found == 0) { /* Then look for substring matches */
|
||||
NAMES *name = (NAMES *)0;
|
||||
int foundOne = 0;
|
||||
@ -318,25 +352,27 @@ CommandCall(pCL, args)
|
||||
}
|
||||
switch (found) {
|
||||
case 0:
|
||||
FilePrint(pCL->fd, "console `%s' not found\r\n", args);
|
||||
FilePrint(pCL->fd, FLAGFALSE, "console `%s' not found\r\n",
|
||||
args);
|
||||
break;
|
||||
case 1:
|
||||
if ((REMOTE *)0 != pRCFound) {
|
||||
if (config->redirect != FLAGTRUE) {
|
||||
FilePrint(pCL->fd,
|
||||
FilePrint(pCL->fd, FLAGFALSE,
|
||||
"automatic redirection disabled - console on master `%s'\r\n",
|
||||
pRCFound->rhost);
|
||||
} else {
|
||||
FilePrint(pCL->fd, "@%s\r\n", pRCFound->rhost);
|
||||
FilePrint(pCL->fd, FLAGFALSE, "@%s\r\n",
|
||||
pRCFound->rhost);
|
||||
}
|
||||
} else {
|
||||
FilePrint(pCL->fd, "%hu\r\n", prnum);
|
||||
FilePrint(pCL->fd, FLAGFALSE, "%hu\r\n", prnum);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
found = strlen(ambiguous);
|
||||
ambiguous[found - 2] = '\000';
|
||||
FilePrint(pCL->fd,
|
||||
FilePrint(pCL->fd, FLAGFALSE,
|
||||
"ambiguous console abbreviation, `%s'\r\n\tchoices are %s\r\n",
|
||||
args, ambiguous);
|
||||
break;
|
||||
@ -377,8 +413,8 @@ DropMasterClient(pCLServing, force)
|
||||
}
|
||||
*(pCLServing->ppCLbscan) = pCLServing->pCLscan;
|
||||
/* put on the free list */
|
||||
pCLServing->pCLnext = pCLfree;
|
||||
pCLfree = pCLServing;
|
||||
pCLServing->pCLnext = pCLmfree;
|
||||
pCLmfree = pCLServing;
|
||||
|
||||
/* we didn't touch pCLServing->pCLscan so the loop works */
|
||||
#if HAVE_DMALLOC && DMALLOC_MARK_CLIENT_CONNECTION
|
||||
@ -423,13 +459,14 @@ DoNormalRead(pCLServing)
|
||||
if (pCLServing->iState == S_PASSWD) {
|
||||
if (CheckPasswd(pCLServing, pCLServing->accmd->string) !=
|
||||
AUTH_SUCCESS) {
|
||||
FileWrite(pCLServing->fd, "invalid password\r\n", -1);
|
||||
FileWrite(pCLServing->fd, FLAGFALSE,
|
||||
"invalid password\r\n", -1);
|
||||
BuildString((char *)0, pCLServing->accmd);
|
||||
DropMasterClient(pCLServing, FLAGFALSE);
|
||||
return;
|
||||
}
|
||||
Verbose("<master> login %s", pCLServing->acid->string);
|
||||
FileWrite(pCLServing->fd, "ok\r\n", -1);
|
||||
FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", 4);
|
||||
pCLServing->iState = S_NORMAL;
|
||||
BuildString((char *)0, pCLServing->accmd);
|
||||
continue;
|
||||
@ -471,16 +508,17 @@ DoNormalRead(pCLServing)
|
||||
for (ppc =
|
||||
(pCLServing->iState == S_IDENT ? apcHelp1 : apcHelp2);
|
||||
(char *)0 != *ppc; ++ppc) {
|
||||
FileWrite(pCLServing->fd, *ppc, -1);
|
||||
FileWrite(pCLServing->fd, FLAGTRUE, *ppc, -1);
|
||||
}
|
||||
FileWrite(pCLServing->fd, FLAGFALSE, (char *)0, 0);
|
||||
} else if (strcmp(pcCmd, "exit") == 0) {
|
||||
FileWrite(pCLServing->fd, "goodbye\r\n", -1);
|
||||
FileWrite(pCLServing->fd, FLAGFALSE, "goodbye\r\n", -1);
|
||||
DropMasterClient(pCLServing, FLAGFALSE);
|
||||
return;
|
||||
#if HAVE_OPENSSL
|
||||
} else if (pCLServing->iState == S_IDENT &&
|
||||
strcmp(pcCmd, "ssl") == 0) {
|
||||
FileWrite(pCLServing->fd, "ok\r\n", -1);
|
||||
FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", -1);
|
||||
if (!AttemptSSL(pCLServing)) {
|
||||
DropMasterClient(pCLServing, FLAGFALSE);
|
||||
return;
|
||||
@ -491,11 +529,12 @@ DoNormalRead(pCLServing)
|
||||
#if HAVE_OPENSSL
|
||||
if (config->sslrequired == FLAGTRUE &&
|
||||
FileGetType(pCLServing->fd) != SSLSocket) {
|
||||
FileWrite(pCLServing->fd, "encryption required\r\n", -1);
|
||||
FileWrite(pCLServing->fd, FLAGFALSE,
|
||||
"encryption required\r\n", -1);
|
||||
} else {
|
||||
#endif
|
||||
if (pcArgs == (char *)0) {
|
||||
FileWrite(pCLServing->fd,
|
||||
FileWrite(pCLServing->fd, FLAGFALSE,
|
||||
"login requires argument\r\n", -1);
|
||||
} else {
|
||||
BuildString((char *)0, pCLServing->username);
|
||||
@ -510,9 +549,10 @@ DoNormalRead(pCLServing)
|
||||
pCLServing->iState = S_NORMAL;
|
||||
Verbose("<master> login %s",
|
||||
pCLServing->acid->string);
|
||||
FileWrite(pCLServing->fd, "ok\r\n", -1);
|
||||
FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", 4);
|
||||
} else {
|
||||
FileWrite(pCLServing->fd, "passwd?\r\n", -1);
|
||||
FilePrint(pCLServing->fd, FLAGFALSE,
|
||||
"passwd? %s\r\n", myHostname);
|
||||
pCLServing->iState = S_PASSWD;
|
||||
}
|
||||
}
|
||||
@ -529,52 +569,56 @@ DoNormalRead(pCLServing)
|
||||
if (-1 ==
|
||||
getsockname(FileFDNum(pCLServing->fd),
|
||||
(struct sockaddr *)&lcl, &so)) {
|
||||
FileWrite(pCLServing->fd,
|
||||
FileWrite(pCLServing->fd, FLAGFALSE,
|
||||
"getsockname failed, try again later\r\n",
|
||||
-1);
|
||||
Error("Master(): getsockname(%u): %s",
|
||||
FileFDNum(pCLServing->fd), strerror(errno));
|
||||
Bye(EX_OSERR);
|
||||
}
|
||||
FilePrint(pCLServing->fd, "@%s", inet_ntoa(lcl.sin_addr));
|
||||
FilePrint(pCLServing->fd, FLAGTRUE, "@%s",
|
||||
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, ":@%s" + iSep, pRC->rhost);
|
||||
FilePrint(pCLServing->fd, FLAGTRUE, ":@%s" + iSep,
|
||||
pRC->rhost);
|
||||
iSep = 0;
|
||||
}
|
||||
}
|
||||
FileWrite(pCLServing->fd, "\r\n", -1);
|
||||
FileWrite(pCLServing->fd, FLAGFALSE, "\r\n", -1);
|
||||
} else if (pCLServing->iState == S_NORMAL &&
|
||||
strcmp(pcCmd, "pid") == 0) {
|
||||
FilePrint(pCLServing->fd, "%lu\r\n", (unsigned long)thepid);
|
||||
FilePrint(pCLServing->fd, FLAGFALSE, "%lu\r\n",
|
||||
(unsigned long)thepid);
|
||||
} else if (pCLServing->iState == S_NORMAL &&
|
||||
strcmp(pcCmd, "version") == 0) {
|
||||
FilePrint(pCLServing->fd, "version `%s'\r\n", THIS_VERSION);
|
||||
FilePrint(pCLServing->fd, FLAGFALSE, "version `%s'\r\n",
|
||||
THIS_VERSION);
|
||||
} else if (pCLServing->iState == S_NORMAL &&
|
||||
strcmp(pcCmd, "quit") == 0) {
|
||||
if (ConsentFindUser(pADList, pCLServing->username->string) !=
|
||||
(CONSENTUSERS *)0 ||
|
||||
ConsentFindUser(pADList, "*") != (CONSENTUSERS *)0) {
|
||||
if (ConsentUserOk(pADList, pCLServing->username->string) == 1) {
|
||||
Verbose("quit command by %s", pCLServing->acid->string);
|
||||
FileWrite(pCLServing->fd, "ok -- terminated\r\n", -1);
|
||||
FileWrite(pCLServing->fd, FLAGFALSE,
|
||||
"ok -- terminated\r\n", -1);
|
||||
DropMasterClient(pCLServing, FLAGFALSE);
|
||||
kill(thepid, SIGTERM);
|
||||
return;
|
||||
} else
|
||||
FileWrite(pCLServing->fd, "unauthorized command\r\n", -1);
|
||||
FileWrite(pCLServing->fd, FLAGFALSE,
|
||||
"unauthorized command\r\n", -1);
|
||||
} else if (pCLServing->iState == S_NORMAL &&
|
||||
strcmp(pcCmd, "restart") == 0) {
|
||||
if (ConsentFindUser(pADList, pCLServing->username->string) !=
|
||||
(CONSENTUSERS *)0 ||
|
||||
ConsentFindUser(pADList, "*") != (CONSENTUSERS *)0) {
|
||||
FileWrite(pCLServing->fd, "ok -- restarting\r\n", -1);
|
||||
if (ConsentUserOk(pADList, pCLServing->username->string) == 1) {
|
||||
FileWrite(pCLServing->fd, FLAGFALSE,
|
||||
"ok -- restarting\r\n", -1);
|
||||
Verbose("restart command by %s", pCLServing->acid->string);
|
||||
kill(thepid, SIGHUP);
|
||||
} else
|
||||
FileWrite(pCLServing->fd, "unauthorized command\r\n", -1);
|
||||
FileWrite(pCLServing->fd, FLAGFALSE,
|
||||
"unauthorized command\r\n", -1);
|
||||
} else if (pCLServing->iState == S_NORMAL &&
|
||||
strcmp(pcCmd, "groups") == 0) {
|
||||
int iSep = 1;
|
||||
@ -583,19 +627,21 @@ DoNormalRead(pCLServing)
|
||||
for (pGE = pGroups; pGE != (GRPENT *)0; pGE = pGE->pGEnext) {
|
||||
if (0 == pGE->imembers)
|
||||
continue;
|
||||
FilePrint(pCLServing->fd, ":%hu" + iSep, pGE->port);
|
||||
FilePrint(pCLServing->fd, FLAGTRUE, ":%hu" + iSep,
|
||||
pGE->port);
|
||||
iSep = 0;
|
||||
}
|
||||
FileWrite(pCLServing->fd, "\r\n", -1);
|
||||
FileWrite(pCLServing->fd, FLAGFALSE, "\r\n", 2);
|
||||
} else if (pCLServing->iState == S_NORMAL &&
|
||||
strcmp(pcCmd, "call") == 0) {
|
||||
if (pcArgs == (char *)0)
|
||||
FileWrite(pCLServing->fd, "call requires argument\r\n",
|
||||
-1);
|
||||
FileWrite(pCLServing->fd, FLAGFALSE,
|
||||
"call requires argument\r\n", -1);
|
||||
else
|
||||
CommandCall(pCLServing, pcArgs);
|
||||
} else {
|
||||
FileWrite(pCLServing->fd, "unknown command\r\n", -1);
|
||||
FileWrite(pCLServing->fd, FLAGFALSE, "unknown command\r\n",
|
||||
-1);
|
||||
}
|
||||
BuildString((char *)0, pCLServing->accmd);
|
||||
}
|
||||
@ -619,7 +665,6 @@ Master()
|
||||
FILE *fp;
|
||||
CONSCLIENT *pCLServing = (CONSCLIENT *)0;
|
||||
CONSCLIENT *pCL = (CONSCLIENT *)0;
|
||||
CONSCLIENT *pCLall = (CONSCLIENT *)0;
|
||||
|
||||
|
||||
/* set up signal handler */
|
||||
@ -642,13 +687,13 @@ Master()
|
||||
SimpleSignal(SIGINT, FlagSawINT);
|
||||
|
||||
/* prime the free connection slots */
|
||||
if ((pCLfree = (CONSCLIENT *)calloc(1, sizeof(CONSCLIENT)))
|
||||
if ((pCLmfree = (CONSCLIENT *)calloc(1, sizeof(CONSCLIENT)))
|
||||
== (CONSCLIENT *)0)
|
||||
OutOfMem();
|
||||
pCLfree->accmd = AllocString();
|
||||
pCLfree->peername = AllocString();
|
||||
pCLfree->username = AllocString();
|
||||
pCLfree->acid = AllocString();
|
||||
pCLmfree->accmd = AllocString();
|
||||
pCLmfree->peername = AllocString();
|
||||
pCLmfree->username = AllocString();
|
||||
pCLmfree->acid = AllocString();
|
||||
|
||||
/* set up port for master to listen on
|
||||
*/
|
||||
@ -713,11 +758,12 @@ Master()
|
||||
fSawHUP = 0;
|
||||
Msg("processing SIGHUP");
|
||||
ReopenLogfile();
|
||||
ReopenUnifiedlog();
|
||||
SignalKids(SIGHUP);
|
||||
ReReadCfg(msfd);
|
||||
/* fix up the client descriptors since ReReadCfg() doesn't
|
||||
* see them like it can in the child processes */
|
||||
for (pCL = pCLall; pCL != (CONSCLIENT *)0; pCL = pCL->pCLscan) {
|
||||
for (pCL = pCLmall; pCL != (CONSCLIENT *)0; pCL = pCL->pCLscan) {
|
||||
FD_SET(FileFDNum(pCL->fd), &rinit);
|
||||
if (maxfd < FileFDNum(pCL->fd) + 1)
|
||||
maxfd = FileFDNum(pCL->fd) + 1;
|
||||
@ -734,6 +780,7 @@ Master()
|
||||
fSawUSR2 = 0;
|
||||
Msg("processing SIGUSR2");
|
||||
ReopenLogfile();
|
||||
ReopenUnifiedlog();
|
||||
SignalKids(SIGUSR2);
|
||||
}
|
||||
if (fSawQuit) { /* Something above set the quit flag */
|
||||
@ -754,7 +801,7 @@ Master()
|
||||
}
|
||||
|
||||
/* anything on a connection? */
|
||||
for (pCLServing = pCLall; (CONSCLIENT *)0 != pCLServing;
|
||||
for (pCLServing = pCLmall; (CONSCLIENT *)0 != pCLServing;
|
||||
pCLServing = pCLServing->pCLscan) {
|
||||
switch (pCLServing->ioState) {
|
||||
#if HAVE_OPENSSL
|
||||
@ -777,7 +824,9 @@ Master()
|
||||
FileCanWrite(pCLServing->fd, &rmask, &wmask)) {
|
||||
CONDDEBUG((1, "Master(): flushing fd %d",
|
||||
FileFDNum(pCLServing->fd)));
|
||||
if (FileWrite(pCLServing->fd, (char *)0, 0) < 0) {
|
||||
if (FileWrite
|
||||
(pCLServing->fd, FLAGFALSE, (char *)0,
|
||||
0) < 0) {
|
||||
DropMasterClient(pCLServing, FLAGTRUE);
|
||||
break;
|
||||
}
|
||||
@ -809,7 +858,7 @@ Master()
|
||||
so = sizeof(struct sockaddr_in);
|
||||
for (cfd = 0; cfd == 0;) {
|
||||
cfd =
|
||||
accept(msfd, (struct sockaddr *)&pCLfree->cnct_port, &so);
|
||||
accept(msfd, (struct sockaddr *)&pCLmfree->cnct_port, &so);
|
||||
if (cfd < 0 && errno == EINTR)
|
||||
cfd = 0;
|
||||
}
|
||||
@ -824,11 +873,11 @@ Master()
|
||||
|
||||
/* set to non-blocking and wrap in a File object */
|
||||
if (SetFlags(cfd, O_NONBLOCK, 0))
|
||||
pCLfree->fd = FileOpenFD(cfd, simpleSocket);
|
||||
pCLmfree->fd = FileOpenFD(cfd, simpleSocket);
|
||||
else
|
||||
pCLfree->fd = (CONSFILE *)0;
|
||||
pCLmfree->fd = (CONSFILE *)0;
|
||||
|
||||
if ((CONSFILE *)0 == pCLfree->fd) {
|
||||
if ((CONSFILE *)0 == pCLmfree->fd) {
|
||||
Error("Master(): FileOpenFD(%u): %s", cfd, strerror(errno));
|
||||
#if HAVE_DMALLOC && DMALLOC_MARK_CLIENT_CONNECTION
|
||||
CONDDEBUG((1, "Master(): dmalloc / MarkClientConnection"));
|
||||
@ -838,27 +887,27 @@ Master()
|
||||
}
|
||||
|
||||
/* remove from the free list */
|
||||
pCL = pCLfree;
|
||||
pCLfree = pCL->pCLnext;
|
||||
pCL = pCLmfree;
|
||||
pCLmfree = pCL->pCLnext;
|
||||
|
||||
/* add another if we ran out */
|
||||
if (pCLfree == (CONSCLIENT *)0) {
|
||||
if ((pCLfree = (CONSCLIENT *)calloc(1, sizeof(CONSCLIENT)))
|
||||
if (pCLmfree == (CONSCLIENT *)0) {
|
||||
if ((pCLmfree = (CONSCLIENT *)calloc(1, sizeof(CONSCLIENT)))
|
||||
== (CONSCLIENT *)0)
|
||||
OutOfMem();
|
||||
pCLfree->accmd = AllocString();
|
||||
pCLfree->peername = AllocString();
|
||||
pCLfree->username = AllocString();
|
||||
pCLfree->acid = AllocString();
|
||||
pCLmfree->accmd = AllocString();
|
||||
pCLmfree->peername = AllocString();
|
||||
pCLmfree->username = AllocString();
|
||||
pCLmfree->acid = AllocString();
|
||||
}
|
||||
|
||||
/* link into all clients list */
|
||||
pCL->pCLscan = pCLall;
|
||||
pCL->ppCLbscan = &pCLall;
|
||||
pCL->pCLscan = pCLmall;
|
||||
pCL->ppCLbscan = &pCLmall;
|
||||
if ((CONSCLIENT *)0 != pCL->pCLscan) {
|
||||
pCL->pCLscan->ppCLbscan = &pCL->pCLscan;
|
||||
}
|
||||
pCLall = pCL;
|
||||
pCLmall = pCL;
|
||||
|
||||
FD_SET(cfd, &rinit);
|
||||
if (maxfd < cfd + 1)
|
||||
@ -874,16 +923,18 @@ Master()
|
||||
if (ClientAccessOk(pCL)) {
|
||||
pCL->ioState = ISNORMAL;
|
||||
/* say hi to start */
|
||||
FileWrite(pCL->fd, "ok\r\n", -1);
|
||||
FileWrite(pCL->fd, FLAGFALSE, "ok\r\n", 4);
|
||||
} else
|
||||
DropMasterClient(pCL, FLAGFALSE);
|
||||
}
|
||||
|
||||
close(msfd);
|
||||
|
||||
/* clean up the free list */
|
||||
while (pCLfree != (CONSCLIENT *)0) {
|
||||
pCL = pCLfree->pCLnext;
|
||||
DestroyClient(pCLfree);
|
||||
pCLfree = pCL;
|
||||
while (pCLmfree != (CONSCLIENT *)0) {
|
||||
pCL = pCLmfree->pCLnext;
|
||||
DestroyClient(pCLmfree);
|
||||
pCLmfree = pCL;
|
||||
}
|
||||
|
||||
unlink(PIDFILE);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: master.h,v 5.16 2003-03-06 10:13:41-08 bryan Exp $
|
||||
* $Id: master.h,v 5.17 2003/10/03 14:23:37 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -37,5 +37,7 @@
|
||||
/*
|
||||
* stuff the master process needs
|
||||
*/
|
||||
extern CONSCLIENT *pCLmall;
|
||||
extern CONSCLIENT *pCLmfree;
|
||||
extern void Master PARAMS((void));
|
||||
extern void SignalKids PARAMS((int));
|
||||
|
1398
conserver/readcfg.c
1398
conserver/readcfg.c
File diff suppressed because it is too large
Load Diff
@ -1,11 +1,13 @@
|
||||
/*
|
||||
* $Id: readcfg.h,v 5.31 2003-08-21 15:02:16-07 bryan Exp $
|
||||
* $Id: readcfg.h,v 5.38 2003/11/10 15:37:24 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
* Maintainer/Enhancer: Bryan Stansell (bryan@conserver.com)
|
||||
*/
|
||||
|
||||
#define BREAKDELAYDEFAULT 250
|
||||
|
||||
typedef struct config {
|
||||
STRING *name;
|
||||
char defaultaccess;
|
||||
@ -14,8 +16,13 @@ typedef struct config {
|
||||
char *passwdfile;
|
||||
char *primaryport;
|
||||
FLAG redirect;
|
||||
FLAG loghostnames;
|
||||
int reinitcheck;
|
||||
char *secondaryport;
|
||||
char *unifiedlog;
|
||||
#if HAVE_SETPROCTITLE
|
||||
FLAG setproctitle;
|
||||
#endif
|
||||
#if HAVE_OPENSSL
|
||||
char *sslcredentials;
|
||||
FLAG sslrequired;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: version.h,v 1.46 2003-09-22 10:41:28-07 bryan Exp $
|
||||
* $Id: version.h,v 1.55 2003/12/10 18:33:48 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -14,4 +14,4 @@
|
||||
@(#) Copyright 2000 conserver.com.\n\
|
||||
All rights reserved.\n"
|
||||
|
||||
#define THIS_VERSION "conserver.com version 8.0.0"
|
||||
#define THIS_VERSION "conserver.com version 8.0.9"
|
||||
|
@ -15,7 +15,7 @@ MKDIR = @MKDIR@
|
||||
|
||||
### Compiler and link options
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@ # -DPUCC -DSUN5
|
||||
CFLAGS = @CFLAGS@
|
||||
DEFS = @DEFS@ -DSYSCONFDIR=\"$(sysconfdir)\"
|
||||
CPPFLAGS = -I.. -I$(top_srcdir) -I$(srcdir) -I$(top_srcdir)/conserver $(DEFS) @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
@ -25,18 +25,23 @@ LIBS = @LIBS@
|
||||
|
||||
### Makefile rules - no user-servicable parts below
|
||||
|
||||
CONSOLE_OBJS = console.o getpassword.o ../conserver/util.o
|
||||
CONSOLE_HDRS = ../config.h $(top_srcdir)/compat.h $(top_srcdir)/conserver/port.h
|
||||
CONSOLE_OBJS = console.o getpassword.o ../conserver/cutil.o
|
||||
CONSOLE_HDRS = ../config.h $(top_srcdir)/compat.h \
|
||||
$(top_srcdir)/conserver/cutil.h \
|
||||
$(top_srcdir)/conserver/version.h \
|
||||
$(srcdir)/getpassword.h
|
||||
ALL = console
|
||||
|
||||
|
||||
all: $(ALL)
|
||||
|
||||
$(CONSOLE_OBJS): $(CONSOLE_HDRS)
|
||||
|
||||
console: $(CONSOLE_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o console $(CONSOLE_OBJS) $(LIBS)
|
||||
|
||||
../conserver/util.o:
|
||||
( cd ../conserver && $(MAKE) $(MAKE_FLAGS) util.o ) || exit 1;
|
||||
../conserver/cutil.o:
|
||||
( cd ../conserver && $(MAKE) $(MAKE_FLAGS) cutil.o ) || exit 1;
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: console.c,v 5.137 2003-09-22 08:23:57-07 bryan Exp $
|
||||
* $Id: console.c,v 5.152 2003/11/28 00:47:30 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -32,7 +32,7 @@
|
||||
#include <pwd.h>
|
||||
|
||||
#include <getpassword.h>
|
||||
#include <util.h>
|
||||
#include <cutil.h>
|
||||
#include <version.h>
|
||||
#if HAVE_OPENSSL
|
||||
#include <openssl/ssl.h>
|
||||
@ -54,8 +54,9 @@ unsigned short bindPort;
|
||||
CONSFILE *cfstdout;
|
||||
char *pcUser = (char *)0;
|
||||
int disconnectCount = 0;
|
||||
|
||||
static char acMesg[8192]; /* the buffer for startup negotiation */
|
||||
STRING *execCmd = (STRING *)0;
|
||||
CONSFILE *execCmdFile = (CONSFILE *)0;
|
||||
pid_t execCmdPid = 0;
|
||||
|
||||
#if HAVE_OPENSSL
|
||||
SSL_CTX *ctx = (SSL_CTX *)0;
|
||||
@ -71,26 +72,26 @@ SetupSSL()
|
||||
SSL_load_error_strings();
|
||||
if (!SSL_library_init()) {
|
||||
Error("SSL library initialization failed");
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
if ((ctx = SSL_CTX_new(SSLv23_method())) == (SSL_CTX *)0) {
|
||||
Error("Creating SSL context failed");
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
if (SSL_CTX_set_default_verify_paths(ctx) != 1) {
|
||||
Error("Could not load SSL default CA file and/or directory");
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
if (pcCredFile != (char *)0) {
|
||||
if (SSL_CTX_use_certificate_chain_file(ctx, pcCredFile) != 1) {
|
||||
Error("Could not load SSL certificate from '%s'",
|
||||
pcCredFile);
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
if (SSL_CTX_use_PrivateKey_file
|
||||
(ctx, pcCredFile, SSL_FILETYPE_PEM) != 1) {
|
||||
Error("Could not SSL private key from '%s'", pcCredFile);
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, SSLVerifyCallback);
|
||||
@ -104,7 +105,7 @@ SetupSSL()
|
||||
if (SSL_CTX_set_cipher_list(ctx, "ALL:!LOW:!EXP:!MD5:@STRENGTH") !=
|
||||
1) {
|
||||
Error("Setting SSL cipher list failed");
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -121,11 +122,11 @@ AttemptSSL(pcf)
|
||||
|
||||
if (ctx == (SSL_CTX *)0) {
|
||||
Error("WTF? The SSL context disappeared?!?!?");
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
if (!(ssl = SSL_new(ctx))) {
|
||||
Error("Couldn't create new SSL context");
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
FileSetSSL(pcf, ssl);
|
||||
SSL_set_fd(ssl, FileFDNum(pcf));
|
||||
@ -133,7 +134,7 @@ AttemptSSL(pcf)
|
||||
if (SSL_connect(ssl) <= 0) {
|
||||
Error("SSL negotiation failed");
|
||||
ERR_print_errors_fp(stderr);
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
FileSetType(pcf, SSLSocket);
|
||||
CONDDEBUG((1, "SSL Connection: %s :: %s", SSL_get_cipher_version(ssl),
|
||||
@ -141,15 +142,6 @@ AttemptSSL(pcf)
|
||||
}
|
||||
#endif
|
||||
|
||||
void
|
||||
#if PROTOTYPES
|
||||
DestroyDataStructures(void)
|
||||
#else
|
||||
DestroyDataStructures()
|
||||
#endif
|
||||
{
|
||||
}
|
||||
|
||||
/* output a control (or plain) character as a UNIX user would expect it (ksb)
|
||||
*/
|
||||
static void
|
||||
@ -189,7 +181,7 @@ Usage(wantfull)
|
||||
#endif
|
||||
{
|
||||
static char *full[] = {
|
||||
"7 strip the high bit of all console data",
|
||||
"7 strip the high bit off all console data",
|
||||
"a(A) attach politely (and replay last 20 lines)",
|
||||
"b(B) send broadcast message to all users (on master)",
|
||||
#if HAVE_OPENSSL
|
||||
@ -206,8 +198,8 @@ Usage(wantfull)
|
||||
"E ignored - encryption not compiled into code",
|
||||
#endif
|
||||
"f(F) force read/write connection (and replay)",
|
||||
"i(I) display information in machine-parseable form (on master)",
|
||||
"h output this message",
|
||||
"i(I) display information in machine-parseable form (on master)",
|
||||
"l user use username instead of current username",
|
||||
"M mach master server to poll first",
|
||||
"p port port to connect to",
|
||||
@ -388,7 +380,7 @@ ValidateEsc()
|
||||
}
|
||||
if (c1 > 127 || c2 > 127) {
|
||||
Error("High-bit set in escape sequence: not allowed with -7");
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -408,12 +400,12 @@ ParseEsc(pcText)
|
||||
pcTemp = pcText;
|
||||
if (ParseChar(&pcTemp, &c1) || ParseChar(&pcTemp, &c2)) {
|
||||
Error("poorly formed escape sequence `%s\'", pcText);
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
if ('\000' != *pcTemp) {
|
||||
Error("too many characters in new escape sequence at ...`%s\'",
|
||||
pcTemp);
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
chAttn = c1;
|
||||
chEsc = c2;
|
||||
@ -521,7 +513,7 @@ C2Raw()
|
||||
|
||||
if (0 != tcgetattr(0, &o_tios)) {
|
||||
Error("tcgetattr(0): %s", strerror(errno));
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
n_tios = o_tios;
|
||||
n_tios.c_iflag &= ~(INLCR | IGNCR | ICRNL | IUCLC | IXON);
|
||||
@ -531,7 +523,7 @@ C2Raw()
|
||||
n_tios.c_cc[VTIME] = 0;
|
||||
if (0 != tcsetattr(0, TCSANOW, &n_tios)) {
|
||||
Error("tcsetattr(0, TCSANOW): %s", strerror(errno));
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
screwy = 1;
|
||||
}
|
||||
@ -552,6 +544,16 @@ C2Cooked()
|
||||
screwy = 0;
|
||||
}
|
||||
|
||||
void
|
||||
#if PROTOTYPES
|
||||
DestroyDataStructures(void)
|
||||
#else
|
||||
DestroyDataStructures()
|
||||
#endif
|
||||
{
|
||||
C2Cooked();
|
||||
}
|
||||
|
||||
char *
|
||||
#if PROTOTYPES
|
||||
ReadReply(CONSFILE *fd, int toEOF)
|
||||
@ -579,13 +581,13 @@ ReadReply(fd)
|
||||
break;
|
||||
C2Cooked();
|
||||
Error("lost connection");
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
default:
|
||||
BuildStringN(buf, nr, result);
|
||||
if (toEOF) /* if toEOF, read until EOF */
|
||||
continue;
|
||||
if ((result->used > 1) &&
|
||||
(result->string[result->used - 2] == '\n'))
|
||||
strchr(result->string, '\n') != (char *)0)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
@ -626,15 +628,17 @@ OOB(sig)
|
||||
|
||||
void
|
||||
#if PROTOTYPES
|
||||
ProcessUrgentData(int s)
|
||||
ProcessUrgentData(CONSFILE *pcf)
|
||||
#else
|
||||
ProcessUrgentData(s)
|
||||
int s;
|
||||
ProcessUrgentData(pcf)
|
||||
CONSFILE *pcf;
|
||||
#endif
|
||||
{
|
||||
static char acCmd;
|
||||
int s;
|
||||
|
||||
SawUrg = 0;
|
||||
s = FileFDNum(pcf);
|
||||
|
||||
/* get the pending urgent message
|
||||
*/
|
||||
@ -643,7 +647,7 @@ ProcessUrgentData(s)
|
||||
case EWOULDBLOCK:
|
||||
/* clear any pending input to make room */
|
||||
read(s, &acCmd, 1);
|
||||
write(1, ".", 1);
|
||||
FileWrite(cfstdout, FLAGFALSE, ".", 1);
|
||||
continue;
|
||||
case EINVAL:
|
||||
default:
|
||||
@ -653,23 +657,59 @@ ProcessUrgentData(s)
|
||||
}
|
||||
}
|
||||
switch (acCmd) {
|
||||
case OB_EXEC:
|
||||
FileWrite(cfstdout, FLAGFALSE, "exec: ", 6);
|
||||
BuildString((char *)0, execCmd);
|
||||
for (;;) {
|
||||
char c;
|
||||
if (read(0, &c, 1) == 0)
|
||||
break;
|
||||
if (c == '\n' || c == '\r') {
|
||||
FileWrite(cfstdout, FLAGFALSE, "]\r\n", 3);
|
||||
if (execCmd->used <= 1) {
|
||||
char s = OB_DROP;
|
||||
FileWrite(pcf, FLAGFALSE, &s, 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (c == '\a' || (c >= ' ' && c <= '~')) {
|
||||
BuildStringChar(c, execCmd);
|
||||
FileWrite(cfstdout, FLAGFALSE, &c, 1);
|
||||
} else if ((c == '\b' || c == 0x7f) && execCmd->used > 1) {
|
||||
if (execCmd->string[execCmd->used - 2] != '\a') {
|
||||
FileWrite(cfstdout, FLAGFALSE, "\b \b", 3);
|
||||
}
|
||||
execCmd->string[execCmd->used - 2] = '\000';
|
||||
execCmd->used--;
|
||||
} else if ((c == 0x15) && execCmd->used > 1) {
|
||||
while (execCmd->used > 1) {
|
||||
if (execCmd->string[execCmd->used - 2] != '\a') {
|
||||
FileWrite(cfstdout, FLAGFALSE, "\b \b", 3);
|
||||
}
|
||||
execCmd->string[execCmd->used - 2] = '\000';
|
||||
execCmd->used--;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case OB_SUSP:
|
||||
#if defined(SIGSTOP)
|
||||
write(1, "stop]", 5);
|
||||
FileWrite(cfstdout, FLAGFALSE, "stop]", 5);
|
||||
C2Cooked();
|
||||
kill(getpid(), SIGSTOP);
|
||||
C2Raw();
|
||||
write(1, "[press any character to continue", 32);
|
||||
FileWrite(cfstdout, FLAGFALSE,
|
||||
"[press any character to continue", 32);
|
||||
#else
|
||||
write(1,
|
||||
"stop not supported -- press any character to continue",
|
||||
53);
|
||||
FileWrite(cfstdout, FLAGFALSE,
|
||||
"stop not supported -- press any character to continue",
|
||||
53);
|
||||
#endif
|
||||
break;
|
||||
case OB_DROP:
|
||||
write(1, "dropped by server]\r\n", 20);
|
||||
FileWrite(cfstdout, FLAGFALSE, "dropped by server]\r\n", 20);
|
||||
C2Cooked();
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
/*NOTREACHED*/ default:
|
||||
Error("unknown out of band command `%c\'\r", acCmd);
|
||||
fflush(stderr);
|
||||
@ -677,6 +717,179 @@ ProcessUrgentData(s)
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
#if PROTOTYPES
|
||||
ReapVirt(void)
|
||||
#else
|
||||
ReapVirt()
|
||||
#endif
|
||||
{
|
||||
pid_t pid;
|
||||
int UWbuf;
|
||||
|
||||
while (-1 != (pid = waitpid(-1, &UWbuf, WNOHANG | WUNTRACED))) {
|
||||
if (0 == pid)
|
||||
break;
|
||||
|
||||
/* stopped child is just continued
|
||||
*/
|
||||
if (WIFSTOPPED(UWbuf) && 0 == kill(pid, SIGCONT)) {
|
||||
Msg("child pid %lu: stopped, sending SIGCONT",
|
||||
(unsigned long)pid);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (WIFEXITED(UWbuf))
|
||||
Verbose("child process %lu: exit(%d)", pid,
|
||||
WEXITSTATUS(UWbuf));
|
||||
if (WIFSIGNALED(UWbuf))
|
||||
Verbose("child process %lu: signal(%d)", pid, WTERMSIG(UWbuf));
|
||||
if (pid == execCmdPid) {
|
||||
if (WIFEXITED(UWbuf))
|
||||
FilePrint(cfstdout, FLAGFALSE,
|
||||
"[local command terminated - pid %lu: exit(%d)]\r\n",
|
||||
pid, WEXITSTATUS(UWbuf));
|
||||
if (WIFSIGNALED(UWbuf))
|
||||
FilePrint(cfstdout, FLAGFALSE,
|
||||
"[local command terminated - pid %lu: signal(%d)]\r\n",
|
||||
pid, WTERMSIG(UWbuf));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static sig_atomic_t fSawReapVirt = 0;
|
||||
|
||||
#if HAVE_SIGACTION
|
||||
static
|
||||
#endif
|
||||
RETSIGTYPE
|
||||
#if PROTOTYPES
|
||||
FlagReapVirt(int sig)
|
||||
#else
|
||||
FlagReapVirt(sig)
|
||||
int sig;
|
||||
#endif
|
||||
{
|
||||
fSawReapVirt = 1;
|
||||
#if !HAVE_SIGACTION
|
||||
SimpleSignal(SIGCHLD, FlagReapVirt);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* invoke the execcmd command */
|
||||
void
|
||||
#if PROTOTYPES
|
||||
ExecCmd(void)
|
||||
#else
|
||||
ExecCmd()
|
||||
#endif
|
||||
{
|
||||
int i;
|
||||
pid_t iNewGrp;
|
||||
extern char **environ;
|
||||
int pin[2];
|
||||
int pout[2];
|
||||
static char *apcArgv[] = {
|
||||
"/bin/sh", "-ce", (char *)0, (char *)0
|
||||
};
|
||||
|
||||
if (execCmd == (STRING *)0 || execCmd->used <= 1)
|
||||
return;
|
||||
|
||||
CONDDEBUG((1, "ExecCmd(): `%s'", execCmd->string));
|
||||
|
||||
/* pin[0] = parent read, pin[1] = child write */
|
||||
if (pipe(pin) != 0) {
|
||||
Error("ExecCmd(): pipe(): %s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
/* pout[0] = child read, pout[l] = parent write */
|
||||
if (pipe(pout) != 0) {
|
||||
close(pin[0]);
|
||||
close(pin[1]);
|
||||
Error("ExecCmd(): pipe(): %s", strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
|
||||
switch (execCmdPid = fork()) {
|
||||
case -1:
|
||||
return;
|
||||
case 0:
|
||||
thepid = getpid();
|
||||
break;
|
||||
default:
|
||||
close(pout[0]);
|
||||
close(pin[1]);
|
||||
if ((execCmdFile =
|
||||
FileOpenPipe(pin[0], pout[1])) == (CONSFILE *)0) {
|
||||
Error("ExecCmd(): FileOpenPipe(%d,%d) failed", pin[0],
|
||||
pout[1]);
|
||||
close(pin[0]);
|
||||
close(pout[1]);
|
||||
kill(execCmdPid, SIGHUP);
|
||||
return;
|
||||
}
|
||||
FilePrint(cfstdout, FLAGFALSE,
|
||||
"[local command running - pid %lu]\r\n", execCmdPid);
|
||||
FD_SET(pin[0], &rinit);
|
||||
if (maxfd < pin[0] + 1)
|
||||
maxfd = pin[0] + 1;
|
||||
fflush(stderr);
|
||||
return;
|
||||
}
|
||||
|
||||
close(pin[0]);
|
||||
close(pout[1]);
|
||||
|
||||
/* put the signals back that we ignore (trapped auto-reset to default)
|
||||
*/
|
||||
#if defined(SIGURG)
|
||||
SimpleSignal(SIGURG, SIG_DFL);
|
||||
#endif
|
||||
SimpleSignal(SIGPIPE, SIG_DFL);
|
||||
SimpleSignal(SIGCHLD, SIG_DFL);
|
||||
|
||||
/* setup new process with clean file descriptors
|
||||
* stderr still goes to stderr...so user sees it
|
||||
*/
|
||||
i = GetMaxFiles();
|
||||
for ( /* i above */ ; --i > 3;) {
|
||||
if (i != pout[0] && i != pin[1])
|
||||
close(i);
|
||||
}
|
||||
close(1);
|
||||
close(0);
|
||||
|
||||
# if HAVE_SETSID
|
||||
iNewGrp = setsid();
|
||||
if (-1 == iNewGrp) {
|
||||
Error("ExecCmd(): setsid(): %s", strerror(errno));
|
||||
iNewGrp = getpid();
|
||||
}
|
||||
# else
|
||||
iNewGrp = getpid();
|
||||
# endif
|
||||
|
||||
if (dup(pout[0]) != 0 || dup(pin[1]) != 1) {
|
||||
Error("ExecCmd(): fd sync error");
|
||||
Bye(EX_OSERR);
|
||||
}
|
||||
close(pout[0]);
|
||||
close(pin[1]);
|
||||
|
||||
tcsetpgrp(0, iNewGrp);
|
||||
|
||||
apcArgv[2] = execCmd->string;
|
||||
|
||||
execve(apcArgv[0], apcArgv, environ);
|
||||
Error("ExecCmd(): execve(%s): %s", apcArgv[2], strerror(errno));
|
||||
Bye(EX_OSERR);
|
||||
return;
|
||||
}
|
||||
|
||||
/* interact with a group server (ksb)
|
||||
*/
|
||||
static int
|
||||
@ -691,9 +904,11 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result)
|
||||
{
|
||||
int nc;
|
||||
int fIn = '-';
|
||||
fd_set rmask, rinit;
|
||||
fd_set rmask, wmask;
|
||||
int i;
|
||||
int justProcessedUrg = 0;
|
||||
char *r = (char *)0;
|
||||
static char acMesg[8192];
|
||||
|
||||
if (fVerbose) {
|
||||
Msg("%s to %s (on %s)", pcHow, pcMach, pcMaster);
|
||||
@ -722,6 +937,7 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result)
|
||||
#if defined(SIGURG)
|
||||
SimpleSignal(SIGURG, OOB);
|
||||
#endif
|
||||
SimpleSignal(SIGCHLD, FlagReapVirt);
|
||||
|
||||
/* if we are going for a particular console
|
||||
* send sign-on stuff, then wait for some indication of what mode
|
||||
@ -735,14 +951,15 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result)
|
||||
/* OK -- we are good as gold */
|
||||
fIn = 'a';
|
||||
} else if (0 == strcmp(result, "[spy]\r\n") ||
|
||||
0 == strcmp(result, "[ok]\r\n")) {
|
||||
0 == strcmp(result, "[ok]\r\n") ||
|
||||
0 == strcmp(result, "[read-only -- initializing]\r\n")) {
|
||||
/* Humph, someone else is on
|
||||
* or we have an old version of the server (4.X)
|
||||
*/
|
||||
fIn = 's';
|
||||
} else if (0 == strcmp(result, "[host is read-only]\r\n")) {
|
||||
} else if (0 == strcmp(result, "[console is read-only]\r\n")) {
|
||||
fIn = 'r';
|
||||
} else if (0 == strcmp(result, "[line to host is down]\r\n")) {
|
||||
} else if (0 == strcmp(result, "[line to console is down]\r\n")) {
|
||||
/* ouch, the machine is down on the server */
|
||||
fIn = '-';
|
||||
Error("%s is down", pcMach);
|
||||
@ -752,18 +969,9 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result)
|
||||
PutCtlc(chEsc, stdout);
|
||||
printf("o\' to open console line]\n");
|
||||
}
|
||||
} else if (0 == strcmp(result, "[no -- on ctl]\r\n")) {
|
||||
fIn = '-';
|
||||
Error("%s is a control port", pcMach);
|
||||
if (fVerbose) {
|
||||
printf("[use `");
|
||||
PutCtlc(chAttn, stdout);
|
||||
PutCtlc(chEsc, stdout);
|
||||
printf(";\' to open a console line]\n");
|
||||
}
|
||||
} else {
|
||||
FilePrint(cfstdout, "%s: %s", pcMach, result);
|
||||
exit(EX_UNAVAILABLE);
|
||||
FilePrint(cfstdout, FLAGFALSE, "%s: %s", pcMach, result);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
|
||||
/* change escape sequence (if set on the command line)
|
||||
@ -773,17 +981,15 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result)
|
||||
chAttn = DEFATTN;
|
||||
chEsc = DEFESC;
|
||||
} else {
|
||||
char *r;
|
||||
/* tell the conserver to change escape sequences, assume OK
|
||||
* (we'll find out soon enough)
|
||||
*/
|
||||
sprintf(acMesg, "%c%ce%c%c", DEFATTN, DEFESC, chAttn, chEsc);
|
||||
FileWrite(pcf, acMesg, 5);
|
||||
/* -bryan */
|
||||
FilePrint(pcf, FLAGFALSE, "%c%ce%c%c", DEFATTN, DEFESC, chAttn,
|
||||
chEsc);
|
||||
r = ReadReply(pcf, 0);
|
||||
if (strncmp(r, "[redef:", 7) != 0) {
|
||||
Error("protocol botch on redef of escape sequence");
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -792,6 +998,19 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result)
|
||||
PutCtlc(chEsc, stdout);
|
||||
printf("?\' for help]\n");
|
||||
|
||||
/* try and display the MOTD */
|
||||
FilePrint(pcf, FLAGFALSE, "%c%cm", chAttn, chEsc);
|
||||
r = ReadReply(pcf, 0);
|
||||
if (strncmp(r, "[unknown", 8) != 0 &&
|
||||
strncmp(r, "[-- MOTD --]", 12) != 0)
|
||||
FileWrite(cfstdout, FLAGFALSE, r, -1);
|
||||
|
||||
FilePrint(pcf, FLAGFALSE, "%c%c;", chAttn, chEsc);
|
||||
r = ReadReply(pcf, 0);
|
||||
if (strncmp(r, "[unknown", 8) != 0 &&
|
||||
strncmp(r, "[connected]", 11) != 0)
|
||||
FileWrite(cfstdout, FLAGFALSE, r, -1);
|
||||
|
||||
/* if the host is not down, finish the connection, and force
|
||||
* the correct attachment for the user
|
||||
*/
|
||||
@ -801,15 +1020,12 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result)
|
||||
Error("%s is read-only", pcMach);
|
||||
}
|
||||
} else if (fIn != (*pcHow == 'f' ? 'a' : *pcHow)) {
|
||||
sprintf(acMesg, "%c%c%c", chAttn, chEsc, *pcHow);
|
||||
FileWrite(pcf, acMesg, 3);
|
||||
FilePrint(pcf, FLAGFALSE, "%c%c%c", chAttn, chEsc, *pcHow);
|
||||
}
|
||||
if (fReplay) {
|
||||
sprintf(acMesg, "%c%cr", chAttn, chEsc);
|
||||
FileWrite(pcf, acMesg, 3);
|
||||
FilePrint(pcf, FLAGFALSE, "%c%cr", chAttn, chEsc);
|
||||
} else if (fVerbose) {
|
||||
sprintf(acMesg, "%c%c\022", chAttn, chEsc);
|
||||
FileWrite(pcf, acMesg, 3);
|
||||
FilePrint(pcf, FLAGFALSE, "%c%c\022", chAttn, chEsc);
|
||||
}
|
||||
}
|
||||
fflush(stdout);
|
||||
@ -817,12 +1033,16 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result)
|
||||
|
||||
C2Raw();
|
||||
|
||||
/* set socket to non-blocking */
|
||||
SetFlags(FileFDNum(pcf), O_NONBLOCK, 0);
|
||||
|
||||
/* read from stdin and the socket (non-blocking!).
|
||||
* rmask indicates which descriptors to read from,
|
||||
* the others are not used, nor is the result from
|
||||
* select, read, or write.
|
||||
*/
|
||||
FD_ZERO(&rinit);
|
||||
FD_ZERO(&winit);
|
||||
FD_SET(FileFDNum(pcf), &rinit);
|
||||
FD_SET(0, &rinit);
|
||||
if (maxfd < FileFDNum(pcf) + 1)
|
||||
@ -830,14 +1050,46 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result)
|
||||
for (;;) {
|
||||
justProcessedUrg = 0;
|
||||
if (SawUrg) {
|
||||
ProcessUrgentData(FileFDNum(pcf));
|
||||
ProcessUrgentData(pcf);
|
||||
justProcessedUrg = 1;
|
||||
}
|
||||
if (execCmd != (STRING *)0 && execCmd->used > 1) {
|
||||
char *r;
|
||||
char s = OB_EXEC;
|
||||
ExecCmd();
|
||||
BuildString((char *)0, execCmd);
|
||||
if (execCmdFile == (CONSFILE *)0) { /* exec failed */
|
||||
s = OB_DROP;
|
||||
FileWrite(pcf, FLAGFALSE, &s, 1); /* say forget it */
|
||||
} else {
|
||||
/* go back to blocking mode */
|
||||
SetFlags(FileFDNum(pcf), 0, O_NONBLOCK);
|
||||
FileWrite(pcf, FLAGFALSE, &s, 1); /* say we're ready */
|
||||
r = ReadReply(pcf, 0);
|
||||
/* now back to non-blocking now that we've got reply */
|
||||
SetFlags(FileFDNum(pcf), O_NONBLOCK, 0);
|
||||
/* if we aren't still r/w, abort */
|
||||
if (strncmp(r, "[rw]", 4) != 0) {
|
||||
FileWrite(cfstdout, FLAGFALSE,
|
||||
"[no longer read-write - aborting command]\r\n",
|
||||
-1);
|
||||
FD_CLR(FileFDNum(execCmdFile), &rinit);
|
||||
FD_CLR(FileFDOutNum(execCmdFile), &winit);
|
||||
FileClose(&execCmdFile);
|
||||
kill(execCmdPid, SIGHUP);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fSawReapVirt) {
|
||||
fSawReapVirt = 0;
|
||||
ReapVirt();
|
||||
}
|
||||
/* reset read mask and select on it
|
||||
*/
|
||||
rmask = rinit;
|
||||
wmask = winit;
|
||||
if (-1 ==
|
||||
select(maxfd, &rmask, (fd_set *)0, (fd_set *)0,
|
||||
select(maxfd, &rmask, &wmask, (fd_set *)0,
|
||||
(struct timeval *)0)) {
|
||||
if (errno != EINTR) {
|
||||
Error("Master(): select(): %s", strerror(errno));
|
||||
@ -846,8 +1098,34 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result)
|
||||
continue;
|
||||
}
|
||||
|
||||
/* anything from execCmd */
|
||||
if (execCmdFile != (CONSFILE *)0) {
|
||||
if (FileCanRead(execCmdFile, &rmask, &wmask)) {
|
||||
if ((nc =
|
||||
FileRead(execCmdFile, acMesg, sizeof(acMesg))) < 0) {
|
||||
FD_CLR(FileFDNum(execCmdFile), &rinit);
|
||||
FD_CLR(FileFDOutNum(execCmdFile), &winit);
|
||||
FileClose(&execCmdFile);
|
||||
} else {
|
||||
if (fStrip) {
|
||||
for (i = 0; i < nc; ++i)
|
||||
acMesg[i] &= 127;
|
||||
}
|
||||
FileWrite(pcf, FLAGFALSE, acMesg, nc);
|
||||
}
|
||||
} else if (!FileBufEmpty(execCmdFile) &&
|
||||
FileCanWrite(execCmdFile, &rmask, &wmask)) {
|
||||
CONDDEBUG((1, "CallUp(): flushing fd %d",
|
||||
FileFDNum(execCmdFile)));
|
||||
if (FileWrite(execCmdFile, FLAGFALSE, (char *)0, 0) < 0) {
|
||||
/* -bryan */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* anything from socket? */
|
||||
if (FD_ISSET(FileFDNum(pcf), &rmask)) {
|
||||
if (FileCanRead(pcf, &rmask, &wmask)) {
|
||||
if ((nc = FileRead(pcf, acMesg, sizeof(acMesg))) < 0) {
|
||||
/* if we got an error/eof after returning from suspend */
|
||||
if (justProcessedUrg) {
|
||||
@ -860,7 +1138,16 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result)
|
||||
for (i = 0; i < nc; ++i)
|
||||
acMesg[i] &= 127;
|
||||
}
|
||||
FileWrite(cfstdout, acMesg, nc);
|
||||
FileWrite(cfstdout, FLAGFALSE, acMesg, nc);
|
||||
if (execCmdFile != (CONSFILE *)0) {
|
||||
FileWrite(execCmdFile, FLAGFALSE, acMesg, nc);
|
||||
}
|
||||
} else if (!FileBufEmpty(pcf) && FileCanWrite(pcf, &rmask, &wmask)) {
|
||||
CONDDEBUG((1, "CallUp(): flushing fd %d", FileFDNum(pcf)));
|
||||
if (FileWrite(pcf, FLAGFALSE, (char *)0, 0) < 0) {
|
||||
/* -bryan */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* anything from stdin? */
|
||||
@ -873,11 +1160,31 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (fStrip) {
|
||||
for (i = 0; i < nc; ++i)
|
||||
acMesg[i] &= 127;
|
||||
if (execCmdFile == (CONSFILE *)0) {
|
||||
if (fStrip) {
|
||||
for (i = 0; i < nc; ++i)
|
||||
acMesg[i] &= 127;
|
||||
}
|
||||
FileWrite(pcf, FLAGFALSE, acMesg, nc);
|
||||
} else {
|
||||
for (i = 0; i < nc; ++i) {
|
||||
if (acMesg[i] == '\n' || acMesg[i] == '\r')
|
||||
FilePrint(cfstdout, FLAGFALSE,
|
||||
"[local command running - pid %lu]\r\n",
|
||||
execCmdPid);
|
||||
else if (acMesg[i] == 0x03) { /* ctrl-c */
|
||||
kill(execCmdPid, SIGHUP);
|
||||
FilePrint(cfstdout, FLAGFALSE,
|
||||
"[local command sent SIGHUP - pid %lu]\r\n",
|
||||
execCmdPid);
|
||||
} else if (acMesg[i] == 0x1c) { /* ctrl-\ */
|
||||
kill(execCmdPid, SIGKILL);
|
||||
FilePrint(cfstdout, FLAGFALSE,
|
||||
"[local command sent SIGKILL - pid %lu]\r\n",
|
||||
execCmdPid);
|
||||
}
|
||||
}
|
||||
}
|
||||
FileWrite(pcf, acMesg, nc);
|
||||
}
|
||||
}
|
||||
C2Cooked();
|
||||
@ -951,11 +1258,11 @@ DoCmds(master, ports, cmdi)
|
||||
t = ReadReply(pcf, 0);
|
||||
if (strcmp(t, "ok\r\n") != 0) {
|
||||
FileClose(&pcf);
|
||||
FilePrint(cfstdout, "%s: %s", server, t);
|
||||
FilePrint(cfstdout, FLAGFALSE, "%s: %s", server, t);
|
||||
continue;
|
||||
}
|
||||
#if HAVE_OPENSSL
|
||||
FileWrite(pcf, "ssl\r\n", 5);
|
||||
FileWrite(pcf, FLAGFALSE, "ssl\r\n", 5);
|
||||
t = ReadReply(pcf, 0);
|
||||
if (strcmp(t, "ok\r\n") == 0) {
|
||||
AttemptSSL(pcf);
|
||||
@ -967,36 +1274,42 @@ DoCmds(master, ports, cmdi)
|
||||
}
|
||||
#endif
|
||||
|
||||
BuildTmpString((char *)0);
|
||||
BuildTmpString("login ");
|
||||
BuildTmpString(pcUser);
|
||||
t = BuildTmpString("\r\n");
|
||||
FileWrite(pcf, t, -1);
|
||||
FilePrint(pcf, FLAGFALSE, "login %s\r\n", pcUser);
|
||||
|
||||
t = ReadReply(pcf, 0);
|
||||
if (strcmp(t, "passwd?\r\n") == 0) {
|
||||
if (strncmp(t, "passwd?", 7) == 0) {
|
||||
static int count = 0;
|
||||
static STRING *tmpString = (STRING *)0;
|
||||
char *hostname = (char *)0;
|
||||
|
||||
if (t[7] == ' ') {
|
||||
hostname = PruneSpace(t + 7);
|
||||
if (*hostname == '\000')
|
||||
hostname = server;
|
||||
} else
|
||||
hostname = server;
|
||||
if (tmpString == (STRING *)0)
|
||||
tmpString = AllocString();
|
||||
if (tmpString->used <= 1) {
|
||||
char *pass;
|
||||
sprintf(acMesg, "Enter %s@%s's password: ", pcUser,
|
||||
master);
|
||||
pass = GetPassword(acMesg);
|
||||
BuildStringPrint(tmpString, "Enter %s@%s's password: ",
|
||||
pcUser, hostname);
|
||||
pass = GetPassword(tmpString->string);
|
||||
if (pass == (char *)0) {
|
||||
Error("could not get password from tty for `%s'",
|
||||
server);
|
||||
FileClose(&pcf);
|
||||
continue;
|
||||
}
|
||||
BuildString((char *)0, tmpString);
|
||||
BuildString(pass, tmpString);
|
||||
BuildString("\r\n", tmpString);
|
||||
}
|
||||
FileWrite(pcf, tmpString->string, tmpString->used - 1);
|
||||
FileWrite(pcf, FLAGFALSE, tmpString->string,
|
||||
tmpString->used - 1);
|
||||
t = ReadReply(pcf, 0);
|
||||
if (strcmp(t, "ok\r\n") != 0) {
|
||||
FilePrint(cfstdout, "%s: %s", server, t);
|
||||
FilePrint(cfstdout, FLAGFALSE, "%s: %s", server, t);
|
||||
if (++count < 3) {
|
||||
BuildString((char *)0, tmpString);
|
||||
goto attemptLogin;
|
||||
@ -1014,9 +1327,9 @@ DoCmds(master, ports, cmdi)
|
||||
* have an arg (always true if it's 'call'), then send the arg
|
||||
*/
|
||||
if ((cmdi == 0 || cmds[cmdi][0] == 'c') && cmdarg != (char *)0)
|
||||
FilePrint(pcf, "%s %s\r\n", cmds[cmdi], cmdarg);
|
||||
FilePrint(pcf, FLAGFALSE, "%s %s\r\n", cmds[cmdi], cmdarg);
|
||||
else
|
||||
FilePrint(pcf, "%s\r\n", cmds[cmdi]);
|
||||
FilePrint(pcf, FLAGFALSE, "%s\r\n", cmds[cmdi]);
|
||||
|
||||
/* if we haven't gone down the stack, do "normal" stuff.
|
||||
* if we did hit the bottom, we send the exit\r\n now so
|
||||
@ -1025,7 +1338,7 @@ DoCmds(master, ports, cmdi)
|
||||
if (cmdi != 0) {
|
||||
t = ReadReply(pcf, 0);
|
||||
/* save the result */
|
||||
if ((result = strdup(t)) == (char *)0)
|
||||
if ((result = StrDup(t)) == (char *)0)
|
||||
OutOfMem();
|
||||
}
|
||||
|
||||
@ -1036,10 +1349,10 @@ DoCmds(master, ports, cmdi)
|
||||
static int limit = 0;
|
||||
if (limit++ > 10) {
|
||||
Error("forwarding level too deep!");
|
||||
exit(EX_SOFTWARE);
|
||||
Bye(EX_SOFTWARE);
|
||||
}
|
||||
} else if (result[0] != '[') { /* did we not get a connection? */
|
||||
FilePrint(cfstdout, "%s: %s", server, result);
|
||||
FilePrint(cfstdout, FLAGFALSE, "%s: %s", server, result);
|
||||
FileClose(&pcf);
|
||||
continue;
|
||||
} else {
|
||||
@ -1053,20 +1366,20 @@ DoCmds(master, ports, cmdi)
|
||||
}
|
||||
} else if (cmds[cmdi][0] == 'q') {
|
||||
t = ReadReply(pcf, 0);
|
||||
FileWrite(cfstdout, t, -1);
|
||||
FileWrite(cfstdout, FLAGFALSE, t, -1);
|
||||
if (t[0] != 'o' || t[1] != 'k') {
|
||||
FileWrite(pcf, "exit\r\n", 6);
|
||||
FileWrite(pcf, FLAGFALSE, "exit\r\n", 6);
|
||||
t = ReadReply(pcf, 1);
|
||||
}
|
||||
} else {
|
||||
/* all done */
|
||||
FileWrite(pcf, "exit\r\n", 6);
|
||||
FileWrite(pcf, FLAGFALSE, "exit\r\n", 6);
|
||||
t = ReadReply(pcf, cmdi == 0 ? 1 : 0);
|
||||
|
||||
if (cmdi == 0) {
|
||||
int len;
|
||||
/* if we hit bottom, this is where we get our results */
|
||||
if ((result = strdup(t)) == (char *)0)
|
||||
if ((result = StrDup(t)) == (char *)0)
|
||||
OutOfMem();
|
||||
len = strlen(result);
|
||||
if (len > 8 &&
|
||||
@ -1080,9 +1393,9 @@ DoCmds(master, ports, cmdi)
|
||||
*/
|
||||
if (cmds[0][0] == 'd') {
|
||||
if (result[0] != 'o' || result[1] != 'k') {
|
||||
FileWrite(cfstdout, server, -1);
|
||||
FileWrite(cfstdout, ": ", 2);
|
||||
FileWrite(cfstdout, result, len);
|
||||
FileWrite(cfstdout, FLAGTRUE, server, -1);
|
||||
FileWrite(cfstdout, FLAGTRUE, ": ", 2);
|
||||
FileWrite(cfstdout, FLAGFALSE, result, len);
|
||||
} else {
|
||||
disconnectCount += atoi(result + 19);
|
||||
}
|
||||
@ -1090,10 +1403,10 @@ DoCmds(master, ports, cmdi)
|
||||
(result[0] != 'o' || result[1] != 'k')) {
|
||||
/* did a 'master' before this or doing a 'disconnect' */
|
||||
if (cmds[1][0] == 'm' || cmds[0][0] == 'd') {
|
||||
FileWrite(cfstdout, server, -1);
|
||||
FileWrite(cfstdout, ": ", 2);
|
||||
FileWrite(cfstdout, FLAGTRUE, server, -1);
|
||||
FileWrite(cfstdout, FLAGTRUE, ": ", 2);
|
||||
}
|
||||
FileWrite(cfstdout, result, len);
|
||||
FileWrite(cfstdout, FLAGFALSE, result, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1260,11 +1573,11 @@ main(argc, argv)
|
||||
BuildString((char *)0, textMsg);
|
||||
if (optarg == (char *)0 || *optarg == '\000') {
|
||||
Error("no destination specified for -t", optarg);
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
} else if (strchr(optarg, ' ') != (char *)0) {
|
||||
Error("-t option cannot contain a space: `%s'",
|
||||
optarg);
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
BuildString("textmsg ", textMsg);
|
||||
BuildString(optarg, textMsg);
|
||||
@ -1296,21 +1609,21 @@ main(argc, argv)
|
||||
|
||||
case 'h': /* huh? */
|
||||
Usage(1);
|
||||
exit(EX_OK);
|
||||
Bye(EX_OK);
|
||||
|
||||
case '\?': /* huh? */
|
||||
Usage(0);
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
|
||||
default:
|
||||
Error("option %c needs a parameter", optopt);
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
}
|
||||
|
||||
if (fVersion) {
|
||||
Version();
|
||||
exit(EX_OK);
|
||||
Bye(EX_OK);
|
||||
}
|
||||
|
||||
/* finish resolving the command to do */
|
||||
@ -1321,20 +1634,20 @@ main(argc, argv)
|
||||
if (*pcCmd == 'a' || *pcCmd == 'f' || *pcCmd == 's') {
|
||||
if (optind >= argc) {
|
||||
Error("missing console name");
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
cmdarg = argv[optind++];
|
||||
} else if (*pcCmd == 't') {
|
||||
if (optind >= argc) {
|
||||
Error("missing message text");
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
cmdarg = argv[optind++];
|
||||
}
|
||||
|
||||
if (optind < argc) {
|
||||
Error("extra garbage on command line? (%s...)", argv[optind]);
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
|
||||
/* if we somehow lost the port (or got an empty string), reset */
|
||||
@ -1353,8 +1666,8 @@ main(argc, argv)
|
||||
/* non-numeric only */
|
||||
struct servent *pSE;
|
||||
if ((pSE = getservbyname(pcPort, "tcp")) == (struct servent *)0) {
|
||||
Error("getservbyname(%s): %s", pcPort, strerror(errno));
|
||||
exit(EX_UNAVAILABLE);
|
||||
Error("getservbyname(%s) failed", pcPort);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
} else {
|
||||
bindPort = ntohs((u_short) pSE->s_port);
|
||||
}
|
||||
@ -1367,19 +1680,21 @@ main(argc, argv)
|
||||
Error
|
||||
("$LOGNAME and $USER do not exist and getpwuid fails: %d: %s",
|
||||
(int)(getuid()), strerror(errno));
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
if (pcUser == (char *)0) {
|
||||
if (pwdMe->pw_name == (char *)0 || pwdMe->pw_name[0] == '\000') {
|
||||
Error("Username for uid %d does not exist",
|
||||
(int)(getuid()));
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
} else {
|
||||
pcUser = pwdMe->pw_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (execCmd == (STRING *)0)
|
||||
execCmd = AllocString();
|
||||
|
||||
SimpleSignal(SIGPIPE, SIG_IGN);
|
||||
|
||||
@ -1412,7 +1727,9 @@ main(argc, argv)
|
||||
retval = DoCmds(pcInMaster, acPorts->string, cmdi);
|
||||
|
||||
if (*pcCmd == 'd')
|
||||
FilePrint(cfstdout, "Disconnected %d users\n", disconnectCount);
|
||||
FilePrint(cfstdout, FLAGFALSE, "Disconnected %d users\n",
|
||||
disconnectCount);
|
||||
|
||||
exit(retval);
|
||||
Bye(retval);
|
||||
return 0; /* noop - Bye() terminates us */
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
.\" $Id: console.man,v 1.33 2003-09-22 08:21:31-07 bryan Exp $
|
||||
.TH CONSOLE 1 "2003-09-22" "conserver-8.0.0" "conserver"
|
||||
.\" $Id: console.man,v 1.41 2003/11/28 00:47:30 bryan Exp $
|
||||
.TH CONSOLE 1 "2003/11/28" "conserver-8.0.9" "conserver"
|
||||
.SH NAME
|
||||
console \- console server client program
|
||||
.SH SYNOPSIS
|
||||
@ -259,7 +259,7 @@ attached to
|
||||
.IR console ).
|
||||
.TP
|
||||
.B \-u
|
||||
Show a list of all consoles with status (`up' or `down')
|
||||
Show a list of all consoles with status (`up', `down', or `init')
|
||||
and attached users
|
||||
.RI ( user @ host
|
||||
if attached read-write, `<spies>' if only users in spy mode, or `<none>').
|
||||
@ -302,7 +302,7 @@ were typed).
|
||||
.PP
|
||||
The
|
||||
.B \-i
|
||||
option outputs information regarding each console in 12 colon-separated fields.
|
||||
option outputs information regarding each console in 15 colon-separated fields.
|
||||
.TP
|
||||
.I name
|
||||
The name of the console.
|
||||
@ -318,7 +318,7 @@ a command, or `!' for a remote port.
|
||||
.TP
|
||||
.I console-details
|
||||
The details regarding the console.
|
||||
The values here (all comma seperated) depend on the type of the console.
|
||||
The values here (all comma separated) depend on the type of the console.
|
||||
Local devices will have values of the device file, baud rate, and
|
||||
file descriptor for the device.
|
||||
Commands will have values of the command, the command's pid, the
|
||||
@ -329,15 +329,15 @@ and file descriptor for the socket connection.
|
||||
.I users-list
|
||||
The details of each user connected to the console.
|
||||
The details for each
|
||||
user are an `@' seperated list of `w', `r', or `s' (for read-write, read-only,
|
||||
user are an `@' separated list of `w', `r', or `s' (for read-write, read-only,
|
||||
or suspended), username, hostname the user is on, the user's idle time,
|
||||
and (for `r' and `s' users only) ``rw'' or ``ro'' (if the user wants
|
||||
read-write mode or not).
|
||||
Each user bundle is seperated by commas.
|
||||
Each user bundle is separated by commas.
|
||||
.TP
|
||||
.I state
|
||||
The state of the console.
|
||||
Values with either be ``up'' or ``down''.
|
||||
Values with either be ``up'', ``down'', or ``init''.
|
||||
.TP
|
||||
.I perm
|
||||
This value will either be ``rw'' or ``ro''.
|
||||
@ -347,7 +347,7 @@ that the server can open the file for read, but not write.
|
||||
.TP
|
||||
.I logfile-details
|
||||
The details regarding the logging for the console.
|
||||
The comma seperated
|
||||
The comma separated
|
||||
values will be the logfile, ``log'' or ``nolog'' (if logging is on
|
||||
or not - toggled via ^EcL), ``act'' or ``noact'' (if activity logging is
|
||||
enabled or not - the `a' timestamp option), the timestamp interval, and
|
||||
@ -362,10 +362,19 @@ is at work, it will have the value of ``autoup'', otherwise it
|
||||
will be ``noautoup''.
|
||||
.TP
|
||||
.I aliases
|
||||
The console aliases are presented in a comma seperated list.
|
||||
The console aliases are presented in a comma separated list.
|
||||
.TP
|
||||
.I options
|
||||
The active options for the console are presented in a comma seperated list.
|
||||
The active options for the console are presented in a comma separated list.
|
||||
.TP
|
||||
.I initcmd
|
||||
The initcmd configuration option for the console.
|
||||
.TP
|
||||
.I idletimeout
|
||||
The idletimeout configuration option for the console.
|
||||
.TP
|
||||
.I idlestring
|
||||
The idlestring configuration option for the console.
|
||||
.SH "ESCAPE SEQUENCES"
|
||||
The connection can be controlled by a two-character escape sequence, followed
|
||||
by a command.
|
||||
@ -399,6 +408,9 @@ forcibly attach read-write
|
||||
.B g
|
||||
group info
|
||||
.TP
|
||||
.B i
|
||||
information dump
|
||||
.TP
|
||||
.B L
|
||||
toggle logging on/off
|
||||
.TP
|
||||
@ -411,6 +423,9 @@ send the break sequence associated with this console
|
||||
.B l1-9
|
||||
send the specific break sequence
|
||||
.TP
|
||||
.B m
|
||||
display the "message of the day"
|
||||
.TP
|
||||
.B o
|
||||
close (if open) and reopen the line (to clear errors (silo overflows))
|
||||
and the log file
|
||||
@ -439,6 +454,9 @@ examine this group's devices and modes
|
||||
.B z
|
||||
suspend this connection
|
||||
.TP
|
||||
.B |
|
||||
attach a local command to the console
|
||||
.TP
|
||||
.B ?
|
||||
display list of commands
|
||||
.TP
|
||||
@ -535,6 +553,9 @@ Never run
|
||||
from within a console connection (unless you set each
|
||||
escape sequence differently).
|
||||
.PP
|
||||
The \-i output can produce more than the stated number of fields of
|
||||
information if the user-provided information has embedded colons.
|
||||
.PP
|
||||
I'm sure there are more, I just don't know where they are.
|
||||
Please let me know if you find any.
|
||||
.SH AUTHORS
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: getpassword.c,v 1.6 2003-09-12 10:36:19-07 bryan Exp $
|
||||
* $Id: getpassword.c,v 1.8 2003/11/20 13:56:41 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
@ -12,7 +12,7 @@
|
||||
|
||||
#include <pwd.h>
|
||||
|
||||
#include <util.h>
|
||||
#include <cutil.h>
|
||||
#include <version.h>
|
||||
|
||||
|
||||
@ -45,7 +45,7 @@ C2Raw(fd)
|
||||
|
||||
if (0 != tcgetattr(fd, &o_tios)) {
|
||||
Error("tcgetattr(%d): %s", fd, strerror(errno));
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
n_tios = o_tios;
|
||||
n_tios.c_iflag &= ~(IUCLC | IXON);
|
||||
@ -55,7 +55,7 @@ C2Raw(fd)
|
||||
n_tios.c_cc[VTIME] = 0;
|
||||
if (0 != tcsetattr(fd, TCSANOW, &n_tios)) {
|
||||
Error("tcsetattr(%d, TCSANOW): %s", fd, strerror(errno));
|
||||
exit(EX_UNAVAILABLE);
|
||||
Bye(EX_UNAVAILABLE);
|
||||
}
|
||||
screwy = 1;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: getpassword.h,v 1.3 2003-09-11 02:10:58-07 bryan Exp $
|
||||
* $Id: getpassword.h,v 1.3 2003/09/11 09:10:58 bryan Exp $
|
||||
*
|
||||
* Copyright conserver.com, 2000
|
||||
*
|
||||
|
@ -1,5 +1,11 @@
|
||||
Various contributions by folks....
|
||||
|
||||
chat
|
||||
Author: Greg Woods <woods@weird.com>
|
||||
Synopsis: A send/expect program...source code from the NetBSD
|
||||
distribution and modified by Greg Woods to work
|
||||
a bit better with conserver
|
||||
|
||||
solaris-package
|
||||
Author: Michael Sullivan <mike@trdlnk.com>
|
||||
Synopsis: Creates a solaris package
|
||||
@ -18,5 +24,5 @@ will be helpful.
|
||||
Bryan Stansell
|
||||
|
||||
#
|
||||
# $Id: README,v 1.3 2002-10-13 19:57:44-07 bryan Exp $
|
||||
# $Id: README,v 1.4 2003/09/29 14:29:37 bryan Exp $
|
||||
#
|
||||
|
52
contrib/chat/Makefile.in
Normal file
52
contrib/chat/Makefile.in
Normal file
@ -0,0 +1,52 @@
|
||||
### Path settings
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
bindir = @bindir@
|
||||
sysconfdir = @sysconfdir@
|
||||
mandir = @mandir@
|
||||
|
||||
### Installation programs and flags
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ -s
|
||||
LN_S = @LN_S@
|
||||
MKDIR = @MKDIR@
|
||||
|
||||
### Compiler and link options
|
||||
CC = @CC@
|
||||
CFLAGS = @CFLAGS@
|
||||
DEFS = @DEFS@
|
||||
CPPFLAGS = -I$(top_srcdir) -I$(srcdir) $(DEFS) @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
@SET_MAKE@
|
||||
|
||||
|
||||
### Makefile rules - no user-servicable parts below
|
||||
|
||||
CHAT_OBJS = chat.o
|
||||
CHAT_HDRS = ../../config.h
|
||||
ALL = chat
|
||||
|
||||
all: $(ALL)
|
||||
|
||||
chat: $(CHAT_OBJS)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o chat $(CHAT_OBJS) $(LIBS)
|
||||
|
||||
.c.o:
|
||||
$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f *~ *.o $(ALL) core
|
||||
|
||||
distclean: clean
|
||||
rm -f Makefile
|
||||
|
||||
install: chat
|
||||
$(MKDIR) $(DESTDIR)$(bindir)
|
||||
$(INSTALL_PROGRAM) chat $(DESTDIR)$(bindir)
|
||||
$(MKDIR) $(DESTDIR)$(mandir)/man1
|
||||
$(INSTALL) chat.man $(DESTDIR)$(mandir)/man1/chat.1
|
||||
|
||||
.PHONY: clean distclean install
|
8
contrib/chat/README
Normal file
8
contrib/chat/README
Normal file
@ -0,0 +1,8 @@
|
||||
Information from Greg Woods <woods@weird.com>:
|
||||
|
||||
This version of "chat" is derived from the NetBSD variant found in
|
||||
/usr/src/usr.sbin/pppd/chat.
|
||||
|
||||
It has had a new '-I' command-line flag added so that it can ignore
|
||||
the fact it's not running on a TTY device (i.e. to allow it to work
|
||||
over a socket).
|
1762
contrib/chat/chat.c
Normal file
1762
contrib/chat/chat.c
Normal file
File diff suppressed because it is too large
Load Diff
511
contrib/chat/chat.man
Normal file
511
contrib/chat/chat.man
Normal file
@ -0,0 +1,511 @@
|
||||
.\" -*- nroff -*-
|
||||
.\" manual page [] for chat 1.8
|
||||
.\" Id: chat.8,v 1.9 1999/09/06 05:10:23 paulus Exp
|
||||
.\" SH section heading
|
||||
.\" SS subsection heading
|
||||
.\" LP paragraph
|
||||
.\" IP indented paragraph
|
||||
.\" TP hanging label
|
||||
.TH CHAT 8 "22 May 1999" "Chat Version 1.22"
|
||||
.SH "NAME"
|
||||
chat \- Automated conversational script with a modem
|
||||
.SH "SYNOPSIS"
|
||||
.B chat
|
||||
[
|
||||
.I options
|
||||
]
|
||||
.I script
|
||||
.SH "DESCRIPTION"
|
||||
.LP
|
||||
The \fIchat\fR program defines a conversational exchange between the
|
||||
computer and the modem. Its primary purpose is to establish the
|
||||
connection between the Point-to-Point Protocol Daemon (\fIpppd\fR) and
|
||||
the remote's \fIpppd\fR process.
|
||||
.SH "OPTIONS"
|
||||
.TP
|
||||
.B -f \fI<chat file>
|
||||
Read the chat script from the chat \fIfile\fR. The use of this option
|
||||
is mutually exclusive with the chat script parameters. The user must
|
||||
have read access to the file. Multiple lines are permitted in the
|
||||
file. Space or horizontal tab characters should be used to separate
|
||||
the strings.
|
||||
.TP
|
||||
.B -t \fI<timeout>
|
||||
Set the timeout for the expected string to be received. If the string
|
||||
is not received within the time limit then the reply string is not
|
||||
sent. An alternate reply may be sent or the script will fail if there
|
||||
is no alternate reply string. A failed script will cause the
|
||||
\fIchat\fR program to terminate with a non-zero error code.
|
||||
.TP
|
||||
.B -r \fI<report file>
|
||||
Set the file for output of the report strings. If you use the keyword
|
||||
\fIREPORT\fR, the resulting strings are written to this file. If this
|
||||
option is not used and you still use \fIREPORT\fR keywords, the
|
||||
\fIstderr\fR file is used for the report strings.
|
||||
.TP
|
||||
.B -e
|
||||
Start with the echo option turned on. Echoing may also be turned on
|
||||
or off at specific points in the chat script by using the \fIECHO\fR
|
||||
keyword. When echoing is enabled, all output from the modem is echoed
|
||||
to \fIstderr\fR.
|
||||
.TP
|
||||
.B -E
|
||||
Enables environment variable substituion within chat scripts using the
|
||||
standard \fI$xxx\fR syntax.
|
||||
.TP
|
||||
.B -v
|
||||
Request that the \fIchat\fR script be executed in a verbose mode. The
|
||||
\fIchat\fR program will then log the execution state of the chat
|
||||
script as well as all text received from the modem and the output
|
||||
strings sent to the modem. The default is to log through the SYSLOG;
|
||||
the logging method may be altered with the -S and -s flags. SYSLOGs
|
||||
are logged to facility LOG_LOCAL2.
|
||||
.TP
|
||||
.B -V
|
||||
Request that the \fIchat\fR script be executed in a stderr verbose
|
||||
mode. The \fIchat\fR program will then log all text received from the
|
||||
modem and the output strings sent to the modem to the stderr device. This
|
||||
device is usually the local console at the station running the chat or
|
||||
pppd program.
|
||||
.TP
|
||||
.B -s
|
||||
Use stderr. All log messages from '-v' and all error messages will be
|
||||
sent to stderr.
|
||||
.TP
|
||||
.B -S
|
||||
Do not use the SYSLOG. By default, error messages are sent to the
|
||||
SYSLOG. The use of -S will prevent both log messages from '-v' and
|
||||
error messages from being sent to the SYSLOG (to facility LOG_LOCAL2).
|
||||
.TP
|
||||
.B -T \fI<phone number>
|
||||
Pass in an arbitary string, usually a phone number, that will be
|
||||
substituted for the \eT substitution metacharacter in a send string.
|
||||
.TP
|
||||
.B -U \fI<phone number 2>
|
||||
Pass in a second string, usually a phone number, that will be
|
||||
substituted for the \eU substitution metacharacter in a send string.
|
||||
This is useful when dialing an ISDN terminal adapter that requires two
|
||||
numbers.
|
||||
.TP
|
||||
.B script
|
||||
If the script is not specified in a file with the \fI-f\fR option then
|
||||
the script is included as parameters to the \fIchat\fR program.
|
||||
.SH "CHAT SCRIPT"
|
||||
.LP
|
||||
The \fIchat\fR script defines the communications.
|
||||
.LP
|
||||
A script consists of one or more "expect-send" pairs of strings,
|
||||
separated by spaces, with an optional "subexpect-subsend" string pair,
|
||||
separated by a dash as in the following example:
|
||||
.IP
|
||||
ogin:-BREAK-ogin: ppp ssword: hello2u2
|
||||
.LP
|
||||
This line indicates that the \fIchat\fR program should expect the string
|
||||
"ogin:". If it fails to receive a login prompt within the time interval
|
||||
allotted, it is to send a break sequence to the remote and then expect the
|
||||
string "ogin:". If the first "ogin:" is received then the break sequence is
|
||||
not generated.
|
||||
.LP
|
||||
Once it received the login prompt the \fIchat\fR program will send the
|
||||
string ppp and then expect the prompt "ssword:". When it receives the
|
||||
prompt for the password, it will send the password hello2u2.
|
||||
.LP
|
||||
A carriage return is normally sent following the reply string. It is not
|
||||
expected in the "expect" string unless it is specifically requested by using
|
||||
the \er character sequence.
|
||||
.LP
|
||||
The expect sequence should contain only what is needed to identify the
|
||||
string. Since it is normally stored on a disk file, it should not contain
|
||||
variable information. It is generally not acceptable to look for time
|
||||
strings, network identification strings, or other variable pieces of data as
|
||||
an expect string.
|
||||
.LP
|
||||
To help correct for characters which may be corrupted during the initial
|
||||
sequence, look for the string "ogin:" rather than "login:". It is possible
|
||||
that the leading "l" character may be received in error and you may never
|
||||
find the string even though it was sent by the system. For this reason,
|
||||
scripts look for "ogin:" rather than "login:" and "ssword:" rather than
|
||||
"password:".
|
||||
.LP
|
||||
A very simple script might look like this:
|
||||
.IP
|
||||
ogin: ppp ssword: hello2u2
|
||||
.LP
|
||||
In other words, expect ....ogin:, send ppp, expect ...ssword:, send hello2u2.
|
||||
.LP
|
||||
In actual practice, simple scripts are rare. At the vary least, you
|
||||
should include sub-expect sequences should the original string not be
|
||||
received. For example, consider the following script:
|
||||
.IP
|
||||
ogin:--ogin: ppp ssword: hello2u2
|
||||
.LP
|
||||
This would be a better script than the simple one used earlier. This would look
|
||||
for the same login: prompt, however, if one was not received, a single
|
||||
return sequence is sent and then it will look for login: again. Should line
|
||||
noise obscure the first login prompt then sending the empty line will
|
||||
usually generate a login prompt again.
|
||||
.SH "COMMENTS"
|
||||
Comments can be embedded in the chat script. A comment is a line which
|
||||
starts with the \fB#\fR (hash) character in column 1. Such comment
|
||||
lines are just ignored by the chat program. If a '#' character is to
|
||||
be expected as the first character of the expect sequence, you should
|
||||
quote the expect string, or give its octal value, `\e043'.
|
||||
In a script file if you want to wait for a prompt that starts with a '#'
|
||||
character, you would have to write something like this:
|
||||
.IP
|
||||
# Now wait for the prompt and send logout string
|
||||
.br
|
||||
\'# ' logout
|
||||
.SH "SENDING DATA FROM A FILE"
|
||||
If the string to send starts with an at sign (@), the rest of the
|
||||
string is taken to be the name of a file to read to get the string to
|
||||
send. If the last character of the data read is a newline, it is
|
||||
removed. The file can be a named pipe (or fifo) instead of a regular
|
||||
file. This provides a way for \fBchat\fR to communicate with another
|
||||
program, for example, a program to prompt the user and receive a
|
||||
password typed in.
|
||||
.SH "ABORT STRINGS"
|
||||
Many modems will report the status of the call as a string. These
|
||||
strings may be \fBCONNECTED\fR or \fBNO CARRIER\fR or \fBBUSY\fR. It
|
||||
is often desirable to terminate the script should the modem fail to
|
||||
connect to the remote. The difficulty is that a script would not know
|
||||
exactly which modem string it may receive. On one attempt, it may
|
||||
receive \fBBUSY\fR while the next time it may receive \fBNO CARRIER\fR.
|
||||
.LP
|
||||
These "abort" strings may be specified in the script using the \fIABORT\fR
|
||||
sequence. It is written in the script as in the following example:
|
||||
.IP
|
||||
ABORT BUSY ABORT 'NO CARRIER' '' ATZ OK ATDT5551212 CONNECT
|
||||
.LP
|
||||
This sequence will expect nothing; and then send the string ATZ. The
|
||||
expected response to this is the string \fIOK\fR. When it receives \fIOK\fR,
|
||||
the string ATDT5551212 to dial the telephone. The expected string is
|
||||
\fICONNECT\fR. If the string \fICONNECT\fR is received the remainder of the
|
||||
script is executed. However, should the modem find a busy telephone, it will
|
||||
send the string \fIBUSY\fR. This will cause the string to match the abort
|
||||
character sequence. The script will then fail because it found a match to
|
||||
the abort string. If it received the string \fINO CARRIER\fR, it will abort
|
||||
for the same reason. Either string may be received. Either string will
|
||||
terminate the \fIchat\fR script.
|
||||
.SH "CLR_ABORT STRINGS"
|
||||
This sequence allows for clearing previously set \fBABORT\fR strings.
|
||||
\fBABORT\fR strings are kept in an array of a pre-determined size (at
|
||||
compilation time); \fBCLR_ABORT\fR will reclaim the space for cleared
|
||||
entries so that new strings can use that space.
|
||||
.SH "SAY STRINGS"
|
||||
The \fBSAY\fR directive allows the script to send strings to the user
|
||||
at the terminal via standard error. If \fBchat\fR is being run by
|
||||
pppd, and pppd is running as a daemon (detached from its controlling
|
||||
terminal), standard error will normally be redirected to the file
|
||||
/etc/ppp/connect-errors.
|
||||
.LP
|
||||
\fBSAY\fR strings must be enclosed in single or double quotes. If
|
||||
carriage return and line feed are needed in the string to be output,
|
||||
you must explicitly add them to your string.
|
||||
.LP
|
||||
The SAY strings could be used to give progress messages in sections of
|
||||
the script where you want to have 'ECHO OFF' but still let the user
|
||||
know what is happening. An example is:
|
||||
.IP
|
||||
ABORT BUSY
|
||||
.br
|
||||
ECHO OFF
|
||||
.br
|
||||
SAY "Dialling your ISP...\en"
|
||||
.br
|
||||
\'' ATDT5551212
|
||||
.br
|
||||
TIMEOUT 120
|
||||
.br
|
||||
SAY "Waiting up to 2 minutes for connection ... "
|
||||
.br
|
||||
CONNECT ''
|
||||
.br
|
||||
SAY "Connected, now logging in ...\n"
|
||||
.br
|
||||
ogin: account
|
||||
.br
|
||||
ssword: pass
|
||||
.br
|
||||
$ \c
|
||||
SAY "Logged in OK ...\n"
|
||||
\fIetc ...\fR
|
||||
.LP
|
||||
This sequence will only present the SAY strings to the user and all
|
||||
the details of the script will remain hidden. For example, if the
|
||||
above script works, the user will see:
|
||||
.IP
|
||||
Dialling your ISP...
|
||||
.br
|
||||
Waiting up to 2 minutes for connection ... Connected, now logging in ...
|
||||
.br
|
||||
Logged in OK ...
|
||||
.LP
|
||||
.SH "REPORT STRINGS"
|
||||
A \fBreport\fR string is similar to the ABORT string. The difference
|
||||
is that the strings, and all characters to the next control character
|
||||
such as a carriage return, are written to the report file.
|
||||
.LP
|
||||
The report strings may be used to isolate the transmission rate of the
|
||||
modem's connect string and return the value to the chat user. The
|
||||
analysis of the report string logic occurs in conjunction with the
|
||||
other string processing such as looking for the expect string. The use
|
||||
of the same string for a report and abort sequence is probably not
|
||||
very useful, however, it is possible.
|
||||
.LP
|
||||
The report strings to no change the completion code of the program.
|
||||
.LP
|
||||
These "report" strings may be specified in the script using the \fIREPORT\fR
|
||||
sequence. It is written in the script as in the following example:
|
||||
.IP
|
||||
REPORT CONNECT ABORT BUSY '' ATDT5551212 CONNECT '' ogin: account
|
||||
.LP
|
||||
This sequence will expect nothing; and then send the string
|
||||
ATDT5551212 to dial the telephone. The expected string is
|
||||
\fICONNECT\fR. If the string \fICONNECT\fR is received the remainder
|
||||
of the script is executed. In addition the program will write to the
|
||||
expect-file the string "CONNECT" plus any characters which follow it
|
||||
such as the connection rate.
|
||||
.SH "CLR_REPORT STRINGS"
|
||||
This sequence allows for clearing previously set \fBREPORT\fR strings.
|
||||
\fBREPORT\fR strings are kept in an array of a pre-determined size (at
|
||||
compilation time); \fBCLR_REPORT\fR will reclaim the space for cleared
|
||||
entries so that new strings can use that space.
|
||||
.SH "ECHO"
|
||||
The echo options controls whether the output from the modem is echoed
|
||||
to \fIstderr\fR. This option may be set with the \fI-e\fR option, but
|
||||
it can also be controlled by the \fIECHO\fR keyword. The "expect-send"
|
||||
pair \fIECHO\fR \fION\fR enables echoing, and \fIECHO\fR \fIOFF\fR
|
||||
disables it. With this keyword you can select which parts of the
|
||||
conversation should be visible. For instance, with the following
|
||||
script:
|
||||
.IP
|
||||
ABORT 'BUSY'
|
||||
.br
|
||||
ABORT 'NO CARRIER'
|
||||
.br
|
||||
'' ATZ
|
||||
.br
|
||||
OK\er\en ATD1234567
|
||||
.br
|
||||
\er\en \ec
|
||||
.br
|
||||
ECHO ON
|
||||
.br
|
||||
CONNECT \ec
|
||||
.br
|
||||
ogin: account
|
||||
.LP
|
||||
all output resulting from modem configuration and dialing is not visible,
|
||||
but starting with the \fICONNECT\fR (or \fIBUSY\fR) message, everything
|
||||
will be echoed.
|
||||
.SH "HANGUP"
|
||||
The HANGUP options control whether a modem hangup should be considered
|
||||
as an error or not. This option is useful in scripts for dialling
|
||||
systems which will hang up and call your system back. The HANGUP
|
||||
options can be \fBON\fR or \fBOFF\fR.
|
||||
.br
|
||||
When HANGUP is set OFF and the modem hangs up (e.g., after the first
|
||||
stage of logging in to a callback system), \fBchat\fR will continue
|
||||
running the script (e.g., waiting for the incoming call and second
|
||||
stage login prompt). As soon as the incoming call is connected, you
|
||||
should use the \fBHANGUP ON\fR directive to reinstall normal hang up
|
||||
signal behavior. Here is an (simple) example script:
|
||||
.IP
|
||||
ABORT 'BUSY'
|
||||
.br
|
||||
'' ATZ
|
||||
.br
|
||||
OK\er\en ATD1234567
|
||||
.br
|
||||
\er\en \ec
|
||||
.br
|
||||
CONNECT \ec
|
||||
.br
|
||||
\'Callback login:' call_back_ID
|
||||
.br
|
||||
HANGUP OFF
|
||||
.br
|
||||
ABORT "Bad Login"
|
||||
.br
|
||||
\'Callback Password:' Call_back_password
|
||||
.br
|
||||
TIMEOUT 120
|
||||
.br
|
||||
CONNECT \ec
|
||||
.br
|
||||
HANGUP ON
|
||||
.br
|
||||
ABORT "NO CARRIER"
|
||||
.br
|
||||
ogin:--BREAK--ogin: real_account
|
||||
.br
|
||||
\fIetc ...\fR
|
||||
.LP
|
||||
.SH "TIMEOUT"
|
||||
The initial timeout value is 45 seconds. This may be changed using the \fB-t\fR
|
||||
parameter.
|
||||
.LP
|
||||
To change the timeout value for the next expect string, the following
|
||||
example may be used:
|
||||
.IP
|
||||
ATZ OK ATDT5551212 CONNECT TIMEOUT 10 ogin:--ogin: TIMEOUT 5 assword: hello2u2
|
||||
.LP
|
||||
This will change the timeout to 10 seconds when it expects the login:
|
||||
prompt. The timeout is then changed to 5 seconds when it looks for the
|
||||
password prompt.
|
||||
.LP
|
||||
The timeout, once changed, remains in effect until it is changed again.
|
||||
.SH "SENDING EOT"
|
||||
The special reply string of \fIEOT\fR indicates that the chat program
|
||||
should send an EOT character to the remote. This is normally the
|
||||
End-of-file character sequence. A return character is not sent
|
||||
following the EOT.
|
||||
.PR
|
||||
The EOT sequence may be embedded into the send string using the
|
||||
sequence \fI^D\fR.
|
||||
.SH "GENERATING BREAK"
|
||||
The special reply string of \fIBREAK\fR will cause a break condition
|
||||
to be sent. The break is a special signal on the transmitter. The
|
||||
normal processing on the receiver is to change the transmission rate.
|
||||
It may be used to cycle through the available transmission rates on
|
||||
the remote until you are able to receive a valid login prompt.
|
||||
.PR
|
||||
The break sequence may be embedded into the send string using the
|
||||
\fI\eK\fR sequence.
|
||||
.SH "ESCAPE SEQUENCES"
|
||||
The expect and reply strings may contain escape sequences. All of the
|
||||
sequences are legal in the reply string. Many are legal in the expect.
|
||||
Those which are not valid in the expect sequence are so indicated.
|
||||
.TP
|
||||
.B ''
|
||||
Expects or sends a null string. If you send a null string then it will still
|
||||
send the return character. This sequence may either be a pair of apostrophe
|
||||
or quote characters.
|
||||
.TP
|
||||
.B \eb
|
||||
represents a backspace character.
|
||||
.TP
|
||||
.B \ec
|
||||
Suppresses the newline at the end of the reply string. This is the only
|
||||
method to send a string without a trailing return character. It must
|
||||
be at the end of the send string. For example,
|
||||
the sequence hello\ec will simply send the characters h, e, l, l, o.
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \ed
|
||||
Delay for one second. The program uses sleep(1) which will delay to a
|
||||
maximum of one second.
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \eK
|
||||
Insert a BREAK
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \en
|
||||
Send a newline or linefeed character.
|
||||
.TP
|
||||
.B \eN
|
||||
Send a null character. The same sequence may be represented by \e0.
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \ep
|
||||
Pause for a fraction of a second. The delay is 1/10th of a second.
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \eq
|
||||
Suppress writing the string to the SYSLOG. The string ?????? is
|
||||
written to the log in its place.
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \er
|
||||
Send or expect a carriage return.
|
||||
.TP
|
||||
.B \es
|
||||
Represents a space character in the string. This may be used when it
|
||||
is not desirable to quote the strings which contains spaces. The
|
||||
sequence 'HI\ TIM' and HI\esTIM are the same.
|
||||
.TP
|
||||
.B \et
|
||||
Send or expect a tab character.
|
||||
.TP
|
||||
.B \eT
|
||||
Send the phone number string as specified with the \fI-T\fR option
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \eU
|
||||
Send the phone number 2 string as specified with the \fI-U\fR option
|
||||
.I (not valid in expect.)
|
||||
.TP
|
||||
.B \e\e
|
||||
Send or expect a backslash character.
|
||||
.TP
|
||||
.B \eddd
|
||||
Collapse the octal digits (ddd) into a single ASCII character and send that
|
||||
character.
|
||||
.I (some characters are not valid in expect.)
|
||||
.TP
|
||||
.B \^^C
|
||||
Substitute the sequence with the control character represented by C.
|
||||
For example, the character DC1 (17) is shown as \^^Q.
|
||||
.I (some characters are not valid in expect.)
|
||||
.SH "ENVIRONMENT VARIABLES"
|
||||
Environment variables are available within chat scripts, if the \fI-E\fR
|
||||
option was specified in the command line. The metacharacter \fI$\fR is used
|
||||
to introduce the name of the environment variable to substitute. If the
|
||||
substition fails, because the requested environment variable is not set,
|
||||
\fInothing\fR is replaced for the variable.
|
||||
.SH "TERMINATION CODES"
|
||||
The \fIchat\fR program will terminate with the following completion
|
||||
codes.
|
||||
.TP
|
||||
.B 0
|
||||
The normal termination of the program. This indicates that the script
|
||||
was executed without error to the normal conclusion.
|
||||
.TP
|
||||
.B 1
|
||||
One or more of the parameters are invalid or an expect string was too
|
||||
large for the internal buffers. This indicates that the program as not
|
||||
properly executed.
|
||||
.TP
|
||||
.B 2
|
||||
An error occurred during the execution of the program. This may be due
|
||||
to a read or write operation failing for some reason or chat receiving
|
||||
a signal such as SIGINT.
|
||||
.TP
|
||||
.B 3
|
||||
A timeout event occurred when there was an \fIexpect\fR string without
|
||||
having a "-subsend" string. This may mean that you did not program the
|
||||
script correctly for the condition or that some unexpected event has
|
||||
occurred and the expected string could not be found.
|
||||
.TP
|
||||
.B 4
|
||||
The first string marked as an \fIABORT\fR condition occurred.
|
||||
.TP
|
||||
.B 5
|
||||
The second string marked as an \fIABORT\fR condition occurred.
|
||||
.TP
|
||||
.B 6
|
||||
The third string marked as an \fIABORT\fR condition occurred.
|
||||
.TP
|
||||
.B 7
|
||||
The fourth string marked as an \fIABORT\fR condition occurred.
|
||||
.TP
|
||||
.B ...
|
||||
The other termination codes are also strings marked as an \fIABORT\fR
|
||||
condition.
|
||||
.LP
|
||||
Using the termination code, it is possible to determine which event
|
||||
terminated the script. It is possible to decide if the string "BUSY"
|
||||
was received from the modem as opposed to "NO DIAL TONE". While the
|
||||
first event may be retried, the second will probably have little
|
||||
chance of succeeding during a retry.
|
||||
.SH "SEE ALSO"
|
||||
Additional information about \fIchat\fR scripts may be found with UUCP
|
||||
documentation. The \fIchat\fR script was taken from the ideas proposed
|
||||
by the scripts used by the \fIuucico\fR program.
|
||||
.LP
|
||||
uucp(1), uucico(8)
|
||||
.SH "COPYRIGHT"
|
||||
The \fIchat\fR program is in public domain. This is not the GNU public
|
||||
license. If it breaks then you get to keep both pieces.
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
|
||||
%define pkg conserver
|
||||
%define ver conserver-8.0.0
|
||||
%define ver 8.0.9
|
||||
|
||||
# define the name of the machine on which the main conserver
|
||||
# daemon will be running if you don't want to use the default
|
||||
@ -17,7 +17,7 @@
|
||||
Summary: Serial console server daemon/client
|
||||
Name: %{pkg}
|
||||
Version: %{ver}
|
||||
Release: 1.%{distver}x
|
||||
Release: 1.%{distver}
|
||||
Copyright: distributable
|
||||
Group: System Environment/Daemons
|
||||
URL: http://www.conserver.com/
|
||||
@ -100,4 +100,6 @@ fi
|
||||
%{prefix}/share/man/man8/conserver.8.gz
|
||||
%{prefix}/share/man/man5/conserver.cf.5.gz
|
||||
%{prefix}/share/man/man5/conserver.passwd.5.gz
|
||||
%{prefix}/share/examples/conserver/conserver.cf
|
||||
%{prefix}/share/examples/conserver/conserver.passwd
|
||||
%{prefix}/sbin/conserver
|
||||
|
@ -1,7 +1,7 @@
|
||||
PKG="conserver"
|
||||
NAME="Console server and client"
|
||||
CATEGORY="system"
|
||||
VERSION="conserver-8.0.0"
|
||||
VERSION="8.0.9"
|
||||
DESC="Console server and client"
|
||||
CLASSES=none
|
||||
ARCH=sparc
|
||||
|
@ -33,7 +33,7 @@ dotest()
|
||||
else
|
||||
if [ -f results/test$testnum ]; then
|
||||
if diff -i test.out results/test$testnum >test$testnum.diff 2>&1; then
|
||||
echo "succeded"
|
||||
echo "succeeded"
|
||||
rm -f test$testnum.diff
|
||||
else
|
||||
echo "failed (diffs in test$testnum.diff)"
|
||||
|
@ -6,11 +6,12 @@
|
||||
f force attach read/write g group info
|
||||
i information dump L toggle logging on/off
|
||||
l? break sequence list l0 send break per config file
|
||||
l1-9 send specific break sequence o (re)open the tty and log file
|
||||
p replay the last 60 lines r replay the last 20 lines
|
||||
s spy read only u show host status
|
||||
v show version info w who is on this console
|
||||
x show console baud info z suspend the connection
|
||||
l1-9 send specific break sequence m display the message of the day
|
||||
o (re)open the tty and log file p replay the last 60 lines
|
||||
r replay the last 20 lines s spy read only
|
||||
u show host status v show version info
|
||||
w who is on this console x show console baud info
|
||||
z suspend the connection | attach local command
|
||||
<cr> ignore/abort command ? print this message
|
||||
^R replay the last line \ooo send character by octal code
|
||||
[disconnect]
|
||||
|
@ -6,11 +6,12 @@
|
||||
f force attach read/write g group info
|
||||
i information dump L toggle logging on/off
|
||||
l? break sequence list l0 send break per config file
|
||||
l1-9 send specific break sequence o (re)open the tty and log file
|
||||
p replay the last 60 lines r replay the last 20 lines
|
||||
s spy read only u show host status
|
||||
v show version info w who is on this console
|
||||
x show console baud info z suspend the connection
|
||||
l1-9 send specific break sequence m display the message of the day
|
||||
o (re)open the tty and log file p replay the last 60 lines
|
||||
r replay the last 20 lines s spy read only
|
||||
u show host status v show version info
|
||||
w who is on this console x show console baud info
|
||||
z suspend the connection | attach local command
|
||||
<cr> ignore/abort command ? print this message
|
||||
^R replay the last line \ooo send character by octal code
|
||||
[disconnect]
|
||||
|
Reference in New Issue
Block a user