Imported from conserver-7.2.6.tar.gz

This commit is contained in:
Bryan Stansell 2003-03-10 18:08:07 -08:00
parent 19eedadfe0
commit d8dfd2cb9a
32 changed files with 3418 additions and 2097 deletions

28
CHANGES
View File

@ -1,6 +1,32 @@
CHANGES CHANGES
======= =======
version 7.2.6 (Mar 20, 2003):
- the -b conserver option was mostly broken (since 7.2.0)
- changed logging format so that all messages are of a similar
form
- fixed bad port number in 'cached previous timeout' message -
reported by Dave Stuit <djs@tellme.com>
- now using pid_t type for better compatibility
- fixed the RPM and Solaris package to include the man
page for conserver.passwd - suggested by R P Herrold
<herrold@owlriver.com>
- added restart option (-HUP) to conserver startup scripts
- added -B option to client for sending messages to a single
server - suggested by Dave Stuit <djs@tellme.com>
- added --with-dmalloc for memory usage debugging
- bug with multiple interfaces and -M option not maching hostname
in configuration file - patch by Igor Sviridov <sia@nest.org>
- memory leak using openssl library plugged
- automatic reinitialization of failed consoles now retries
every minute like the manpage says it does - reported by Chris
Fowler <cfowler@outpostsentinel.com>
- when -R option is used, substring matches on console names
from clients only match local console names (and if that
fails just remote console names) but ambiguous name list
returns both local and remote consoles - suggested by Todd
Stansell <todd@stansell.org>
version 7.2.5 (Jan 27, 2003): version 7.2.5 (Jan 27, 2003):
- fixed many documentation bugs - reported by Dave Stuit - fixed many documentation bugs - reported by Dave Stuit
<djs@tellme.com> <djs@tellme.com>
@ -377,5 +403,5 @@ before version 6.05:
and enhancements of various types were applied. and enhancements of various types were applied.
# #
# $Id: CHANGES,v 1.75 2003-01-27 17:47:59-08 bryan Exp $ # $Id: CHANGES,v 1.78 2003-03-10 17:45:55-08 bryan Exp $
# #

View File

@ -259,3 +259,15 @@ typedef int socklen_t;
#ifndef ONLRET #ifndef ONLRET
#define ONLRET 0 #define ONLRET 0
#endif #endif
#ifndef PARAMS
# if PROTOTYPES
# define PARAMS(protos) protos
# else /* no PROTOTYPES */
# define PARAMS(protos) ()
# endif /* no PROTOTYPES */
#endif
#if HAVE_DMALLOC
#include <dmalloc.h>
#endif

View File

@ -21,8 +21,8 @@
/* Define to 1 if you have the <crypt.h> header file. */ /* Define to 1 if you have the <crypt.h> header file. */
#undef HAVE_CRYPT_H #undef HAVE_CRYPT_H
/* Define to 1 if you have the `flock' function. */ /* have dmalloc support */
#undef HAVE_FLOCK #undef HAVE_DMALLOC
/* Define if libbsm has `getaudit'. */ /* Define if libbsm has `getaudit'. */
#undef HAVE_GETAUDIT #undef HAVE_GETAUDIT
@ -261,6 +261,9 @@
/* pidfile to write to */ /* pidfile to write to */
#undef PIDFILE #undef PIDFILE
/* Define to 1 if the C compiler supports function prototypes. */
#undef PROTOTYPES
/* Define as the return type of signal handlers (`int' or `void'). */ /* Define as the return type of signal handlers (`int' or `void'). */
#undef RETSIGTYPE #undef RETSIGTYPE
@ -276,9 +279,6 @@
/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */ /* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
#undef TIME_WITH_SYS_TIME #undef TIME_WITH_SYS_TIME
/* use ansi prototypes/decls */
#undef USE_ANSI_PROTO
/* use tcp_wrappers libwrap */ /* use tcp_wrappers libwrap */
#undef USE_LIBWRAP #undef USE_LIBWRAP
@ -289,11 +289,17 @@
# undef _ALL_SOURCE # undef _ALL_SOURCE
#endif #endif
/* Define like PROTOTYPES; this can be used by system headers. */
#undef __PROTOTYPES
/* Define to empty if `const' does not conform to ANSI C. */ /* Define to empty if `const' does not conform to ANSI C. */
#undef const #undef const
/* Define to `int' if <sys/types.h> does not define. */ /* Define to `int' if <sys/types.h> does not define. */
#undef mode_t #undef mode_t
/* Define to `int' if <sys/types.h> does not define. */
#undef pid_t
/* Define if <signal.h> does not define sig_atomic_t */ /* Define if <signal.h> does not define sig_atomic_t */
#undef sig_atomic_t #undef sig_atomic_t

898
configure vendored
View File

@ -852,6 +852,8 @@ Optional Packages:
Compile in libwrap (tcp_wrappers) support Compile in libwrap (tcp_wrappers) support
--with-openssl[=PATH] --with-openssl[=PATH]
Compile in OpenSSL support Compile in OpenSSL support
--with-dmalloc[=PATH]
Compile in dmalloc support
--with-regex Use regular expressions in conserver.passwd --with-regex Use regular expressions in conserver.passwd
--with-pam Enable PAM support --with-pam Enable PAM support
@ -2756,6 +2758,642 @@ fi
rm -f conftest* rm -f conftest*
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
set dummy ${ac_tool_prefix}gcc; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}gcc"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
echo "$as_me:$LINENO: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
fi
if test -z "$ac_cv_prog_CC"; then
ac_ct_CC=$CC
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="gcc"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
echo "${ECHO_T}$ac_ct_CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
CC=$ac_ct_CC
else
CC="$ac_cv_prog_CC"
fi
if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
set dummy ${ac_tool_prefix}cc; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="${ac_tool_prefix}cc"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
echo "$as_me:$LINENO: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
fi
if test -z "$ac_cv_prog_CC"; then
ac_ct_CC=$CC
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="cc"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
echo "${ECHO_T}$ac_ct_CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
CC=$ac_ct_CC
else
CC="$ac_cv_prog_CC"
fi
fi
if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
ac_prog_rejected=no
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
ac_prog_rejected=yes
continue
fi
ac_cv_prog_CC="cc"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
if test $ac_prog_rejected = yes; then
# We found a bogon in the path, so make sure we never use it.
set dummy $ac_cv_prog_CC
shift
if test $# != 0; then
# We chose a different compiler from the bogus one.
# However, it has the same basename, so the bogon will be chosen
# first if we set CC to just the basename; use the full file name.
shift
ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
fi
fi
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
echo "$as_me:$LINENO: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
fi
if test -z "$CC"; then
if test -n "$ac_tool_prefix"; then
for ac_prog in cl
do
# Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
set dummy $ac_tool_prefix$ac_prog; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$CC"; then
ac_cv_prog_CC="$CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
CC=$ac_cv_prog_CC
if test -n "$CC"; then
echo "$as_me:$LINENO: result: $CC" >&5
echo "${ECHO_T}$CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
test -n "$CC" && break
done
fi
if test -z "$CC"; then
ac_ct_CC=$CC
for ac_prog in cl
do
# Extract the first word of "$ac_prog", so it can be a program name with args.
set dummy $ac_prog; ac_word=$2
echo "$as_me:$LINENO: checking for $ac_word" >&5
echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6
if test "${ac_cv_prog_ac_ct_CC+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
if test -n "$ac_ct_CC"; then
ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if $as_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_CC="$ac_prog"
echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
fi
fi
ac_ct_CC=$ac_cv_prog_ac_ct_CC
if test -n "$ac_ct_CC"; then
echo "$as_me:$LINENO: result: $ac_ct_CC" >&5
echo "${ECHO_T}$ac_ct_CC" >&6
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
test -n "$ac_ct_CC" && break
done
CC=$ac_ct_CC
fi
fi
test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH" >&5
echo "$as_me: error: no acceptable C compiler found in \$PATH" >&2;}
{ (exit 1); exit 1; }; }
# Provide some information about the compiler.
echo "$as_me:$LINENO:" \
"checking for C compiler version" >&5
ac_compiler=`set X $ac_compile; echo $2`
{ (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
(eval $ac_compiler --version </dev/null >&5) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
{ (eval echo "$as_me:$LINENO: \"$ac_compiler -v </dev/null >&5\"") >&5
(eval $ac_compiler -v </dev/null >&5) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
{ (eval echo "$as_me:$LINENO: \"$ac_compiler -V </dev/null >&5\"") >&5
(eval $ac_compiler -V </dev/null >&5) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }
echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5
echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6
if test "${ac_cv_c_compiler_gnu+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
int
main ()
{
#ifndef __GNUC__
choke me
#endif
;
return 0;
}
_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
ac_compiler_gnu=yes
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_compiler_gnu=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
ac_cv_c_compiler_gnu=$ac_compiler_gnu
fi
echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5
echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6
GCC=`test $ac_compiler_gnu = yes && echo yes`
ac_test_CFLAGS=${CFLAGS+set}
ac_save_CFLAGS=$CFLAGS
CFLAGS="-g"
echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5
echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6
if test "${ac_cv_prog_cc_g+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
int
main ()
{
;
return 0;
}
_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
ac_cv_prog_cc_g=yes
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_prog_cc_g=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5
echo "${ECHO_T}$ac_cv_prog_cc_g" >&6
if test "$ac_test_CFLAGS" = set; then
CFLAGS=$ac_save_CFLAGS
elif test $ac_cv_prog_cc_g = yes; then
if test "$GCC" = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-g"
fi
else
if test "$GCC" = yes; then
CFLAGS="-O2"
else
CFLAGS=
fi
fi
echo "$as_me:$LINENO: checking for $CC option to accept ANSI C" >&5
echo $ECHO_N "checking for $CC option to accept ANSI C... $ECHO_C" >&6
if test "${ac_cv_prog_cc_stdc+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_cv_prog_cc_stdc=no
ac_save_CC=$CC
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include <stdarg.h>
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */
struct buf { int x; };
FILE * (*rcsopen) (struct buf *, struct stat *, int);
static char *e (p, i)
char **p;
int i;
{
return p[i];
}
static char *f (char * (*g) (char **, int), char **p, ...)
{
char *s;
va_list v;
va_start (v,p);
s = g (p, va_arg (v,int));
va_end (v);
return s;
}
int test (int i, double x);
struct s1 {int (*f) (int a);};
struct s2 {int (*f) (double a);};
int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
int argc;
char **argv;
int
main ()
{
return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1];
;
return 0;
}
_ACEOF
# Don't try gcc -ansi; that turns off useful extensions and
# breaks some systems' header files.
# AIX -qlanglvl=ansi
# Ultrix and OSF/1 -std1
# HP-UX 10.20 and later -Ae
# HP-UX older versions -Aa -D_HPUX_SOURCE
# SVR4 -Xc -D__EXTENSIONS__
for ac_arg in "" -qlanglvl=ansi -std1 -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
do
CC="$ac_save_CC $ac_arg"
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
ac_cv_prog_cc_stdc=$ac_arg
break
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext
done
rm -f conftest.$ac_ext conftest.$ac_objext
CC=$ac_save_CC
fi
case "x$ac_cv_prog_cc_stdc" in
x|xno)
echo "$as_me:$LINENO: result: none needed" >&5
echo "${ECHO_T}none needed" >&6 ;;
*)
echo "$as_me:$LINENO: result: $ac_cv_prog_cc_stdc" >&5
echo "${ECHO_T}$ac_cv_prog_cc_stdc" >&6
CC="$CC $ac_cv_prog_cc_stdc" ;;
esac
# Some people use a C++ compiler to compile C. Since we use `exit',
# in C++ we need to declare it. In case someone uses the same compiler
# for both compiling C and C++ we need to have the C++ compiler decide
# the declaration of exit, since it's the most demanding environment.
cat >conftest.$ac_ext <<_ACEOF
#ifndef __cplusplus
choke me
#endif
_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
for ac_declaration in \
''\
'#include <stdlib.h>' \
'extern "C" void std::exit (int) throw (); using std::exit;' \
'extern "C" void std::exit (int); using std::exit;' \
'extern "C" void exit (int) throw ();' \
'extern "C" void exit (int);' \
'void exit (int);'
do
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include <stdlib.h>
$ac_declaration
int
main ()
{
exit (42);
;
return 0;
}
_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
:
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
continue
fi
rm -f conftest.$ac_objext conftest.$ac_ext
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
$ac_declaration
int
main ()
{
exit (42);
;
return 0;
}
_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
break
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
done
rm -f conftest*
if test -n "$ac_declaration"; then
echo '#ifdef __cplusplus' >>confdefs.h
echo $ac_declaration >>confdefs.h
echo '#endif' >>confdefs.h
fi
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
fi
rm -f conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5
echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6 echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6
@ -2850,6 +3488,26 @@ _ACEOF
fi fi
echo "$as_me:$LINENO: checking for function prototypes" >&5
echo $ECHO_N "checking for function prototypes... $ECHO_C" >&6
if test "$ac_cv_prog_cc_stdc" != no; then
echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
cat >>confdefs.h <<\_ACEOF
#define PROTOTYPES 1
_ACEOF
cat >>confdefs.h <<\_ACEOF
#define __PROTOTYPES 1
_ACEOF
else
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo "$as_me:$LINENO: checking for ANSI C header files" >&5
echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
@ -3379,13 +4037,6 @@ echo "$as_me: WARNING: building a 64bit version of conserver - good luck!" >&2;}
fi fi
fi fi
if test "$ac_cv_prog_cc_stdc" != "no"; then
cat >>confdefs.h <<_ACEOF
#define USE_ANSI_PROTO 1
_ACEOF
fi
echo "$as_me:$LINENO: checking for ANSI C header files" >&5 echo "$as_me:$LINENO: checking for ANSI C header files" >&5
echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6 echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6
if test "${ac_cv_header_stdc+set}" = set; then if test "${ac_cv_header_stdc+set}" = set; then
@ -4338,6 +4989,58 @@ cat >>confdefs.h <<_ACEOF
_ACEOF _ACEOF
echo "$as_me:$LINENO: checking for pid_t" >&5
echo $ECHO_N "checking for pid_t... $ECHO_C" >&6
if test "${ac_cv_type_pid_t+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
$ac_includes_default
int
main ()
{
if ((pid_t *) 0)
return 0;
if (sizeof (pid_t))
return 0;
;
return 0;
}
_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
ac_cv_type_pid_t=yes
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_cv_type_pid_t=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
fi
echo "$as_me:$LINENO: result: $ac_cv_type_pid_t" >&5
echo "${ECHO_T}$ac_cv_type_pid_t" >&6
if test $ac_cv_type_pid_t = yes; then
:
else
cat >>confdefs.h <<_ACEOF
#define pid_t int
_ACEOF
fi
echo "$as_me:$LINENO: checking for sig_atomic_t" >&5 echo "$as_me:$LINENO: checking for sig_atomic_t" >&5
echo $ECHO_N "checking for sig_atomic_t... $ECHO_C" >&6 echo $ECHO_N "checking for sig_atomic_t... $ECHO_C" >&6
@ -5149,6 +5852,184 @@ fi
fi; fi;
# Check whether --with-dmalloc or --without-dmalloc was given.
if test "${with_dmalloc+set}" = set; then
withval="$with_dmalloc"
if test "$withval" != "no"; then
if test "$withval" != "yes"; then
DMALLOCCPPFLAGS="-I$withval/include"
DMALLOCLDFLAGS="-L$withval/lib"
else
DMALLOCCPPFLAGS=""
DMALLOCLDFLAGS=""
fi
oCPPFLAGS="$CPPFLAGS"
oLDFLAGS="$LDFLAGS"
oLIBS="$LIBS"
have_dmalloc=no
CPPFLAGS="$CPPFLAGS $DMALLOCCPPFLAGS"
LDFLAGS="$LDFLAGS $DMALLOCLDFLAGS"
if test "${ac_cv_header_dmalloc_h+set}" = set; then
echo "$as_me:$LINENO: checking for dmalloc.h" >&5
echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6
if test "${ac_cv_header_dmalloc_h+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
fi
echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5
echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6
else
# Is the header compilable?
echo "$as_me:$LINENO: checking dmalloc.h usability" >&5
echo $ECHO_N "checking dmalloc.h usability... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
$ac_includes_default
#include <dmalloc.h>
_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
ac_header_compiler=yes
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_header_compiler=no
fi
rm -f conftest.$ac_objext conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
echo "${ECHO_T}$ac_header_compiler" >&6
# Is the header present?
echo "$as_me:$LINENO: checking dmalloc.h presence" >&5
echo $ECHO_N "checking dmalloc.h presence... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include <dmalloc.h>
_ACEOF
if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
(eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
ac_status=$?
grep -v '^ *+' conftest.er1 >conftest.err
rm -f conftest.er1
cat conftest.err >&5
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } >/dev/null; then
if test -s conftest.err; then
ac_cpp_err=$ac_c_preproc_warn_flag
else
ac_cpp_err=
fi
else
ac_cpp_err=yes
fi
if test -z "$ac_cpp_err"; then
ac_header_preproc=yes
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
ac_header_preproc=no
fi
rm -f conftest.err conftest.$ac_ext
echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
echo "${ECHO_T}$ac_header_preproc" >&6
# So? What about this header?
case $ac_header_compiler:$ac_header_preproc in
yes:no )
{ echo "$as_me:$LINENO: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&5
echo "$as_me: WARNING: dmalloc.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
{ echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&2;};;
no:yes )
{ echo "$as_me:$LINENO: WARNING: dmalloc.h: present but cannot be compiled" >&5
echo "$as_me: WARNING: dmalloc.h: present but cannot be compiled" >&2;}
{ echo "$as_me:$LINENO: WARNING: dmalloc.h: check for missing prerequisite headers?" >&5
echo "$as_me: WARNING: dmalloc.h: check for missing prerequisite headers?" >&2;}
{ echo "$as_me:$LINENO: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&5
echo "$as_me: WARNING: dmalloc.h: proceeding with the preprocessor's result" >&2;};;
esac
echo "$as_me:$LINENO: checking for dmalloc.h" >&5
echo $ECHO_N "checking for dmalloc.h... $ECHO_C" >&6
if test "${ac_cv_header_dmalloc_h+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_cv_header_dmalloc_h=$ac_header_preproc
fi
echo "$as_me:$LINENO: result: $ac_cv_header_dmalloc_h" >&5
echo "${ECHO_T}$ac_cv_header_dmalloc_h" >&6
fi
if test $ac_cv_header_dmalloc_h = yes; then
LIBS="$LIBS -ldmalloc"
echo "$as_me:$LINENO: checking for dmalloc libraries -ldmalloc" >&5
echo $ECHO_N "checking for dmalloc libraries -ldmalloc... $ECHO_C" >&6
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
#include "confdefs.h"
#include <dmalloc.h>
int
main ()
{
dmalloc_debug(0)
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (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
echo "$as_me:$LINENO: result: yes" >&5
echo "${ECHO_T}yes" >&6
cat >>confdefs.h <<\_ACEOF
#define HAVE_DMALLOC 1
_ACEOF
have_dmalloc=yes
else
echo "$as_me: failed program was:" >&5
cat conftest.$ac_ext >&5
echo "$as_me:$LINENO: result: no" >&5
echo "${ECHO_T}no" >&6
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
fi
if test $have_dmalloc = no; then
LIBS="$oLIBS"
CPPFLAGS="$oCPPFLAGS"
LDFLAGS="$oLDFLAGS"
fi
fi
fi;
echo "$as_me:$LINENO: checking for POSIX regex" >&5 echo "$as_me:$LINENO: checking for POSIX regex" >&5
echo $ECHO_N "checking for POSIX regex... $ECHO_C" >&6 echo $ECHO_N "checking for POSIX regex... $ECHO_C" >&6
@ -5497,8 +6378,7 @@ fi;
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 sysconf getpassphrase getlogin
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 flock sigaction setsockopt getdtablesize putenv memset memcpy memcmp sysconf getpassphrase getlogin
do do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5 echo "$as_me:$LINENO: checking for $ac_func" >&5

View File

@ -10,10 +10,10 @@ AH_TEMPLATE([MAXMEMB], [Number of consoles per child process])
AH_TEMPLATE([CONNECTTIMEOUT], [TCP connection timeout]) AH_TEMPLATE([CONNECTTIMEOUT], [TCP connection timeout])
AH_TEMPLATE([PIDFILE], [pidfile to write to]) AH_TEMPLATE([PIDFILE], [pidfile to write to])
AH_TEMPLATE([USE_LIBWRAP], [use tcp_wrappers libwrap]) AH_TEMPLATE([USE_LIBWRAP], [use tcp_wrappers libwrap])
AH_TEMPLATE([USE_ANSI_PROTO], [use ansi prototypes/decls])
AH_TEMPLATE([HAVE_POSIX_REGCOMP], [have POSIX regcomp]) AH_TEMPLATE([HAVE_POSIX_REGCOMP], [have POSIX regcomp])
AH_TEMPLATE([HAVE_PAM], [have PAM support]) AH_TEMPLATE([HAVE_PAM], [have PAM support])
AH_TEMPLATE([HAVE_OPENSSL], [have openssl support]) AH_TEMPLATE([HAVE_OPENSSL], [have openssl support])
AH_TEMPLATE([HAVE_DMALLOC], [have dmalloc support])
dnl ### Normal initialization. ###################################### dnl ### Normal initialization. ######################################
AC_INIT AC_INIT
@ -174,8 +174,9 @@ AC_PROG_LN_S
AC_PROG_MAKE_SET AC_PROG_MAKE_SET
dnl ### Compiler characteristics. ################################## dnl ### Compiler characteristics. ##################################
AC_AIX AC_AIX
AC_PROG_CC_STDC AC_PROG_CC
AC_C_CONST AC_C_CONST
AC_C_PROTOTYPES
AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long)
if test "$ac_cv_sizeof_long" -gt 4; then if test "$ac_cv_sizeof_long" -gt 4; then
@ -186,10 +187,6 @@ if test "$ac_cv_sizeof_long" -gt 4; then
fi fi
fi fi
if test "$ac_cv_prog_cc_stdc" != "no"; then
AC_DEFINE_UNQUOTED(USE_ANSI_PROTO, 1)
fi
dnl ### Checks for header files. ################################### dnl ### Checks for header files. ###################################
AC_HEADER_STDC AC_HEADER_STDC
AC_CHECK_HEADERS(sys/ioctl.h) AC_CHECK_HEADERS(sys/ioctl.h)
@ -213,6 +210,7 @@ AC_HEADER_TIME
AC_HEADER_SYS_WAIT AC_HEADER_SYS_WAIT
AC_TYPE_MODE_T AC_TYPE_MODE_T
AC_TYPE_SIGNAL AC_TYPE_SIGNAL
AC_TYPE_PID_T
AC_CHECK_TYPE([sig_atomic_t],, AC_CHECK_TYPE([sig_atomic_t],,
AC_DEFINE(sig_atomic_t, volatile int, AC_DEFINE(sig_atomic_t, volatile int,
@ -312,6 +310,44 @@ AC_ARG_WITH(openssl,
fi] fi]
) )
AC_ARG_WITH(dmalloc,
AC_HELP_STRING([--with-dmalloc@<:@=PATH@:>@],
[Compile in dmalloc support]),
[if test "$withval" != "no"; then
if test "$withval" != "yes"; then
DMALLOCCPPFLAGS="-I$withval/include"
DMALLOCLDFLAGS="-L$withval/lib"
else
DMALLOCCPPFLAGS=""
DMALLOCLDFLAGS=""
fi
oCPPFLAGS="$CPPFLAGS"
oLDFLAGS="$LDFLAGS"
oLIBS="$LIBS"
have_dmalloc=no
CPPFLAGS="$CPPFLAGS $DMALLOCCPPFLAGS"
LDFLAGS="$LDFLAGS $DMALLOCLDFLAGS"
AC_CHECK_HEADER([dmalloc.h],
[LIBS="$LIBS -ldmalloc"
AC_MSG_CHECKING(for dmalloc libraries -ldmalloc)
AC_TRY_LINK([#include <dmalloc.h>
],[dmalloc_debug(0)],
[AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_DMALLOC)
have_dmalloc=yes],
[AC_MSG_RESULT(no)])],)
if test $have_dmalloc = no; then
LIBS="$oLIBS"
CPPFLAGS="$oCPPFLAGS"
LDFLAGS="$oLDFLAGS"
fi
fi]
)
dnl ### Check for needed functions. ################################ dnl ### Check for needed functions. ################################
@ -374,7 +410,7 @@ AC_ARG_WITH(pam,
fi],) fi],)
AC_CHECK_FUNCS(getopt strerror getrlimit getsid setsid getuserattr setgroups tcgetpgrp tcsetpgrp tcgetattr tcsetattr tcsendbreak setpgrp getutent setttyent getspnam setlinebuf setvbuf ptsname grantpt unlockpt flock sigaction setsockopt getdtablesize putenv memset memcpy memcmp sysconf getpassphrase getlogin) 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 sysconf getpassphrase getlogin)
AC_FUNC_SETPGRP AC_FUNC_SETPGRP
dnl Checks for libbsm functions dnl Checks for libbsm functions

View File

@ -8,8 +8,7 @@
"conserver,serial,console,serial console,unix,tty,ttya,ttyb, rs-232,rs232,bryan stansell,stansell,console server,terminal server,headless"> "conserver,serial,console,serial console,unix,tty,ttya,ttyb, rs-232,rs232,bryan stansell,stansell,console server,terminal server,headless">
<META name="author" content= <META name="author" content=
"Bryan Stansell &lt;bryan@conserver.com&gt;"> "Bryan Stansell &lt;bryan@conserver.com&gt;">
<LINK rel="SHORTCUT ICON" href= <LINK rel="SHORTCUT ICON" href="conserver.ico">
"http://www.conserver.com/conserver.ico">
<TITLE>Conserver</TITLE> <TITLE>Conserver</TITLE>
@ -25,16 +24,23 @@
<TABLE summary="Logo" bgcolor="black" width="100%" align= <TABLE summary="Logo" bgcolor="black" width="100%" align=
"center"> "center">
<TR> <TR>
<TD align="center"><BR> <TD align="center"><IMG src="conserver.jpg" alt=
<IMG src="conserver.gif" alt="Conserver"><BR> "Conserver"><BR>
<BR>
</TD> </TD>
</TR> </TR>
</TABLE> </TABLE>
<BR>
<TABLE summary="Conserver Page" width="80%" align="center"> <TABLE summary="Conserver Page" width="80%" align="center">
<TR>
<TD colspan="2" align="center">Please pick your closest
mirror: &nbsp;&nbsp;<A href=
"http://planetmirror.com/pub/conserver/">Australia</A>
&nbsp;&nbsp;<A href="http://www.conserver.com/">US
(Primary)</A><BR>
<BR>
</TD>
</TR>
<TR> <TR>
<TD> <TD>
<!-- empty cell here, then search box on right spans two rows, <!-- empty cell here, then search box on right spans two rows,
@ -84,8 +90,7 @@
from home or wherever.</P> from home or wherever.</P>
<H3>The FAQ</H3> <H3>The FAQ</H3>
Here's the conserver <A href= Here's the conserver <A href="FAQ">FAQ</A>. Got any
"http://www.conserver.com/FAQ">FAQ</A>. Got any
additions? Let me know. additions? Let me know.
<H3>Mailing Lists</H3> <H3>Mailing Lists</H3>
@ -170,24 +175,21 @@
port line toggling bits) that the conserver.com version port line toggling bits) that the conserver.com version
doesn't have. What does the conserver.com distribution doesn't have. What does the conserver.com distribution
have? Well, in reality, too many things to list. You'll have? Well, in reality, too many things to list. You'll
have to look at the <A href= have to look at the <A href="CHANGES">CHANGES</A> file
"http://www.conserver.com/CHANGES">CHANGES</A> file and and see the enhancements, bug fixes, and general
see the enhancements, bug fixes, and general development development since the original. Don't let the version
since the original. Don't let the version numbers fool numbers fool you - you'll have to compare and contrast
you - you'll have to compare and contrast for for yourself.</P>
yourself.</P>
<H3>Downloading</H3> <H3>Downloading</H3>
<P>The current version, released on Jan 27, 2003, is <A <P>The current version, released on Mar 20, 2003, is <A
href= href="7.2.6.tar.gz">7.2.6.tar.gz</A>. You can get it via
"http://www.conserver.com/7.2.5.tar.gz">7.2.5.tar.gz</A>. <A href=
You can get it via <A href= "ftp://ftp.conserver.com/conserver/7.2.6.tar.gz">FTP</A>
"ftp://ftp.conserver.com/conserver/7.2.5.tar.gz">FTP</A> or <A href="7.2.6.tar.gz">HTTP</A>. See the <A href=
or <A href= "CHANGES">CHANGES</A> file for information on the latest
"http://www.conserver.com/7.2.5.tar.gz">HTTP</A>. See the updates.</P>
<A href="http://www.conserver.com/CHANGES">CHANGES</A>
file for information on the latest updates.</P>
<P>As of version 6.1.7, the packaging and numbering <P>As of version 6.1.7, the packaging and numbering
scheme has changed. I used to package conserver as scheme has changed. I used to package conserver as
@ -203,8 +205,7 @@
<H3>Installation</H3> <H3>Installation</H3>
<P>Check the <A href= <P>Check the <A href="INSTALL">INSTALL</A> file for
"http://www.conserver.com/INSTALL">INSTALL</A> file for
instructions.</P> instructions.</P>
<H3>Systems Tested</H3> <H3>Systems Tested</H3>
@ -242,8 +243,7 @@
<P>Zonker Harris has fabulous documents regarding the <P>Zonker Harris has fabulous documents regarding the
hookup of consoles to terminal servers and other such hookup of consoles to terminal servers and other such
devices. His <A href= devices. His <A href="consoles/">Greater Scroll of
"http://www.conserver.com/consoles/">Greater Scroll of
Console Knowledge</A> is a great place to start.</P> Console Knowledge</A> is a great place to start.</P>
<HR noshade> <HR noshade>

View File

@ -1,5 +1,5 @@
/* /*
* $Id: access.c,v 5.45 2002-10-12 20:08:07-07 bryan Exp $ * $Id: access.c,v 5.52 2003-03-08 08:37:24-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -74,7 +74,7 @@
* Returns 0 if the addresses match, else returns 1. * Returns 0 if the addresses match, else returns 1.
*/ */
int int
#if USE_ANSI_PROTO #if PROTOTYPES
AddrCmp(struct in_addr *addr, char *pattern) AddrCmp(struct in_addr *addr, char *pattern)
#else #else
AddrCmp(addr, pattern) AddrCmp(addr, pattern)
@ -84,14 +84,16 @@ AddrCmp(addr, pattern)
{ {
in_addr_t hostaddr, pattern_addr, netmask; in_addr_t hostaddr, pattern_addr, netmask;
char *p, *slash_posn; char *p, *slash_posn;
static STRING buf = { (char *)0, 0, 0 }; static STRING *buf = (STRING *) 0;
if (buf == (STRING *) 0)
buf = AllocString();
slash_posn = strchr(pattern, '/'); slash_posn = strchr(pattern, '/');
if (slash_posn != NULL) { if (slash_posn != NULL) {
buildMyString((char *)0, &buf); BuildString((char *)0, buf);
buildMyString(pattern, &buf); BuildString(pattern, buf);
buf.string[slash_posn - pattern] = '\0'; /* isolate the address */ buf->string[slash_posn - pattern] = '\0'; /* isolate the address */
p = buf.string; p = buf->string;
} else } else
p = pattern; p = pattern;
@ -121,17 +123,16 @@ AddrCmp(addr, pattern)
netmask = 0xffffffff; /* compare entire addresses */ netmask = 0xffffffff; /* compare entire addresses */
hostaddr = addr->s_addr; hostaddr = addr->s_addr;
Debug(1, "Access check: host=%lx(%lx/%lx)", hostaddr & netmask, Debug(1, "AddrCmp(): host=%lx(%lx/%lx) acl=%lx(%lx/%lx)",
hostaddr, netmask); hostaddr & netmask, hostaddr, netmask, pattern_addr & netmask,
Debug(1, "Access check: acl=%lx(%lx/%lx)", pattern_addr, netmask);
pattern_addr & netmask, pattern_addr, netmask);
return (hostaddr & netmask) != (pattern_addr & netmask); return (hostaddr & netmask) != (pattern_addr & netmask);
} }
/* return the access type for a given host entry (ksb) /* return the access type for a given host entry (ksb)
*/ */
char char
#if USE_ANSI_PROTO #if PROTOTYPES
AccType(struct in_addr *addr, char *hname) AccType(struct in_addr *addr, char *hname)
#else #else
AccType(addr, hname) AccType(addr, hname)
@ -145,15 +146,15 @@ AccType(addr, hname)
if (fDebug) { if (fDebug) {
if (hname) if (hname)
Debug(1, "Access check: hostname=%s, ip=%s", hname, Debug(1, "AccType(): hostname=%s, ip=%s", hname,
inet_ntoa(*addr)); inet_ntoa(*addr));
else else
Debug(1, "Access check: hostname=<unresolvable>, ip=%s", Debug(1, "AccType(): hostname=<unresolvable>, ip=%s",
inet_ntoa(*addr)); inet_ntoa(*addr));
} }
for (pACtmp = pACList; pACtmp != (ACCESS *) 0; for (pACtmp = pACList; pACtmp != (ACCESS *) 0;
pACtmp = pACtmp->pACnext) { pACtmp = pACtmp->pACnext) {
Debug(1, "Access check: who=%s, trust=%c", pACtmp->pcwho, Debug(1, "AccType(): who=%s, trust=%c", pACtmp->pcwho,
pACtmp->ctrust); pACtmp->ctrust);
if (pACtmp->isCIDR != 0) { if (pACtmp->isCIDR != 0) {
if (0 == AddrCmp(addr, pACtmp->pcwho)) { if (0 == AddrCmp(addr, pACtmp->pcwho)) {
@ -165,7 +166,7 @@ AccType(addr, hname)
pcName = hname; pcName = hname;
len = strlen(pcName); len = strlen(pcName);
while (len >= pACtmp->ilen) { while (len >= pACtmp->ilen) {
Debug(1, "Access check: name=%s", pcName); Debug(1, "AccType(): name=%s", pcName);
if (0 == strcmp(pcName, pACtmp->pcwho)) { if (0 == strcmp(pcName, pACtmp->pcwho)) {
return pACtmp->ctrust; return pACtmp->ctrust;
} }
@ -182,7 +183,7 @@ AccType(addr, hname)
} }
void void
#if USE_ANSI_PROTO #if PROTOTYPES
SetDefAccess(struct in_addr *pAddr, char *pHost) SetDefAccess(struct in_addr *pAddr, char *pHost)
#else #else
SetDefAccess(pAddr, pHost) SetDefAccess(pAddr, pHost)
@ -206,7 +207,7 @@ SetDefAccess(pAddr, pHost)
pACList->ilen = iLen; pACList->ilen = iLen;
pACList->pcwho = strcpy(pcWho, addr); pACList->pcwho = strcpy(pcWho, addr);
Debug(1, "Access list prime: trust=%c, who=%s", pACList->ctrust, Debug(1, "SetDefAccess(): trust=%c, who=%s", pACList->ctrust,
pACList->pcwho); pACList->pcwho);
if ((char *)0 == (pcDomain = strchr(pHost, '.'))) { if ((char *)0 == (pcDomain = strchr(pHost, '.'))) {
@ -226,15 +227,15 @@ SetDefAccess(pAddr, pHost)
pACList->pACnext->ilen = iLen; pACList->pACnext->ilen = iLen;
pACList->pACnext->pcwho = strcpy(pcWho, pcDomain); pACList->pACnext->pcwho = strcpy(pcWho, pcDomain);
Debug(1, "Access list prime: trust=%c, who=%s", Debug(1, "SetDefAccess(): trust=%c, who=%s", pACList->pACnext->ctrust,
pACList->pACnext->ctrust, pACList->pACnext->pcwho); pACList->pACnext->pcwho);
} }
/* thread ther list of uniq console server machines, aliases for (ksb) /* thread ther list of uniq console server machines, aliases for (ksb)
* machines will screw us up * machines will screw us up
*/ */
REMOTE * REMOTE *
#if USE_ANSI_PROTO #if PROTOTYPES
FindUniq(REMOTE * pRCAll) FindUniq(REMOTE * pRCAll)
#else #else
FindUniq(pRCAll) FindUniq(pRCAll)
@ -262,3 +263,29 @@ FindUniq(pRCAll)
} }
return pRCAll; return pRCAll;
} }
void
#if PROTOTYPES
DestroyRemoteConsole(REMOTE * pRCList)
#else
DestroyRemoteConsole(pRCList)
REMOTE *pRCList;
#endif
{
DestroyString(&pRCList->rserver);
DestroyString(&pRCList->rhost);
free(pRCList);
}
void
#if PROTOTYPES
DestroyAccessList(ACCESS * pACList)
#else
DestroyAccessList(pACList)
ACCESS *pACList;
#endif
{
if (pACList->pcwho != (char *)0)
free(pACList->pcwho);
free(pACList);
}

View File

@ -1,5 +1,5 @@
/* /*
* $Id: access.h,v 5.18 2002-09-29 19:04:32-07 bryan Exp $ * $Id: access.h,v 5.22 2003-03-06 10:13:41-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -52,12 +52,8 @@ typedef struct remote { /* console at another host */
STRING rhost; /* remote host to call to get it */ STRING rhost; /* remote host to call to get it */
} REMOTE; } REMOTE;
#if USE_ANSI_PROTO extern REMOTE *FindUniq PARAMS((REMOTE *));
extern REMOTE *FindUniq(REMOTE *); extern char AccType PARAMS((struct in_addr *, char *));
extern char AccType(struct in_addr *, char *); extern void SetDefAccess PARAMS((struct in_addr *, char *));
extern void SetDefAccess(struct in_addr *, char *); extern void DestroyRemoteConsole PARAMS((REMOTE *));
#else extern void DestroyAccessList PARAMS((ACCESS *));
extern REMOTE *FindUniq();
extern char AccType();
extern void SetDefAccess();
#endif

View File

@ -1,5 +1,5 @@
/* /*
* $Id: client.c,v 5.49 2002-10-12 20:07:43-07 bryan Exp $ * $Id: client.c,v 5.58 2003-03-09 13:53:40-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -59,7 +59,7 @@
/* find the next guy who wants to write on the console (ksb) /* find the next guy who wants to write on the console (ksb)
*/ */
CONSCLIENT * CONSCLIENT *
#if USE_ANSI_PROTO #if PROTOTYPES
FindWrite(CONSCLIENT * pCL) FindWrite(CONSCLIENT * pCL)
#else #else
FindWrite(pCL) FindWrite(pCL)
@ -79,54 +79,16 @@ FindWrite(pCL)
pCL->fwantwr = 0; pCL->fwantwr = 0;
pCL->fwr = 1; pCL->fwr = 1;
if (pCL->pCEto->nolog) { if (pCL->pCEto->nolog) {
fileWrite(pCL->fd, "\r\n[attached (nologging)]\r\n", -1); FileWrite(pCL->fd, "\r\n[attached (nologging)]\r\n", -1);
} else { } else {
fileWrite(pCL->fd, "\r\n[attached]\r\n", -1); FileWrite(pCL->fd, "\r\n[attached]\r\n", -1);
} }
tagLogfile(pCL->pCEto, "%s attached", pCL->acid.string); TagLogfile(pCL->pCEto, "%s attached", pCL->acid.string);
return pCL; return pCL;
} }
return (CONSCLIENT *) 0; return (CONSCLIENT *) 0;
} }
/* show a character as a string so the user cannot mistake it for (ksb)
* another
*
* must pass us at least 16 characters to put fill with text
*/
char *
#if USE_ANSI_PROTO
FmtCtl(int ci, STRING * pcIn)
#else
FmtCtl(ci, pcIn)
int ci;
STRING *pcIn;
#endif
{
unsigned char c;
buildMyString((char *)0, pcIn);
c = ci & 0xff;
if (c > 127) {
c -= 128;
buildMyString("M-", pcIn);
}
if (c < ' ' || c == '\177') {
buildMyStringChar('^', pcIn);
buildMyStringChar(c ^ 0100, pcIn);
} else if (c == ' ') {
buildMyString("<space>", pcIn);
} else if (c == '^') {
buildMyString("<circumflex>", pcIn);
} else if (c == '\\') {
buildMyString("<backslash>", pcIn);
} else {
buildMyStringChar(c, pcIn);
}
return pcIn->string;
}
/* replay last iBack lines of the log file upon connect to console (ksb) /* replay last iBack lines of the log file upon connect to console (ksb)
* *
* NB: we know the console might be spewing when the replay happens, * NB: we know the console might be spewing when the replay happens,
@ -134,7 +96,7 @@ FmtCtl(ci, pcIn)
* so we don't drop chars... * so we don't drop chars...
*/ */
void void
#if USE_ANSI_PROTO #if PROTOTYPES
Replay(CONSFILE * fdLog, CONSFILE * fdOut, int iBack) Replay(CONSFILE * fdLog, CONSFILE * fdOut, int iBack)
#else #else
Replay(fdLog, fdOut, iBack) Replay(fdLog, fdOut, iBack)
@ -164,17 +126,24 @@ Replay(fdLog, fdOut, iBack)
int u; int u;
int is_mark; int is_mark;
char dummy[4]; char dummy[4];
#if HAVE_DMALLOC && DMALLOC_MARK_REPLAY
unsigned long dmallocMarkReplay = 0;
#endif
if ((CONSFILE *) 0 == fdLog) { if ((CONSFILE *) 0 == fdLog) {
fileWrite(fdOut, "[no log file on this console]\r\n", -1); FileWrite(fdOut, "[no log file on this console]\r\n", -1);
return; return;
} }
/* find the size of the file /* find the size of the file
*/ */
if (0 != fileStat(fdLog, &stLog)) { if (0 != FileStat(fdLog, &stLog)) {
return; return;
} }
#if HAVE_DMALLOC && DMALLOC_MARK_REPLAY
dmallocMarkReplay = dmalloc_mark();
#endif
file_pos = stLog.st_size - 1; file_pos = stLog.st_size - 1;
buf_pos = file_pos + 1; buf_pos = file_pos + 1;
@ -208,15 +177,15 @@ Replay(fdLog, fdOut, iBack)
#if defined(SEEK_SET) #if defined(SEEK_SET)
/* PTX and maybe other Posix systems /* PTX and maybe other Posix systems
*/ */
if (fileSeek(fdLog, buf_pos, SEEK_SET) < 0) { if (FileSeek(fdLog, buf_pos, SEEK_SET) < 0) {
goto common_exit; goto common_exit;
} }
#else #else
if (fileSeek(fdLog, buf_pos, L_SET) < 0) { if (FileSeek(fdLog, buf_pos, L_SET) < 0) {
goto common_exit; goto common_exit;
} }
#endif #endif
if ((r = fileRead(fdLog, buf, BUFSIZ)) <= 0) { if ((r = FileRead(fdLog, buf, BUFSIZ)) <= 0) {
goto common_exit; goto common_exit;
} }
bp = buf + r; bp = buf + r;
@ -275,10 +244,10 @@ Replay(fdLog, fdOut, iBack)
lines[ln].line.used = 0; lines[ln].line.used = 0;
lines[ln].line.allocated = 0; lines[ln].line.allocated = 0;
} else { } else {
buildMyString((char *)0, &lines[ln - 1].line); BuildString((char *)0, &lines[ln - 1].line);
buildMyString(lines[ln].line.string, BuildString(lines[ln].line.string,
&lines[ln - 1].line); &lines[ln - 1].line);
buildMyString((char *)0, &lines[ln].line); BuildString((char *)0, &lines[ln].line);
} }
ln--; ln--;
} }
@ -299,7 +268,7 @@ Replay(fdLog, fdOut, iBack)
if (ln < 0) { if (ln < 0) {
ln = 0; ln = 0;
} }
(void)buildMyStringChar(ch, &lines[ln].line); BuildStringChar(ch, &lines[ln].line);
/* if we've processed "a lot" of data for a line, then bail /* if we've processed "a lot" of data for a line, then bail
* why? there must be some very long non-newline terminated * why? there must be some very long non-newline terminated
@ -343,8 +312,8 @@ Replay(fdLog, fdOut, iBack)
if ((char *)0 != s) { if ((char *)0 != s) {
*s = '\000'; *s = '\000';
} }
(void)fileWrite(fdOut, lines[i].line.string, -1); FileWrite(fdOut, lines[i].line.string, -1);
(void)fileWrite(fdOut, " .. ", -1); FileWrite(fdOut, " .. ", -1);
/* build the end string by removing the leading "[-- MARK -- " /* build the end string by removing the leading "[-- MARK -- "
* and replacing "]\r\n" on the end with " -- MARK --]\r\n" * and replacing "]\r\n" on the end with " -- MARK --]\r\n"
@ -355,31 +324,20 @@ Replay(fdLog, fdOut, iBack)
if ((char *)0 != s) { if ((char *)0 != s) {
*s = '\000'; *s = '\000';
} }
(void)fileWrite(fdOut, lines[i].mark_end.string + mark_len, FileWrite(fdOut, lines[i].mark_end.string + mark_len, -1);
-1); FileWrite(fdOut, " -- MARK --]\r\n", -1);
(void)fileWrite(fdOut, " -- MARK --]\r\n", -1);
u = lines[i].mark_end.used; u = lines[i].mark_end.used;
s = lines[i].mark_end.string; s = lines[i].mark_end.string;
} else } else
(void)fileWrite(fdOut, lines[i].line.string, -1); FileWrite(fdOut, lines[i].line.string, -1);
} }
common_exit: common_exit:
if ((struct lines *)0 != lines) { if ((struct lines *)0 != lines) {
for (i = 0; i < n_lines; i++) { for (i = 0; i < n_lines; i++) {
if ((char *)0 != lines[i].mark_end.string) { DestroyString(&lines[i].mark_end);
free(lines[i].mark_end.string); DestroyString(&lines[i].line);
lines[i].mark_end.string = (char *)0;
lines[i].mark_end.used = 0;
lines[i].mark_end.allocated = 0;
}
if ((char *)0 != lines[i].line.string) {
free(lines[i].line.string);
lines[i].line.string = (char *)0;
lines[i].line.used = 0;
lines[i].line.allocated = 0;
}
} }
free(lines); free(lines);
lines = (struct lines *)0; lines = (struct lines *)0;
@ -388,6 +346,10 @@ Replay(fdLog, fdOut, iBack)
free(buf); free(buf);
buf = (char *)0; buf = (char *)0;
} }
#if HAVE_DMALLOC && DMALLOC_MARK_REPLAY
Debug(1, "Replay(): dmalloc / MarkReplay");
dmalloc_log_changed(dmallocMarkReplay, 1, 0, 1);
#endif
} }
@ -445,7 +407,7 @@ static HELP aHLTable[] = {
/* list the commands we know for the user (ksb) /* list the commands we know for the user (ksb)
*/ */
void void
#if USE_ANSI_PROTO #if PROTOTYPES
HelpUser(CONSCLIENT * pCL) HelpUser(CONSCLIENT * pCL)
#else #else
HelpUser(pCL) HelpUser(pCL)
@ -456,52 +418,55 @@ HelpUser(pCL)
static char static char
acH1[] = "help]\r\n", acH2[] = "help spy mode]\r\n", acEoln[] = acH1[] = "help]\r\n", acH2[] = "help spy mode]\r\n", acEoln[] =
"\r\n"; "\r\n";
static STRING acLine = { (char *)0, 0, 0 }; static STRING *acLine = (STRING *) 0;
if (acLine == (STRING *) 0)
acLine = AllocString();
iCmp = WHEN_ALWAYS | WHEN_SPY; iCmp = WHEN_ALWAYS | WHEN_SPY;
if (pCL->fwr) { if (pCL->fwr) {
(void)fileWrite(pCL->fd, acH1, sizeof(acH1) - 1); FileWrite(pCL->fd, acH1, sizeof(acH1) - 1);
iCmp |= WHEN_ATTACH; iCmp |= WHEN_ATTACH;
} else { } else {
(void)fileWrite(pCL->fd, acH2, sizeof(acH2) - 1); FileWrite(pCL->fd, acH2, sizeof(acH2) - 1);
} }
if ('\033' == pCL->ic[0] && 'O' == pCL->ic[1]) { if ('\033' == pCL->ic[0] && 'O' == pCL->ic[1]) {
iCmp |= WHEN_VT100; iCmp |= WHEN_VT100;
} }
buildMyString((char *)0, &acLine); BuildString((char *)0, acLine);
for (i = 0; i < sizeof(aHLTable) / sizeof(HELP); ++i) { for (i = 0; i < sizeof(aHLTable) / sizeof(HELP); ++i) {
if (0 == (aHLTable[i].iwhen & iCmp)) { if (0 == (aHLTable[i].iwhen & iCmp)) {
continue; continue;
} }
if (acLine.used != 0) { /* second part of line */ if (acLine->used != 0) { /* second part of line */
if (strlen(aHLTable[i].actext) < HALFLINE) { if (strlen(aHLTable[i].actext) < HALFLINE) {
for (j = acLine.used; j <= HALFLINE; ++j) { for (j = acLine->used; j <= HALFLINE; ++j) {
buildMyStringChar(' ', &acLine); BuildStringChar(' ', acLine);
} }
buildMyString(aHLTable[i].actext, &acLine); BuildString(aHLTable[i].actext, acLine);
buildMyString(acEoln, &acLine); BuildString(acEoln, acLine);
(void)fileWrite(pCL->fd, acLine.string, -1); FileWrite(pCL->fd, acLine->string, -1);
buildMyString((char *)0, &acLine); BuildString((char *)0, acLine);
continue; continue;
} else { } else {
buildMyString(acEoln, &acLine); BuildString(acEoln, acLine);
(void)fileWrite(pCL->fd, acLine.string, -1); FileWrite(pCL->fd, acLine->string, -1);
buildMyString((char *)0, &acLine); BuildString((char *)0, acLine);
} }
} }
if (acLine.used == 0) { /* at new line */ if (acLine->used == 0) { /* at new line */
buildMyStringChar(' ', &acLine); BuildStringChar(' ', acLine);
buildMyString(aHLTable[i].actext, &acLine); BuildString(aHLTable[i].actext, acLine);
if (acLine.used > HALFLINE) { if (acLine->used > HALFLINE) {
buildMyString(acEoln, &acLine); BuildString(acEoln, acLine);
(void)fileWrite(pCL->fd, acLine.string, -1); FileWrite(pCL->fd, acLine->string, -1);
buildMyString((char *)0, &acLine); BuildString((char *)0, acLine);
} }
} }
} }
if (acLine.used != 0) { if (acLine->used != 0) {
buildMyString(acEoln, &acLine); BuildString(acEoln, acLine);
(void)fileWrite(pCL->fd, acLine.string, -1); FileWrite(pCL->fd, acLine->string, -1);
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: client.h,v 5.25 2002-02-25 14:00:38-08 bryan Exp $ * $Id: client.h,v 5.27 2003-03-06 10:13:41-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -78,14 +78,6 @@ typedef struct client { /* Connection Information: */
cnct_port; /* where from */ cnct_port; /* where from */
} CONSCLIENT; } CONSCLIENT;
#if USE_ANSI_PROTO extern void Replay PARAMS((CONSFILE *, CONSFILE *, int));
extern char *FmtCtl(int, STRING *); extern void HelpUser PARAMS((CONSCLIENT *));
extern void Replay(CONSFILE *, CONSFILE *, int); extern CONSCLIENT *FindWrite PARAMS((CONSCLIENT *));
extern void HelpUser(CONSCLIENT *);
extern CONSCLIENT *FindWrite(CONSCLIENT *);
#else
extern char *FmtCtl();
extern void Replay();
extern void HelpUser();
extern CONSCLIENT *FindWrite();
#endif

View File

@ -1,5 +1,5 @@
/* /*
* $Id: consent.c,v 5.92 2002-10-12 20:07:43-07 bryan Exp $ * $Id: consent.c,v 5.101 2003-03-09 15:51:15-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -94,7 +94,7 @@ BAUD baud[] = {
/* find a baud rate for the string "9600x" -> B9600 (ksb) /* find a baud rate for the string "9600x" -> B9600 (ksb)
*/ */
BAUD * BAUD *
#if USE_ANSI_PROTO #if PROTOTYPES
FindBaud(char *pcMode) FindBaud(char *pcMode)
#else #else
FindBaud(pcMode) FindBaud(pcMode)
@ -151,7 +151,7 @@ PARITY parity[] = {
/* find a parity on the end of a baud "9600even" -> EVEN (ksb) /* find a parity on the end of a baud "9600even" -> EVEN (ksb)
*/ */
PARITY * PARITY *
#if USE_ANSI_PROTO #if PROTOTYPES
FindParity(char *pcMode) FindParity(char *pcMode)
#else #else
FindParity(pcMode) FindParity(pcMode)
@ -180,7 +180,7 @@ FindParity(pcMode)
/* setup a tty device (ksb) /* setup a tty device (ksb)
*/ */
static int static int
#if USE_ANSI_PROTO #if PROTOTYPES
TtyDev(CONSENT * pCE) TtyDev(CONSENT * pCE)
#else #else
TtyDev(pCE) TtyDev(pCE)
@ -193,7 +193,8 @@ TtyDev(pCE)
/* here we should fstat for `read-only' checks /* here we should fstat for `read-only' checks
*/ */
if (-1 == fstat(pCE->fdtty, &stPerm)) { if (-1 == fstat(pCE->fdtty, &stPerm)) {
Error("fstat: %s: %s", pCE->dfile.string, strerror(errno)); Error("[%s] fstat(%s(%d)): %s", pCE->server.string,
pCE->dfile.string, pCE->fdtty, strerror(errno));
} else if (0 == (stPerm.st_mode & 0222)) { } else if (0 == (stPerm.st_mode & 0222)) {
/* any device that is read-only we won't write to /* any device that is read-only we won't write to
*/ */
@ -204,8 +205,8 @@ TtyDev(pCE)
* Get terminal attributes * Get terminal attributes
*/ */
if (-1 == tcgetattr(pCE->fdtty, &termp)) { if (-1 == tcgetattr(pCE->fdtty, &termp)) {
Error("tcgetattr: %s(%d): %s", pCE->dfile.string, pCE->fdtty, Error("[%s] tcgetattr(%s(%d)): %s", pCE->server.string,
strerror(errno)); pCE->dfile.string, pCE->fdtty, strerror(errno));
return -1; return -1;
} }
@ -234,13 +235,13 @@ TtyDev(pCE)
termp.c_cc[VTIME] = 1; termp.c_cc[VTIME] = 1;
if (-1 == cfsetospeed(&termp, pCE->pbaud->irate)) { if (-1 == cfsetospeed(&termp, pCE->pbaud->irate)) {
Error("cfsetospeed: %s(%d): %s", pCE->dfile.string, pCE->fdtty, Error("[%s] cfsetospeed(%s(%d)): %s", pCE->server.string,
strerror(errno)); pCE->dfile.string, pCE->fdtty, strerror(errno));
return -1; return -1;
} }
if (-1 == cfsetispeed(&termp, pCE->pbaud->irate)) { if (-1 == cfsetispeed(&termp, pCE->pbaud->irate)) {
Error("cfsetispeed: %s(%d): %s", pCE->dfile.string, pCE->fdtty, Error("[%s] cfsetispeed(%s(%d)): %s", pCE->server.string,
strerror(errno)); pCE->dfile.string, pCE->fdtty, strerror(errno));
return -1; return -1;
} }
@ -248,8 +249,8 @@ TtyDev(pCE)
* Set terminal attributes * Set terminal attributes
*/ */
if (-1 == tcsetattr(pCE->fdtty, TCSADRAIN, &termp)) { if (-1 == tcsetattr(pCE->fdtty, TCSADRAIN, &termp)) {
Error("tcsetattr: %s(%d): %s", pCE->dfile.string, pCE->fdtty, Error("[%s] tcsetattr(%s(%d),TCSADRAIN): %s", pCE->server.string,
strerror(errno)); pCE->dfile.string, pCE->fdtty, strerror(errno));
return -1; return -1;
} }
# if HAVE_STROPTS_H # if HAVE_STROPTS_H
@ -257,7 +258,7 @@ TtyDev(pCE)
* eat all the streams modules upto and including ttcompat * eat all the streams modules upto and including ttcompat
*/ */
while (ioctl(pCE->fdtty, I_FIND, "ttcompat") == 1) { while (ioctl(pCE->fdtty, I_FIND, "ttcompat") == 1) {
(void)ioctl(pCE->fdtty, I_POP, 0); ioctl(pCE->fdtty, I_POP, 0);
} }
# endif # endif
pCE->fup = 1; pCE->fup = 1;
@ -271,7 +272,7 @@ TtyDev(pCE)
/* setup a tty device (ksb) /* setup a tty device (ksb)
*/ */
static int static int
#if USE_ANSI_PROTO #if PROTOTYPES
TtyDev(CONSENT * pCE) TtyDev(CONSENT * pCE)
#else #else
TtyDev(pCE) TtyDev(pCE)
@ -286,7 +287,8 @@ TtyDev(pCE)
/* here we should fstat for `read-only' checks /* here we should fstat for `read-only' checks
*/ */
if (-1 == fstat(pCE->fdtty, &stPerm)) { if (-1 == fstat(pCE->fdtty, &stPerm)) {
Error("fstat: %s: %s", pCE->dfile.string, strerror(errno)); Error("[%s] fstat(%s(%d)): %s", pCE->server.string,
pCE->dfile.string, pCE->fdtty, strerror(errno));
} else if (0 == (stPerm.st_mode & 0222)) { } else if (0 == (stPerm.st_mode & 0222)) {
/* any device that is read-only we won't write to /* any device that is read-only we won't write to
*/ */
@ -294,7 +296,8 @@ TtyDev(pCE)
} }
# if defined(TIOCSSOFTCAR) # if defined(TIOCSSOFTCAR)
if (-1 == ioctl(pCE->fdtty, TIOCSSOFTCAR, &fSoftcar)) { if (-1 == ioctl(pCE->fdtty, TIOCSSOFTCAR, &fSoftcar)) {
Error("softcar: %d: %s", pCE->fdtty, strerror(errno)); Error("[%s] ioctl(%s(%d),TIOCSSOFTCAR): %s", pCE->server.string,
pCE->dfile.string, pCE->fdtty, strerror(errno));
return -1; return -1;
} }
# endif # endif
@ -302,8 +305,8 @@ TtyDev(pCE)
/* stty 9600 raw cs7 /* stty 9600 raw cs7
*/ */
if (-1 == ioctl(pCE->fdtty, TIOCGETP, (char *)&sty)) { if (-1 == ioctl(pCE->fdtty, TIOCGETP, (char *)&sty)) {
Error("ioctl1: %s(%d): %s", pCE->dfile.string, pCE->fdtty, Error("[%s] ioctl(%s(%d),TIOCGETP): %s", pCE->server.string,
strerror(errno)); pCE->dfile.string, pCE->fdtty, strerror(errno));
return -1; return -1;
} }
sty.sg_flags &= ~(ECHO | CRMOD | pCE->pparity->iclr); sty.sg_flags &= ~(ECHO | CRMOD | pCE->pparity->iclr);
@ -313,7 +316,8 @@ TtyDev(pCE)
sty.sg_ispeed = pCE->pbaud->irate; sty.sg_ispeed = pCE->pbaud->irate;
sty.sg_ospeed = pCE->pbaud->irate; sty.sg_ospeed = pCE->pbaud->irate;
if (-1 == ioctl(pCE->fdtty, TIOCSETP, (char *)&sty)) { if (-1 == ioctl(pCE->fdtty, TIOCSETP, (char *)&sty)) {
Error("ioctl2: %d: %s", pCE->fdtty, strerror(errno)); Error("[%s] ioctl(%s(%d),TIOCSETP): %s", pCE->server.string,
pCE->dfile.string, pCE->fdtty, strerror(errno));
return -1; return -1;
} }
@ -321,7 +325,8 @@ TtyDev(pCE)
* (in cbreak mode we may not need to this... but we do) * (in cbreak mode we may not need to this... but we do)
*/ */
if (-1 == ioctl(pCE->fdtty, TIOCGETC, (char *)&m_tchars)) { if (-1 == ioctl(pCE->fdtty, TIOCGETC, (char *)&m_tchars)) {
Error("ioctl3: %d: %s", pCE->fdtty, strerror(errno)); Error("[%s] ioctl(%s(%d),TIOCGETC): %s", pCE->server.string,
pCE->dfile.string, pCE->fdtty, strerror(errno));
return -1; return -1;
} }
m_tchars.t_intrc = -1; m_tchars.t_intrc = -1;
@ -331,11 +336,13 @@ TtyDev(pCE)
m_tchars.t_eofc = -1; m_tchars.t_eofc = -1;
m_tchars.t_brkc = -1; m_tchars.t_brkc = -1;
if (-1 == ioctl(pCE->fdtty, TIOCSETC, (char *)&m_tchars)) { if (-1 == ioctl(pCE->fdtty, TIOCSETC, (char *)&m_tchars)) {
Error("ioctl4: %d: %s", pCE->fdtty, strerror(errno)); Error("[%s] ioctl(%s(%d),TIOCSETC): %s", pCE->server.string,
pCE->dfile.string, pCE->fdtty, strerror(errno));
return -1; return -1;
} }
if (-1 == ioctl(pCE->fdtty, TIOCGLTC, (char *)&m_ltchars)) { if (-1 == ioctl(pCE->fdtty, TIOCGLTC, (char *)&m_ltchars)) {
Error("ioctl5: %d: %s", pCE->fdtty, strerror(errno)); Error("[%s] ioctl(%s(%d),TIOCGLTC): %s", pCE->server.string,
pCE->dfile.string, pCE->fdtty, strerror(errno));
return -1; return -1;
} }
m_ltchars.t_werasc = -1; m_ltchars.t_werasc = -1;
@ -344,7 +351,8 @@ TtyDev(pCE)
m_ltchars.t_suspc = -1; m_ltchars.t_suspc = -1;
m_ltchars.t_dsuspc = -1; m_ltchars.t_dsuspc = -1;
if (-1 == ioctl(pCE->fdtty, TIOCSLTC, (char *)&m_ltchars)) { if (-1 == ioctl(pCE->fdtty, TIOCSLTC, (char *)&m_ltchars)) {
Error("ioctl6: %d: %s", pCE->fdtty, strerror(errno)); Error("[%s] ioctl(%s(%d),TIOCSLTC): %s", pCE->server.string,
pCE->dfile.string, pCE->fdtty, strerror(errno));
return -1; return -1;
} }
# if HAVE_STROPTS_H # if HAVE_STROPTS_H
@ -365,7 +373,7 @@ TtyDev(pCE)
/* setup a virtual device (ksb) /* setup a virtual device (ksb)
*/ */
static int static int
#if USE_ANSI_PROTO #if PROTOTYPES
VirtDev(CONSENT * pCE) VirtDev(CONSENT * pCE)
#else #else
VirtDev(pCE) VirtDev(pCE)
@ -381,12 +389,13 @@ VirtDev(pCE)
struct ltchars m_ltchars; struct ltchars m_ltchars;
# endif # endif
# endif # endif
int i, iNewGrp; int i;
pid_t iNewGrp;
extern char **environ; extern char **environ;
char *pcShell, **ppcArgv; char *pcShell, **ppcArgv;
(void)fflush(stdout); fflush(stdout);
(void)fflush(stderr); fflush(stderr);
switch (pCE->ipid = fork()) { switch (pCE->ipid = fork()) {
case -1: case -1:
@ -395,35 +404,34 @@ VirtDev(pCE)
thepid = getpid(); thepid = getpid();
break; break;
default: default:
if (fVerbose) Verbose("[%s] pid %lu on %s", pCE->server.string, pCE->ipid,
Error("%s has pid %d on %s", pCE->server.string, pCE->ipid,
pCE->acslave.string); pCE->acslave.string);
(void)fflush(stderr); fflush(stderr);
pCE->fup = 1; pCE->fup = 1;
return 0; return 0;
} }
/* put the signals back that we ignore (trapped auto-reset to default) /* put the signals back that we ignore (trapped auto-reset to default)
*/ */
simpleSignal(SIGQUIT, SIG_DFL); SimpleSignal(SIGQUIT, SIG_DFL);
simpleSignal(SIGINT, SIG_DFL); SimpleSignal(SIGINT, SIG_DFL);
simpleSignal(SIGPIPE, SIG_DFL); SimpleSignal(SIGPIPE, SIG_DFL);
#if defined(SIGTTOU) #if defined(SIGTTOU)
simpleSignal(SIGTTOU, SIG_DFL); SimpleSignal(SIGTTOU, SIG_DFL);
#endif #endif
#if defined(SIGTTIN) #if defined(SIGTTIN)
simpleSignal(SIGTTIN, SIG_DFL); SimpleSignal(SIGTTIN, SIG_DFL);
#endif #endif
#if defined(SIGTSTP) #if defined(SIGTSTP)
simpleSignal(SIGTSTP, SIG_DFL); SimpleSignal(SIGTSTP, SIG_DFL);
#endif #endif
#if defined(SIGPOLL) #if defined(SIGPOLL)
simpleSignal(SIGPOLL, SIG_DFL); SimpleSignal(SIGPOLL, SIG_DFL);
#endif #endif
/* setup new process with clean filew descriptors /* setup new process with clean filew descriptors
*/ */
i = cmaxfiles(); i = GetMaxFiles();
for ( /* i above */ ; --i > 2;) { for ( /* i above */ ; --i > 2;) {
close(i); close(i);
} }
@ -435,7 +443,7 @@ VirtDev(pCE)
# if HAVE_SETSID # if HAVE_SETSID
iNewGrp = setsid(); iNewGrp = setsid();
if (-1 == iNewGrp) { if (-1 == iNewGrp) {
Error("%s: setsid: %s", pCE->server.string, strerror(errno)); Error("[%s] setsid(): %s", pCE->server.string, strerror(errno));
iNewGrp = getpid(); iNewGrp = getpid();
} }
# else # else
@ -443,7 +451,7 @@ VirtDev(pCE)
# endif # endif
if (0 != open(pCE->acslave.string, O_RDWR, 0) || 1 != dup(0)) { if (0 != open(pCE->acslave.string, O_RDWR, 0) || 1 != dup(0)) {
Error("%s: fd sync error", pCE->server.string); Error("[%s] fd sync error", pCE->server.string);
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
# if HAVE_STROPTS_H && !defined(_AIX) # if HAVE_STROPTS_H && !defined(_AIX)
@ -451,13 +459,13 @@ VirtDev(pCE)
* under PTX (others?) we have to push the compatibility * under PTX (others?) we have to push the compatibility
* streams modules `ptem', `ld', and `ttcompat' * streams modules `ptem', `ld', and `ttcompat'
*/ */
Debug(1, "Pushing ptemp onto pseudo-terminal"); Debug(1, "VirtDev(): pushing ptemp onto pseudo-terminal");
(void)ioctl(0, I_PUSH, "ptem"); ioctl(0, I_PUSH, "ptem");
Debug(1, "Pushing ldterm onto pseudo-terminal"); Debug(1, "VirtDev(): pushing ldterm onto pseudo-terminal");
(void)ioctl(0, I_PUSH, "ldterm"); ioctl(0, I_PUSH, "ldterm");
Debug(1, "Pushing ttcompat onto pseudo-terminal"); Debug(1, "VirtDev(): pushing ttcompat onto pseudo-terminal");
(void)ioctl(0, I_PUSH, "ttcompat"); ioctl(0, I_PUSH, "ttcompat");
Debug(1, "Done pushing modules onto pseudo-terminal"); Debug(1, "VirtDev(): done pushing modules onto pseudo-terminal");
# endif # endif
# if HAVE_TERMIOS_H # if HAVE_TERMIOS_H
@ -467,7 +475,8 @@ VirtDev(pCE)
if (0 != ioctl(0, TCGETS, &n_tio)) if (0 != ioctl(0, TCGETS, &n_tio))
# endif # endif
{ {
Error("ioctl: getsw: %s", strerror(errno)); Error("[%s] ioctl(0,TCGETS): %s", pCE->server.string,
strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
n_tio.c_iflag &= ~(IGNCR | IUCLC); n_tio.c_iflag &= ~(IGNCR | IUCLC);
@ -493,7 +502,8 @@ VirtDev(pCE)
if (0 != ioctl(0, TCSETS, &n_tio)) if (0 != ioctl(0, TCSETS, &n_tio))
# endif # endif
{ {
Error("getattr: %s", strerror(errno)); Error("[%s] ioctl(0,TCSETS): %s", pCE->server.string,
strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
@ -502,7 +512,8 @@ VirtDev(pCE)
/* stty 9600 raw cs7 /* stty 9600 raw cs7
*/ */
if (-1 == ioctl(0, TIOCGETP, (char *)&sty)) { if (-1 == ioctl(0, TIOCGETP, (char *)&sty)) {
Error("ioctl1: %s: %s", pCE->fdtty, strerror(errno)); Error("[%s] ioctl(0,TIOCGETP): %s", pCE->server.string,
strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
sty.sg_flags &= ~(CBREAK | TANDEM | pCE->pparity->iclr); sty.sg_flags &= ~(CBREAK | TANDEM | pCE->pparity->iclr);
@ -512,7 +523,8 @@ VirtDev(pCE)
sty.sg_ispeed = pCE->pbaud->irate; sty.sg_ispeed = pCE->pbaud->irate;
sty.sg_ospeed = pCE->pbaud->irate; sty.sg_ospeed = pCE->pbaud->irate;
if (-1 == ioctl(0, TIOCSETP, (char *)&sty)) { if (-1 == ioctl(0, TIOCSETP, (char *)&sty)) {
Error("ioctl2: %s", strerror(errno)); Error("[%s] ioctl(0,TIOCSETP): %s", pCE->server.string,
strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
@ -520,7 +532,8 @@ VirtDev(pCE)
* (in cbreak mode we may not need to this... but we do) * (in cbreak mode we may not need to this... but we do)
*/ */
if (-1 == ioctl(0, TIOCGETC, (char *)&m_tchars)) { if (-1 == ioctl(0, TIOCGETC, (char *)&m_tchars)) {
Error("ioctl3: %s", strerror(errno)); Error("[%s] ioctl(0,TIOCGETC): %s", pCE->server.string,
strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
m_tchars.t_intrc = '\003'; m_tchars.t_intrc = '\003';
@ -530,11 +543,13 @@ VirtDev(pCE)
m_tchars.t_eofc = '\004'; m_tchars.t_eofc = '\004';
m_tchars.t_brkc = '\033'; m_tchars.t_brkc = '\033';
if (-1 == ioctl(0, TIOCSETC, (char *)&m_tchars)) { if (-1 == ioctl(0, TIOCSETC, (char *)&m_tchars)) {
Error("ioctl4: %s", strerror(errno)); Error("[%s] ioctl(0,TIOCSETC): %s", pCE->server.string,
strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
if (-1 == ioctl(0, TIOCGLTC, (char *)&m_ltchars)) { if (-1 == ioctl(0, TIOCGLTC, (char *)&m_ltchars)) {
Error("ioctl5: %s", strerror(errno)); Error("[%s] ioctl(0,TIOCGLTC): %s", pCE->server.string,
strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
m_ltchars.t_werasc = '\027'; m_ltchars.t_werasc = '\027';
@ -543,7 +558,8 @@ VirtDev(pCE)
m_ltchars.t_suspc = '\032'; m_ltchars.t_suspc = '\032';
m_ltchars.t_dsuspc = '\031'; m_ltchars.t_dsuspc = '\031';
if (-1 == ioctl(0, TIOCSLTC, (char *)&m_ltchars)) { if (-1 == ioctl(0, TIOCSLTC, (char *)&m_ltchars)) {
Error("ioctl6: %s", strerror(errno)); Error("[%s] ioctl(0,TIOCSLTC): %s", pCE->server.string,
strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
@ -560,13 +576,13 @@ VirtDev(pCE)
# endif /* HAVE_TERMIOS_H */ # endif /* HAVE_TERMIOS_H */
close(2); close(2);
(void)dup(1); /* better be 2, but it is too late now */ dup(1); /* better be 2, but it is too late now */
/* if the command is null we should run root's shell, directly /* if the command is null we should run root's shell, directly
* if we can't find root's shell run /bin/sh * if we can't find root's shell run /bin/sh
*/ */
pcShell = "/bin/sh"; pcShell = "/bin/sh";
if (pCE->pccmd.used == 0 || pCE->pccmd.string[0] == '\000') { if (pCE->pccmd.used <= 1) {
static char *apcArgv[] = { static char *apcArgv[] = {
"-shell", "-i", (char *)0 "-shell", "-i", (char *)0
}; };
@ -586,14 +602,14 @@ VirtDev(pCE)
ppcArgv = apcArgv; ppcArgv = apcArgv;
} }
execve(pcShell, ppcArgv, environ); execve(pcShell, ppcArgv, environ);
Error("execve: %s", strerror(errno)); Error("[%s] execve(): %s", pCE->server.string, strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
/* down a console, virtual or real (ksb) /* down a console, virtual or real (ksb)
*/ */
void void
#if USE_ANSI_PROTO #if PROTOTYPES
ConsDown(CONSENT * pCE, fd_set * pfdSet) ConsDown(CONSENT * pCE, fd_set * pfdSet)
#else #else
ConsDown(pCE, pfdSet) ConsDown(pCE, pfdSet)
@ -602,25 +618,26 @@ ConsDown(pCE, pfdSet)
#endif #endif
{ {
if (-1 != pCE->ipid) { if (-1 != pCE->ipid) {
Debug(1, "Sending pid %d signal %d", pCE->ipid, SIGHUP); Debug(1, "ConsDown(): sending pid %lu signal %d",
(unsigned long)pCE->ipid, SIGHUP);
kill(pCE->ipid, SIGHUP); kill(pCE->ipid, SIGHUP);
pCE->ipid = -1; pCE->ipid = -1;
} }
if (-1 != pCE->fdtty) { if (-1 != pCE->fdtty) {
if ((fd_set *) 0 != pfdSet) if ((fd_set *) 0 != pfdSet)
FD_CLR(pCE->fdtty, pfdSet); FD_CLR(pCE->fdtty, pfdSet);
(void)close(pCE->fdtty); close(pCE->fdtty);
pCE->fdtty = -1; pCE->fdtty = -1;
} }
if ((CONSFILE *) 0 != pCE->fdlog) { if ((CONSFILE *) 0 != pCE->fdlog) {
if (pCE->nolog) { if (pCE->nolog) {
filePrint(pCE->fdlog, FilePrint(pCE->fdlog,
"[-- Console logging restored -- %s]\r\n", "[-- Console logging restored -- %s]\r\n",
strtime(NULL)); StrTime(NULL));
} }
filePrint(pCE->fdlog, "[-- Console down -- %s]\r\n", FilePrint(pCE->fdlog, "[-- Console down -- %s]\r\n",
strtime(NULL)); StrTime(NULL));
fileClose(&pCE->fdlog); FileClose(&pCE->fdlog);
pCE->fdlog = (CONSFILE *) 0; pCE->fdlog = (CONSFILE *) 0;
} }
pCE->fup = 0; pCE->fup = 0;
@ -629,7 +646,7 @@ ConsDown(pCE, pfdSet)
} }
int int
#if USE_ANSI_PROTO #if PROTOTYPES
CheckHostCache(const char *hostname) CheckHostCache(const char *hostname)
#else #else
CheckHostCache(hostname) CheckHostCache(hostname)
@ -648,7 +665,7 @@ CheckHostCache(hostname)
} }
void void
#if USE_ANSI_PROTO #if PROTOTYPES
AddHostCache(const char *hostname) AddHostCache(const char *hostname)
#else #else
AddHostCache(hostname) AddHostCache(hostname)
@ -658,16 +675,16 @@ AddHostCache(hostname)
struct hostcache *n; struct hostcache *n;
if ((struct hostcache *)0 == if ((struct hostcache *)0 ==
(n = (struct hostcache *)calloc(1, sizeof(struct hostcache)))) { (n = (struct hostcache *)calloc(1, sizeof(struct hostcache)))) {
Error("calloc failure: %s", strerror(errno)); Error("AddHostCache(): calloc(): %s", strerror(errno));
return; return;
} }
buildMyString(hostname, &n->hostname); BuildString(hostname, &n->hostname);
n->next = hostcachelist; n->next = hostcachelist;
hostcachelist = n; hostcachelist = n;
} }
void void
#if USE_ANSI_PROTO #if PROTOTYPES
ClearHostCache(void) ClearHostCache(void)
#else #else
ClearHostCache() ClearHostCache()
@ -690,7 +707,7 @@ ClearHostCache()
* We also maintian the select set for the caller. * We also maintian the select set for the caller.
*/ */
void void
#if USE_ANSI_PROTO #if PROTOTYPES
ConsInit(CONSENT * pCE, fd_set * pfdSet, int useHostCache) ConsInit(CONSENT * pCE, fd_set * pfdSet, int useHostCache)
#else #else
ConsInit(pCE, pfdSet, useHostCache) ConsInit(pCE, pfdSet, useHostCache)
@ -700,7 +717,7 @@ ConsInit(pCE, pfdSet, useHostCache)
#endif #endif
{ {
time_t tyme; time_t tyme;
#if USE_ANSI_PROTO #if PROTOTYPES
extern int FallBack(STRING *, STRING *); extern int FallBack(STRING *, STRING *);
#else #else
extern int FallBack(); extern int FallBack();
@ -714,7 +731,7 @@ ConsInit(pCE, pfdSet, useHostCache)
if (pCE->fup) { if (pCE->fup) {
ConsDown(pCE, pfdSet); ConsDown(pCE, pfdSet);
usleep(500000); /* pause 0.50 sec to let things settle a bit */ usleep(500000); /* pause 0.50 sec to let things settle a bit */
resetMark(); ResetMark();
} }
pCE->autoReUp = 0; pCE->autoReUp = 0;
@ -727,15 +744,17 @@ ConsInit(pCE, pfdSet, useHostCache)
*/ */
if ((CONSFILE *) 0 == if ((CONSFILE *) 0 ==
(pCE->fdlog = (pCE->fdlog =
fileOpen(pCE->lfile.string, O_RDWR | O_CREAT | O_APPEND, 0644))) { FileOpen(pCE->lfile.string, O_RDWR | O_CREAT | O_APPEND, 0644))) {
Error("open: %s: %s", pCE->lfile.string, strerror(errno)); Error("[%s] FileOpen(%s): %s", pCE->server.string,
pCE->lfile.string, strerror(errno));
return; return;
} }
filePrint(pCE->fdlog, "[-- Console up -- %s]\r\n", strtime(NULL)); FilePrint(pCE->fdlog, "[-- Console up -- %s]\r\n", StrTime(NULL));
if (0 != pCE->fvirtual) { if (0 != pCE->fvirtual) {
if (-1 == (pCE->fdtty = FallBack(&pCE->acslave, &pCE->dfile))) { if (-1 == (pCE->fdtty = FallBack(&pCE->acslave, &pCE->dfile))) {
Error("Failed to allocate pseudo-tty: %s", strerror(errno)); Error("[%s] failed to allocate pseudo-tty: %s",
pCE->server.string, strerror(errno));
ConsDown(pCE, pfdSet); ConsDown(pCE, pfdSet);
return; return;
} }
@ -748,60 +767,63 @@ ConsInit(pCE, pfdSet, useHostCache)
struct timeval tv; struct timeval tv;
if (CheckHostCache(pCE->networkConsoleHost.string)) { if (CheckHostCache(pCE->networkConsoleHost.string)) {
Error("cached previous timeout: %s (%u@%s): forcing down", Error("[%s] cached previous timeout: %s: forcing down",
pCE->server.string, ntohs(port.sin_port), pCE->server.string, pCE->networkConsoleHost.string);
pCE->networkConsoleHost.string);
ConsDown(pCE, pfdSet); ConsDown(pCE, pfdSet);
return; return;
} }
usleep(100000); /* Not all terminal servers can keep up */ usleep(100000); /* Not all terminal servers can keep up */
resetMark(); ResetMark();
#if HAVE_MEMSET #if HAVE_MEMSET
(void)memset((void *)&port, 0, sizeof(port)); memset((void *)&port, 0, sizeof(port));
#else #else
(void)bzero((char *)&port, sizeof(port)); bzero((char *)&port, sizeof(port));
#endif #endif
if ((hp = gethostbyname(pCE->networkConsoleHost.string)) == NULL) { if ((hp = gethostbyname(pCE->networkConsoleHost.string)) == NULL) {
Error("gethostbyname(%s): %s: forcing down", Error("[%s] gethostbyname(%s): %s: forcing down",
pCE->networkConsoleHost.string, hstrerror(h_errno)); pCE->server.string, pCE->networkConsoleHost.string,
hstrerror(h_errno));
ConsDown(pCE, pfdSet); ConsDown(pCE, pfdSet);
return; return;
} }
#if HAVE_MEMCPY #if HAVE_MEMCPY
(void)memcpy(&port.sin_addr.s_addr, hp->h_addr, hp->h_length); memcpy(&port.sin_addr.s_addr, hp->h_addr, hp->h_length);
#else #else
(void)bcopy(hp->h_addr, &port.sin_addr.s_addr, hp->h_length); bcopy(hp->h_addr, &port.sin_addr.s_addr, hp->h_length);
#endif #endif
port.sin_family = hp->h_addrtype; port.sin_family = hp->h_addrtype;
port.sin_port = htons(pCE->networkConsolePort); port.sin_port = htons(pCE->networkConsolePort);
if ((pCE->fdtty = socket(AF_INET, SOCK_STREAM, 0)) < 0) { if ((pCE->fdtty = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
Error("socket: %s", strerror(errno)); Error("[%s] socket(AF_INET,SOCK_STREAM): %s",
pCE->server.string, strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
if (setsockopt if (setsockopt
(pCE->fdtty, SOL_SOCKET, SO_KEEPALIVE, (char *)&one, (pCE->fdtty, SOL_SOCKET, SO_KEEPALIVE, (char *)&one,
sizeof(one)) < 0) { sizeof(one)) < 0) {
Error("setsockopt SO_KEEPALIVE: %s", strerror(errno)); Error("[%s] setsockopt(%u,SO_KEEPALIVE): %s",
pCE->server.string, pCE->fdtty, strerror(errno));
} }
if ((flags = fcntl(pCE->fdtty, F_GETFL)) >= 0) { if ((flags = fcntl(pCE->fdtty, F_GETFL)) >= 0) {
flags |= O_NONBLOCK; flags |= O_NONBLOCK;
if (fcntl(pCE->fdtty, F_SETFL, flags) < 0) { if (fcntl(pCE->fdtty, F_SETFL, flags) < 0) {
Error("fcntl O_NONBLOCK: %s", strerror(errno)); Error("[%s] fcntl(%u,F_SETFL): %s", pCE->server.string,
pCE->fdtty, strerror(errno));
} }
} else { } else {
Error("fcntl: %s", strerror(errno)); Error("[%s] fcntl(%u,F_GETFL): %s", pCE->server.string,
pCE->fdtty, strerror(errno));
} }
if (connect(pCE->fdtty, (struct sockaddr *)&port, sizeof(port)) < if (connect(pCE->fdtty, (struct sockaddr *)&port, sizeof(port)) <
0) { 0) {
if (errno != EINPROGRESS) { if (errno != EINPROGRESS) {
Error("connect: %s (%u@%s): %s: forcing down", Error("[%s] connect(%u): %s: forcing down",
pCE->server.string, ntohs(port.sin_port), pCE->server.string, pCE->fdtty, strerror(errno));
pCE->networkConsoleHost.string, strerror(errno));
ConsDown(pCE, pfdSet); ConsDown(pCE, pfdSet);
return; return;
} }
@ -813,17 +835,16 @@ ConsInit(pCE, pfdSet, useHostCache)
FD_SET(pCE->fdtty, &fds); FD_SET(pCE->fdtty, &fds);
if ((one = select(pCE->fdtty + 1, NULL, &fds, NULL, &tv)) < 0) { if ((one = select(pCE->fdtty + 1, NULL, &fds, NULL, &tv)) < 0) {
Error("select: %s (%u@%s): %s: forcing down", Error("[%s] select(%u): %s: forcing down", pCE->server.string,
pCE->server.string, ntohs(port.sin_port), pCE->fdtty, strerror(errno));
pCE->networkConsoleHost.string, strerror(errno));
ConsDown(pCE, pfdSet); ConsDown(pCE, pfdSet);
return; return;
} }
if (one == 0) { /* Timeout */ if (one == 0) { /* Timeout */
AddHostCache(pCE->networkConsoleHost.string); AddHostCache(pCE->networkConsoleHost.string);
Error("timeout: %s (%u@%s): forcing down", pCE->server.string, Error("[%s] connect timeout: forcing down", pCE->server.string,
ntohs(port.sin_port), pCE->networkConsoleHost.string); strerror(errno));
ConsDown(pCE, pfdSet); ConsDown(pCE, pfdSet);
return; return;
} else { /* Response */ } else { /* Response */
@ -836,16 +857,14 @@ ConsInit(pCE, pfdSet, useHostCache)
if (getsockopt if (getsockopt
(pCE->fdtty, SOL_SOCKET, SO_ERROR, (char *)&flags, (pCE->fdtty, SOL_SOCKET, SO_ERROR, (char *)&flags,
&slen) < 0) { &slen) < 0) {
Error("getsockopt SO_ERROR: %s (%u@%s): %s: forcing down", Error("[%s] getsockopt(%u,SO_ERROR): %s: forcing down",
pCE->server.string, ntohs(port.sin_port), pCE->server.string, pCE->fdtty, strerror(errno));
pCE->networkConsoleHost.string, strerror(errno));
ConsDown(pCE, pfdSet); ConsDown(pCE, pfdSet);
return; return;
} }
if (flags != 0) { if (flags != 0) {
Error("connect: %s (%u@%s): %s: forcing down", Error("[%s] connect(%u): %s: forcing down",
pCE->server.string, ntohs(port.sin_port), pCE->server.string, pCE->fdtty, strerror(flags));
pCE->networkConsoleHost.string, strerror(flags));
ConsDown(pCE, pfdSet); ConsDown(pCE, pfdSet);
return; return;
} }
@ -861,7 +880,8 @@ ConsInit(pCE, pfdSet, useHostCache)
} else if (-1 == } else if (-1 ==
(pCE->fdtty = (pCE->fdtty =
open(pCE->dfile.string, O_RDWR | O_NDELAY, 0600))) { open(pCE->dfile.string, O_RDWR | O_NDELAY, 0600))) {
Error("open: %s: %s", pCE->dfile.string, strerror(errno)); Error("[%s] open(%s): %s", pCE->server.string, pCE->dfile.string,
strerror(errno));
ConsDown(pCE, pfdSet); ConsDown(pCE, pfdSet);
return; return;
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: consent.h,v 5.31 2002-09-29 19:04:43-07 bryan Exp $ * $Id: consent.h,v 5.35 2003-03-09 15:21:49-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -51,8 +51,6 @@ typedef struct parity { /* a parity bits table */
int iclr; int iclr;
} PARITY; } PARITY;
#define ALARMTIME 60 /* time between chimes */
typedef struct consent { /* console information */ typedef struct consent { /* console information */
STRING server; /* server name */ STRING server; /* server name */
STRING dfile; /* device file */ STRING dfile; /* device file */
@ -61,20 +59,20 @@ typedef struct consent { /* console information */
PARITY *pparity; /* the parity on this line */ PARITY *pparity; /* the parity on this line */
int mark; /* Mark (chime) interval */ int mark; /* Mark (chime) interval */
long nextMark; /* Next mark (chime) time */ long nextMark; /* Next mark (chime) time */
short int breakType; /* break type [1-9] */ short breakType; /* break type [1-9] */
int autoReUp; int autoReUp;
/* Used if network console */ /* Used if network console */
int isNetworkConsole; int isNetworkConsole;
STRING networkConsoleHost; STRING networkConsoleHost;
int networkConsolePort; unsigned short networkConsolePort;
int telnetState; int telnetState;
/* used if virtual console */ /* used if virtual console */
STRING acslave; /* pseudo-device slave side */ STRING acslave; /* pseudo-device slave side */
int fvirtual; /* is a pty device we use as a console */ int fvirtual; /* is a pty device we use as a console */
STRING pccmd; /* virtual console command */ STRING pccmd; /* virtual console command */
int ipid; /* pid of virtual command */ pid_t ipid; /* pid of virtual command */
/* only used in child */ /* only used in child */
int nolog; /* don't log output */ int nolog; /* don't log output */
@ -82,12 +80,12 @@ typedef struct consent { /* console information */
int fdtty; /* the port to talk to machine on */ int fdtty; /* the port to talk to machine on */
int activitylog; /* log attach/detach/bump */ int activitylog; /* log attach/detach/bump */
int breaklog; /* log breaks sent */ int breaklog; /* log breaks sent */
short int fup; /* we setup this line? */ short fup; /* we setup this line? */
short int fronly; /* we can only read this console */ short fronly; /* we can only read this console */
struct client *pCLon; /* clients on this console */ struct client *pCLon; /* clients on this console */
struct client *pCLwr; /* client that is writting on console */ struct client *pCLwr; /* client that is writting on console */
char acline[132 * 2 + 2]; /* max chars we will call a line */ char acline[132 * 2 + 2]; /* max chars we will call a line */
short int iend; /* length of data stored in acline */ short iend; /* length of data stored in acline */
struct consent *pCEnext; /* next console entry */ struct consent *pCEnext; /* next console entry */
} CONSENT; } CONSENT;
@ -96,20 +94,10 @@ struct hostcache {
struct hostcache *next; struct hostcache *next;
}; };
#if USE_ANSI_PROTO extern PARITY *FindParity PARAMS((char *));
extern PARITY *FindParity(char *); extern BAUD *FindBaud PARAMS((char *));
extern BAUD *FindBaud(char *); extern void ConsInit PARAMS((CONSENT *, fd_set *, int));
extern void ConsInit(CONSENT *, fd_set *, int); extern void ConsDown PARAMS((CONSENT *, fd_set *));
extern void ConsDown(CONSENT *, fd_set *); extern int CheckHostCache PARAMS((const char *));
extern int CheckHostCache(const char *); extern void AddHostCache PARAMS((const char *));
extern void AddHostCache(const char *); extern void ClearHostCache PARAMS((void));
extern void ClearHostCache(void);
#else
extern PARITY *FindParity();
extern BAUD *FindBaud();
extern void ConsInit();
extern void ConsDown();
extern int CheckHostCache();
extern void AddHostCache();
extern void ClearHostCache();
#endif

View File

@ -16,8 +16,13 @@ case "$1" in
[ "$master" ] && kill -TERM $master [ "$master" ] && kill -TERM $master
;; ;;
'restart')
master=`ps -ef | grep conserver | awk '$3 == "1"{print $2}'`
[ "$master" ] && kill -HUP $master
;;
*) *)
echo "Usage: $0 { start | stop }" echo "Usage: $0 { start | stop | restart }"
;; ;;
esac esac

View File

@ -1,5 +1,5 @@
/* /*
* $Id: fallback.c,v 5.46 2002-10-12 20:07:43-07 bryan Exp $ * $Id: fallback.c,v 5.52 2003-03-08 08:38:14-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -37,10 +37,10 @@
* get a pty for the user (emulate the neato sequent call) (mm) * get a pty for the user (emulate the neato sequent call) (mm)
*/ */
static int static int
#if USE_ANSI_PROTO #if PROTOTYPES
getpseudotty(STRING * slave, STRING * master) GetPseudoTTY(STRING * slave, STRING * master)
#else #else
getpseudotty(slave, master) GetPseudoTTY(slave, master)
STRING *slave; STRING *slave;
STRING *master; STRING *master;
#endif #endif
@ -54,11 +54,11 @@ getpseudotty(slave, master)
if ((char *)0 == (pcName = ttyname(fd))) { if ((char *)0 == (pcName = ttyname(fd))) {
return -1; return -1;
} }
buildMyString((char *)0, slave); BuildString((char *)0, slave);
buildMyString(pcName, slave); BuildString(pcName, slave);
buildMyString((char *)0, master); BuildString((char *)0, master);
buildMyString(pcName, master); BuildString(pcName, master);
master->string[7] = 'c'; master->string[7] = 'c';
return fd; return fd;
@ -77,10 +77,10 @@ extern int unlockpt();
* DYNIX/ptx v4.0 * DYNIX/ptx v4.0
*/ */
static int static int
#if USE_ANSI_PROTO #if PROTOTYPES
getpseudotty(STRING * slave, STRING * master) GetPseudoTTY(STRING * slave, STRING * master)
#else #else
getpseudotty(slave, master) GetPseudoTTY(slave, master)
STRING *slave; STRING *slave;
STRING *master; STRING *master;
#endif #endif
@ -100,34 +100,36 @@ getpseudotty(slave, master)
sigemptyset(&newmask); sigemptyset(&newmask);
sigaddset(&newmask, SIGCHLD); sigaddset(&newmask, SIGCHLD);
if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0) if (sigprocmask(SIG_BLOCK, &newmask, &oldmask) < 0)
Error("sigprocmask(SIG_BLOCK): %s", strerror(errno)); Error("GetPseudoTTY(): sigprocmask(SIG_BLOCK): %s",
strerror(errno));
#else #else
simpleSignal(SIGCHLD, SIG_DFL); SimpleSignal(SIGCHLD, SIG_DFL);
#endif #endif
grantpt(fd); /* change permission of slave */ grantpt(fd); /* change permission of slave */
#if HAVE_SIGACTION #if HAVE_SIGACTION
if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0) if (sigprocmask(SIG_SETMASK, &oldmask, NULL) < 0)
Error("sigprocmask(SIG_SETMASK): %s", strerror(errno)); Error("GetPseudoTTY(): sigprocmask(SIG_SETMASK): %s",
strerror(errno));
#else #else
simpleSignal(SIGCHLD, FlagReapVirt); SimpleSignal(SIGCHLD, FlagReapVirt);
#endif #endif
unlockpt(fd); /* unlock slave */ unlockpt(fd); /* unlock slave */
buildMyString((char *)0, master); BuildString((char *)0, master);
if ((char *)0 == (pcName = ttyname(fd))) { if ((char *)0 == (pcName = ttyname(fd))) {
buildMyString("/dev/ptmx", master); BuildString("/dev/ptmx", master);
} else { } else {
buildMyString(pcName, master); BuildString(pcName, master);
} }
if ((char *)0 == (pcName = ptsname(fd))) { if ((char *)0 == (pcName = ptsname(fd))) {
return -1; return -1;
} }
buildMyString((char *)0, slave); BuildString((char *)0, slave);
buildMyString(pcName, slave); BuildString(pcName, slave);
return fd; return fd;
} }
@ -148,10 +150,10 @@ static char chartwo[] =
* get a pty for the user (emulate the neato sequent call) (ksb) * get a pty for the user (emulate the neato sequent call) (ksb)
*/ */
static int static int
#if USE_ANSI_PROTO #if PROTOTYPES
getpseudotty(STRING * slave, STRING * master) GetPseudoTTY(STRING * slave, STRING * master)
#else #else
getpseudotty(slave, master) GetPseudoTTY(slave, master)
STRING *slave; STRING *slave;
STRING *master; STRING *master;
#endif #endif
@ -195,16 +197,16 @@ getpseudotty(slave, master)
acSlave[iIndex] = *pcOne; acSlave[iIndex] = *pcOne;
acSlave[iIndex + 1] = *pcTwo; acSlave[iIndex + 1] = *pcTwo;
if (-1 == access(acSlave, F_OK)) { if (-1 == access(acSlave, F_OK)) {
(void)close(fd); close(fd);
continue; continue;
} }
break; break;
} }
buildMyString((char *)0, master); BuildString((char *)0, master);
buildMyString(acMaster, master); BuildString(acMaster, master);
buildMyString((char *)0, slave); BuildString((char *)0, slave);
buildMyString(acSlave, slave); BuildString(acSlave, slave);
return fd; return fd;
} }
#endif #endif
@ -214,7 +216,7 @@ getpseudotty(slave, master)
* get a Joe pty bacause the daemon is not with us, sadly. (ksb) * get a Joe pty bacause the daemon is not with us, sadly. (ksb)
*/ */
int int
#if USE_ANSI_PROTO #if PROTOTYPES
FallBack(STRING * pcSlave, STRING * pcMaster) FallBack(STRING * pcSlave, STRING * pcMaster)
#else #else
FallBack(pcSlave, pcMaster) FallBack(pcSlave, pcMaster)
@ -222,15 +224,20 @@ FallBack(pcSlave, pcMaster)
#endif #endif
{ {
int fd; int fd;
static STRING pcTSlave = { (char *)0, 0, 0 }; static STRING *pcTSlave = (STRING *) 0;
static STRING pcTMaster = { (char *)0, 0, 0 }; static STRING *pcTMaster = (STRING *) 0;
if (-1 == (fd = getpseudotty(&pcTSlave, &pcTMaster))) { if (pcTSlave == (STRING *) 0)
pcTSlave = AllocString();
if (pcTMaster == (STRING *) 0)
pcTMaster = AllocString();
if (-1 == (fd = GetPseudoTTY(pcTSlave, pcTMaster))) {
return -1; return -1;
} }
buildMyString((char *)0, pcSlave); BuildString((char *)0, pcSlave);
buildMyString(pcTSlave.string, pcSlave); BuildString(pcTSlave->string, pcSlave);
buildMyString((char *)0, pcMaster); BuildString((char *)0, pcMaster);
buildMyString(pcTMaster.string, pcMaster); BuildString(pcTMaster->string, pcMaster);
return fd; return fd;
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
/* /*
* $Id: group.h,v 5.25 2002-09-20 23:04:45-07 bryan Exp $ * $Id: group.h,v 5.30 2003-03-09 15:21:49-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -43,7 +43,7 @@
typedef struct grpent { /* group info */ typedef struct grpent { /* group info */
unsigned int id; /* uniqueue group id */ unsigned int id; /* uniqueue group id */
unsigned short port; /* port group listens on */ unsigned short port; /* port group listens on */
int pid; /* pid of server for group */ pid_t pid; /* pid of server for group */
int imembers; /* number of consoles in this group */ int imembers; /* number of consoles in this group */
fd_set rinit; /* descriptor list */ fd_set rinit; /* descriptor list */
CONSENT *pCElist; /* list of consoles in this group */ CONSENT *pCElist; /* list of consoles in this group */
@ -53,24 +53,11 @@ typedef struct grpent { /* group info */
struct grpent *pGEnext; /* next group entry */ struct grpent *pGEnext; /* next group entry */
} GRPENT; } GRPENT;
#if USE_ANSI_PROTO extern void Spawn PARAMS((GRPENT *));
extern void Spawn(GRPENT *); extern int CheckPass PARAMS((char *, char *));
extern int CheckPass(char *, char *); extern void TagLogfile PARAMS((const CONSENT *, const char *, ...));
extern const char *strtime(time_t *); extern void CleanupBreak PARAMS((short));
extern void tagLogfile(const CONSENT *, const char *, ...); extern void DestroyGroup PARAMS((GRPENT *));
extern void cleanupBreak(short int); extern void DestroyConsent PARAMS((GRPENT *, CONSENT *));
extern void destroyGroup(GRPENT *); extern void SendClientsMsg PARAMS((CONSENT *, char *));
extern void destroyConsent(GRPENT *, CONSENT *); extern void ResetMark PARAMS((void));
extern void SendClientsMsg(CONSENT *, char *);
extern void resetMark(void);
#else
extern void Spawn();
extern int CheckPass();
extern const char *strtime();
extern void tagLogfile();
extern void cleanupBreak();
extern void destroyGroup();
extern void destroyConsent();
extern void SendClientsMsg();
extern void resetMark();
#endif

View File

@ -1,5 +1,5 @@
/* /*
* $Id: main.c,v 5.106 2003-01-08 17:18:59-08 bryan Exp $ * $Id: main.c,v 5.120 2003-03-09 15:20:43-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -53,8 +53,8 @@
#include <readcfg.h> #include <readcfg.h>
#include <version.h> #include <version.h>
int fAll = 0, fVerbose = 0, fSoftcar = 0, fNoinit = 0, fVersion = int fAll = 0, fSoftcar = 0, fNoinit = 0, fVersion = 0, fStrip =
0, fStrip = 0, fDaemon = 0, fUseLogfile = 0, fReopen = 0, fReopenall = 0, fDaemon = 0, fUseLogfile = 0, fReopen = 0, fReopenall =
0, fNoautoreup = 0, fNoredir = 0; 0, fNoautoreup = 0, fNoredir = 0;
char chDefAcc = 'r'; char chDefAcc = 'r';
@ -64,13 +64,14 @@ char *pcConfig = CONFIGFILE;
char *pcPasswd = PASSWDFILE; char *pcPasswd = PASSWDFILE;
char *pcPort = DEFPORT; char *pcPort = DEFPORT;
char *pcBasePort = DEFBASEPORT; char *pcBasePort = DEFBASEPORT;
STRING *defaultShell = (STRING *) 0;
int domainHack = 0; int domainHack = 0;
int isMaster = 1; int isMaster = 1;
int cMaxMemb = MAXMEMB; int cMaxMemb = MAXMEMB;
char *pcAddress = NULL; char *pcAddress = NULL;
in_addr_t bindAddr; in_addr_t bindAddr;
unsigned int bindPort; unsigned short bindPort;
unsigned int bindBasePort; unsigned short bindBasePort;
struct sockaddr_in in_port; struct sockaddr_in in_port;
struct in_addr acMyAddr; struct in_addr acMyAddr;
@ -80,12 +81,17 @@ char acMyHost[1024]; /* staff.cc.purdue.edu */
SSL_CTX *ctx = (SSL_CTX *) 0; SSL_CTX *ctx = (SSL_CTX *) 0;
int fReqEncryption = 1; int fReqEncryption = 1;
char *pcCredFile = (char *)0; char *pcCredFile = (char *)0;
DH *dh512 = (DH *) 0;
DH *dh1024 = (DH *) 0;
DH *dh2048 = (DH *) 0;
DH *dh4096 = (DH *) 0;
DH * DH *
#if USE_ANSI_PROTO #if PROTOTYPES
get_dh512(void) GetDH512(void)
#else #else
get_dh512() GetDH512()
#endif #endif
{ {
static unsigned char dh512_p[] = { static unsigned char dh512_p[] = {
@ -114,10 +120,10 @@ get_dh512()
} }
DH * DH *
#if USE_ANSI_PROTO #if PROTOTYPES
get_dh1024(void) GetDH1024(void)
#else #else
get_dh1024() GetDH1024()
#endif #endif
{ {
static unsigned char dh1024_p[] = { static unsigned char dh1024_p[] = {
@ -152,10 +158,10 @@ get_dh1024()
} }
DH * DH *
#if USE_ANSI_PROTO #if PROTOTYPES
get_dh2048(void) GetDH2048(void)
#else #else
get_dh2048() GetDH2048()
#endif #endif
{ {
static unsigned char dh2048_p[] = { static unsigned char dh2048_p[] = {
@ -203,10 +209,10 @@ get_dh2048()
} }
DH * DH *
#if USE_ANSI_PROTO #if PROTOTYPES
get_dh4096() GetDH4096(void)
#else #else
get_dh4096(void) GetDH4096()
#endif #endif
{ {
static unsigned char dh4096_p[] = { static unsigned char dh4096_p[] = {
@ -280,61 +286,73 @@ get_dh4096(void)
} }
DH * DH *
#if USE_ANSI_PROTO #if PROTOTYPES
tmp_dh_callback(SSL * ssl, int is_export, int keylength) TmpDHCallback(SSL * ssl, int is_export, int keylength)
#else #else
tmp_dh_callback(ssl, is_export, keylength) TmpDHCallback(ssl, is_export, keylength)
SSL *ssl; SSL *ssl;
int is_export; int is_export;
int keylength; int keylength;
#endif #endif
{ {
Debug(1, "TmpDHCallback(): asked for a DH key length %u", keylength);
switch (keylength) { switch (keylength) {
case 512: case 512:
return get_dh512(); if (dh512 == (DH *) 0)
dh512 = GetDH512();
return dh512;
case 1024: case 1024:
return get_dh1024(); if (dh1024 == (DH *) 0)
dh1024 = GetDH1024();
return dh1024;
case 2048: case 2048:
return get_dh2048(); if (dh2048 == (DH *) 0)
dh2048 = GetDH2048();
return dh2048;
default: default:
return get_dh4096(); if (dh4096 == (DH *) 0)
dh4096 = GetDH4096();
return dh4096;
} }
} }
void void
#if USE_ANSI_PROTO #if PROTOTYPES
setupSSL(void) SetupSSL(void)
#else #else
setupSSL() SetupSSL()
#endif #endif
{ {
if (ctx == (SSL_CTX *) 0) { if (ctx == (SSL_CTX *) 0) {
SSL_load_error_strings(); SSL_load_error_strings();
if (!SSL_library_init()) { if (!SSL_library_init()) {
Error("SSL library initialization failed"); Error("SetupSSL(): SSL_library_init() failed");
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
if ((ctx = SSL_CTX_new(SSLv23_method())) == (SSL_CTX *) 0) { if ((ctx = SSL_CTX_new(SSLv23_method())) == (SSL_CTX *) 0) {
Error("Creating SSL context failed"); Error("SetupSSL(): SSL_CTX_new() failed");
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
if (SSL_CTX_set_default_verify_paths(ctx) != 1) { if (SSL_CTX_set_default_verify_paths(ctx) != 1) {
Error("Could not load SSL default CA file and/or directory"); Error
("SetupSSL(): could not load SSL default CA file and/or directory");
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
if (pcCredFile != (char *)0) { if (pcCredFile != (char *)0) {
if (SSL_CTX_use_certificate_chain_file(ctx, pcCredFile) != 1) { if (SSL_CTX_use_certificate_chain_file(ctx, pcCredFile) != 1) {
Error("Could not load SSL certificate from '%s'", Error
("SetupSSL(): could not load SSL certificate from `%s'",
pcCredFile); pcCredFile);
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
if (SSL_CTX_use_PrivateKey_file if (SSL_CTX_use_PrivateKey_file
(ctx, pcCredFile, SSL_FILETYPE_PEM) != 1) { (ctx, pcCredFile, SSL_FILETYPE_PEM) != 1) {
Error("Could not SSL private key from '%s'", pcCredFile); Error("SetupSSL(): could not SSL private key from `%s'",
pcCredFile);
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
} }
SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, ssl_verify_callback); SSL_CTX_set_verify(ctx, SSL_VERIFY_PEER, SSLVerifyCallback);
SSL_CTX_set_options(ctx, SSL_CTX_set_options(ctx,
SSL_OP_ALL | SSL_OP_NO_SSLv2 | SSL_OP_ALL | SSL_OP_NO_SSLv2 |
SSL_OP_SINGLE_DH_USE); SSL_OP_SINGLE_DH_USE);
@ -342,21 +360,25 @@ setupSSL()
SSL_MODE_ENABLE_PARTIAL_WRITE | SSL_MODE_ENABLE_PARTIAL_WRITE |
SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER | SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER |
SSL_MODE_AUTO_RETRY); SSL_MODE_AUTO_RETRY);
SSL_CTX_set_tmp_dh_callback(ctx, tmp_dh_callback); SSL_CTX_set_tmp_dh_callback(ctx, TmpDHCallback);
if (SSL_CTX_set_cipher_list(ctx, "ALL:!LOW:!EXP:!MD5:@STRENGTH") != if (SSL_CTX_set_cipher_list(ctx, "ALL:!LOW:!EXP:!MD5:@STRENGTH") !=
1) { 1) {
Error("Setting SSL cipher list failed"); Error("SetupSSL(): setting SSL cipher list failed");
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
/* might want to turn this back on at some point, but i can't
* see why right now.
*/
SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF);
} }
} }
#endif #endif
void void
#if USE_ANSI_PROTO #if PROTOTYPES
reopenLogfile(void) ReopenLogfile(void)
#else #else
reopenLogfile() ReopenLogfile()
#endif #endif
{ {
/* redirect stdout and stderr to the logfile. /* redirect stdout and stderr to the logfile.
@ -370,7 +392,7 @@ reopenLogfile()
close(1); close(1);
if (1 != open(pcLogfile, O_WRONLY | O_CREAT | O_APPEND, 0644)) { if (1 != open(pcLogfile, O_WRONLY | O_CREAT | O_APPEND, 0644)) {
Error("open: %s: %s", pcLogfile, strerror(errno)); Error("ReopenLogfile(): open(%s): %s", pcLogfile, strerror(errno));
exit(EX_TEMPFAIL); exit(EX_TEMPFAIL);
} }
close(2); close(2);
@ -380,10 +402,10 @@ reopenLogfile()
/* become a daemon (ksb) /* become a daemon (ksb)
*/ */
static void static void
#if USE_ANSI_PROTO #if PROTOTYPES
daemonize() Daemonize()
#else #else
daemonize() Daemonize()
#endif #endif
{ {
int res; int res;
@ -391,56 +413,66 @@ daemonize()
int td; int td;
#endif #endif
simpleSignal(SIGQUIT, SIG_IGN); SimpleSignal(SIGQUIT, SIG_IGN);
simpleSignal(SIGINT, SIG_IGN); SimpleSignal(SIGINT, SIG_IGN);
#if defined(SIGTTOU) #if defined(SIGTTOU)
simpleSignal(SIGTTOU, SIG_IGN); SimpleSignal(SIGTTOU, SIG_IGN);
#endif #endif
#if defined(SIGTTIN) #if defined(SIGTTIN)
simpleSignal(SIGTTIN, SIG_IGN); SimpleSignal(SIGTTIN, SIG_IGN);
#endif #endif
#if defined(SIGTSTP) #if defined(SIGTSTP)
simpleSignal(SIGTSTP, SIG_IGN); SimpleSignal(SIGTSTP, SIG_IGN);
#endif #endif
(void)fflush(stdout); fflush(stdout);
(void)fflush(stderr); fflush(stderr);
switch (res = fork()) { switch (res = fork()) {
case -1: case -1:
Error("fork: %s", strerror(errno)); Error("Daemonize(): fork(): %s", strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
case 0: case 0:
thepid = getpid(); thepid = getpid();
break; break;
default: default:
exit(EX_OK); Bye(EX_OK);
} }
reopenLogfile(); ReopenLogfile();
/* Further disassociate this process from the terminal /* Further disassociate this process from the terminal
* Maybe this will allow you to start a daemon from rsh, * Maybe this will allow you to start a daemon from rsh,
* i.e. with no controlling terminal. * i.e. with no controlling terminal.
*/ */
#if HAVE_SETSID #if HAVE_SETSID
(void)setsid(); setsid();
#else #else
(void)setpgrp(0, getpid()); setpgrp(0, getpid());
/* lose our controlling terminal /* lose our controlling terminal
*/ */
if (-1 != (td = open("/dev/tty", O_RDWR, 0600))) { if (-1 != (td = open("/dev/tty", O_RDWR, 0600))) {
(void)ioctl(td, TIOCNOTTY, (char *)0); ioctl(td, TIOCNOTTY, (char *)0);
close(td); close(td);
} }
#endif #endif
} }
static char u_terse[] = /* output a long message to the user (ksb)
" [-7dDEFhinRouvV] [-a type] [-m max] [-M addr] [-p port] [-b port] [-c cred] [-C config] [-P passwd] [-L logfile] [-O min]"; */
static char *apcLong[] = { static void
#if PROTOTYPES
Usage(int wantfull)
#else
Usage(wantfull)
int wantfull;
#endif
{
static char u_terse[] =
"[-7dDEFhinRouvV] [-a type] [-m max] [-M addr] [-p port] [-b port] [-c cred] [-C config] [-P passwd] [-L logfile] [-O min]";
static char *full[] = {
"7 strip the high bit of all console data", "7 strip the high bit of all console data",
"a type set the default access type", "a type set the default access type",
"b port base port for secondary channel (any by default)", "b port base port for secondary channel (any by default)",
@ -473,35 +505,31 @@ static char *apcLong[] = {
"v be verbose on startup", "v be verbose on startup",
"V output version info", "V output version info",
(char *)0 (char *)0
}; };
fprintf(stderr, "%s: usage %s\n", progname, u_terse);
/* output a long message to the user (ksb) if (wantfull) {
*/ int i;
static void for (i = 0; full[i] != (char *)0; i++)
#if USE_ANSI_PROTO fprintf(stderr, "\t%s\n", full[i]);
Usage(char **ppc) }
#else
Usage(ppc)
char **ppc;
#endif
{
for ( /* passed */ ; (char *)0 != *ppc; ++ppc)
fprintf(stderr, "\t%s\n", *ppc);
} }
/* show the user our version info (ksb) /* show the user our version info (ksb)
*/ */
static void static void
#if USE_ANSI_PROTO #if PROTOTYPES
Version() Version()
#else #else
Version() Version()
#endif #endif
{ {
static STRING acA1 = { (char *)0, 0, 0 }; static STRING *acA1 = (STRING *) 0;
static STRING acA2 = { (char *)0, 0, 0 }; static STRING *acA2 = (STRING *) 0;
int i; int i;
char *optionlist[] = { char *optionlist[] = {
#if HAVE_DMALLOC
"dmalloc",
#endif
#if USE_LIBWRAP #if USE_LIBWRAP
"libwrap", "libwrap",
#endif #endif
@ -517,17 +545,22 @@ Version()
(char *)0 (char *)0
}; };
outputPid = 0; if (acA1 == (STRING *) 0)
acA1 = AllocString();
if (acA2 == (STRING *) 0)
acA2 = AllocString();
Info("%s", THIS_VERSION); isMultiProc = 0;
Info("default access type `%c\'", chDefAcc);
Info("default escape sequence `%s%s\'", FmtCtl(DEFATTN, &acA1), Msg("%s", THIS_VERSION);
FmtCtl(DEFESC, &acA2)); Msg("default access type `%c'", chDefAcc);
Info("configuration in `%s\'", pcConfig); Msg("default escape sequence `%s%s'", FmtCtl(DEFATTN, acA1),
Info("password in `%s\'", pcPasswd); FmtCtl(DEFESC, acA2));
Info("logfile is `%s\'", pcLogfile); Msg("configuration in `%s'", pcConfig);
Info("pidfile is `%s\'", PIDFILE); Msg("password in `%s'", pcPasswd);
Info("limited to %d member%s per group", cMaxMemb, Msg("logfile is `%s'", pcLogfile);
Msg("pidfile is `%s'", PIDFILE);
Msg("limited to %d member%s per group", cMaxMemb,
cMaxMemb == 1 ? "" : "s"); cMaxMemb == 1 ? "" : "s");
/* Look for non-numeric characters */ /* Look for non-numeric characters */
@ -538,15 +571,16 @@ Version()
if (pcPort[i] == '\000') { if (pcPort[i] == '\000') {
/* numeric only */ /* numeric only */
bindPort = atoi(pcPort); bindPort = atoi(pcPort);
Info("on port %u (referenced as `%s')", bindPort, pcPort); Msg("on port %hu (referenced as `%s')", bindPort, pcPort);
} else { } else {
/* non-numeric only */ /* non-numeric only */
struct servent *pSE; struct servent *pSE;
if ((struct servent *)0 == (pSE = getservbyname(pcPort, "tcp"))) { if ((struct servent *)0 == (pSE = getservbyname(pcPort, "tcp"))) {
Error("getservbyname: %s: %s", pcPort, strerror(errno)); Error("Version(): getservbyname(%s): %s", pcPort,
strerror(errno));
} else { } else {
bindPort = ntohs((u_short) pSE->s_port); bindPort = ntohs((unsigned short)pSE->s_port);
Info("on port %u (referenced as `%s')", bindPort, pcPort); Msg("on port %hu (referenced as `%s')", bindPort, pcPort);
} }
} }
@ -558,44 +592,91 @@ Version()
if (pcBasePort[i] == '\000') { if (pcBasePort[i] == '\000') {
/* numeric only */ /* numeric only */
bindBasePort = atoi(pcBasePort); bindBasePort = atoi(pcBasePort);
Info("secondary channel base port %u (referenced as `%s')", Msg("secondary channel base port %hu (referenced as `%s')",
bindBasePort, pcBasePort); bindBasePort, pcBasePort);
} else { } else {
/* non-numeric only */ /* non-numeric only */
struct servent *pSE; struct servent *pSE;
if ((struct servent *)0 == if ((struct servent *)0 ==
(pSE = getservbyname(pcBasePort, "tcp"))) { (pSE = getservbyname(pcBasePort, "tcp"))) {
Error("getservbyname: %s: %s", pcBasePort, strerror(errno)); Error("Version(): getservbyname(%s): %s", pcBasePort,
strerror(errno));
} else { } else {
bindBasePort = ntohs((u_short) pSE->s_port); bindBasePort = ntohs((unsigned short)pSE->s_port);
Info("secondary channel base port %u (referenced as `%s')", Msg("secondary channel base port %hu (referenced as `%s')",
bindBasePort, pcBasePort); bindBasePort, pcBasePort);
} }
} }
buildMyString((char *)0, &acA1); BuildString((char *)0, acA1);
if (optionlist[0] == (char *)0) if (optionlist[0] == (char *)0)
buildMyString("none", &acA1); BuildString("none", acA1);
for (i = 0; optionlist[i] != (char *)0; i++) { for (i = 0; optionlist[i] != (char *)0; i++) {
if (i == 0) if (i == 0)
buildMyString(optionlist[i], &acA1); BuildString(optionlist[i], acA1);
else { else {
buildMyString(", ", &acA1); BuildString(", ", acA1);
buildMyString(optionlist[i], &acA1); BuildString(optionlist[i], acA1);
} }
} }
Info("options: %s", acA1.string); Msg("options: %s", acA1->string);
Info("built with `%s'", CONFIGINVOCATION); Msg("built with `%s'", CONFIGINVOCATION);
if (fVerbose) if (fVerbose)
printf(COPYRIGHT); printf(COPYRIGHT);
exit(EX_OK); Bye(EX_OK);
} }
void void
#if USE_ANSI_PROTO #if PROTOTYPES
dumpDataStructures(void) DestroyDataStructures(void)
#else #else
dumpDataStructures() DestroyDataStructures()
#endif
{
GRPENT *pGE;
REMOTE *pRC;
ACCESS *pAC;
while (pGroups != (GRPENT *) 0) {
pGE = pGroups->pGEnext;
DestroyGroup(pGroups);
pGroups = pGE;
}
while (pRCList != (REMOTE *) 0) {
pRC = pRCList->pRCnext;
DestroyRemoteConsole(pRCList);
pRCList = pRC;
}
while (pACList != (ACCESS *) 0) {
pAC = pACList->pACnext;
DestroyAccessList(pACList);
pACList = pAC;
}
#if HAVE_OPENSSL
if (ctx != (SSL_CTX *) 0)
SSL_CTX_free(ctx);
if (dh512 != (DH *) 0)
DH_free(dh512);
if (dh1024 != (DH *) 0)
DH_free(dh1024);
if (dh2048 != (DH *) 0)
DH_free(dh2048);
if (dh4096 != (DH *) 0)
DH_free(dh4096);
#endif
DestroyBreakList();
DestroyStrings();
}
void
#if PROTOTYPES
DumpDataStructures(void)
#else
DumpDataStructures()
#endif #endif
{ {
GRPENT *pGE; GRPENT *pGE;
@ -607,8 +688,9 @@ dumpDataStructures()
return; return;
for (pGE = pGroups; pGE != (GRPENT *) 0; pGE = pGE->pGEnext) { for (pGE = pGroups; pGE != (GRPENT *) 0; pGE = pGE->pGEnext) {
Debug(1, "Group: id=%u pid=%d, port=%d, imembers=%d", pGE->id, Debug(1,
pGE->port, pGE->pid, pGE->imembers); "DumpDataStructures(): group: id=%u pid=%lu, port=%hu, imembers=%d",
pGE->id, pGE->port, (unsigned long)pGE->pid, pGE->imembers);
for (pCE = pGE->pCElist; pCE != (CONSENT *) 0; pCE = pCE->pCEnext) { for (pCE = pGE->pCElist; pCE != (CONSENT *) 0; pCE = pCE->pCEnext) {
if (pCE->pccmd.string == (char *)0) if (pCE->pccmd.string == (char *)0)
@ -624,29 +706,36 @@ dumpDataStructures()
if (pCE->acslave.string == (char *)0) if (pCE->acslave.string == (char *)0)
pCE->acslave.string = empty; pCE->acslave.string = empty;
Debug(1, " server=%s, dfile=%s, lfile=%s", pCE->server.string, Debug(1,
pCE->dfile.string, pCE->lfile.string); "DumpDataStructures(): server=%s, dfile=%s, lfile=%s",
Debug(1, " mark=%d, nextMark=%ld, breakType=%d", pCE->mark, pCE->server.string, pCE->dfile.string,
pCE->nextMark, pCE->breakType); pCE->lfile.string);
Debug(1,
"DumpDataStructures(): mark=%d, nextMark=%ld, breakType=%d",
pCE->mark, pCE->nextMark, pCE->breakType);
Debug(1, " isNetworkConsole=%d, networkConsoleHost=%s", Debug(1,
"DumpDataStructures(): isNetworkConsole=%d, networkConsoleHost=%s",
pCE->isNetworkConsole, pCE->networkConsoleHost.string); pCE->isNetworkConsole, pCE->networkConsoleHost.string);
Debug(1, Debug(1,
" networkConsolePort=%d, telnetState=%d, autoReup=%d", "DumpDataStructures(): networkConsolePort=%hu, telnetState=%d, autoReup=%d",
pCE->networkConsolePort, pCE->telnetState, pCE->networkConsolePort, pCE->telnetState,
pCE->autoReUp); pCE->autoReUp);
Debug(1, " baud=%s, parity=%c", pCE->pbaud->acrate, Debug(1, "DumpDataStructures(): baud=%s, parity=%c",
pCE->pparity->ckey); pCE->pbaud->acrate, pCE->pparity->ckey);
Debug(1, " fvirtual=%d, acslave=%s, pccmd=%s, ipid=%d", Debug(1,
"DumpDataStructures(): fvirtual=%d, acslave=%s, pccmd=%s, ipid=%lu",
pCE->fvirtual, pCE->acslave.string, pCE->pccmd.string, pCE->fvirtual, pCE->acslave.string, pCE->pccmd.string,
pCE->ipid); (unsigned long)pCE->ipid);
Debug(1, " nolog=%d, fdtty=%d, activitylog=%d, breaklog=%d", Debug(1,
"DumpDataStructures(): nolog=%d, fdtty=%d, activitylog=%d, breaklog=%d",
pCE->nolog, pCE->fdtty, pCE->activitylog, pCE->breaklog); pCE->nolog, pCE->fdtty, pCE->activitylog, pCE->breaklog);
Debug(1, " fup=%d, fronly=%d", pCE->fup, pCE->fronly); Debug(1, "DumpDataStructures(): fup=%d, fronly=%d", pCE->fup,
Debug(1, " ------"); pCE->fronly);
Debug(1, "DumpDataStructures(): ------");
} }
} }
for (pRC = pRCList; (REMOTE *) 0 != pRC; pRC = pRC->pRCnext) { for (pRC = pRCList; (REMOTE *) 0 != pRC; pRC = pRC->pRCnext) {
@ -654,8 +743,8 @@ dumpDataStructures()
pRC->rserver.string = empty; pRC->rserver.string = empty;
if (pRC->rhost.string == (char *)0) if (pRC->rhost.string == (char *)0)
pRC->rhost.string = empty; pRC->rhost.string = empty;
Debug(1, "Remote: rserver=%s, rhost =%s", pRC->rserver.string, Debug(1, "DumpDataStructures(): remote: rserver=%s, rhost =%s",
pRC->rhost.string); pRC->rserver.string, pRC->rhost.string);
} }
} }
@ -668,7 +757,7 @@ dumpDataStructures()
* exit happy * exit happy
*/ */
int int
#if USE_ANSI_PROTO #if PROTOTYPES
main(int argc, char **argv) main(int argc, char **argv)
#else #else
main(argc, argv) main(argc, argv)
@ -689,7 +778,7 @@ main(argc, argv)
GRPENT *pGE; GRPENT *pGE;
CONSENT *pCE; CONSENT *pCE;
outputPid = 1; /* make sure stuff has the pid */ isMultiProc = 1; /* make sure stuff has the pid */
thepid = getpid(); thepid = getpid();
if ((char *)0 == (progname = strrchr(argv[0], '/'))) { if ((char *)0 == (progname = strrchr(argv[0], '/'))) {
@ -698,7 +787,7 @@ main(argc, argv)
++progname; ++progname;
} }
(void)setpwent(); setpwent();
#if HAVE_SETLINEBUF #if HAVE_SETLINEBUF
setlinebuf(stdout); setlinebuf(stdout);
@ -710,7 +799,7 @@ main(argc, argv)
#endif #endif
(void)gethostname(acMyHost, sizeof(acMyHost)); gethostname(acMyHost, sizeof(acMyHost));
if ((struct hostent *)0 == (hpMe = gethostbyname(acMyHost))) { if ((struct hostent *)0 == (hpMe = gethostbyname(acMyHost))) {
Error("gethostbyname(%s): %s", acMyHost, hstrerror(h_errno)); Error("gethostbyname(%s): %s", acMyHost, hstrerror(h_errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
@ -721,9 +810,9 @@ main(argc, argv)
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
#if HAVE_MEMCPY #if HAVE_MEMCPY
(void)memcpy(&acMyAddr, hpMe->h_addr, hpMe->h_length); memcpy(&acMyAddr, hpMe->h_addr, hpMe->h_length);
#else #else
(void)bcopy(hpMe->h_addr, &acMyAddr, hpMe->h_length); bcopy(hpMe->h_addr, &acMyAddr, hpMe->h_length);
#endif #endif
while (EOF != (i = getopt(argc, argv, acOpts))) { while (EOF != (i = getopt(argc, argv, acOpts))) {
@ -742,7 +831,7 @@ main(argc, argv)
case 't': case 't':
break; break;
default: default:
Error("unknown access type `%s\'", optarg); Error("unknown access type `%s'", optarg);
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
break; break;
@ -773,9 +862,8 @@ main(argc, argv)
fNoautoreup = 1; fNoautoreup = 1;
break; break;
case 'h': case 'h':
fprintf(stderr, "%s: usage%s\n", progname, u_terse); Usage(1);
Usage(apcLong); Bye(EX_OK);
exit(EX_OK);
case 'i': case 'i':
fNoinit = 1; fNoinit = 1;
break; break;
@ -821,7 +909,7 @@ main(argc, argv)
fVerbose = 1; fVerbose = 1;
break; break;
case '\?': case '\?':
fprintf(stderr, "%s: usage%s\n", progname, u_terse); Usage(0);
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
default: default:
Error("option %c needs a parameter", optopt); Error("option %c needs a parameter", optopt);
@ -839,25 +927,35 @@ main(argc, argv)
*/ */
close(0); close(0);
if (0 != open("/dev/null", O_RDWR, 0644)) { if (0 != open("/dev/null", O_RDWR, 0644)) {
Error("open: /dev/null: %s", strerror(errno)); Error("open(/dev/null): %s", strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
if (fVersion) { if (fVersion) {
Version(); Version();
exit(EX_OK); Bye(EX_OK);
} }
if (fDaemon) { if (fDaemon) {
daemonize(); Daemonize();
} }
Info("%s", THIS_VERSION); Msg("%s", THIS_VERSION);
#if HAVE_GETLOGIN #if HAVE_GETLOGIN
origuser = getlogin(); origuser = getlogin();
#endif #endif
curuid = getuid(); curuid = getuid();
if (defaultShell == (STRING *) 0)
defaultShell = AllocString();
if ((pwd = getpwuid(0)) != (struct passwd *)0 &&
pwd->pw_shell[0] != '\000') {
BuildString(pwd->pw_shell, defaultShell);
} else {
BuildString("/bin/sh", defaultShell);
}
if ((struct passwd *)0 != (pwd = getpwuid(curuid))) if ((struct passwd *)0 != (pwd = getpwuid(curuid)))
curuser = pwd->pw_name; curuser = pwd->pw_name;
@ -867,20 +965,17 @@ main(argc, argv)
if (curuser == (char *)0) if (curuser == (char *)0)
if (origuser == (char *)0) if (origuser == (char *)0)
Info("Started as uid %d by uid %d at %s", curuid, curuid, Msg("started as uid %d by uid %d", curuid, curuid);
strtime(NULL));
else else
Info("Started as uid %d by `%s' at %s", curuid, origuser, Msg("started as uid %d by `%s'", curuid, origuser);
strtime(NULL));
else else
Info("Started as `%s' by `%s' at %s", curuser, Msg("started as `%s' by `%s'", curuser,
(origuser == (char *)0) ? curuser : origuser, strtime(NULL)); (origuser == (char *)0) ? curuser : origuser);
(void)endpwent(); endpwent();
#if HAVE_GETSPNAM && !HAVE_PAM #if HAVE_GETSPNAM && !HAVE_PAM
if (0 != geteuid()) { if (0 != geteuid()) {
Error Msg("Warning: running as a non-root user - any shadow password usage will most likely fail!");
("Warning: Running as a non-root user - any shadow password usage will most likely fail!");
} }
#endif #endif
@ -889,18 +984,20 @@ main(argc, argv)
} else { } else {
bindAddr = inet_addr(pcAddress); bindAddr = inet_addr(pcAddress);
if (bindAddr == (in_addr_t) (-1)) { if (bindAddr == (in_addr_t) (-1)) {
Error("inet_addr: %s: %s", pcAddress, "invalid IP address"); Error("inet_addr(%s): %s", pcAddress, "invalid IP address");
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
acMyAddr.s_addr = bindAddr;
} }
if (fDebug) { if (fDebug) {
struct in_addr ba; struct in_addr ba;
ba.s_addr = bindAddr; ba.s_addr = bindAddr;
Debug(1, "Bind address set to `%s'", inet_ntoa(ba)); Debug(1, "main(): bind address set to `%s'", inet_ntoa(ba));
} }
if (pcPort == NULL) { if (pcPort == NULL) {
Error("Severe error: pcPort is NULL???? How can that be?"); Error
("main(): severe error - pcPort is NULL???? how can that be?");
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
@ -916,10 +1013,10 @@ main(argc, argv)
/* non-numeric only */ /* non-numeric only */
struct servent *pSE; struct servent *pSE;
if ((struct servent *)0 == (pSE = getservbyname(pcPort, "tcp"))) { if ((struct servent *)0 == (pSE = getservbyname(pcPort, "tcp"))) {
Error("getservbyname: %s: %s", pcPort, strerror(errno)); Error("getservbyname(%s): %s", pcPort, strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} else { } else {
bindPort = ntohs((u_short) pSE->s_port); bindPort = ntohs((unsigned short)pSE->s_port);
} }
} }
@ -936,39 +1033,28 @@ main(argc, argv)
struct servent *pSE; struct servent *pSE;
if ((struct servent *)0 == if ((struct servent *)0 ==
(pSE = getservbyname(pcBasePort, "tcp"))) { (pSE = getservbyname(pcBasePort, "tcp"))) {
Error("getservbyname: %s: %s", pcBasePort, strerror(errno)); Error("getservbyname(%s): %s", pcBasePort, strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} else { } else {
bindBasePort = ntohs((u_short) pSE->s_port); bindBasePort = ntohs((unsigned short)pSE->s_port);
} }
} }
/* read the config file /* read the config file
*/ */
if ((FILE *) 0 == (fpConfig = fopen(pcConfig, "r"))) { if ((FILE *) 0 == (fpConfig = fopen(pcConfig, "r"))) {
Error("fopen: %s: %s", pcConfig, strerror(errno)); Error("fopen(%s): %s", pcConfig, strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
#if HAVE_FLOCK
/* we lock the configuration file so that two identical
* conservers will not be running together (but two with
* different configurations can run on the same host).
*/
if (-1 == flock(fileno(fpConfig), LOCK_NB | LOCK_EX)) {
Error("%s is locked, won\'t run more than one conserver?",
pcConfig);
exit(EX_UNAVAILABLE);
}
#endif
ReadCfg(pcConfig, fpConfig); ReadCfg(pcConfig, fpConfig);
if (pGroups == (GRPENT *) 0 && pRCList == (REMOTE *) 0) { if (pGroups == (GRPENT *) 0 && pRCList == (REMOTE *) 0) {
Error("No consoles found in configuration file"); Error("no consoles found in configuration file");
} else { } else {
#if HAVE_OPENSSL #if HAVE_OPENSSL
/* Prep the SSL layer */ /* Prep the SSL layer */
setupSSL(); SetupSSL();
#endif #endif
/* if no one can use us we need to come up with a default /* if no one can use us we need to come up with a default
@ -985,14 +1071,12 @@ main(argc, argv)
Spawn(pGE); Spawn(pGE);
if (fVerbose) { Verbose("group #%d pid %lu on port %hu", pGE->id,
Info("group #%d pid %d on port %u", pGE->id, pGE->pid, (unsigned long)pGE->pid, ntohs(pGE->port));
ntohs(pGE->port));
}
for (pCE = pGE->pCElist; pCE != (CONSENT *) 0; for (pCE = pGE->pCElist; pCE != (CONSENT *) 0;
pCE = pCE->pCEnext) { pCE = pCE->pCEnext) {
if (-1 != pCE->fdtty) if (-1 != pCE->fdtty)
(void)close(pCE->fdtty); close(pCE->fdtty);
} }
} }
@ -1000,7 +1084,7 @@ main(argc, argv)
ACCESS *pACtmp; ACCESS *pACtmp;
for (pACtmp = pACList; pACtmp != (ACCESS *) 0; for (pACtmp = pACList; pACtmp != (ACCESS *) 0;
pACtmp = pACtmp->pACnext) { pACtmp = pACtmp->pACnext) {
Info("access type '%c' for \"%s\"", pACtmp->ctrust, Verbose("access type `%c' for `%s'", pACtmp->ctrust,
pACtmp->pcwho); pACtmp->pcwho);
} }
} }
@ -1011,24 +1095,25 @@ main(argc, argv)
if (fVerbose) { if (fVerbose) {
REMOTE *pRC; REMOTE *pRC;
for (pRC = pRCUniq; (REMOTE *) 0 != pRC; pRC = pRC->pRCuniq) { for (pRC = pRCUniq; (REMOTE *) 0 != pRC; pRC = pRC->pRCuniq) {
Info("peer server on `%s'", pRC->rhost.string); Verbose("peer server on `%s'", pRC->rhost.string);
} }
} }
(void)fflush(stdout); fflush(stdout);
(void)fflush(stderr); fflush(stderr);
Master(); Master();
/* stop putting kids back, and shoot them /* stop putting kids back, and shoot them
*/ */
simpleSignal(SIGCHLD, SIG_DFL); SimpleSignal(SIGCHLD, SIG_DFL);
SignalKids(SIGTERM); SignalKids(SIGTERM);
} }
dumpDataStructures(); DumpDataStructures();
Info("Stopped at %s", strtime(NULL)); Msg("terminated");
(void)endpwent(); endpwent();
(void)fclose(fpConfig); fclose(fpConfig);
exit(EX_OK); Bye(EX_OK);
return EX_OK; /* never gets here clears the compiler warning */
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: main.h,v 5.39 2003-01-08 17:12:38-08 bryan Exp $ * $Id: main.h,v 5.45 2003-03-09 15:20:43-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -37,14 +37,15 @@
/* program options and stuff /* program options and stuff
*/ */
extern char rcsid[]; extern char rcsid[];
extern int fAll, fVerbose, fSoftcar, fNoinit, fInteractive, fStrip, extern int fAll, fSoftcar, fNoinit, fInteractive, fStrip, fDaemon, fReopen,
fDaemon, fReopen, fReopenall, fNoautoreup, fNoredir; fReopenall, fNoautoreup, fNoredir;
extern char chDefAcc; extern char chDefAcc;
extern in_addr_t bindAddr; extern in_addr_t bindAddr;
extern unsigned int bindPort, bindBasePort; extern unsigned short bindPort, bindBasePort;
extern char *pcLogfile; extern char *pcLogfile;
extern char *pcConfig; extern char *pcConfig;
extern char *pcPasswd; extern char *pcPasswd;
extern STRING *defaultShell;
extern int cMaxMemb; extern int cMaxMemb;
extern struct sockaddr_in in_port; extern struct sockaddr_in in_port;
extern char acMyHost[]; extern char acMyHost[];
@ -55,10 +56,5 @@ extern int isMaster;
extern SSL_CTX *ctx; extern SSL_CTX *ctx;
extern int fReqEncryption; extern int fReqEncryption;
#endif #endif
#if USE_ANSI_PROTO extern void ReopenLogfile PARAMS((void));
extern void reopenLogfile(void); extern void DumpDataStructures PARAMS((void));
extern void dumpDataStructures(void);
#else
extern void reopenLogfile();
extern void dumpDataStructures();
#endif

View File

@ -1,5 +1,5 @@
/* /*
* $Id: master.c,v 5.82 2003-01-08 17:18:44-08 bryan Exp $ * $Id: master.c,v 5.91 2003-03-10 17:37:04-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -66,7 +66,7 @@ static sig_atomic_t fSawQuit = 0, fSawHUP = 0, fSawUSR2 = 0, fSawUSR1 =
static RETSIGTYPE static RETSIGTYPE
#if USE_ANSI_PROTO #if PROTOTYPES
FlagSawCHLD(int sig) FlagSawCHLD(int sig)
#else #else
FlagSawCHLD(sig) FlagSawCHLD(sig)
@ -75,7 +75,7 @@ FlagSawCHLD(sig)
{ {
fSawCHLD = 1; fSawCHLD = 1;
#if !HAVE_SIGACTION #if !HAVE_SIGACTION
simpleSignal(SIGCHLD, FlagSawCHLD); SimpleSignal(SIGCHLD, FlagSawCHLD);
#endif #endif
} }
@ -83,13 +83,13 @@ FlagSawCHLD(sig)
* Called when master process receives SIGCHLD * Called when master process receives SIGCHLD
*/ */
static void static void
#if USE_ANSI_PROTO #if PROTOTYPES
FixKids() FixKids()
#else #else
FixKids() FixKids()
#endif #endif
{ {
int pid; pid_t pid;
int UWbuf; int UWbuf;
GRPENT *pGE; GRPENT *pGE;
@ -114,36 +114,30 @@ FixKids()
fSawQuit = 1; fSawQuit = 1;
/* So we don't kill something that's dead */ /* So we don't kill something that's dead */
pGE->pid = -1; pGE->pid = -1;
Info("%s: exit(%d), shutdown [%s]", Msg("[%s] exit(%d), shutdown", pGE->pCElist->server.string,
pGE->pCElist->server.string, WEXITSTATUS(UWbuf), WEXITSTATUS(UWbuf));
strtime(NULL));
break; break;
} }
if (WIFSIGNALED(UWbuf) && (WTERMSIG(UWbuf) == SIGTERM)) { if (WIFSIGNALED(UWbuf) && (WTERMSIG(UWbuf) == SIGTERM)) {
fSawQuit = 1; fSawQuit = 1;
/* So we don't kill something that's dead */ /* So we don't kill something that's dead */
pGE->pid = -1; pGE->pid = -1;
Info("%s: signal(%d), shutdown [%s]", Msg("[%s] signal(%d), shutdown",
pGE->pCElist->server.string, WTERMSIG(UWbuf), pGE->pCElist->server.string, WTERMSIG(UWbuf));
strtime(NULL));
break; break;
} }
/* If not, then just a simple restart of the child */ /* If not, then just a simple restart of the child */
if (WIFEXITED(UWbuf)) if (WIFEXITED(UWbuf))
Info("%s(%d): exit(%d), restarted [%s]", progname, pid, Msg("[%s] exit(%d), restarted", WEXITSTATUS(UWbuf));
WEXITSTATUS(UWbuf), strtime(NULL));
if (WIFSIGNALED(UWbuf)) if (WIFSIGNALED(UWbuf))
Info("%s(%d): signal(%d), restarted [%s]", progname, pid, Msg("[%s] signal(%d), restarted", WTERMSIG(UWbuf));
WTERMSIG(UWbuf), strtime(NULL));
/* this kid kid is dead, start another /* this kid kid is dead, start another
*/ */
Spawn(pGE); Spawn(pGE);
if (fVerbose) { Verbose("group #%d pid %lu on port %hu", pGE->id,
Info("group #%d pid %d on port %u", pGE->id, pGE->pid, (unsigned long)pGE->pid, ntohs(pGE->port));
ntohs(pGE->port));
}
} }
} }
} }
@ -152,7 +146,7 @@ FixKids()
* Called when master process receives SIGTERM * Called when master process receives SIGTERM
*/ */
static RETSIGTYPE static RETSIGTYPE
#if USE_ANSI_PROTO #if PROTOTYPES
FlagQuitIt(int arg) FlagQuitIt(int arg)
#else #else
FlagQuitIt(arg) FlagQuitIt(arg)
@ -161,7 +155,7 @@ FlagQuitIt(arg)
{ {
fSawQuit = 1; fSawQuit = 1;
#if !HAVE_SIGACTION #if !HAVE_SIGACTION
simpleSignal(SIGTERM, FlagQuitIt); SimpleSignal(SIGTERM, FlagQuitIt);
#endif #endif
} }
@ -169,7 +163,7 @@ FlagQuitIt(arg)
* want to do something special on SIGINT at some point. * want to do something special on SIGINT at some point.
*/ */
static RETSIGTYPE static RETSIGTYPE
#if USE_ANSI_PROTO #if PROTOTYPES
FlagSawINT(int arg) FlagSawINT(int arg)
#else #else
FlagSawINT(arg) FlagSawINT(arg)
@ -178,12 +172,12 @@ FlagSawINT(arg)
{ {
fSawQuit = 1; fSawQuit = 1;
#if !HAVE_SIGACTION #if !HAVE_SIGACTION
simpleSignal(SIGINT, FlagSawINT); SimpleSignal(SIGINT, FlagSawINT);
#endif #endif
} }
static RETSIGTYPE static RETSIGTYPE
#if USE_ANSI_PROTO #if PROTOTYPES
FlagSawHUP(int arg) FlagSawHUP(int arg)
#else #else
FlagSawHUP(arg) FlagSawHUP(arg)
@ -192,12 +186,12 @@ FlagSawHUP(arg)
{ {
fSawHUP = 1; fSawHUP = 1;
#if !HAVE_SIGACTION #if !HAVE_SIGACTION
simpleSignal(SIGHUP, FlagSawHUP); SimpleSignal(SIGHUP, FlagSawHUP);
#endif #endif
} }
static RETSIGTYPE static RETSIGTYPE
#if USE_ANSI_PROTO #if PROTOTYPES
FlagSawUSR2(int arg) FlagSawUSR2(int arg)
#else #else
FlagSawUSR2(arg) FlagSawUSR2(arg)
@ -206,12 +200,12 @@ FlagSawUSR2(arg)
{ {
fSawUSR2 = 1; fSawUSR2 = 1;
#if !HAVE_SIGACTION #if !HAVE_SIGACTION
simpleSignal(SIGUSR2, FlagSawUSR2); SimpleSignal(SIGUSR2, FlagSawUSR2);
#endif #endif
} }
static RETSIGTYPE static RETSIGTYPE
#if USE_ANSI_PROTO #if PROTOTYPES
FlagSawUSR1(int arg) FlagSawUSR1(int arg)
#else #else
FlagSawUSR1(arg) FlagSawUSR1(arg)
@ -220,14 +214,14 @@ FlagSawUSR1(arg)
{ {
fSawUSR1 = 1; fSawUSR1 = 1;
#if !HAVE_SIGACTION #if !HAVE_SIGACTION
simpleSignal(SIGUSR1, FlagSawUSR1); SimpleSignal(SIGUSR1, FlagSawUSR1);
#endif #endif
} }
/* Signal all the kids... /* Signal all the kids...
*/ */
void void
#if USE_ANSI_PROTO #if PROTOTYPES
SignalKids(int arg) SignalKids(int arg)
#else #else
SignalKids(arg) SignalKids(arg)
@ -239,9 +233,11 @@ SignalKids(arg)
for (pGE = pGroups; pGE != (GRPENT *) 0; pGE = pGE->pGEnext) { for (pGE = pGroups; pGE != (GRPENT *) 0; pGE = pGE->pGEnext) {
if (0 == pGE->imembers || -1 == pGE->pid) if (0 == pGE->imembers || -1 == pGE->pid)
continue; continue;
Debug(1, "Sending pid %d signal %d", pGE->pid, arg); Debug(1, "SignalKids(): sending pid %lu signal %d",
(unsigned long)pGE->pid, arg);
if (-1 == kill(pGE->pid, arg)) { if (-1 == kill(pGE->pid, arg)) {
Error("kill: %s", strerror(errno)); Error("SignalKids(): kill(%lu): %s", (unsigned long)pGE->pid,
strerror(errno));
} }
} }
} }
@ -250,7 +246,7 @@ SignalKids(arg)
/* this routine is used by the master console server process (ksb) /* this routine is used by the master console server process (ksb)
*/ */
void void
#if USE_ANSI_PROTO #if PROTOTYPES
Master(void) Master(void)
#else #else
Master() Master()
@ -269,7 +265,7 @@ Master()
unsigned char acIn[1024]; /* a command to the master is limited to this */ unsigned char acIn[1024]; /* a command to the master is limited to this */
struct sockaddr_in master_port, response_port; struct sockaddr_in master_port, response_port;
int true = 1; int true = 1;
int pid, parentpid; pid_t pid, parentpid;
char *ambiguous = (char *)0; char *ambiguous = (char *)0;
GRPENT *pGE; GRPENT *pGE;
CONSENT *pCE; CONSENT *pCE;
@ -277,63 +273,65 @@ Master()
/* set up signal handler */ /* set up signal handler */
simpleSignal(SIGPIPE, SIG_IGN); SimpleSignal(SIGPIPE, SIG_IGN);
simpleSignal(SIGQUIT, SIG_IGN); SimpleSignal(SIGQUIT, SIG_IGN);
#if defined(SIGTTOU) #if defined(SIGTTOU)
simpleSignal(SIGTTOU, SIG_IGN); SimpleSignal(SIGTTOU, SIG_IGN);
#endif #endif
#if defined(SIGTTIN) #if defined(SIGTTIN)
simpleSignal(SIGTTIN, SIG_IGN); SimpleSignal(SIGTTIN, SIG_IGN);
#endif #endif
#if defined(SIGPOLL) #if defined(SIGPOLL)
simpleSignal(SIGPOLL, SIG_IGN); SimpleSignal(SIGPOLL, SIG_IGN);
#endif #endif
simpleSignal(SIGCHLD, FlagSawCHLD); SimpleSignal(SIGCHLD, FlagSawCHLD);
simpleSignal(SIGTERM, FlagQuitIt); SimpleSignal(SIGTERM, FlagQuitIt);
simpleSignal(SIGUSR1, FlagSawUSR1); SimpleSignal(SIGUSR1, FlagSawUSR1);
simpleSignal(SIGHUP, FlagSawHUP); SimpleSignal(SIGHUP, FlagSawHUP);
simpleSignal(SIGUSR2, FlagSawUSR2); SimpleSignal(SIGUSR2, FlagSawUSR2);
simpleSignal(SIGINT, FlagSawINT); SimpleSignal(SIGINT, FlagSawINT);
/* set up port for master to listen on /* set up port for master to listen on
*/ */
#if HAVE_MEMSET #if HAVE_MEMSET
(void)memset((void *)&master_port, 0, sizeof(master_port)); memset((void *)&master_port, 0, sizeof(master_port));
#else #else
(void)bzero((char *)&master_port, sizeof(master_port)); bzero((char *)&master_port, sizeof(master_port));
#endif #endif
master_port.sin_family = AF_INET; master_port.sin_family = AF_INET;
master_port.sin_addr.s_addr = bindAddr; master_port.sin_addr.s_addr = bindAddr;
master_port.sin_port = htons(bindPort); master_port.sin_port = htons(bindPort);
if ((msfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) { if ((msfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
Error("socket: %s", strerror(errno)); Error("Master(): socket(AF_INET,SOCK_STREAM): %s",
strerror(errno));
return; return;
} }
#if HAVE_SETSOCKOPT #if HAVE_SETSOCKOPT
if (setsockopt if (setsockopt
(msfd, SOL_SOCKET, SO_REUSEADDR, (char *)&true, (msfd, SOL_SOCKET, SO_REUSEADDR, (char *)&true,
sizeof(true)) < 0) { sizeof(true)) < 0) {
Error("setsockopt: %s", strerror(errno)); Error("Master(): setsockopt(%u,SO_REUSEADDR): %s", msfd,
strerror(errno));
return; return;
} }
#endif #endif
if (bind(msfd, (struct sockaddr *)&master_port, sizeof(master_port)) < if (bind(msfd, (struct sockaddr *)&master_port, sizeof(master_port)) <
0) { 0) {
Error("bind: %s", strerror(errno)); Error("Master(): bind(%u): %s", msfd, strerror(errno));
return; return;
} }
if (listen(msfd, SOMAXCONN) < 0) { if (listen(msfd, SOMAXCONN) < 0) {
Error("listen: %s", strerror(errno)); Error("Master(): listen(%u): %s", msfd, strerror(errno));
return; return;
} }
fp = fopen(PIDFILE, "w"); fp = fopen(PIDFILE, "w");
if (fp) { if (fp) {
fprintf(fp, "%d\n", (int)getpid()); fprintf(fp, "%lu\n", (unsigned long)getpid());
fclose(fp); fclose(fp);
} else { } else {
Error("can't write pid to %s", PIDFILE); Error("Master(): can't write pid to %s", PIDFILE);
} }
FD_ZERO(&rmaster); FD_ZERO(&rmaster);
@ -346,20 +344,20 @@ Master()
} }
if (fSawHUP) { if (fSawHUP) {
fSawHUP = 0; fSawHUP = 0;
Info("Processing SIGHUP at %s", strtime(NULL)); Msg("processing SIGHUP");
reopenLogfile(); ReopenLogfile();
SignalKids(SIGHUP); SignalKids(SIGHUP);
ReReadCfg(); ReReadCfg();
} }
if (fSawUSR1) { if (fSawUSR1) {
fSawUSR1 = 0; fSawUSR1 = 0;
Info("Processing SIGUSR1 at %s", strtime(NULL)); Msg("processing SIGUSR1");
SignalKids(SIGUSR1); SignalKids(SIGUSR1);
} }
if (fSawUSR2) { if (fSawUSR2) {
fSawUSR2 = 0; fSawUSR2 = 0;
Info("Processing SIGUSR2 at %s", strtime(NULL)); Msg("processing SIGUSR2");
reopenLogfile(); ReopenLogfile();
SignalKids(SIGUSR2); SignalKids(SIGUSR2);
} }
if (fSawQuit) { /* Something above set the quit flag */ if (fSawQuit) { /* Something above set the quit flag */
@ -372,7 +370,7 @@ Master()
select(msfd + 1, &rmask, (fd_set *) 0, (fd_set *) 0, select(msfd + 1, &rmask, (fd_set *) 0, (fd_set *) 0,
(struct timeval *)0)) { (struct timeval *)0)) {
if (errno != EINTR) { if (errno != EINTR) {
Error("select: %s", strerror(errno)); Error("Master(): select(): %s", strerror(errno));
} }
continue; continue;
} }
@ -382,12 +380,12 @@ Master()
so = sizeof(response_port); so = sizeof(response_port);
cfd = accept(msfd, (struct sockaddr *)&response_port, &so); cfd = accept(msfd, (struct sockaddr *)&response_port, &so);
if (cfd < 0) { if (cfd < 0) {
Error("accept: %s", strerror(errno)); Error("Master(): accept(%u): %s", msfd, strerror(errno));
continue; continue;
} }
if ((CONSFILE *) 0 == (csocket = fileOpenFD(cfd, simpleSocket))) { if ((CONSFILE *) 0 == (csocket = FileOpenFD(cfd, simpleSocket))) {
Error("fileOpenFD: %s", strerror(errno)); Error("Master(): FileOpenFD(%u): %s", cfd, strerror(errno));
close(cfd); close(cfd);
continue; continue;
} }
@ -397,9 +395,9 @@ Master()
request_init(&request, RQ_DAEMON, progname, RQ_FILE, cfd, 0); request_init(&request, RQ_DAEMON, progname, RQ_FILE, cfd, 0);
fromhost(&request); fromhost(&request);
if (!hosts_access(&request)) { if (!hosts_access(&request)) {
fileWrite(csocket, "access from your host refused\r\n", FileWrite(csocket, "access from your host refused\r\n",
-1); -1);
fileClose(&csocket); FileClose(&csocket);
continue; continue;
} }
} }
@ -407,10 +405,10 @@ Master()
so = sizeof(in_port); so = sizeof(in_port);
if (-1 == if (-1 ==
getpeername(fileFDNum(csocket), (struct sockaddr *)&in_port, getpeername(FileFDNum(csocket), (struct sockaddr *)&in_port,
&so)) { &so)) {
fileWrite(csocket, "getpeername failed\r\n", -1); FileWrite(csocket, "getpeername failed\r\n", -1);
fileClose(&csocket); FileClose(&csocket);
continue; continue;
} }
so = sizeof(in_port.sin_addr); so = sizeof(in_port.sin_addr);
@ -422,33 +420,33 @@ Master()
cType = AccType(&in_port.sin_addr, hpPeer->h_name); cType = AccType(&in_port.sin_addr, hpPeer->h_name);
} }
if ('r' == cType) { if ('r' == cType) {
fileWrite(csocket, "access from your host refused\r\n", -1); FileWrite(csocket, "access from your host refused\r\n", -1);
fileClose(&csocket); FileClose(&csocket);
continue; continue;
} }
(void)fflush(stdin); fflush(stdin);
(void)fflush(stderr); fflush(stderr);
switch (pid = fork()) { switch (pid = fork()) {
case -1: case -1:
fileWrite(csocket, "fork failed, try again later\r\n", -1); FileWrite(csocket, "fork failed, try again later\r\n", -1);
fileClose(&csocket); FileClose(&csocket);
Error("fork: %s", strerror(errno)); Error("Master(): fork(): %s", strerror(errno));
continue; continue;
default: default:
#if defined(__CYGWIN__) #if defined(__CYGWIN__)
/* Since we've got all that "special" stuff in the fileClose /* Since we've got all that "special" stuff in the FileClose
* routine for getting around a winsock bug, we have to * routine for getting around a winsock bug, we have to
* shut things down differently here. Instead of calling * shut things down differently here. Instead of calling
* fileClose (which half-closes the socket as well as just * FileClose (which half-closes the socket as well as just
* closing the descriptor), we "unopen" the structure (to * closing the descriptor), we "unopen" the structure (to
* free memory) and then do a regular close. The child (which * free memory) and then do a regular close. The child (which
* writes to the client) will do a fileClose and all the * writes to the client) will do a FileClose and all the
* flushing magic will happen. UGH! -bryan * flushing magic will happen. UGH! -bryan
*/ */
close(fileUnopen(csocket)); close(FileUnopen(csocket));
#else #else
fileClose(&csocket); FileClose(&csocket);
#endif #endif
continue; continue;
case 0: case 0:
@ -460,10 +458,10 @@ Master()
/* handle the connection /* handle the connection
* (port lookup, who, users, or quit) * (port lookup, who, users, or quit)
*/ */
fileWrite(csocket, "ok\r\n", -1); FileWrite(csocket, "ok\r\n", -1);
for (i = 0; i < sizeof(acIn) - 1; /* i+=nr */ ) { for (i = 0; i < sizeof(acIn) - 1; /* i+=nr */ ) {
if ((nr = if ((nr =
fileRead(csocket, &acIn[i], sizeof(acIn) - 1 - i)) <= 0) { FileRead(csocket, &acIn[i], sizeof(acIn) - 1 - i)) <= 0) {
break; break;
} }
for (j = 0; j < nr; j++, i++) { for (j = 0; j < nr; j++, i++) {
@ -479,9 +477,9 @@ Master()
acIn[i] = '\000'; acIn[i] = '\000';
} }
if (0 == i) { if (0 == i) {
Error("lost connection"); Error("Master(): lost connection (%u)", FileFDNum(csocket));
fileClose(&csocket); FileClose(&csocket);
exit(EX_OK); Bye(EX_OK);
} }
if ((char *)0 != (pcArgs = strchr((char *)acIn, ':'))) { if ((char *)0 != (pcArgs = strchr((char *)acIn, ':'))) {
*pcArgs++ = '\000'; *pcArgs++ = '\000';
@ -501,30 +499,30 @@ Master()
}; };
char **ppc; char **ppc;
for (ppc = apcHelp; (char *)0 != *ppc; ++ppc) { for (ppc = apcHelp; (char *)0 != *ppc; ++ppc) {
(void)fileWrite(csocket, *ppc, -1); FileWrite(csocket, *ppc, -1);
} }
fileClose(&csocket); FileClose(&csocket);
exit(EX_OK); Bye(EX_OK);
} }
if (0 == strcmp((char *)acIn, "quit")) { if (0 == strcmp((char *)acIn, "quit")) {
if ('t' == cType) { if ('t' == cType) {
fileWrite(csocket, "trusted -- terminated\r\n", -1); FileWrite(csocket, "trusted -- terminated\r\n", -1);
kill(parentpid, SIGTERM); kill(parentpid, SIGTERM);
} else if ((char *)0 == pcArgs) { } else if ((char *)0 == pcArgs) {
fileWrite(csocket, "must be trusted to terminate\r\n", -1); FileWrite(csocket, "must be trusted to terminate\r\n", -1);
} else if (CheckPass("root", pcArgs) != AUTH_SUCCESS) { } else if (CheckPass("root", pcArgs) != AUTH_SUCCESS) {
fileWrite(csocket, "Sorry.\r\n", -1); FileWrite(csocket, "Sorry.\r\n", -1);
} else { } else {
fileWrite(csocket, "ok -- terminated\r\n", -1); FileWrite(csocket, "ok -- terminated\r\n", -1);
kill(parentpid, SIGTERM); kill(parentpid, SIGTERM);
} }
fileClose(&csocket); FileClose(&csocket);
exit(EX_OK); Bye(EX_OK);
} }
if (0 == strcmp((char *)acIn, "pid")) { if (0 == strcmp((char *)acIn, "pid")) {
filePrint(csocket, "%d\r\n", parentpid); FilePrint(csocket, "%lu\r\n", (unsigned long)parentpid);
fileClose(&csocket); FileClose(&csocket);
exit(EX_OK); Bye(EX_OK);
} }
if (0 == strcmp((char *)acIn, "groups")) { if (0 == strcmp((char *)acIn, "groups")) {
int iSep = 1; int iSep = 1;
@ -532,12 +530,12 @@ Master()
for (pGE = pGroups; pGE != (GRPENT *) 0; pGE = pGE->pGEnext) { for (pGE = pGroups; pGE != (GRPENT *) 0; pGE = pGE->pGEnext) {
if (0 == pGE->imembers) if (0 == pGE->imembers)
continue; continue;
filePrint(csocket, ":%u" + iSep, ntohs(pGE->port)); FilePrint(csocket, ":%hu" + iSep, ntohs(pGE->port));
iSep = 0; iSep = 0;
} }
fileWrite(csocket, "\r\n", -1); FileWrite(csocket, "\r\n", -1);
fileClose(&csocket); FileClose(&csocket);
exit(EX_OK); Bye(EX_OK);
} }
if (0 == strcmp((char *)acIn, "master")) { if (0 == strcmp((char *)acIn, "master")) {
int iSep = 1; int iSep = 1;
@ -546,43 +544,44 @@ Master()
struct sockaddr_in lcl; struct sockaddr_in lcl;
so = sizeof(lcl); so = sizeof(lcl);
if (-1 == if (-1 ==
getsockname(fileFDNum(csocket), getsockname(FileFDNum(csocket),
(struct sockaddr *)&lcl, &so)) { (struct sockaddr *)&lcl, &so)) {
fileWrite(csocket, FileWrite(csocket,
"getsockname failed, try again later\r\n", "getsockname failed, try again later\r\n",
-1); -1);
Error("getsockname: %s", strerror(errno)); Error("Master(): getsockname(%u): %s",
FileFDNum(csocket), strerror(errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
filePrint(csocket, "@%s", inet_ntoa(lcl.sin_addr)); FilePrint(csocket, "@%s", inet_ntoa(lcl.sin_addr));
iSep = 0; iSep = 0;
} }
if (!fNoredir) { if (!fNoredir) {
for (pRC = pRCUniq; (REMOTE *) 0 != pRC; for (pRC = pRCUniq; (REMOTE *) 0 != pRC;
pRC = pRC->pRCuniq) { pRC = pRC->pRCuniq) {
filePrint(csocket, ":@%s" + iSep, pRC->rhost.string); FilePrint(csocket, ":@%s" + iSep, pRC->rhost.string);
iSep = 0; iSep = 0;
} }
} }
fileWrite(csocket, "\r\n", -1); FileWrite(csocket, "\r\n", -1);
fileClose(&csocket); FileClose(&csocket);
exit(EX_OK); Bye(EX_OK);
} }
if (0 == strcmp((char *)acIn, "version")) { if (0 == strcmp((char *)acIn, "version")) {
filePrint(csocket, "version `%s\'\r\n", THIS_VERSION); FilePrint(csocket, "version `%s'\r\n", THIS_VERSION);
fileClose(&csocket); FileClose(&csocket);
exit(EX_OK); Bye(EX_OK);
} }
if (0 != strcmp((char *)acIn, "call")) { if (0 != strcmp((char *)acIn, "call")) {
fileWrite(csocket, "unknown command\r\n", -1); FileWrite(csocket, "unknown command\r\n", -1);
fileClose(&csocket); FileClose(&csocket);
exit(EX_OK); Bye(EX_OK);
} }
if ((char *)0 == pcArgs) { if ((char *)0 == pcArgs) {
fileWrite(csocket, "call requires argument\r\n", -1); FileWrite(csocket, "call requires argument\r\n", -1);
fileClose(&csocket); FileClose(&csocket);
exit(EX_OK); Bye(EX_OK);
} }
/* look up the machine to call /* look up the machine to call
@ -599,8 +598,8 @@ Master()
continue; continue;
} }
prnum = ntohs(pGE->port); prnum = ntohs(pGE->port);
ambiguous = buildString(pCE->server.string); ambiguous = BuildTmpString(pCE->server.string);
ambiguous = buildString(", "); ambiguous = BuildTmpString(", ");
++found; ++found;
} }
} }
@ -608,15 +607,17 @@ Master()
* duplicates - a bad state to be in. * duplicates - a bad state to be in.
* Does the readcfg.c code even check for dups? * Does the readcfg.c code even check for dups?
*/ */
if (!fNoredir || (fNoredir && found == 0)) {
for (pRC = pRCList; (REMOTE *) 0 != pRC; pRC = pRC->pRCnext) { for (pRC = pRCList; (REMOTE *) 0 != pRC; pRC = pRC->pRCnext) {
if (0 != strcmp(pcArgs, pRC->rserver.string)) { if (0 != strcmp(pcArgs, pRC->rserver.string)) {
continue; continue;
} }
ambiguous = buildString(pRC->rserver.string); ambiguous = BuildTmpString(pRC->rserver.string);
ambiguous = buildString(", "); ambiguous = BuildTmpString(", ");
++found; ++found;
pRCFound = pRC; pRCFound = pRC;
} }
}
if (found == 0) { /* Then look for substring matches */ if (found == 0) { /* Then look for substring matches */
for (pGE = pGroups; pGE != (GRPENT *) 0; pGE = pGE->pGEnext) { for (pGE = pGroups; pGE != (GRPENT *) 0; pGE = pGE->pGEnext) {
if (0 == pGE->imembers) if (0 == pGE->imembers)
@ -629,55 +630,59 @@ Master()
continue; continue;
} }
prnum = ntohs(pGE->port); prnum = ntohs(pGE->port);
ambiguous = buildString(pCE->server.string); ambiguous = BuildTmpString(pCE->server.string);
ambiguous = buildString(", "); ambiguous = BuildTmpString(", ");
++found; ++found;
} }
} }
/* look for a remote server */ /* look for a remote server */
/* again, looks for dups with local consoles */ /* again, looks for dups with local consoles */
for (pRC = pRCList; (REMOTE *) 0 != pRC; pRC = pRC->pRCnext) { if (!fNoredir || (fNoredir && found != 1)) {
for (pRC = pRCList; (REMOTE *) 0 != pRC;
pRC = pRC->pRCnext) {
if (0 != if (0 !=
strncmp(pcArgs, pRC->rserver.string, strlen(pcArgs))) { strncmp(pcArgs, pRC->rserver.string,
strlen(pcArgs))) {
continue; continue;
} }
ambiguous = buildString(pRC->rserver.string); ambiguous = BuildTmpString(pRC->rserver.string);
ambiguous = buildString(", "); ambiguous = BuildTmpString(", ");
++found; ++found;
pRCFound = pRC; pRCFound = pRC;
} }
} }
}
switch (found) { switch (found) {
case 0: case 0:
filePrint(csocket, "console `%s' not found\r\n", pcArgs); FilePrint(csocket, "console `%s' not found\r\n", pcArgs);
break; break;
case 1: case 1:
if ((REMOTE *) 0 != pRCFound) { if ((REMOTE *) 0 != pRCFound) {
if (fNoredir) { if (fNoredir) {
filePrint(csocket, FilePrint(csocket,
"automatic redirection disabled - console on master `%s'\r\n", "automatic redirection disabled - console on master `%s'\r\n",
pRCFound->rhost.string); pRCFound->rhost.string);
} else { } else {
filePrint(csocket, "@%s\r\n", FilePrint(csocket, "@%s\r\n",
pRCFound->rhost.string); pRCFound->rhost.string);
} }
} else { } else {
filePrint(csocket, "%u\r\n", prnum); FilePrint(csocket, "%hu\r\n", prnum);
} }
break; break;
default: default:
found = strlen(ambiguous); found = strlen(ambiguous);
ambiguous[found - 2] = '\000'; ambiguous[found - 2] = '\000';
filePrint(csocket, FilePrint(csocket,
"ambiguous console abbreviation, `%s'\r\n\tchoices are %s\r\n", "ambiguous console abbreviation, `%s'\r\n\tchoices are %s\r\n",
pcArgs, ambiguous); pcArgs, ambiguous);
break; break;
} }
buildString((char *)0); /* we're done - clean up */ BuildTmpString((char *)0); /* we're done - clean up */
ambiguous = (char *)0; ambiguous = (char *)0;
fileClose(&csocket); FileClose(&csocket);
exit(EX_OK); Bye(EX_OK);
} }
(void)unlink(PIDFILE); unlink(PIDFILE);
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: master.h,v 5.15 2002-09-29 19:05:25-07 bryan Exp $ * $Id: master.h,v 5.16 2003-03-06 10:13:41-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -37,10 +37,5 @@
/* /*
* stuff the master process needs * stuff the master process needs
*/ */
#if USE_ANSI_PROTO extern void Master PARAMS((void));
extern void Master(void); extern void SignalKids PARAMS((int));
extern void SignalKids(int);
#else
extern void Master();
extern void SignalKids();
#endif

View File

@ -1,5 +1,5 @@
/* /*
* $Id: readcfg.c,v 5.90 2003-01-08 17:12:21-08 bryan Exp $ * $Id: readcfg.c,v 5.99 2003-03-09 15:20:15-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -67,11 +67,11 @@ static unsigned int groupID = 0;
* return 0 on invalid spec, non-zero on valid spec * return 0 on invalid spec, non-zero on valid spec
*/ */
int int
#if USE_ANSI_PROTO #if PROTOTYPES
parseMark(const char *pcFile, const int iLine, const char *pcMark, ParseMark(const char *pcFile, const int iLine, const char *pcMark,
time_t tyme, CONSENT * pCE) time_t tyme, CONSENT * pCE)
#else #else
parseMark(pcFile, iLine, pcMark, tyme, pCE) ParseMark(pcFile, iLine, pcMark, tyme, pCE)
const char *pcFile; const char *pcFile;
const int iLine; const int iLine;
const char *pcMark; const char *pcMark;
@ -79,7 +79,7 @@ parseMark(pcFile, iLine, pcMark, tyme, pCE)
CONSENT *pCE; CONSENT *pCE;
#endif #endif
{ {
static STRING mark = { (char *)0, 0, 0 }; static STRING *mark = (STRING *) 0;
char *p, *n = (char *)0; char *p, *n = (char *)0;
int activity = 0, bactivity = 0; int activity = 0, bactivity = 0;
int factor = 0, pfactor = 0; int factor = 0, pfactor = 0;
@ -87,10 +87,14 @@ parseMark(pcFile, iLine, pcMark, tyme, pCE)
if ((pcMark == (char *)0) || (*pcMark == '\000')) if ((pcMark == (char *)0) || (*pcMark == '\000'))
return 0; return 0;
buildMyString((char *)0, &mark);
buildMyString(pcMark, &mark);
for (p = mark.string; *p != '\000'; p++) { if (mark == (STRING *) 0)
mark = AllocString();
BuildString((char *)0, mark);
BuildString(pcMark, mark);
for (p = mark->string; *p != '\000'; p++) {
if (*p == 'a' || *p == 'A') { if (*p == 'a' || *p == 'A') {
if (n != (char *)0) { if (n != (char *)0) {
Error Error
@ -160,7 +164,7 @@ parseMark(pcFile, iLine, pcMark, tyme, pCE)
} }
Debug(1, Debug(1,
"Mark spec of `%s' parsed: factor=%d, value=%d, activity=%d, bactivity=%d", "ParseMark(): mark spec of `%s' parsed: factor=%d, value=%d, activity=%d, bactivity=%d",
pcMark, factor, value, activity, bactivity); pcMark, factor, value, activity, bactivity);
if (pCE != (CONSENT *) 0) { if (pCE != (CONSENT *) 0) {
@ -202,10 +206,10 @@ parseMark(pcFile, iLine, pcMark, tyme, pCE)
* a pointer to the start of the non-space part * a pointer to the start of the non-space part
*/ */
char * char *
#if USE_ANSI_PROTO #if PROTOTYPES
pruneSpace(char *string) PruneSpace(char *string)
#else #else
pruneSpace(string) PruneSpace(string)
char *string; char *string;
#endif #endif
{ {
@ -238,11 +242,30 @@ pruneSpace(string)
return string; return string;
} }
void
#if PROTOTYPES
DestroyBreakList(void)
#else
DestroyBreakList()
#endif
{
int i;
if (breakList == (STRING *) 0)
return;
for (i = 0; i < 9; i++) {
DestroyString(&breakList[i]);
}
free(breakList);
breakList = (STRING *) 0;
}
/* read in the configuration file, fill in all the structs we use (ksb) /* read in the configuration file, fill in all the structs we use (ksb)
* to manage the consoles * to manage the consoles
*/ */
void void
#if USE_ANSI_PROTO #if PROTOTYPES
ReadCfg(char *pcFile, FILE * fp) ReadCfg(char *pcFile, FILE * fp)
#else #else
ReadCfg(pcFile, fp, master) ReadCfg(pcFile, fp, master)
@ -259,20 +282,23 @@ ReadCfg(pcFile, fp, master)
GRPENT *pGEstage = (GRPENT *) 0; GRPENT *pGEstage = (GRPENT *) 0;
int iLine; int iLine;
unsigned char *acIn; unsigned char *acIn;
static STRING acInSave = { (char *)0, 0, 0 }; static STRING *acInSave = (STRING *) 0;
char *acStart; char *acStart;
CONSENT *pCE = (CONSENT *) 0; CONSENT *pCE = (CONSENT *) 0;
CONSENT *pCEtmp = (CONSENT *) 0; CONSENT *pCEtmp = (CONSENT *) 0;
CONSENT *pCEmatch = (CONSENT *) 0; CONSENT *pCEmatch = (CONSENT *) 0;
REMOTE **ppRC; REMOTE **ppRC;
REMOTE *pRCtmp; REMOTE *pRCtmp;
static STRING LogDirectory = { (char *)0, 0, 0 }; static STRING *logDirectory = (STRING *) 0;
time_t tyme; time_t tyme;
static STRING defMark = { (char *)0, 0, 0 }; static STRING *defMark = (STRING *) 0;
int isStartup = (pGroups == (GRPENT *) 0 && pRCList == (REMOTE *) 0); int isStartup = (pGroups == (GRPENT *) 0 && pRCList == (REMOTE *) 0);
REMOTE *pRCListOld = (REMOTE *) 0; REMOTE *pRCListOld = (REMOTE *) 0;
GRPENT *pGroupsOld = (GRPENT *) 0; GRPENT *pGroupsOld = (GRPENT *) 0;
CONSCLIENT *pCLtmp = (CONSCLIENT *) 0; CONSCLIENT *pCLtmp = (CONSCLIENT *) 0;
#if HAVE_DMALLOC && DMALLOC_MARK_READCFG
unsigned long dmallocMarkReadCfg = 0;
#endif
/* if we're the master process, this will either be the first time /* if we're the master process, this will either be the first time
* reading the config file (in which case we'll just build the two * reading the config file (in which case we'll just build the two
@ -292,6 +318,16 @@ ReadCfg(pcFile, fp, master)
* *
* yep, slippery little slope we're walking here. hope we survive! * yep, slippery little slope we're walking here. hope we survive!
*/ */
#if HAVE_DMALLOC && DMALLOC_MARK_READCFG
dmallocMarkReadCfg = dmalloc_mark();
#endif
if (acInSave == (STRING *) 0)
acInSave = AllocString();
if (logDirectory == (STRING *) 0)
logDirectory = AllocString();
if (defMark == (STRING *) 0)
defMark = AllocString();
if (!isStartup) { if (!isStartup) {
pGroupsOld = pGroups; pGroupsOld = pGroups;
pRCListOld = pRCList; pRCListOld = pRCList;
@ -300,9 +336,9 @@ ReadCfg(pcFile, fp, master)
} }
tyme = time((time_t *) 0); tyme = time((time_t *) 0);
buildMyString((char *)0, &defMark); BuildString((char *)0, defMark);
buildMyString((char *)0, &LogDirectory); BuildString((char *)0, logDirectory);
buildMyString((char *)0, &acInSave); BuildString((char *)0, acInSave);
ppRC = &pRCList; ppRC = &pRCList;
/* initialize the break lists */ /* initialize the break lists */
@ -313,37 +349,35 @@ ReadCfg(pcFile, fp, master)
} }
} else { } else {
for (iLine = 0; iLine < 9; iLine++) { for (iLine = 0; iLine < 9; iLine++) {
buildMyString((char *)0, &breakList[iLine]); BuildString((char *)0, &breakList[iLine]);
} }
} }
buildMyString("\\z", &breakList[0]); BuildString("\\z", &breakList[0]);
buildMyString("\\r~^b", &breakList[1]); BuildString("\\r~^b", &breakList[1]);
buildMyString("#.reset -x\\r", &breakList[2]); BuildString("#.reset -x\\r", &breakList[2]);
/* nuke the groups lists (should be a noop, but...) */ /* nuke the groups lists (should be a noop, but...) */
while (pGroups != (GRPENT *) 0) { while (pGroups != (GRPENT *) 0) {
pGEtmp = pGroups->pGEnext; pGEtmp = pGroups->pGEnext;
destroyGroup(pGroups); DestroyGroup(pGroups);
pGroups = pGEtmp; pGroups = pGEtmp;
} }
/* nuke the remote consoles */ /* nuke the remote consoles */
while (pRCList != (REMOTE *) 0) { while (pRCList != (REMOTE *) 0) {
pRCtmp = pRCList->pRCnext; pRCtmp = pRCList->pRCnext;
destroyString(&pRCList->rserver); DestroyRemoteConsole(pRCList);
destroyString(&pRCList->rhost);
free(pRCList);
pRCList = pRCtmp; pRCList = pRCtmp;
} }
iLine = 0; iLine = 0;
while ((acIn = while ((acIn =
(unsigned char *)readLine(fp, &acInSave, (unsigned char *)ReadLine(fp, acInSave,
&iLine)) != (unsigned char *)0) { &iLine)) != (unsigned char *)0) {
char *pcLine, *pcMode, *pcLog, *pcRem, *pcStart, *pcMark, *pcBreak; char *pcLine, *pcMode, *pcLog, *pcRem, *pcStart, *pcMark, *pcBreak;
char *pcColon; char *pcColon;
acStart = pruneSpace((char *)acIn); acStart = PruneSpace((char *)acIn);
if ('%' == acStart[0] && '%' == acStart[1] && '\000' == acStart[2]) { if ('%' == acStart[0] && '%' == acStart[1] && '\000' == acStart[2]) {
break; break;
@ -352,28 +386,29 @@ ReadCfg(pcFile, fp, master)
((char *)0 == (pcColon = strchr(acStart, ':')) || ((char *)0 == (pcColon = strchr(acStart, ':')) ||
pcColon > pcLine)) { pcColon > pcLine)) {
*pcLine++ = '\000'; *pcLine++ = '\000';
acStart = pruneSpace(acStart); acStart = PruneSpace(acStart);
pcLine = pruneSpace(pcLine); pcLine = PruneSpace(pcLine);
if (0 == strcmp(acStart, "LOGDIR")) { if (0 == strcmp(acStart, "LOGDIR")) {
buildMyString((char *)0, &LogDirectory); BuildString((char *)0, logDirectory);
buildMyString(pcLine, &LogDirectory); BuildString(pcLine, logDirectory);
} else if (0 == strcmp(acStart, "TIMESTAMP")) { } else if (0 == strcmp(acStart, "TIMESTAMP")) {
buildMyString((char *)0, &defMark); BuildString((char *)0, defMark);
if (parseMark(pcFile, iLine, pcLine, tyme, NULL)) { if (ParseMark(pcFile, iLine, pcLine, tyme, NULL)) {
buildMyString(pcLine, &defMark); BuildString(pcLine, defMark);
} }
} else if (0 == strcmp(acStart, "DOMAINHACK")) { } else if (0 == strcmp(acStart, "DOMAINHACK")) {
domainHack = 1; domainHack = 1;
} else if (0 == strncmp(acStart, "BREAK", 5) && } else if (0 == strncmp(acStart, "BREAK", 5) &&
acStart[5] >= '1' && acStart[5] <= '9' && acStart[5] >= '1' && acStart[5] <= '9' &&
acStart[6] == '\000') { acStart[6] == '\000') {
Debug(1, "BREAK%c found with `%s'", acStart[5], pcLine); Debug(1, "ReadCfg(): BREAK%c found with `%s'", acStart[5],
pcLine);
if (pcLine[0] == '\000') { if (pcLine[0] == '\000') {
buildMyString((char *)0, &breakList[acStart[5] - '1']); BuildString((char *)0, &breakList[acStart[5] - '1']);
} else { } else {
buildMyString((char *)0, &breakList[acStart[5] - '1']); BuildString((char *)0, &breakList[acStart[5] - '1']);
buildMyString(pcLine, &breakList[acStart[5] - '1']); BuildString(pcLine, &breakList[acStart[5] - '1']);
cleanupBreak(acStart[5] - '0'); CleanupBreak(acStart[5] - '0');
} }
} else { } else {
Error("%s(%d) unknown variable `%s'", pcFile, iLine, Error("%s(%d) unknown variable `%s'", pcFile, iLine,
@ -391,7 +426,7 @@ ReadCfg(pcFile, fp, master)
*pcMode++ = '\000'; *pcMode++ = '\000';
*pcLog++ = '\000'; *pcLog++ = '\000';
acStart = pruneSpace(acStart); acStart = PruneSpace(acStart);
/* before going any further, we might was well check for /* before going any further, we might was well check for
* duplicates. gotta do it somewhere, and we only need * duplicates. gotta do it somewhere, and we only need
@ -455,14 +490,14 @@ ReadCfg(pcFile, fp, master)
if (pCEtmp != (CONSENT *) 0) if (pCEtmp != (CONSENT *) 0)
continue; continue;
pcLine = pruneSpace(pcLine); pcLine = PruneSpace(pcLine);
pcMode = pruneSpace(pcMode); pcMode = PruneSpace(pcMode);
pcLog = pruneSpace(pcLog); pcLog = PruneSpace(pcLog);
if ((char *)0 != (pcMark = strchr(pcLog, ':'))) { if ((char *)0 != (pcMark = strchr(pcLog, ':'))) {
*pcMark++ = '\000'; *pcMark++ = '\000';
pcLog = pruneSpace(pcLog); pcLog = PruneSpace(pcLog);
pcMark = pruneSpace(pcMark); pcMark = PruneSpace(pcMark);
/* Skip null intervals */ /* Skip null intervals */
if (pcMark[0] == '\000') if (pcMark[0] == '\000')
pcMark = (char *)0; pcMark = (char *)0;
@ -473,8 +508,8 @@ ReadCfg(pcFile, fp, master)
} else { } else {
if ((char *)0 != (pcBreak = strchr(pcMark, ':'))) { if ((char *)0 != (pcBreak = strchr(pcMark, ':'))) {
*pcBreak++ = '\000'; *pcBreak++ = '\000';
pcMark = pruneSpace(pcMark); pcMark = PruneSpace(pcMark);
pcBreak = pruneSpace(pcBreak); pcBreak = PruneSpace(pcBreak);
/* Ignore null specs */ /* Ignore null specs */
if (pcMark[0] == '\000') if (pcMark[0] == '\000')
pcMark = (char *)0; pcMark = (char *)0;
@ -492,16 +527,17 @@ ReadCfg(pcFile, fp, master)
struct hostent *hpMe; struct hostent *hpMe;
*pcRem++ = '\000'; *pcRem++ = '\000';
pcLine = pruneSpace(pcLine); pcLine = PruneSpace(pcLine);
pcRem = pruneSpace(pcRem); pcRem = PruneSpace(pcRem);
if ((struct hostent *)0 == (hpMe = gethostbyname(pcRem))) { if ((struct hostent *)0 == (hpMe = gethostbyname(pcRem))) {
Error("gethostbyname(%s): %s", pcRem, hstrerror(h_errno)); Error("ReadCfg(): gethostbyname(%s): %s", pcRem,
hstrerror(h_errno));
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
if (4 != hpMe->h_length || AF_INET != hpMe->h_addrtype) { if (4 != hpMe->h_length || AF_INET != hpMe->h_addrtype) {
Error Error
("wrong address size (4 != %d) or address family (%d != %d)", ("ReadCfg(): wrong address size (4 != %d) or address family (%d != %d)",
hpMe->h_length, AF_INET, hpMe->h_addrtype); hpMe->h_length, AF_INET, hpMe->h_addrtype);
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
@ -523,15 +559,13 @@ ReadCfg(pcFile, fp, master)
if ((REMOTE *) 0 == pRCTemp) { if ((REMOTE *) 0 == pRCTemp) {
OutOfMem(); OutOfMem();
} }
buildMyString((char *)0, &pRCTemp->rhost); BuildString((char *)0, &pRCTemp->rhost);
buildMyString(pcRem, &pRCTemp->rhost); BuildString(pcRem, &pRCTemp->rhost);
buildMyString((char *)0, &pRCTemp->rserver); BuildString((char *)0, &pRCTemp->rserver);
buildMyString(acStart, &pRCTemp->rserver); BuildString(acStart, &pRCTemp->rserver);
*ppRC = pRCTemp; *ppRC = pRCTemp;
ppRC = &pRCTemp->pRCnext; ppRC = &pRCTemp->pRCnext;
if (fVerbose) { Verbose("[%s] remote on %s", acStart, pcRem);
Info("%s remote on %s", acStart, pcRem);
}
} }
continue; continue;
} }
@ -613,7 +647,7 @@ ReadCfg(pcFile, fp, master)
* everything is calloc()ed, so STRING types are ready to rock * everything is calloc()ed, so STRING types are ready to rock
*/ */
buildMyString(acStart, &pCE->server); BuildString(acStart, &pCE->server);
/* /*
* Here we substitute the console name for any '&' character in the * Here we substitute the console name for any '&' character in the
@ -623,27 +657,27 @@ ReadCfg(pcFile, fp, master)
pcStart = pcLog; pcStart = pcLog;
while ((char *)0 != (pcRem = strchr(pcStart, '&'))) { while ((char *)0 != (pcRem = strchr(pcStart, '&'))) {
*pcRem = '\000'; *pcRem = '\000';
buildMyString(pcStart, &pCE->lfile); BuildString(pcStart, &pCE->lfile);
buildMyString(acStart, &pCE->lfile); BuildString(acStart, &pCE->lfile);
pcStart = pcRem + 1; pcStart = pcRem + 1;
} }
buildMyString(pcStart, &pCE->lfile); BuildString(pcStart, &pCE->lfile);
if (LogDirectory.used > 1 && pCE->lfile.used > 1 && if (logDirectory->used > 1 && pCE->lfile.used > 1 &&
*pCE->lfile.string != '/') { *pCE->lfile.string != '/') {
char *p; char *p;
buildString((char *)0); BuildTmpString((char *)0);
p = buildString(pCE->lfile.string); p = BuildTmpString(pCE->lfile.string);
buildMyString((char *)0, &pCE->lfile); BuildString((char *)0, &pCE->lfile);
buildMyString(LogDirectory.string, &pCE->lfile); BuildString(logDirectory->string, &pCE->lfile);
buildMyStringChar('/', &pCE->lfile); BuildStringChar('/', &pCE->lfile);
buildMyString(p, &pCE->lfile); BuildString(p, &pCE->lfile);
buildString((char *)0); BuildTmpString((char *)0);
} }
if (pcMark) { if (pcMark) {
(void)parseMark(pcFile, iLine, pcMark, tyme, pCE); ParseMark(pcFile, iLine, pcMark, tyme, pCE);
} else { } else {
(void)parseMark(pcFile, iLine, defMark.string, tyme, pCE); ParseMark(pcFile, iLine, defMark->string, tyme, pCE);
} }
pCE->breakType = 1; pCE->breakType = 1;
@ -653,8 +687,8 @@ ReadCfg(pcFile, fp, master)
if (bt > 9 || bt < 0) { if (bt > 9 || bt < 0) {
Error("%s(%d) bad break spec `%d'", pcFile, iLine, bt); Error("%s(%d) bad break spec `%d'", pcFile, iLine, bt);
} else { } else {
pCE->breakType = (short int)bt; pCE->breakType = (short)bt;
Debug(1, "breakType set to %d", pCE->breakType); Debug(1, "ReadCfg(): breakType set to %d", pCE->breakType);
} }
} }
@ -665,56 +699,56 @@ ReadCfg(pcFile, fp, master)
if (pcLine[0] == '!') { if (pcLine[0] == '!') {
char acOut[100]; char acOut[100];
pcLine = pruneSpace(pcLine + 1); pcLine = PruneSpace(pcLine + 1);
pCE->isNetworkConsole = 1; pCE->isNetworkConsole = 1;
pCE->telnetState = 0; pCE->telnetState = 0;
buildMyString((char *)0, &pCE->networkConsoleHost); BuildString((char *)0, &pCE->networkConsoleHost);
buildMyString(pcLine, &pCE->networkConsoleHost); BuildString(pcLine, &pCE->networkConsoleHost);
pCE->networkConsolePort = atoi(pcMode); pCE->networkConsolePort = atoi(pcMode);
pCE->fvirtual = 0; pCE->fvirtual = 0;
buildMyString((char *)0, &pCE->dfile); BuildString((char *)0, &pCE->dfile);
buildMyString(pCE->networkConsoleHost.string, &pCE->dfile); BuildString(pCE->networkConsoleHost.string, &pCE->dfile);
sprintf(acOut, "/%d", pCE->networkConsolePort); sprintf(acOut, "/%hu", pCE->networkConsolePort);
buildMyString(acOut, &pCE->dfile); BuildString(acOut, &pCE->dfile);
pCE->pbaud = FindBaud("Netwk"); pCE->pbaud = FindBaud("Netwk");
pCE->pparity = FindParity(" "); pCE->pparity = FindParity(" ");
if (isStartup && fVerbose) { if (isStartup) {
Info("%s is network on %s logged to %s", acStart, Verbose("[%s] socket on %s logged to %s", acStart,
pCE->dfile.string, pCE->lfile.string); pCE->dfile.string, pCE->lfile.string);
} }
} else if ('|' == pcLine[0]) { } else if ('|' == pcLine[0]) {
pcLine = pruneSpace(pcLine + 1); pcLine = PruneSpace(pcLine + 1);
pCE->isNetworkConsole = 0; pCE->isNetworkConsole = 0;
pCE->telnetState = 0; pCE->telnetState = 0;
pCE->fvirtual = 1; pCE->fvirtual = 1;
buildMyString((char *)0, &pCE->pccmd); BuildString((char *)0, &pCE->pccmd);
buildMyString(pcLine, &pCE->pccmd); BuildString(pcLine, &pCE->pccmd);
buildMyString((char *)0, &pCE->dfile); BuildString((char *)0, &pCE->dfile);
buildMyString("/dev/null", &pCE->dfile); BuildString("/dev/null", &pCE->dfile);
buildMyString((char *)0, &pCE->acslave); BuildString((char *)0, &pCE->acslave);
buildMyString("/dev/null", &pCE->acslave); BuildString("/dev/null", &pCE->acslave);
pCE->pbaud = FindBaud("Local"); pCE->pbaud = FindBaud("Local");
pCE->pparity = FindParity(" "); pCE->pparity = FindParity(" ");
if (isStartup && fVerbose) { if (isStartup) {
Info("%s with command `%s' logged to %s", acStart, Verbose("[%s] command `%s' logged to %s", acStart,
pCE->pccmd.string, pCE->lfile.string); pCE->pccmd.string, pCE->lfile.string);
} }
} else { } else {
pCE->isNetworkConsole = 0; pCE->isNetworkConsole = 0;
pCE->telnetState = 0; pCE->telnetState = 0;
pCE->fvirtual = 0; pCE->fvirtual = 0;
buildMyString((char *)0, &pCE->dfile); BuildString((char *)0, &pCE->dfile);
buildMyString(pcLine, &pCE->dfile); BuildString(pcLine, &pCE->dfile);
pCE->pbaud = FindBaud(pcMode); pCE->pbaud = FindBaud(pcMode);
if (pCE->pbaud->irate == 0) { if (pCE->pbaud->irate == 0) {
Error("%s(%d) invalid baud rate `%s'", pcFile, iLine, Error("%s(%d) invalid baud rate `%s'", pcFile, iLine,
pcMode); pcMode);
destroyConsent(pGE, pCE); DestroyConsent(pGE, pCE);
continue; continue;
} }
pCE->pparity = FindParity(pcMode); pCE->pparity = FindParity(pcMode);
if (isStartup && fVerbose) { if (isStartup) {
Info("%s is on %s (%s%c) logged to %s", acStart, Verbose("[%s] %s (%s%c) logged to %s", acStart,
pCE->dfile.string, pCE->pbaud->acrate, pCE->dfile.string, pCE->pbaud->acrate,
pCE->pparity->ckey, pCE->lfile.string); pCE->pparity->ckey, pCE->lfile.string);
} }
@ -722,7 +756,7 @@ ReadCfg(pcFile, fp, master)
/* ok, now for the hard part of the reread */ /* ok, now for the hard part of the reread */
if (pCEmatch != (CONSENT *) 0) { if (pCEmatch != (CONSENT *) 0) {
short int closeMatch = 1; short closeMatch = 1;
/* see if the group is already staged */ /* see if the group is already staged */
for (pGEtmp = pGEstage; pGEtmp != (GRPENT *) 0; for (pGEtmp = pGEstage; pGEtmp != (GRPENT *) 0;
pGEtmp = pGEtmp->pGEnext) { pGEtmp = pGEtmp->pGEnext) {
@ -778,7 +812,7 @@ ReadCfg(pcFile, fp, master)
} }
pGEtmp->pCLall = pCLtmp; pGEtmp->pCLall = pCLtmp;
/* set file descriptors */ /* set file descriptors */
FD_SET(fileFDNum(pCLtmp->fd), &pGEtmp->rinit); FD_SET(FileFDNum(pCLtmp->fd), &pGEtmp->rinit);
} }
} }
} }
@ -800,7 +834,7 @@ ReadCfg(pcFile, fp, master)
} }
pGEtmp->pCLall = pCLtmp; pGEtmp->pCLall = pCLtmp;
/* set file descriptors */ /* set file descriptors */
FD_SET(fileFDNum(pCLtmp->fd), &pGEtmp->rinit); FD_SET(FileFDNum(pCLtmp->fd), &pGEtmp->rinit);
} }
/* add the original console to the new group */ /* add the original console to the new group */
@ -818,28 +852,28 @@ ReadCfg(pcFile, fp, master)
closeMatch = 0; closeMatch = 0;
if (pCEmatch->dfile.used && pCE->dfile.used) { if (pCEmatch->dfile.used && pCE->dfile.used) {
if (strcmp(pCEmatch->dfile.string, pCE->dfile.string) != 0) { if (strcmp(pCEmatch->dfile.string, pCE->dfile.string) != 0) {
buildMyString((char *)0, &pCEmatch->dfile); BuildString((char *)0, &pCEmatch->dfile);
buildMyString(pCE->dfile.string, &pCEmatch->dfile); BuildString(pCE->dfile.string, &pCEmatch->dfile);
if (!pCE->fvirtual) if (!pCE->fvirtual)
closeMatch = 0; closeMatch = 0;
} }
} else if (pCEmatch->dfile.used || pCE->dfile.used) { } else if (pCEmatch->dfile.used || pCE->dfile.used) {
buildMyString((char *)0, &pCEmatch->dfile); BuildString((char *)0, &pCEmatch->dfile);
buildMyString(pCE->dfile.string, &pCEmatch->dfile); BuildString(pCE->dfile.string, &pCEmatch->dfile);
if (!pCE->fvirtual) if (!pCE->fvirtual)
closeMatch = 0; closeMatch = 0;
} }
if (pCEmatch->lfile.used && pCE->lfile.used) { if (pCEmatch->lfile.used && pCE->lfile.used) {
if (strcmp(pCEmatch->lfile.string, pCE->lfile.string) != 0) { if (strcmp(pCEmatch->lfile.string, pCE->lfile.string) != 0) {
buildMyString((char *)0, &pCEmatch->lfile); BuildString((char *)0, &pCEmatch->lfile);
buildMyString(pCE->lfile.string, &pCEmatch->lfile); BuildString(pCE->lfile.string, &pCEmatch->lfile);
fileClose(&pCEmatch->fdlog); FileClose(&pCEmatch->fdlog);
closeMatch = 0; closeMatch = 0;
} }
} else if (pCEmatch->lfile.used || pCE->lfile.used) { } else if (pCEmatch->lfile.used || pCE->lfile.used) {
buildMyString((char *)0, &pCEmatch->lfile); BuildString((char *)0, &pCEmatch->lfile);
buildMyString(pCE->lfile.string, &pCEmatch->lfile); BuildString(pCE->lfile.string, &pCEmatch->lfile);
fileClose(&pCEmatch->fdlog); FileClose(&pCEmatch->fdlog);
closeMatch = 0; closeMatch = 0;
} }
if (pCEmatch->pbaud != pCE->pbaud) { if (pCEmatch->pbaud != pCE->pbaud) {
@ -864,17 +898,16 @@ ReadCfg(pcFile, fp, master)
if (strcmp if (strcmp
(pCEmatch->networkConsoleHost.string, (pCEmatch->networkConsoleHost.string,
pCE->networkConsoleHost.string) != 0) { pCE->networkConsoleHost.string) != 0) {
buildMyString((char *)0, BuildString((char *)0,
&pCEmatch->networkConsoleHost); &pCEmatch->networkConsoleHost);
buildMyString(pCE->networkConsoleHost.string, BuildString(pCE->networkConsoleHost.string,
&pCEmatch->networkConsoleHost); &pCEmatch->networkConsoleHost);
closeMatch = 0; closeMatch = 0;
} }
} else if (pCEmatch->networkConsoleHost.used || } else if (pCEmatch->networkConsoleHost.used ||
pCE->networkConsoleHost.used) { pCE->networkConsoleHost.used) {
buildMyString((char *)0, BuildString((char *)0, &pCEmatch->networkConsoleHost);
&pCEmatch->networkConsoleHost); BuildString(pCE->networkConsoleHost.string,
buildMyString(pCE->networkConsoleHost.string,
&pCEmatch->networkConsoleHost); &pCEmatch->networkConsoleHost);
closeMatch = 0; closeMatch = 0;
} }
@ -892,13 +925,13 @@ ReadCfg(pcFile, fp, master)
if (pCEmatch->pccmd.used && pCE->pccmd.used) { if (pCEmatch->pccmd.used && pCE->pccmd.used) {
if (strcmp(pCEmatch->pccmd.string, pCE->pccmd.string) if (strcmp(pCEmatch->pccmd.string, pCE->pccmd.string)
!= 0) { != 0) {
buildMyString((char *)0, &pCEmatch->pccmd); BuildString((char *)0, &pCEmatch->pccmd);
buildMyString(pCE->pccmd.string, &pCEmatch->pccmd); BuildString(pCE->pccmd.string, &pCEmatch->pccmd);
closeMatch = 0; closeMatch = 0;
} }
} else if (pCEmatch->pccmd.used || pCE->pccmd.used) { } else if (pCEmatch->pccmd.used || pCE->pccmd.used) {
buildMyString((char *)0, &pCEmatch->pccmd); BuildString((char *)0, &pCEmatch->pccmd);
buildMyString(pCE->pccmd.string, &pCEmatch->pccmd); BuildString(pCE->pccmd.string, &pCEmatch->pccmd);
closeMatch = 0; closeMatch = 0;
} }
} }
@ -916,7 +949,7 @@ ReadCfg(pcFile, fp, master)
} }
/* nuke the temp data structure */ /* nuke the temp data structure */
destroyConsent(pGE, pCE); DestroyConsent(pGE, pCE);
} }
} }
@ -925,7 +958,7 @@ ReadCfg(pcFile, fp, master)
if (!isMaster || (*ppGE)->imembers == 0) { if (!isMaster || (*ppGE)->imembers == 0) {
pGEtmp = *ppGE; pGEtmp = *ppGE;
*ppGE = (*ppGE)->pGEnext; *ppGE = (*ppGE)->pGEnext;
destroyGroup(pGEtmp); DestroyGroup(pGEtmp);
} else { } else {
ppGE = &((*ppGE)->pGEnext); ppGE = &((*ppGE)->pGEnext);
} }
@ -936,16 +969,14 @@ ReadCfg(pcFile, fp, master)
/* nuke the old groups lists */ /* nuke the old groups lists */
while (pGroupsOld != (GRPENT *) 0) { while (pGroupsOld != (GRPENT *) 0) {
pGEtmp = pGroupsOld->pGEnext; pGEtmp = pGroupsOld->pGEnext;
destroyGroup(pGroupsOld); DestroyGroup(pGroupsOld);
pGroupsOld = pGEtmp; pGroupsOld = pGEtmp;
} }
/* nuke the old remote consoles */ /* nuke the old remote consoles */
while (pRCListOld != (REMOTE *) 0) { while (pRCListOld != (REMOTE *) 0) {
pRCtmp = pRCListOld->pRCnext; pRCtmp = pRCListOld->pRCnext;
destroyString(&pRCListOld->rserver); DestroyRemoteConsole(pRCListOld);
destroyString(&pRCListOld->rhost);
free(pRCListOld);
pRCListOld = pRCtmp; pRCListOld = pRCtmp;
} }
@ -954,23 +985,21 @@ ReadCfg(pcFile, fp, master)
/* clean out the access restrictions /* clean out the access restrictions
*/ */
while (pACList != (ACCESS *) 0) { while (pACList != (ACCESS *) 0) {
if (pACList->pcwho != (char *)0)
free(pACList->pcwho);
pACtmp = pACList->pACnext; pACtmp = pACList->pACnext;
free(pACList); DestroyAccessList(pACList);
pACList = pACtmp; pACList = pACtmp;
} }
pACList = (ACCESS *) 0; pACList = (ACCESS *) 0;
ppAC = &pACList; ppAC = &pACList;
while ((acIn = while ((acIn =
(unsigned char *)readLine(fp, &acInSave, (unsigned char *)ReadLine(fp, acInSave,
&iLine)) != (unsigned char *)0) { &iLine)) != (unsigned char *)0) {
char *pcMach, *pcNext, *pcMem; char *pcMach, *pcNext, *pcMem;
char cType; char cType;
int iLen; int iLen;
acStart = pruneSpace((char *)acIn); acStart = PruneSpace((char *)acIn);
if ('%' == acStart[0] && '%' == acStart[1] && '\000' == acStart[2]) { if ('%' == acStart[0] && '%' == acStart[1] && '\000' == acStart[2]) {
break; break;
@ -998,7 +1027,7 @@ ReadCfg(pcFile, fp, master)
cType = 't'; cType = 't';
break; break;
default: default:
Error("%s(%d) unknown access key `%s\'", pcFile, iLine, Error("%s(%d) unknown access key `%s'", pcFile, iLine,
acStart); acStart);
exit(EX_UNAVAILABLE); exit(EX_UNAVAILABLE);
} }
@ -1027,7 +1056,7 @@ ReadCfg(pcFile, fp, master)
char *sPtr = (char *)0, *nPtr = (char *)0; char *sPtr = (char *)0, *nPtr = (char *)0;
char cidr[BUFSIZ]; char cidr[BUFSIZ];
(void)strcpy(cidr, pcMach); strcpy(cidr, pcMach);
/* Scan for [0-9./], and stop if you find something else */ /* Scan for [0-9./], and stop if you find something else */
for (j = 0; cidr[j] != '\000'; j++) { for (j = 0; cidr[j] != '\000'; j++) {
if (isdigit((int)(cidr[j]))) { if (isdigit((int)(cidr[j]))) {
@ -1101,14 +1130,15 @@ ReadCfg(pcFile, fp, master)
ppAC = &pACtmp->pACnext; ppAC = &pACtmp->pACnext;
} }
} }
#if HAVE_DMALLOC && DMALLOC_MARK_READCFG
destroyString(&LogDirectory); Debug(1, "ReadCfg(): dmalloc / MarkReadCfg");
destroyString(&defMark); dmalloc_log_changed(dmallocMarkReadCfg, 1, 0, 1);
#endif
} }
/* Unless otherwise stated, returns the same values as send(2) */ /* Unless otherwise stated, returns the same values as send(2) */
void void
#if USE_ANSI_PROTO #if PROTOTYPES
ReReadCfg(void) ReReadCfg(void)
#else #else
ReReadCfg() ReReadCfg()
@ -1117,7 +1147,7 @@ ReReadCfg()
FILE *fpConfig; FILE *fpConfig;
if ((FILE *) 0 == (fpConfig = fopen(pcConfig, "r"))) { if ((FILE *) 0 == (fpConfig = fopen(pcConfig, "r"))) {
Error("fopen: %s: %s", pcConfig, strerror(errno)); Error("ReReadCfg(): fopen(%s): %s", pcConfig, strerror(errno));
return; return;
} }
@ -1127,12 +1157,12 @@ ReReadCfg()
if (pGroups == (GRPENT *) 0 && pRCList == (REMOTE *) 0) { if (pGroups == (GRPENT *) 0 && pRCList == (REMOTE *) 0) {
if (isMaster) { if (isMaster) {
Error("No consoles found in configuration file"); Error("no consoles found in configuration file");
kill(thepid, SIGTERM); /* shoot myself in the head */ kill(thepid, SIGTERM); /* shoot myself in the head */
return; return;
} else { } else {
Error("No consoles to manage after reconfiguration - exiting"); Error("no consoles to manage after reconfiguration - exiting");
exit(EX_OK); Bye(EX_OK);
} }
} }
@ -1153,14 +1183,12 @@ ReReadCfg()
Spawn(pGE); Spawn(pGE);
if (fVerbose) { Verbose("group #%d pid %lu on port %hu", pGE->id,
Info("group #%d pid %d on port %u", pGE->id, pGE->pid, (unsigned long)pGE->pid, ntohs(pGE->port));
ntohs(pGE->port));
}
for (pCE = pGE->pCElist; pCE != (CONSENT *) 0; for (pCE = pGE->pCElist; pCE != (CONSENT *) 0;
pCE = pCE->pCEnext) { pCE = pCE->pCEnext) {
if (-1 != pCE->fdtty) if (-1 != pCE->fdtty)
(void)close(pCE->fdtty); close(pCE->fdtty);
} }
} }
@ -1168,7 +1196,7 @@ ReReadCfg()
ACCESS *pACtmp; ACCESS *pACtmp;
for (pACtmp = pACList; pACtmp != (ACCESS *) 0; for (pACtmp = pACList; pACtmp != (ACCESS *) 0;
pACtmp = pACtmp->pACnext) { pACtmp = pACtmp->pACnext) {
Info("access type '%c' for \"%s\"", pACtmp->ctrust, Verbose("access type `%c' for `%s'", pACtmp->ctrust,
pACtmp->pcwho); pACtmp->pcwho);
} }
} }
@ -1180,7 +1208,7 @@ ReReadCfg()
if (fVerbose) { if (fVerbose) {
REMOTE *pRC; REMOTE *pRC;
for (pRC = pRCUniq; (REMOTE *) 0 != pRC; pRC = pRC->pRCuniq) { for (pRC = pRCUniq; (REMOTE *) 0 != pRC; pRC = pRC->pRCuniq) {
Info("peer server on `%s'", pRC->rhost.string); Verbose("peer server on `%s'", pRC->rhost.string);
} }
} }
} }

View File

@ -1,5 +1,5 @@
/* /*
* $Id: readcfg.h,v 5.20 2002-09-29 19:05:12-07 bryan Exp $ * $Id: readcfg.h,v 5.23 2003-03-06 10:13:41-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -44,12 +44,7 @@ extern REMOTE *pRCUniq; /* list of uniq console servers */
extern ACCESS *pACList; /* `who do you love' (or trust) */ extern ACCESS *pACList; /* `who do you love' (or trust) */
extern STRING *breakList; /* list of break sequences */ extern STRING *breakList; /* list of break sequences */
#if USE_ANSI_PROTO extern void ReadCfg PARAMS((char *, FILE *));
extern void ReadCfg(char *, FILE *); extern char *PruneSpace PARAMS((char *));
extern char *pruneSpace(char *); extern void ReReadCfg PARAMS((void));
extern void ReReadCfg(void); extern void DestroyBreakList PARAMS((void));
#else
extern void ReadCfg();
extern char *pruneSpace();
extern void ReReadCfg();
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1,12 +1,12 @@
/* /*
* $Id: util.h,v 1.32 2002-10-01 20:52:02-07 bryan Exp $ * $Id: util.h,v 1.41 2003-03-08 08:39:57-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
* Maintainer/Enhancer: Bryan Stansell (bryan@conserver.com) * Maintainer/Enhancer: Bryan Stansell (bryan@conserver.com)
*/ */
#if USE_ANSI_PROTO #if PROTOTYPES
#include <stdarg.h> #include <stdarg.h>
#else #else
#include <varargs.h> #include <varargs.h>
@ -38,6 +38,8 @@ typedef struct dynamicString {
char *string; char *string;
int used; int used;
int allocated; int allocated;
struct dynamicString *next;
struct dynamicString *prev;
} STRING; } STRING;
typedef struct consFile { typedef struct consFile {
@ -53,74 +55,47 @@ typedef struct consFile {
/* Add crypto stuff to suit */ /* Add crypto stuff to suit */
} CONSFILE; } CONSFILE;
extern int outputPid, fDebug; extern int isMultiProc, fDebug, fVerbose;
extern char *progname; extern char *progname;
extern int thepid; extern pid_t thepid;
#if USE_ANSI_PROTO extern const char *StrTime PARAMS((time_t *));
extern void Debug(int, char *, ...); extern void Debug PARAMS((int, char *, ...));
extern void Error(char *, ...); extern void Error PARAMS((char *, ...));
extern void Info(char *, ...); extern void Msg PARAMS((char *, ...));
extern void simpleSignal(int, RETSIGTYPE(*)(int)); extern void Verbose PARAMS((char *, ...));
extern int cmaxfiles(); extern void SimpleSignal PARAMS((int, RETSIGTYPE(*)(int)));
extern void FmtCtlStr(char *, int, STRING *); extern int GetMaxFiles PARAMS(());
extern CONSFILE *fileOpenFD(int, enum consFileType); extern char *FmtCtl PARAMS((int, STRING *));
extern CONSFILE *fileOpen(const char *, int, int); extern void FmtCtlStr PARAMS((char *, int, STRING *));
extern int fileClose(CONSFILE **); extern CONSFILE *FileOpenFD PARAMS((int, enum consFileType));
extern int fileRead(CONSFILE *, void *, int); extern CONSFILE *FileOpen PARAMS((const char *, int, int));
extern int fileWrite(CONSFILE *, const char *, int); extern int FileClose PARAMS((CONSFILE **));
extern void fileVwrite(CONSFILE *, const char *, va_list); extern int FileRead PARAMS((CONSFILE *, void *, int));
extern void filePrint(CONSFILE *, const char *, ...); extern int FileWrite PARAMS((CONSFILE *, const char *, int));
extern int fileStat(CONSFILE *, struct stat *); extern void FileVWrite PARAMS((CONSFILE *, const char *, va_list));
extern int fileSeek(CONSFILE *, off_t, int); extern void FilePrint PARAMS((CONSFILE *, const char *, ...));
extern int fileSend(CONSFILE *, const void *, size_t, int); extern int FileStat PARAMS((CONSFILE *, struct stat *));
extern int fileFDNum(CONSFILE *); extern int FileSeek PARAMS((CONSFILE *, off_t, int));
extern void OutOfMem(); extern int FileSend PARAMS((CONSFILE *, const void *, size_t, int));
extern char *buildString(const char *); extern int FileFDNum PARAMS((CONSFILE *));
extern char *buildStringChar(const char); extern int FileUnopen PARAMS((CONSFILE *));
extern char *buildMyString(const char *, STRING *); extern void OutOfMem PARAMS(());
extern char *buildMyStringChar(const char, STRING *); extern char *BuildTmpString PARAMS((const char *));
extern void initString(STRING *); extern char *BuildTmpStringChar PARAMS((const char));
extern void destroyString(STRING *); extern char *BuildString PARAMS((const char *, STRING *));
extern char *readLine(FILE *, STRING *, int *); extern char *BuildStringChar PARAMS((const char, STRING *));
extern enum consFileType fileGetType(CONSFILE *); extern void InitString PARAMS((STRING *));
extern void fileSetType(CONSFILE *, enum consFileType); extern void DestroyString PARAMS((STRING *));
extern void DestroyStrings PARAMS((void));
extern STRING *AllocString PARAMS((void));
extern char *ReadLine PARAMS((FILE *, STRING *, int *));
extern enum consFileType FileGetType PARAMS((CONSFILE *));
extern void FileSetType PARAMS((CONSFILE *, enum consFileType));
extern void Bye PARAMS((int));
extern void DestroyDataStructures PARAMS((void));
#if HAVE_OPENSSL #if HAVE_OPENSSL
extern SSL *fileGetSSL(CONSFILE *); extern SSL *FileGetSSL PARAMS((CONSFILE *));
extern void fileSetSSL(CONSFILE *, SSL *); extern void FileSetSSL PARAMS((CONSFILE *, SSL *));
extern int ssl_verify_callback(int, X509_STORE_CTX *); extern int SSLVerifyCallback PARAMS((int, X509_STORE_CTX *));
#endif
#else
extern void Debug();
extern void Error();
extern void Info();
extern void simpleSignal();
extern int cmaxfiles();
extern void FmtCtlStr();
extern CONSFILE *fileOpenFD();
extern CONSFILE *fileOpen();
extern int fileClose();
extern int fileRead();
extern int fileWrite();
extern void fileVWrite();
extern void filePrint();
extern int fileStat();
extern int fileSeek();
extern int fileSend();
extern int fileFDNum();
extern void OutOfMem();
extern char *buildString();
extern char *buildStringChar();
extern char *buildMyString();
extern char *buildMyStringChar();
extern void initString();
extern void destroyString();
extern char *readLine();
extern enum consFileType fileGetType();
extern void fileSetType();
#if HAVE_OPENSSL
extern SSL *fileGetSSL();
extern void fileSetSSL();
extern int ssl_verify_callback();
#endif
#endif #endif

View File

@ -1,5 +1,5 @@
/* /*
* $Id: version.h,v 1.40 2003-01-27 17:47:53-08 bryan Exp $ * $Id: version.h,v 1.41 2003-03-10 17:37:27-08 bryan Exp $
* *
* Copyright conserver.com, 2000 * Copyright conserver.com, 2000
* *
@ -14,4 +14,4 @@
@(#) Copyright 2000 conserver.com.\n\ @(#) Copyright 2000 conserver.com.\n\
All rights reserved.\n" All rights reserved.\n"
#define THIS_VERSION "conserver.com version 7.2.5" #define THIS_VERSION "conserver.com version 7.2.6"

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,4 @@
.\" $Id: console.man,v 1.24 2003-01-08 17:07:51-08 bryan Exp $ .\" $Id: console.man,v 1.25 2003-03-04 07:53:03-08 bryan Exp $
.TH CONSOLE 1 "Local" .TH CONSOLE 1 "Local"
.SH NAME .SH NAME
console \- console server client program console \- console server client program
@ -9,7 +9,7 @@ console \- console server client program
\fIconsole\fP \fIconsole\fP
.br .br
\fBconsole\fP [\fB\-hiIPrRuVwWx\fP] [\fB\-7Dv\fP] [\fB\-M\fP \fImach\fP] \fBconsole\fP [\fB\-hiIPrRuVwWx\fP] [\fB\-7Dv\fP] [\fB\-M\fP \fImach\fP]
[\fB\-p\fP \fIport\fP] [\fB\-b\fP \fImessage\fP] [\fB\-p\fP \fIport\fP] [\fB\-\fP[\fBbB\fP] \fImessage\fP]
.br .br
\fBconsole\fP [\fB\-qQ\fP] [\fB\-7Dv\fP] [\fB\-M\fP \fImach\fP] \fBconsole\fP [\fB\-qQ\fP] [\fB\-7Dv\fP] [\fB\-M\fP \fImach\fP]
[\fB\-p\fP \fIport\fP] [\fB\-p\fP \fIport\fP]
@ -73,7 +73,10 @@ Access a console with a two-way (read-write) connection (this is the default).
The connection is dropped to spy mode if someone else is attached read-write. The connection is dropped to spy mode if someone else is attached read-write.
.TP .TP
.BI \-b message .BI \-b message
Broadcast a \fImessage\fP to all users connected to the console server. Broadcast a \fImessage\fP to all users connected to each server.
.TP
.BI \-B message
Same as \fB\-b\fP but just send a \fImessage\fP to users on the primary server.
.TP .TP
.BI \-c cred .BI \-c cred
Load an SSL certificate and key from the PEM encoded file \fIcred\fP. Load an SSL certificate and key from the PEM encoded file \fIcred\fP.

View File

@ -38,8 +38,9 @@ case "$1" in
status conserver status conserver
;; ;;
restart) restart)
$0 stop echo -n "Restarting conserver: "
$0 start killproc conserver -HUP
echo
;; ;;
*) *)
echo "Usage: conserver {start|stop|restart|status}" echo "Usage: conserver {start|stop|restart|status}"

View File

@ -4,7 +4,7 @@
# #
%define pkg conserver %define pkg conserver
%define ver 7.2.5 %define ver 7.2.6
# define the name of the machine on which the main conserver # define the name of the machine on which the main conserver
# daemon will be running if you don't want to use the default # daemon will be running if you don't want to use the default
@ -99,4 +99,5 @@ fi
%{prefix}/share/man/man1/console.1.gz %{prefix}/share/man/man1/console.1.gz
%{prefix}/share/man/man8/conserver.8.gz %{prefix}/share/man/man8/conserver.8.gz
%{prefix}/share/man/man5/conserver.cf.5.gz %{prefix}/share/man/man5/conserver.cf.5.gz
%{prefix}/share/man/man5/conserver.passwd.5.gz
%{prefix}/sbin/conserver %{prefix}/sbin/conserver

View File

@ -39,4 +39,5 @@ fakeinstall:
$(FIXMANCMD) man_tbl_header $(BUILDDIR)/conserver/conserver.man > $(MAN1MDIR)/conserver.$(MAN1MEXT) $(FIXMANCMD) man_tbl_header $(BUILDDIR)/conserver/conserver.man > $(MAN1MDIR)/conserver.$(MAN1MEXT)
$(FIXMANCMD) man_tbl_header $(BUILDDIR)/console/console.man > $(MAN1MDIR)/console.$(MAN1MEXT) $(FIXMANCMD) man_tbl_header $(BUILDDIR)/console/console.man > $(MAN1MDIR)/console.$(MAN1MEXT)
$(FIXMANCMD) $(BUILDDIR)/conserver.cf/conserver.cf.man > $(MAN4DIR)/conserver.cf.$(MAN4EXT) $(FIXMANCMD) $(BUILDDIR)/conserver.cf/conserver.cf.man > $(MAN4DIR)/conserver.cf.$(MAN4EXT)
$(FIXMANCMD) $(BUILDDIR)/conserver.cf/conserver.passwd.man > $(MAN4DIR)/conserver.passwd.$(MAN4EXT)
$(FIXSCRIPTCMD) $(BUILDDIR)/conserver/conserver.rc > $(LIBDIR)/conserver.rc $(FIXSCRIPTCMD) $(BUILDDIR)/conserver/conserver.rc > $(LIBDIR)/conserver.rc

View File

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

View File

@ -12,3 +12,4 @@ f none share/man/man1m/conserver.1m 0644 bin bin
f none share/man/man1m/console.1m 0644 bin bin f none share/man/man1m/console.1m 0644 bin bin
d none share/man/man5 0755 bin bin d none share/man/man5 0755 bin bin
f none share/man/man5/conserver.cf.5 0644 bin bin f none share/man/man5/conserver.cf.5 0644 bin bin
f none share/man/man5/conserver.passwd.5 0644 bin bin