Codebase list conserver / 96b8a0e
Import Upstream version 8.1.14 Bernhard Schmidt 4 years ago
35 changed file(s) with 1337 addition(s) and 598 deletion(s). Raw diff Collapse all Expand all
00 CHANGES
11 =======
2
3 version 8.1.14 (Apr 9, 2006):
4 - fixed rpm conserver.spec file - based on patch by Martin Evans
5 <m.d.t.evans@qmul.ac.uk>
6 - added 'uds' console type for unix domain socket connections -
7 based on patch by DJ Gregor <dj@gregor.com>
8 - probing of interfaces under cygwin (and possibly others?) now
9 skips unconfigured interfaces (even if flagged as up!) -
10 reported by Chris Riddoch <chrisr@digeo.com>
11 - added the '!login' console option to prevent clients from
12 connecting to a console - suggested by Greg Tillman
13 <gregtillman@comcast.net>
14 - added a 'noop' console type for consoles you'd like to name,
15 but have no connection to - suggested by Greg Tillman
16 <gregtillman@comcast.net>
17 - deprecated escape commands removed from the code
18 - added '^EcP' and '^EcR' sequences to set the playback and
19 replay line lengths
20 - new console config options 'playback' and 'replay' to let the
21 client set prefered output lengths (with a special feature for
22 a size of zero)
23 - prefer strlcpy() over strcpy() - based on patch by Peter
24 Valchev <pvalchev@openbsd.org>
25 - fixed bug where '^Eco' by user on an 'exec' console with an
26 'initcmd' causes input by user to be ignored (could be other
27 console types as well) - reported by Mark Wedel
28 <Mark.Wedel@sun.com>
29 - made POSIX termios code in autologin a requirement (since
30 conserver requires it) and cleaned up a few other issues -
31 based on reports by Arthur Clune <ajc22@york.ac.uk>
232
333 version 8.1.13 (Jan 15, 2006):
434 - use SIOCGIFNUM for interface count (if available) and catch
822852 and enhancements of various types were applied.
823853
824854 #
825 # $Id: CHANGES,v 1.212 2006/01/15 17:11:42 bryan Exp $
855 # $Id: CHANGES,v 1.215 2006/04/10 02:07:13 bryan Exp $
826856 #
2020 Mirrors of the site are at:
2121
2222 Australia http://planetmirror.com/pub/conserver/
23 Ireland http://conserver.oss-mirror.org/
24 Germany http://conserver.linux-mirror.org/
2325 Russia http://conserver.rinet.ru/
2426
2527
3436 Cygwin (w2k),gcc 2.95.3
3537 DEC Tru64 4.0, gcc
3638 DEC Tru64 4.0/5.1, native cc
37 FreeBSD 4.2/4.8/5.1 (x86), gcc
39 FreeBSD 4.x (i386) gcc
40 FreeBSD 5.x (i386/amd64/sparc64) gcc
41 FreeBSD 6.x/7.x (i386/amd64/sparc64/ia64) gcc
3842 HP-UX 10.20, gcc
3943 HP-UX 11.10 parisc and ia64, native cc
4044 Irix 6.15, native cc
6064 http://www.columbia.edu/acis/sy/unixdev/zinc
6165
6266 #
63 # $Id: README,v 1.24 2005/09/05 21:46:43 bryan Exp $
67 # $Id: README,v 1.25 2006/03/20 16:48:37 bryan Exp $
6468 #
5353
5454 - cyclades ts1000/2000 port : "Moses, Joel" <jmoses@deloitte.com>
5555
56 - config file for client (list of masters, for example)
57
5856 - strftime() idea for logfile names : Lars Kellogg-Stedman <lars@larsshack.org>
5957
6058 - 9600baud log replay?
8583 - not even sure if this is possible w/o confusing the client,
8684 but maybe with the new 8.1.0 client-server protocol, we can!
8785
88 - allow for very long replays (hundres of lines) : John Stoffel
89 <stoffel@lucent.com>
90
9186 - log rotation by date : Tom Pachla <tom.pachla@nlc-bnc.ca>
9287
9388 - strict file permission checks on conserver.passwd/conserver.cf : Erik
108103 - reintroduce console grouping : Martin Turba
109104 <martin.turba@igd.fraunhofer.de>
110105
106 - quick-recheck of down consoles (for uds) and possibly only log state
107 changes (instead of each try) : DJ Gregor <dj@gregor.com>
108
111109 #
112 # $Id: TODO,v 1.55 2005/06/06 23:02:36 bryan Exp $
110 # $Id: TODO,v 1.56 2006/04/03 22:20:34 bryan Exp $
113111 #
6868 */
6969
7070 #ifndef lint
71 char *rcsid = "$Id: autologin.c,v 1.24 2004/12/12 07:36:07 bryan Exp $";
71 char *rcsid = "$Id: autologin.c,v 1.25 2006/04/10 01:50:16 bryan Exp $";
7272 #endif /* not lint */
7373 extern char *progname;
7474 gid_t awGrps[NGROUPS_MAX];
8787 int
8888 Process()
8989 {
90 register int c;
9190 int iErrs = 0;
9291 int i, iNewGrp;
9392 gid_t wGid;
9493 uid_t wUid;
9594 char *pcCmd = (char *)0,
9695 *pcDevTty = (char *)0;
97 char *pcTmp;
9896 #ifdef HAVE_GETUSERATTR
9997 char *pcGrps;
10098 #endif
10199 struct passwd *pwd;
102100 struct stat st;
103 #ifdef HAVE_TERMIOS_H
104101 struct termios n_tio;
105 #else
106 # ifdef TIOCNOTTY
107 # ifdef O_CBREAK
108 auto struct tc n_tchars;
109 # else
110 auto struct tchars n_tchars;
111 # endif
112 # ifdef TIOCGLTC
113 auto struct ltchars n_ltchars;
114 # endif
115 # else
116 # ifdef TIOCGETP
117 auto struct sgttyb n_sty;
118 # endif
119 # endif
120 #endif
121102 #if defined(HAVE_BSM_AUDIT_H) && defined(HAVE_LIBBSM)
122103 char my_hostname[MAXHOSTNAMELEN];
123104 #endif
319300 # endif
320301 (void)au_write(iAuditFile, ptAuditToken);
321302 if(0 > au_close(iAuditFile, AU_TO_WRITE, AUE_autologin)) {
322 fprintf(stderr, "%s: audit write failed",
303 fprintf(stderr, "%s: audit write failed: %s",
323304 progname,
324305 strerror(errno));
325306 }
371352
372353 /* put the tty in the correct mode
373354 */
374 #ifndef HAVE_TERMIOS_H
375 if (0 != ioctl(0, TIOCGETP, (char *)&n_sty)) {
376 fprintf(stderr, "%s: iotcl: getp: %s\n", progname, strerror(errno));
377 exit(10);
378 }
379 #ifdef O_CBREAK
380 n_sty.sg_flags &= ~(O_CBREAK);
381 n_sty.sg_flags |= (O_CRMOD|O_ECHO);
382 #else
383 n_sty.sg_flags &= ~(CBREAK);
384 n_sty.sg_flags |= (CRMOD|ECHO);
385 #endif
386 n_sty.sg_kill = '\025'; /* ^U */
387 n_sty.sg_erase = '\010'; /* ^H */
388 if (0 != ioctl(0, TIOCSETP, (char *)&n_sty)) {
389 fprintf(stderr, "%s: iotcl: setp: %s\n", progname, strerror(errno));
390 exit(10);
391 }
392
393 /* stty undef all tty chars
394 */
395 #if 0
396 if (-1 == ioctl(0, TIOCGETC, (char *)&n_tchars)) {
397 fprintf(stderr, "%s: ioctl: getc: %s\n", progname, strerror(errno));
398 return;
399 }
400 n_tchars.t_intrc = -1;
401 n_tchars.t_quitc = -1;
402 if (-1 == ioctl(0, TIOCSETC, (char *)&n_tchars)) {
403 fprintf(stderr, "%s: ioctl: setc: %s\n", progname, strerror(errno));
404 return;
405 }
406 #endif
407 #ifdef TIOCGLTC
408 if (-1 == ioctl(0, TIOCGLTC, (char *)&n_ltchars)) {
409 fprintf(stderr, "%s: ioctl: gltc: %s\n", progname, strerror(errno));
410 return;
411 }
412 n_ltchars.t_suspc = -1;
413 n_ltchars.t_dsuspc = -1;
414 n_ltchars.t_flushc = -1;
415 n_ltchars.t_lnextc = -1;
416 if (-1 == ioctl(0, TIOCSLTC, (char *)&n_ltchars)) {
417 fprintf(stderr, "%s: ioctl: sltc: %s\n", progname, strerror(errno));
418 return;
419 }
420 #endif
421 #else /* not using ioctl, using POSIX or sun stuff */
422355 #ifdef HAVE_TCGETATTR
423356 if (0 != tcgetattr(0, &n_tio)) {
424357 (void) fprintf(stderr, "%s: tcgetattr: %s\n", progname, strerror(errno));
454387 exit(1);
455388 /* NOTREACHED */
456389 }
457 #else
458 #ifndef HAVE_TERMIOS_H
459 if (0 != ioctl(0, TCSETS, &n_tio)) {
460 (void) fprintf(stderr, "%s: ioctl: TCSETS: %s\n", progname, strerror(errno));
461 exit(1);
462 /* NOTREACHED */
463 }
464 #endif
465 #endif
466 #endif /* setup tty */
390 #endif
467391
468392 if (fMakeUtmp) {
469393 extern char *ttyname();
531455 register int fdUtmp;
532456 register char *pcDev;
533457 register struct utmp *up;
534 auto struct utmp outmp, utmp;
458 auto struct utmp utmp;
535459
536460
537461 if ((char *)0 == pctty) {
77 #include <sys/stat.h>
88 #include <fcntl.h>
99 #include <netinet/in.h>
10 #if USE_UNIX_DOMAIN_SOCKETS
1110 #include <sys/un.h>
12 #endif
1311 #include <arpa/inet.h>
1412 #include <netdb.h>
1513 #include <ctype.h>
3432 #endif
3533 #if !defined(DEFESC)
3634 # define DEFESC 'c'
35 #endif
36
37 /* set the default length of the replay functions
38 * DEFREPLAY for 'r'
39 * DEFPLAYBACK for 'p'
40 */
41 #if !defined(DEFREPLAY)
42 # define DEFREPLAY 20
43 #endif
44 #if !defined(PLAYBACK)
45 # define DEFPLAYBACK 60
3746 #endif
3847
3948 /* For legacy compile-time setting of the port...
93102
94103 #include <termios.h>
95104
105 #ifndef TAB3
106 # ifdef OXTABS
107 # define TAB3 OXTABS
108 # else
109 # ifdef XTABS
110 # define TAB3 XTABS
111 # else
112 # define TAB3 0
113 # endif
114 # endif
115 #endif
116
96117 #ifdef HAVE_STROPTS_H
97118 # include <stropts.h>
98119 #endif
00 #! /bin/sh
11 # Attempt to guess a canonical system name.
22 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4
5 timestamp='2006-01-02'
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
4 # Inc.
5
6 timestamp='2006-03-13'
67
78 # This file is free software; you can redistribute it and/or modify it
89 # under the terms of the GNU General Public License as published by
105106 trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
106107 trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
107108 : ${TMPDIR=/tmp} ;
108 { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
109 { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
109110 { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
110111 { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
111112 { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
787788 echo ${UNAME_MACHINE}-pc-pw32
788789 exit ;;
789790 x86:Interix*:[345]*)
790 echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
791 echo i586-pc-interix${UNAME_RELEASE}
792 exit ;;
793 EM64T:Interix*:[345]*)
794 echo x86_64-unknown-interix${UNAME_RELEASE}
791795 exit ;;
792796 [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
793797 echo i${UNAME_MACHINE}-pc-mks
858862 #endif
859863 #endif
860864 EOF
861 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '/^CPU/{s: ::g;p;}'`"
865 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
866 /^CPU/{
867 s: ::g
868 p
869 }'`"
862870 test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
863871 ;;
864872 mips64:Linux:*:*)
877885 #endif
878886 #endif
879887 EOF
880 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '/^CPU/{s: ::g;p;}'`"
888 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
889 /^CPU/{
890 s: ::g
891 p
892 }'`"
881893 test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
882894 ;;
883895 or32:Linux:*:*)
974986 LIBC=gnulibc1
975987 # endif
976988 #else
977 #if defined(__INTEL_COMPILER) || defined(__PGI)
989 #if defined(__INTEL_COMPILER) || defined(__PGI) || defined(__sun)
978990 LIBC=gnu
979991 #else
980992 LIBC=gnuaout
984996 LIBC=dietlibc
985997 #endif
986998 EOF
987 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '/^LIBC/{s: ::g;p;}'`"
999 eval "`$CC_FOR_BUILD -E $dummy.c 2>/dev/null | sed -n '
1000 /^LIBC/{
1001 s: ::g
1002 p
1003 }'`"
9881004 test x"${LIBC}" != x && {
9891005 echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
9901006 exit
194194 /* Define to 1 if you have the <string.h> header file. */
195195 #undef HAVE_STRING_H
196196
197 /* Define to 1 if you have the `strlcpy' function. */
198 #undef HAVE_STRLCPY
199
197200 /* Define to 1 if you have the <stropts.h> header file. */
198201 #undef HAVE_STROPTS_H
199202
241244
242245 /* Define to 1 if you have the <sys/uio.h> header file. */
243246 #undef HAVE_SYS_UIO_H
247
248 /* Define to 1 if you have the <sys/un.h> header file. */
249 #undef HAVE_SYS_UN_H
244250
245251 /* Define to 1 if you have the <sys/vlimit.h> header file. */
246252 #undef HAVE_SYS_VLIMIT_H
00 #! /bin/sh
11 # Configuration validation subroutine script.
22 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
3 # 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
4
5 timestamp='2006-01-02'
3 # 2000, 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation,
4 # Inc.
5
6 timestamp='2006-03-07'
67
78 # This file is (in principle) common to ALL GNU software.
89 # The presence of a machine in this file suggests that SOME GNU software
267268 | mn10200 | mn10300 \
268269 | mt \
269270 | msp430 \
271 | nios | nios2 \
270272 | ns16k | ns32k \
271273 | or32 \
272274 | pdp10 | pdp11 | pj | pjl \
273275 | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
274276 | pyramid \
275 | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
277 | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
276278 | sh64 | sh64le \
277 | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
278 | sparcv8 | sparcv9 | sparcv9b \
279 | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
280 | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
279281 | strongarm \
280282 | tahoe | thumb | tic4x | tic80 | tron \
281283 | v850 | v850e \
349351 | mmix-* \
350352 | mt-* \
351353 | msp430-* \
354 | nios-* | nios2-* \
352355 | none-* | np1-* | ns16k-* | ns32k-* \
353356 | orion-* \
354357 | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
355358 | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
356359 | pyramid-* \
357360 | romp-* | rs6000-* \
358 | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
361 | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
359362 | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
360 | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
363 | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
361364 | sparclite-* \
362 | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
365 | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | strongarm-* | sv1-* | sx?-* \
363366 | tahoe-* | thumb-* \
364367 | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
365368 | tron-* \
11251128 sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
11261129 basic_machine=sh-unknown
11271130 ;;
1128 sparc | sparcv8 | sparcv9 | sparcv9b)
1131 sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
11291132 basic_machine=sparc-sun
11301133 ;;
11311134 cydra)
37693769
37703770
37713771
3772 for ac_header in unistd.h getopt.h sys/vlimit.h sys/resource.h ttyent.h sys/ttold.h sys/uio.h sys/ioctl_compat.h usersec.h sys/select.h stropts.h sys/audit.h shadow.h sys/time.h crypt.h sysexits.h types.h sys/sockio.h sys/param.h
3772
3773 for ac_header in unistd.h getopt.h sys/vlimit.h sys/resource.h ttyent.h sys/ttold.h sys/uio.h sys/ioctl_compat.h usersec.h sys/select.h stropts.h sys/audit.h shadow.h sys/time.h crypt.h sysexits.h types.h sys/sockio.h sys/param.h sys/un.h
37733774 do
37743775 as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
37753776 if eval "test \"\${$as_ac_Header+set}\" = set"; then
69546955
69556956
69566957
6957 for ac_func in getopt strerror getrlimit getsid setsid getuserattr setgroups tcgetpgrp tcsetpgrp tcgetattr tcsetattr tcsendbreak setpgrp getutent setttyent getspnam setlinebuf setvbuf ptsname grantpt unlockpt sigaction setsockopt getdtablesize putenv memset memcpy memcmp memmove sysconf getlogin inet_aton setproctitle gettimeofday
6958
6959 for ac_func in getopt strerror getrlimit getsid setsid getuserattr setgroups tcgetpgrp tcsetpgrp tcgetattr tcsetattr tcsendbreak setpgrp getutent setttyent getspnam setlinebuf setvbuf ptsname grantpt unlockpt sigaction setsockopt getdtablesize putenv memset memcpy memcmp memmove sysconf getlogin inet_aton setproctitle gettimeofday strlcpy
69586960 do
69596961 as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
69606962 echo "$as_me:$LINENO: checking for $ac_func" >&5
325325 AC_MSG_ERROR([POSIX termios interface required])
326326 fi
327327
328 AC_CHECK_HEADERS(unistd.h getopt.h sys/vlimit.h sys/resource.h ttyent.h sys/ttold.h sys/uio.h sys/ioctl_compat.h usersec.h sys/select.h stropts.h sys/audit.h shadow.h sys/time.h crypt.h sysexits.h types.h sys/sockio.h sys/param.h)
328 AC_CHECK_HEADERS(unistd.h getopt.h sys/vlimit.h sys/resource.h ttyent.h sys/ttold.h sys/uio.h sys/ioctl_compat.h usersec.h sys/select.h stropts.h sys/audit.h shadow.h sys/time.h crypt.h sysexits.h types.h sys/sockio.h sys/param.h sys/un.h)
329329 dnl sys/proc.h needs sys/param.h on openbsd, apparently
330330 AC_CHECK_HEADERS(sys/proc.h, [], [],
331331 [#if HAVE_SYS_PARAM_H
609609 AC_CHECK_LIB(util, openpty)
610610 AC_CHECK_FUNCS(openpty)
611611
612 AC_CHECK_FUNCS(getopt strerror getrlimit getsid setsid getuserattr setgroups tcgetpgrp tcsetpgrp tcgetattr tcsetattr tcsendbreak setpgrp getutent setttyent getspnam setlinebuf setvbuf ptsname grantpt unlockpt sigaction setsockopt getdtablesize putenv memset memcpy memcmp memmove sysconf getlogin inet_aton setproctitle gettimeofday)
612 AC_CHECK_FUNCS(getopt strerror getrlimit getsid setsid getuserattr setgroups tcgetpgrp tcsetpgrp tcgetattr tcsetattr tcsendbreak setpgrp getutent setttyent getspnam setlinebuf setvbuf ptsname grantpt unlockpt sigaction setsockopt getdtablesize putenv memset memcpy memcmp memmove sysconf getlogin inet_aton setproctitle gettimeofday strlcpy)
613613 AC_FUNC_SETPGRP
614614 AC_CHECK_FUNC(strcasecmp,
615615 [AC_DEFINE(HAVE_STRCASECMP, 1, [Define if strcasecmp is available])],
00 /*
1 * $Id: client.c,v 5.89 2005/09/04 00:28:58 bryan Exp $
1 * $Id: client.c,v 5.90 2006/04/03 13:32:08 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
106106 pCE->pCLwr = (CONSCLIENT *)0;
107107 }
108108
109 /* replay last iBack lines of the log file upon connect to console (ksb)
109 /* replay last 'back' lines of the log file upon connect to console (ksb)
110110 *
111111 * NB: we know the console might be spewing when the replay happens,
112112 * we want to just output what is in the log file and get out,
113113 * so we don't drop chars...
114114 */
115 #define REPLAYBUFFER 4096
116
115117 void
116118 #if PROTOTYPES
117 Replay(CONSENT *pCE, CONSFILE *fdOut, int iBack)
118 #else
119 Replay(pCE, fdOut, iBack)
119 Replay(CONSENT *pCE, CONSFILE *fdOut, unsigned short back)
120 #else
121 Replay(pCE, fdOut, back)
120122 CONSENT *pCE;
121123 CONSFILE *fdOut;
122 int iBack;
124 unsigned short back;
123125 #endif
124126 {
125127 CONSFILE *fdLog = (CONSFILE *)0;
128 STRING *line = (STRING *)0;
126129 off_t file_pos;
127130 off_t buf_pos;
128131 char *buf;
129132 char *bp = (char *)0;
130 char *s;
131 int r;
132133 int ch;
133134 struct stat stLog;
134 struct lines {
135 int is_mark;
136 STRING *line;
137 STRING *mark_end;
138 } *lines;
139 int n_lines;
140135 int ln;
141 int i;
142 int j;
143 int u;
144 int is_mark;
145 char dummy[4];
136 int was_mark = 0;
146137 #if HAVE_DMALLOC && DMALLOC_MARK_REPLAY
147138 unsigned long dmallocMarkReplay = 0;
148139 #endif
149140
150 if (pCE != (CONSENT *)0) {
151 fdLog = pCE->fdlog;
152
153 /* no logfile and down and logfile defined? try and open it */
154 if (fdLog == (CONSFILE *)0 && !pCE->fup &&
155 pCE->logfile != (char *)0)
156 fdLog = FileOpen(pCE->logfile, O_RDONLY, 0644);
157 }
141 if (pCE != (CONSENT *)0 && pCE->logfile != (char *)0)
142 fdLog = FileOpen(pCE->logfile, O_RDONLY, 0644);
158143
159144 if (fdLog == (CONSFILE *)0) {
160145 FileWrite(fdOut, FLAGFALSE, "[no log file on this console]\r\n",
161146 -1);
162147 return;
163148 }
149 #if HAVE_DMALLOC && DMALLOC_MARK_REPLAY
150 dmallocMarkReplay = dmalloc_mark();
151 #endif
164152
165153 /* find the size of the file
166154 */
167 if (0 != FileStat(fdLog, &stLog)) {
168 return;
169 }
170 #if HAVE_DMALLOC && DMALLOC_MARK_REPLAY
171 dmallocMarkReplay = dmalloc_mark();
172 #endif
173
174 file_pos = stLog.st_size - 1;
155 if (0 != FileStat(fdLog, &stLog))
156 goto common_exit;
157
158 file_pos = stLog.st_size - 1; /* point at last byte */
175159 buf_pos = file_pos + 1;
176160
177 /* get space for the line information and initialize it
178 *
179 * we allocate room for one more line than requested to be able to
180 * do the mark ranges
181 */
182 if ((char *)0 == (buf = malloc(BUFSIZ))) {
161 if ((char *)0 == (buf = malloc(REPLAYBUFFER)))
183162 OutOfMem();
184 }
185 n_lines = iBack + 1;
186 lines = (struct lines *)calloc(n_lines, sizeof(*lines));
187 if ((struct lines *)0 == lines) {
188 OutOfMem();
189 }
190 for (i = 0; i < n_lines; i++) {
191 lines[i].mark_end = AllocString();
192 lines[i].line = AllocString();
193 }
194 ln = -1;
163 bp = buf + 1; /* just give it something - it resets below */
164
165 line = AllocString();
195166
196167 /* loop as long as there is data in the file or we have not found
197168 * the requested number of lines
198169 */
199 while (file_pos >= 0) {
170 ln = -1;
171 for (; file_pos >= 0; file_pos--, bp--) {
200172 if (file_pos < buf_pos) {
173 int r;
201174
202175 /* read one buffer worth of data a buffer boundary
203176 *
204177 * the first read will probably not get a full buffer but
205178 * the rest (as we work our way back in the file) should be
206179 */
207 buf_pos = (file_pos / BUFSIZ) * BUFSIZ;
180 buf_pos = (file_pos / REPLAYBUFFER) * REPLAYBUFFER;
208181 if (FileSeek(fdLog, buf_pos, SEEK_SET) < 0) {
209182 goto common_exit;
210183 }
211 if ((r = FileRead(fdLog, buf, BUFSIZ)) < 0) {
184 if ((r = FileRead(fdLog, buf, REPLAYBUFFER)) < 0) {
212185 goto common_exit;
213186 }
214 bp = buf + r;
187 bp = buf + r - 1;
215188 }
216189
217190 /* process the next character
218191 */
219 --file_pos;
220 if ((ch = *--bp) == '\n') {
192 if ((ch = *bp) == '\n') {
221193 if (ln >= 0) {
194 int i;
195 int u;
196 int is_mark = 0;
222197
223198 /* reverse the text to put it in forward order
224199 */
225 u = lines[ln].line->used - 1;
200 u = line->used - 1;
226201 for (i = 0; i < u / 2; i++) {
227202 int temp;
228203
229 temp = lines[ln].line->string[i];
230 lines[ln].line->string[i]
231 = lines[ln].line->string[u - i - 1];
232 lines[ln].line->string[u - i - 1] = temp;
204 temp = line->string[i];
205 line->string[i] = line->string[u - i - 1];
206 line->string[u - i - 1] = temp;
233207 }
234208
235209 /* see if this line is a MARK
236210 */
237 if (lines[ln].line->used > 0 &&
238 lines[ln].line->string[0] == '[') {
239 i = sscanf(lines[ln].line->string + 1,
211 if (line->used > 0 && line->string[0] == '[') {
212 char dummy[4];
213 int j;
214 i = sscanf(line->string + 1,
240215 "-- MARK -- %3c %3c %d %d:%d:%d %d]\r\n",
241216 dummy, dummy, &j, &j, &j, &j, &j);
242217 is_mark = (i == 7);
243 } else {
244 is_mark = 0;
245218 }
246219
247220 /* process this line
248221 */
249 if (is_mark && ln > 0 && lines[ln - 1].is_mark) {
222 if (is_mark && was_mark) {
250223 /* this is a mark and the previous line is also
251 * a mark, so make (or continue) that range
224 * a mark, so reduce the line count 'cause it'll
225 * go up by one and we're joining them on output.
252226 */
253 if (0 == lines[ln - 1].mark_end->used) {
254 /* this is a new range - shuffle pointers
255 *
256 * remember that we are moving backward
257 */
258 BuildStringN(lines[ln - 1].line->string,
259 lines[ln - 1].line->used - 1,
260 lines[ln - 1].mark_end);
261 BuildString((char *)0, lines[ln - 1].line);
262 }
263 BuildString((char *)0, lines[ln - 1].line);
264 BuildStringN(lines[ln].line->string,
265 lines[ln].line->used - 1,
266 lines[ln - 1].line);
267 BuildString((char *)0, lines[ln].line);
268227 ln--;
269228 }
270 lines[ln].is_mark = is_mark;
229 was_mark = is_mark;
271230 }
272231
273232 /* advance to the next line and break if we have enough
274233 */
275234 ln++;
276 if (ln >= n_lines - 1) {
235 BuildString((char *)0, line);
236 if (ln >= back) {
277237 break;
278238 }
279239 }
284244 if (ln < 0) {
285245 ln = 0;
286246 }
287 BuildStringChar(ch, lines[ln].line);
247 BuildStringChar(ch, line);
288248
289249 /* if we've processed "a lot" of data for a line, then bail
290250 * why? there must be some very long non-newline terminated
291251 * strings and if we just keep going back, we could spew lots
292252 * of data and chew up lots of memory
293253 */
294 if (lines[ln].line->used > MAXREPLAYLINELEN) {
254 if (line->used > MAXREPLAYLINELEN) {
295255 break;
296256 }
297257 }
298 free(buf);
299 buf = (char *)0;
300
301 /* if we got back to beginning of file but saw some data, include it
258
259 /* move forward. either we hit the beginning of the file and we
260 * move to the first byte, or we hit a \n and we move past it
302261 */
303 if (ln >= 0 && lines[ln].line->used > 0) {
304
305 /* reverse the text to put it in forward order
306 */
307 u = lines[ln].line->used - 1;
308 for (i = 0; i < u / 2; i++) {
309 int temp;
310
311 temp = lines[ln].line->string[i];
312 lines[ln].line->string[i]
313 = lines[ln].line->string[u - i - 1];
314 lines[ln].line->string[u - i - 1] = temp;
315 }
316 ln++;
317 }
318
319 /* copy the lines into the buffer and put them in order
320 */
321 for (i = ln - 1; i >= 0; i--) {
322 if (lines[i].is_mark && 0 != lines[i].mark_end->used) {
323 int mark_len;
324
325 /* output the start of the range, stopping at the ']'
326 */
327 s = strrchr(lines[i].line->string, ']');
328 if ((char *)0 != s) {
329 *s = '\000';
330 }
331 FileWrite(fdOut, FLAGTRUE, lines[i].line->string, -1);
332 FileWrite(fdOut, FLAGTRUE, " .. ", 4);
333
334 /* build the end string by removing the leading "[-- MARK -- "
335 * and replacing "]\r\n" on the end with " -- MARK --]\r\n"
336 */
337 mark_len = sizeof("[-- MARK -- ") - 1;
338
339 s = strrchr(lines[i].mark_end->string + mark_len, ']');
340 if ((char *)0 != s) {
341 *s = '\000';
342 }
343 FileWrite(fdOut, FLAGTRUE,
344 lines[i].mark_end->string + mark_len, -1);
345 FileWrite(fdOut, FLAGFALSE, " -- MARK --]\r\n", -1);
346 u = lines[i].mark_end->used;
347 s = lines[i].mark_end->string;
348 } else
349 FileWrite(fdOut, FLAGFALSE, lines[i].line->string,
350 lines[i].line->used - 1);
262 file_pos++;
263
264 /* Now output the lines, starting from where we stopped */
265 if (FileSeek(fdLog, file_pos, SEEK_SET) >= 0) {
266 int eof = 0;
267 int i = 0;
268 int r = 0;
269 STRING *mark_beg = (STRING *)0;
270 STRING *mark_end = (STRING *)0;
271
272 mark_beg = AllocString();
273 mark_end = AllocString();
274
275 ln = 0; /* number of lines output */
276 BuildString((char *)0, line);
277
278 while (ln < back && !eof) {
279 if (r <= 0) {
280 if ((r = FileRead(fdLog, buf, REPLAYBUFFER)) < 0)
281 eof = 1;
282 i = 0;
283 }
284
285 if (!eof)
286 BuildStringChar(buf[i], line);
287
288 if (buf[i] == '\n' || eof) {
289 int is_mark = 0;
290 if (line->used > 0 && line->string[0] == '[') {
291 char dummy[4];
292 int j;
293 int i;
294 i = sscanf(line->string + 1,
295 "-- MARK -- %3c %3c %d %d:%d:%d %d]\r\n",
296 dummy, dummy, &j, &j, &j, &j, &j);
297 is_mark = (i == 7);
298 }
299 if (is_mark) {
300 if (mark_beg->used > 1) {
301 BuildString((char *)0, mark_end);
302 BuildString(line->string, mark_end);
303 } else
304 BuildString(line->string, mark_beg);
305 } else {
306 if (mark_beg->used > 1) {
307 if (mark_end->used > 1) {
308 char *s;
309
310 /* output the start of the range, stopping at the ']' */
311 s = strrchr(mark_beg->string, ']');
312 if ((char *)0 != s)
313 *s = '\000';
314 FileWrite(fdOut, FLAGTRUE, mark_beg->string,
315 -1);
316 FileWrite(fdOut, FLAGTRUE, " .. ", 4);
317
318 /* build the end string by removing the leading "[-- MARK -- "
319 * and replacing "]\r\n" on the end with " -- MARK --]\r\n"
320 */
321 s = strrchr(mark_end->string, ']');
322 if ((char *)0 != s)
323 *s = '\000';
324 FileWrite(fdOut, FLAGTRUE,
325 mark_end->string +
326 sizeof("[-- MARK -- ") - 1, -1);
327 FileWrite(fdOut, FLAGFALSE, " -- MARK --]\r\n",
328 -1);
329 } else {
330 FileWrite(fdOut, FLAGFALSE, mark_beg->string,
331 mark_beg->used - 1);
332 }
333 BuildString((char *)0, mark_beg);
334 BuildString((char *)0, mark_end);
335 ln++;
336 if (ln >= back)
337 break;
338 }
339 FileWrite(fdOut, FLAGFALSE, line->string,
340 line->used - 1);
341 ln++;
342 }
343 BuildString((char *)0, line);
344 }
345
346 /* move the counters */
347 i++;
348 r--;
349 }
350 DestroyString(mark_end);
351 DestroyString(mark_beg);
351352 }
352353
353354 common_exit:
354355
355 /* if we opened the logfile, close it */
356 if (fdLog != pCE->fdlog)
356 if (line != (STRING *)0)
357 DestroyString(line);
358 if (buf != (char *)0)
359 free(buf);
360 if (fdLog != (CONSFILE *)0)
357361 FileClose(&fdLog);
358362
359 if ((struct lines *)0 != lines) {
360 for (i = 0; i < n_lines; i++) {
361 DestroyString(lines[i].mark_end);
362 DestroyString(lines[i].line);
363 }
364 free(lines);
365 lines = (struct lines *)0;
366 }
367 if ((char *)0 != buf) {
368 free(buf);
369 buf = (char *)0;
370 }
371363 #if HAVE_DMALLOC && DMALLOC_MARK_REPLAY
372364 CONDDEBUG((1, "Replay(): dmalloc / MarkReplay"));
373365 dmalloc_log_changed(dmallocMarkReplay, 1, 0, 1);
407399 {WHEN_ATTACH, "l1-9 send specific break sequence"},
408400 {WHEN_ALWAYS, "m display the message of the day"},
409401 {WHEN_ALWAYS, "o (re)open the tty and log file"},
410 {WHEN_ALWAYS, "p replay the last 60 lines"},
411 {WHEN_ALWAYS, "r replay the last 20 lines"},
412 {WHEN_ATTACH, "s spy read only"},
402 {WHEN_ALWAYS, "p playback the last %hu lines"},
403 {WHEN_ALWAYS, "P set number of playback lines"},
404 {WHEN_ALWAYS, "r replay the last %hu lines"},
405 {WHEN_ALWAYS, "R set number of replay lines"},
406 {WHEN_ATTACH, "s spy mode (read only)"},
413407 {WHEN_ALWAYS, "u show host status"},
414408 {WHEN_ALWAYS, "v show version info"},
415409 {WHEN_ALWAYS, "w who is on this console"},
453447
454448 BuildString((char *)0, acLine);
455449 for (i = 0; i < sizeof(aHLTable) / sizeof(HELP); ++i) {
450 char *text;
451
456452 if (aHLTable[i].iwhen & IS_LIMITED &&
457453 ConsentUserOk(pLUList, pCL->username->string) == 1)
458454 continue;
460456 if (0 == (aHLTable[i].iwhen & iCmp))
461457 continue;
462458
459 text = aHLTable[i].actext;
460 if (text[0] == 'p') {
461 BuildTmpString((char *)0);
462 text = BuildTmpStringPrint(text, pCL->playback);
463 } else if (text[0] == 'r') {
464 BuildTmpString((char *)0);
465 text = BuildTmpStringPrint(text, pCL->replay);
466 }
467
463468 if (acLine->used != 0) { /* second part of line */
464 if (strlen(aHLTable[i].actext) < HALFLINE) {
469 if (strlen(text) < HALFLINE) {
465470 for (j = acLine->used; j <= HALFLINE; ++j) {
466471 BuildStringChar(' ', acLine);
467472 }
468 BuildString(aHLTable[i].actext, acLine);
473 BuildString(text, acLine);
469474 BuildString(acEoln, acLine);
470475 FileWrite(pCL->fd, FLAGTRUE, acLine->string,
471476 acLine->used - 1);
480485 }
481486 if (acLine->used == 0) { /* at new line */
482487 BuildStringChar(' ', acLine);
483 BuildString(aHLTable[i].actext, acLine);
488 BuildString(text, acLine);
484489 if (acLine->used > HALFLINE) {
485490 BuildString(acEoln, acLine);
486491 FileWrite(pCL->fd, FLAGTRUE, acLine->string,
00 /*
1 * $Id: client.h,v 5.40 2005/06/07 19:55:51 bryan Exp $
1 * $Id: client.h,v 5.41 2006/04/03 13:32:08 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
4747 S_QUOTE, /* send any character we can spell */
4848 S_BCAST, /* send a broadcast message to all clients */
4949 S_CWAIT, /* wait for client */
50 S_CEXEC /* client execing a program */
50 S_CEXEC, /* client execing a program */
51 S_REPLAY, /* set replay length for 'r' */
52 S_PLAYBACK /* set replay length for 'p' */
5153 } CLIENTSTATE;
5254
5355 typedef struct client { /* Connection Information: */
7476 *pCLnext; /* next person on this list */
7577 /* next lists link clients on a console */
7678 char ic[2]; /* two character escape sequence */
79 unsigned short replay; /* lines to replay for 'r' */
80 unsigned short playback; /* lines to replay for 'p' */
7781 CLIENTSTATE iState; /* state for fsm in server */
7882 char caccess; /* did we trust the remote machine */
7983 IOSTATE ioState; /* state of the socket */
8084 time_t stateTimer; /* timer for various ioState states */
8185 STRING *accmd; /* the command the user issued */
82 STRING *msg; /* the broadcast message */
8386 struct sockaddr_in
8487 cnct_port; /* where from */
8588 } CONSCLIENT;
8689
87 extern void Replay PARAMS((CONSENT *, CONSFILE *, int));
90 extern void Replay PARAMS((CONSENT *, CONSFILE *, unsigned short));
8891 extern void HelpUser PARAMS((CONSCLIENT *));
8992 extern void FindWrite PARAMS((CONSENT *));
9093 extern int ClientAccessOk PARAMS((CONSCLIENT *));
00 /*
1 * $Id: consent.c,v 5.145 2005/06/08 18:09:40 bryan Exp $
1 * $Id: consent.c,v 5.149 2006/04/07 15:47:20 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
274274 {
275275 if (pCE->initcmd == (char *)0)
276276 return;
277
278 if (pCE->initpid != 0 || pCE->initfile != (CONSFILE *)0)
279 SendIWaitClientsMsg(pCE,
280 (pCE->fup &&
281 pCE->ioState ==
282 ISNORMAL) ? "up]\r\n" : "down]\r\n");
277283
278284 if (pCE->initpid != 0) {
279285 kill(pCE->initpid, SIGHUP);
777783
778784 switch (pCE->type) {
779785 case UNKNOWNTYPE: /* shut up gcc */
786 break;
787 case NOOP:
788 pCE->fup = 1;
789 pCE->ioState = ISNORMAL;
780790 break;
781791 case EXEC:
782792 if ((cofile =
886896 }
887897 pCE->fup = 1;
888898 break;
899 case UDS:
900 {
901 struct sockaddr_un port;
902
903 #if HAVE_MEMSET
904 memset((void *)&port, 0, sizeof(port));
905 #else
906 bzero((char *)&port, sizeof(port));
907 #endif
908
909 /* we ensure that pCE->uds exists and fits inside port.sun_path
910 * in readcfg.c, so we can just defend ourselves here (which
911 * should never trigger).
912 */
913 if (strlen(pCE->uds) >= sizeof(port.sun_path)) {
914 Error
915 ("[%s] strlen(uds path) > sizeof(port.sun_path): forcing down",
916 pCE->server);
917 ConsDown(pCE, FLAGTRUE, FLAGTRUE);
918 return;
919 }
920 StrCpy(port.sun_path, pCE->uds, sizeof(port.sun_path));
921 port.sun_family = AF_UNIX;
922
923 if ((cofile = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
924 Error
925 ("[%s] socket(AF_UNIX,SOCK_STREAM): %s: forcing down",
926 pCE->server, strerror(errno));
927 ConsDown(pCE, FLAGTRUE, FLAGTRUE);
928 return;
929 }
930
931 if (!SetFlags(cofile, O_NONBLOCK, 0)) {
932 ConsDown(pCE, FLAGTRUE, FLAGTRUE);
933 return;
934 }
935
936 if ((ret =
937 connect(cofile, (struct sockaddr *)&port,
938 sizeof(port))) < 0) {
939 if (errno != EINPROGRESS) {
940 Error("[%s] connect(%u): %s: forcing down",
941 pCE->server, cofile, strerror(errno));
942 ConsDown(pCE, FLAGTRUE, FLAGTRUE);
943 return;
944 }
945 }
946 }
947 if ((pCE->cofile =
948 FileOpenFD(cofile, simpleSocket)) == (CONSFILE *)0) {
949 Error
950 ("[%s] FileOpenFD(%d,simpleSocket) failed: forcing down",
951 pCE->server, cofile);
952 ConsDown(pCE, FLAGTRUE, FLAGTRUE);
953 return;
954 }
955 if (ret == 0) {
956 pCE->ioState = ISNORMAL;
957 pCE->stateTimer = 0;
958 } else {
959 pCE->ioState = INCONNECT;
960 pCE->stateTimer = time((time_t *)0) + CONNECTTIMEOUT;
961 if (timers[T_STATE] == (time_t)0 ||
962 timers[T_STATE] > pCE->stateTimer)
963 timers[T_STATE] = pCE->stateTimer;
964 }
965 pCE->fup = 1;
966 break;
889967 case DEVICE:
890968 if (-1 ==
891969 (cofile = open(pCE->device, O_RDWR | O_NONBLOCK, 0600))) {
9241002 Verbose("[%s] port %hu on %s", pCE->server, pCE->netport,
9251003 pCE->host);
9261004 break;
1005 case NOOP:
1006 Verbose("[%s] noop", pCE->server);
1007 break;
1008 case UDS:
1009 Verbose("[%s] uds %s", pCE->server, pCE->uds);
1010 break;
9271011 case DEVICE:
9281012 Verbose("[%s] at %s%c on %s", pCE->server, pCE->baud->acrate,
9291013 pCE->parity->key[0], pCE->device);
9301014 break;
9311015 }
9321016
933 /* if we're waiting for connect() to finish, watch the
934 * write bit, otherwise watch for the read bit
935 */
936 if (pCE->ioState == INCONNECT)
937 FD_SET(cofile, &winit);
938 else
939 FD_SET(cofile, &rinit);
940 if (maxfd < cofile + 1)
941 maxfd = cofile + 1;
1017 if (cofile != -1) {
1018 /* if we're waiting for connect() to finish, watch the
1019 * write bit, otherwise watch for the read bit
1020 */
1021 if (pCE->ioState == INCONNECT)
1022 FD_SET(cofile, &winit);
1023 else
1024 FD_SET(cofile, &rinit);
1025 if (maxfd < cofile + 1)
1026 maxfd = cofile + 1;
1027 }
9421028
9431029 tyme = time((time_t *)0);
9441030
00 /*
1 * $Id: consent.h,v 5.63 2005/06/08 18:09:40 bryan Exp $
1 * $Id: consent.h,v 5.66 2006/03/20 16:47:03 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
5454 UNKNOWNTYPE = 0,
5555 DEVICE,
5656 EXEC,
57 HOST
57 HOST,
58 NOOP,
59 UDS
5860 } CONSTYPE;
5961
6062 typedef struct names {
101103 char *execsubst; /* exec substitution pattern */
102104 uid_t execuid; /* user to run exec as */
103105 gid_t execgid; /* group to run exec as */
106 /* type == UDS */
107 char *uds; /* socket file */
108 char *udssubst; /* socket file substitution pattern */
104109 /* global stuff */
105110 char *master; /* master hostname */
106111 unsigned short breakNum; /* break type [1-9] */
126131 FLAG striphigh; /* strip high-bit of console data */
127132 FLAG autoreinit; /* auto-reinitialize if failed */
128133 FLAG unloved; /* copy "unloved" data to stdout */
134 FLAG login; /* allow logins to the console */
129135
130136 /*** runtime settings ***/
131137 CONSFILE *fdlog; /* the local log file */
00 .\" @(#)conserver.8 01/06/91 OSU CIS; Thomas A. Fine
1 .\" $Id: conserver.man,v 1.51 2005/04/02 09:59:48 bryan Exp $
2 .TH CONSERVER 8 "2005/04/02" "conserver-8.1.13" "conserver"
1 .\" $Id: conserver.man,v 1.53 2006/03/20 16:47:03 bryan Exp $
2 .TH CONSERVER 8 "2006/03/20" "conserver-8.1.14" "conserver"
33 .SH NAME
44 conserver \- console server daemon
55 .SH SYNOPSIS
379379 .I type
380380 The type of console.
381381 Values will be a `/' for a local device, `|' for
382 a command, or `!' for a remote port.
382 a command, `!' for a remote port, `%' for a Unix domain socket,
383 and `#' for a noop console.
383384 .TP
384385 .I details
385386 Multiple values are comma-separated and depend on the type of the console.
386387 Local devices will have the values of the device file and baud rate/parity.
387388 Commands will have string to invoke.
388389 Remote ports will have the values of the remote hostname and port number.
390 Unix domain sockets will have the path to the socket.
391 Noop consoles will have nothing.
389392 .RE
390393 .TP
391394 .B \-u
00 /*
1 * $Id: convert.c,v 1.10 2004/05/28 01:08:28 bryan Exp $
1 * $Id: convert.c,v 1.12 2006/04/07 15:47:20 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
8585 || peek) {
8686 /* If we have a previously saved line, use it instead */
8787 if (save->used) {
88 strcpy(buf, save->string);
88 StrCpy(buf, save->string, sizeof(buf));
8989 BuildString((char *)0, save);
9090 }
9191
00 /*
1 * $Id: cutil.c,v 1.125 2006/01/15 17:10:14 bryan Exp $
1 * $Id: cutil.c,v 1.130 2006/04/07 15:47:20 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
88 #include <compat.h>
99
1010 #include <cutil.h>
11 #include <version.h>
1112
1213 #include <net/if.h>
1314 #if HAVE_SYS_SOCKIO_H
8384 time_t tyme;
8485
8586 tyme = time((time_t *)0);
86 strcpy(curtime, ctime(&tyme));
87 StrCpy(curtime, ctime(&tyme), sizeof(curtime));
8788 curtime[24] = '\000'; /* might need to adjust this at some point */
8889 if (ltime != NULL)
8990 *ltime = tyme;
423424 || peek) {
424425 /* If we have a previously saved line, use it instead */
425426 if (save->used) {
426 strcpy(buf, save->string);
427 StrCpy(buf, save->string, sizeof(buf));
427428 BuildString((char *)0, save);
428429 }
429430
22892290
22902291 if (sa->sa_family == AF_INET) {
22912292 struct sockaddr_in *sin = (struct sockaddr_in *)sa;
2293
2294 /* make sure the address isn't 0.0.0.0, which is how we
2295 * signal the end of our list
2296 */
2297 if (
2298 #if HAVE_MEMCMP
2299 memcmp(&(myAddrs[m]), &(sin->sin_addr),
2300 sizeof(struct in_addr))
2301 #else
2302 bcmp(&(myAddrs[m]), &(sin->sin_addr),
2303 sizeof(struct in_addr))
2304 #endif
2305 == 0)
2306 continue;
2307
22922308 #ifdef SIOCGIFFLAGS
22932309 /* make sure the interface is up */
22942310 ifrcopy = *ifr;
22962312 ((ifrcopy.ifr_flags & IFF_UP) == 0))
22972313 continue;
22982314 #endif
2315
22992316 CONDDEBUG((1, "ProbeInterfaces(): name=%s addr=%s",
23002317 ifr->ifr_name, inet_ntoa(sin->sin_addr)));
2318
23012319 #if HAVE_MEMCPY
23022320 memcpy(&myAddrs[m], &(sin->sin_addr), sizeof(struct in_addr));
23032321 #else
23042322 bcopy(&(sin->sin_addr), &myAddrs[m], sizeof(struct in_addr));
23052323 #endif
2324
23062325 Verbose("interface address %s (%s)", inet_ntoa(myAddrs[m]),
23072326 ifr->ifr_name);
23082327 m++;
25072526
25082527 char *
25092528 #if PROTOTYPES
2510 StrDup(char *msg)
2529 StrDup(const char *msg)
25112530 #else
25122531 StrDup(msg)
2513 char *msg;
2532 const char *msg;
25142533 #endif
25152534 {
25162535 int len;
31623181 REP_END
31633182 } state;
31643183
3184 if (s == (SUBST *)0) {
3185 Error("ProcessSubst(): WTF? No substitute support structure?!?!");
3186 Bye(EX_SOFTWARE);
3187 }
3188
31653189 if (str != (char **)0) {
31663190 if (*str != (char *)0) {
31673191 free(*str);
32033227 break;
32043228 case REP_EQ:
32053229 repfmt[repnum] = p;
3206 if (s->tokens[(unsigned)(*(repfmt[repnum]))] != ISNOTHING)
3230 if (s->token(*(repfmt[repnum])) != ISNOTHING)
32073231 state = REP_INT;
32083232 else
32093233 goto subst_err;
32113235 case REP_INT:
32123236 if (*p == 'd' || *p == 'x' || *p == 'X' || *p == 'a' ||
32133237 *p == 'A') {
3214 if (s->tokens[(unsigned)(*(repfmt[repnum]))] !=
3215 ISNUMBER)
3238 if (s->token(*(repfmt[repnum])) != ISNUMBER)
32163239 goto subst_err;
32173240 state = REP_END;
32183241 } else if (*p == 's') {
3219 if (s->tokens[(unsigned)(*(repfmt[repnum]))] !=
3220 ISSTRING)
3242 if (s->token(*(repfmt[repnum])) != ISSTRING)
32213243 goto subst_err;
32223244 state = REP_END;
32233245 } else if (!isdigit((int)(*p)))
32453267 OutOfMem();
32463268 }
32473269
3248 if (s != (SUBST *)0 && repl != (char **)0) {
3270 if (s != (SUBST *)0 && repl != (char **)0 && *repl != (char *)0) {
32493271 static STRING *result = (STRING *)0;
32503272
32513273 if (result == (STRING *)0)
32593281 char *c = (char *)0;
32603282 int o = 0;
32613283
3262 if (s->tokens[(unsigned)(*r)] == ISSTRING) {
3284 if (s->token(*r) == ISSTRING) {
32633285 /* check the pattern for a length */
32643286 if (isdigit((int)(*(r + 1))))
32653287 plen = atoi(r + 1);
32663288
32673289 /* this should never return zero, but just in case */
3268 if ((*s->callback) (*r, &c, (int *)0) == 0)
3290 if ((*s->value) (*r, &c, (int *)0) == 0)
32693291 c = "";
32703292 plen -= strlen(c);
32713293
32873309 BuildString((char *)0, num);
32883310
32893311 /* this should never return zero, but just in case */
3290 if ((*s->callback) (*r, (char **)0, &i) == 0)
3312 if ((*s->value) (*r, (char **)0, &i) == 0)
32913313 port = 0;
32923314 else
32933315 port = (unsigned short)i;
33643386
33653387 return;
33663388 }
3389
3390 char *
3391 #if PROTOTYPES
3392 MyVersion(void)
3393 #else
3394 MyVersion()
3395 #endif
3396 {
3397 static STRING *version = (STRING *)0;
3398 if (version != (STRING *)0)
3399 return version->string;
3400 version = AllocString();
3401 BuildStringPrint(version, "%s %d.%d.%d", VERSION_TEXT, VERSION_MAJOR,
3402 VERSION_MINOR, VERSION_REV);
3403 return version->string;
3404 }
3405
3406 unsigned int
3407 #if PROTOTYPES
3408 AtoU(char *str)
3409 #else
3410 AtoU(c)
3411 char *str;
3412 #endif
3413 {
3414 unsigned int v;
3415 int i;
3416 v = 0;
3417 for (i = 0; isdigit((int)str[i]); i++) {
3418 v *= 10;
3419 v += str[i] - '0';
3420 }
3421 return v;
3422 }
3423
3424 void
3425 #if PROTOTYPES
3426 StrCpy(char *dst, const char *src, unsigned int size)
3427 #else
3428 StrCpy(dst, src, size)
3429 char *dst;
3430 const char *src;
3431 unsigned int size;
3432 #endif
3433 {
3434 #ifdef HAVE_STRLCPY
3435 strlcpy(dst, src, size);
3436 #else
3437 strcpy(dst, src);
3438 #endif
3439 }
00 /*
1 * $Id: cutil.h,v 1.64 2006/01/15 17:10:14 bryan Exp $
1 * $Id: cutil.h,v 1.68 2006/04/07 15:47:20 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
110110 } SUBSTTOKEN;
111111
112112 typedef struct subst {
113 SUBSTTOKEN tokens[255];
113 /* function to retrieve a token type based on a character
114 */
115 SUBSTTOKEN (*token) PARAMS((char));
114116 /* data for callback function
115117 */
116118 void *data;
117119 /* function to retrieve a value (as a char* or int or both) for
118120 * a substitution
119121 */
120 int (*callback) PARAMS((char, char **, int *));
122 int (*value) PARAMS((char, char **, int *));
121123 } SUBST;
122124
123125 extern int isMultiProc, fDebug, fVerbose, fErrorPrinted;
188190 extern int FileCanWrite PARAMS((CONSFILE *, fd_set *, fd_set *));
189191 extern int FileBufEmpty PARAMS((CONSFILE *));
190192 extern int SetFlags PARAMS((int, int, int));
191 extern char *StrDup PARAMS((char *));
193 extern char *StrDup PARAMS((const char *));
192194 extern int ParseIACBuf PARAMS((CONSFILE *, void *, int *));
193195 extern void *MemMove PARAMS((void *, void *, size_t));
194196 extern char *StringChar PARAMS((STRING *, int, char));
196198 extern void ProbeInterfaces PARAMS((in_addr_t));
197199 extern void ProcessSubst
198200 PARAMS((SUBST *, char **, char **, char *, char *));
201 extern char *MyVersion PARAMS((void));
202 extern unsigned int AtoU PARAMS((char *));
203 extern void StrCpy PARAMS((char *, const char *, unsigned int));
199204 #if HAVE_OPENSSL
200205 extern SSL *FileGetSSL PARAMS((CONSFILE *));
201206 extern void FileSetSSL PARAMS((CONSFILE *, SSL *));
00 /*
1 * $Id: group.c,v 5.319 2005/11/28 20:46:08 bryan Exp $
1 * $Id: group.c,v 5.325 2006/04/07 15:47:20 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
6767 #include <client.h>
6868 #include <access.h>
6969 #include <group.h>
70 #include <version.h>
7170 #include <readcfg.h>
7271 #include <master.h>
7372 #include <main.h>
73 #include <version.h>
7474
7575 #if HAVE_PAM
7676 #include <security/pam_appl.h>
418418 DestroyString(pCL->peername);
419419 if (pCL->accmd != (STRING *)0)
420420 DestroyString(pCL->accmd);
421 if (pCL->msg != (STRING *)0)
422 DestroyString(pCL->msg);
423421 if (pCL->username != (STRING *)0)
424422 DestroyString(pCL->username);
425423 FileClose(&pCL->fd);
20842082 b = "Netwk";
20852083 p = ' ';
20862084 break;
2085 case NOOP:
2086 d = "NOOP";
2087 b = "NOOP";
2088 p = ' ';
2089 break;
2090 case UDS:
2091 d = pCE->uds;
2092 b = "UDS";
2093 p = ' ';
2094 break;
20872095 case UNKNOWNTYPE: /* shut up gcc */
20882096 break;
20892097 }
22582266 myHostname, (unsigned long)thepid, pGE->port);
22592267 switch (pCE->type) {
22602268 case EXEC:
2261 FilePrint(pCLServing->fd, FLAGTRUE, "|:%s,%lu,%s",
2269 FilePrint(pCLServing->fd, FLAGTRUE, "|:%s,%lu,%s,%d:",
22622270 (pCE->exec != (char *)0 ? pCE->exec : "/bin/sh"),
2263 (unsigned long)pCE->ipid, pCE->execSlave);
2271 (unsigned long)pCE->ipid, pCE->execSlave,
2272 FileFDNum(pCE->cofile));
22642273 break;
22652274 case HOST:
2266 FilePrint(pCLServing->fd, FLAGTRUE, "!:%s,%hu,%s",
2275 FilePrint(pCLServing->fd, FLAGTRUE, "!:%s,%hu,%s,%d:",
22672276 pCE->host, pCE->netport,
2268 (pCE->raw == FLAGTRUE ? "raw" : "telnet"));
2277 (pCE->raw == FLAGTRUE ? "raw" : "telnet"),
2278 FileFDNum(pCE->cofile));
2279 break;
2280 case NOOP:
2281 FileWrite(pCLServing->fd, FLAGTRUE, "#::", 3);
2282 break;
2283 case UDS:
2284 FilePrint(pCLServing->fd, FLAGTRUE, "%%:%s,%d:", pCE->uds,
2285 FileFDNum(pCE->cofile));
22692286 break;
22702287 case DEVICE:
2271 FilePrint(pCLServing->fd, FLAGTRUE, "/:%s,%s%c",
2288 FilePrint(pCLServing->fd, FLAGTRUE, "/:%s,%s%c,%d:",
22722289 pCE->device,
22732290 (pCE->baud ? pCE->baud->acrate : ""),
2274 (pCE->parity ? pCE->parity->key[0] : ' '));
2291 (pCE->parity ? pCE->parity->key[0] : ' '),
2292 FileFDNum(pCE->cofile));
22752293 break;
22762294 case UNKNOWNTYPE: /* shut up gcc */
22772295 break;
22782296 }
2279 FilePrint(pCLServing->fd, FLAGTRUE, ",%d:",
2280 FileFDNum(pCE->cofile));
22812297 if (pCE->pCLwr) {
22822298 FilePrint(pCLServing->fd, FLAGTRUE, "w@%s@%ld",
22832299 pCE->pCLwr->acid->string,
23502366 s = BuildTmpString(",autoreinit");
23512367 if (pCE->unloved == FLAGTRUE)
23522368 s = BuildTmpString(",unloved");
2369 if (pCE->login == FLAGTRUE)
2370 s = BuildTmpString(",login");
23532371 FilePrint(pCLServing->fd, FLAGFALSE, ":%s:%s:%d:%s\r\n",
23542372 (s == (char *)0 ? "" : s + 1),
23552373 (pCE->initcmd == (char *)0 ? "" : pCE->initcmd),
27962814 return n[cnt];
27972815 }
27982816
2817
2818 /* This routine is used to gather input from the
2819 * client and save it in the accmd string.
2820 * GatherLine returns 0 until the user signals
2821 * they're "done" (a \r), then it returns 1.
2822 */
2823 typedef enum gatherType {
2824 G_INT,
2825 G_TEXT
2826 } GATHERTYPE;
2827
2828 int
2829 #if PROTOTYPES
2830 GatherLine(char c, int limit, GATHERTYPE g, CONSCLIENT *pCL)
2831 #else
2832 GatherLine(c, pCL)
2833 char c;
2834 GATHERTYPE g;
2835 CONSCLIENT *pCL;
2836 #endif
2837 {
2838 if (c == '\r')
2839 return 1;
2840
2841 if ((limit <= 0 || pCL->accmd->used - 1 < limit) &&
2842 ((g == G_TEXT && (c == '\a' || (c >= ' ' && c <= '~'))) ||
2843 (g == G_INT && isdigit((int)c)))) {
2844 BuildStringChar(c, pCL->accmd);
2845 FileWrite(pCL->fd, FLAGFALSE, (char *)&c, 1);
2846 } else if ((c == '\b' || c == 0x7f)
2847 && pCL->accmd->used > 1) {
2848 if (pCL->accmd->string[pCL->accmd->used - 2] != '\a')
2849 FileWrite(pCL->fd, FLAGFALSE, "\b \b", 3);
2850 pCL->accmd->string[pCL->accmd->used - 2] = '\000';
2851 pCL->accmd->used--;
2852 } else if ((c == 0x15) && pCL->accmd->used > 1) {
2853 while (pCL->accmd->used > 1) {
2854 if (pCL->accmd->string[pCL->accmd->used - 2] != '\a')
2855 FileWrite(pCL->fd, FLAGFALSE, "\b \b", 3);
2856 pCL->accmd->string[pCL->accmd->used - 2] = '\000';
2857 pCL->accmd->used--;
2858 }
2859 }
2860 return 0;
2861 }
2862
27992863 void
28002864 #if PROTOTYPES
28012865 DoClientRead(GRPENT *pGE, CONSCLIENT *pCLServing)
30213085 if (pCLServing->fro == -1) {
30223086 FilePrint(pCLServing->fd, FLAGFALSE,
30233087 "%s: permission denied\r\n", pcArgs);
3088 DisconnectClient(pGE, pCLServing, (char *)0,
3089 FLAGFALSE);
3090 return;
3091 }
3092
3093 if (pCEwant->login != FLAGTRUE) {
3094 if (pCEwant->motd == (char *)0) {
3095 FilePrint(pCLServing->fd, FLAGFALSE,
3096 "%s: no logins allowed at this time\r\n",
3097 pcArgs);
3098 } else {
3099 FilePrint(pCLServing->fd, FLAGFALSE,
3100 "%s: %s\r\n", pcArgs,
3101 pCEwant->motd);
3102 }
30243103 DisconnectClient(pGE, pCLServing, (char *)0,
30253104 FLAGFALSE);
30263105 return;
31873266 case S_PASSWD:
31883267 /* these are not used in this mode */
31893268 break;
3269
31903270 case S_BCAST:
3191 /* gather message */
3192 if ('\r' != acIn[i]) {
3193 if (acIn[i] == '\a' ||
3194 (acIn[i] >= ' ' && acIn[i] <= '~')) {
3195 BuildStringChar(acIn[i], pCLServing->msg);
3196 if (pGE->pCEctl != pCEServing)
3271 if (GatherLine(acIn[i], 0, G_TEXT, pCLServing)) {
3272 FileWrite(pCLServing->fd, FLAGFALSE, "]\r\n",
3273 3);
3274 BuildString((char *)0, bcast);
3275 BuildStringChar('[', bcast);
3276 BuildString(pCLServing->acid->string, bcast);
3277 BuildString(": ", bcast);
3278 BuildString(pCLServing->accmd->string, bcast);
3279 BuildString("]\r\n", bcast);
3280 SendClientsMsg(pCEServing, bcast->string);
3281
3282 BuildString((char *)0, pCLServing->accmd);
3283 pCLServing->iState = S_NORMAL;
3284 }
3285 continue;
3286
3287 case S_REPLAY:
3288 case S_PLAYBACK:
3289 if (GatherLine(acIn[i], 4, G_INT, pCLServing)) {
3290 unsigned short *s;
3291
3292 if (pCLServing->iState == S_REPLAY)
3293 s = &(pCLServing->replay);
3294 else
3295 s = &(pCLServing->playback);
3296
3297 if (pCLServing->accmd->used > 1) {
3298 unsigned short u;
3299 u = (unsigned short)atoi(pCLServing->
3300 accmd->string);
3301 /* i'm limiting the value here to 10000 for a couple
3302 * of reasons:
3303 *
3304 * 1. this process could be busy parsing a file for
3305 * a long time if the logfile and replay are big.
3306 * 2. who needs more than 10000 lines of replay? if
3307 * you need that much, go find the raw logfile.
3308 * and if you don't have access, find someone who
3309 * does.
3310 *
3311 * change this to something bigger if you want, but
3312 * it would scare me...even 10000 seems a bit large,
3313 * but no one *has* to set the value so large.
3314 * and watch out...it's an unsigned short, so you
3315 * can't go really huge.
3316 */
3317 if (u > 10000)
31973318 FileWrite(pCLServing->fd, FLAGFALSE,
3198 (char *)&acIn[i], 1);
3199 } else if ((acIn[i] == '\b' || acIn[i] == 0x7f)
3200 && pCLServing->msg->used > 1) {
3201 if (pCLServing->msg->
3202 string[pCLServing->msg->used - 2] !=
3203 '\a' && pGE->pCEctl != pCEServing) {
3204 FileWrite(pCLServing->fd, FLAGFALSE,
3205 "\b \b", 3);
3206 }
3207 pCLServing->msg->string[pCLServing->msg->
3208 used - 2] = '\000';
3209 pCLServing->msg->used--;
3210 } else if ((acIn[i] == 0x15) &&
3211 pCLServing->msg->used > 1) {
3212 while (pCLServing->msg->used > 1) {
3213 if (pCLServing->msg->
3214 string[pCLServing->msg->used -
3215 2] != '\a' &&
3216 pGE->pCEctl != pCEServing) {
3217 FileWrite(pCLServing->fd,
3218 FLAGFALSE, "\b \b", 3);
3219 }
3220 pCLServing->msg->string[pCLServing->
3221 msg->used -
3222 2] = '\000';
3223 pCLServing->msg->used--;
3224 }
3225 }
3226 continue;
3319 " <value too large>", 18);
3320 else
3321 *s = u;
3322 } else
3323 FilePrint(pCLServing->fd, FLAGFALSE, "%u",
3324 *s);
3325
3326 FileWrite(pCLServing->fd, FLAGFALSE, "]\r\n",
3327 3);
3328 pCLServing->iState = S_NORMAL;
32273329 }
3228 FileWrite(pCLServing->fd, FLAGFALSE, "]\r\n", 3);
3229 BuildString((char *)0, bcast);
3230 BuildStringChar('[', bcast);
3231 BuildString(pCLServing->acid->string, bcast);
3232 BuildString(": ", bcast);
3233 BuildString(pCLServing->msg->string, bcast);
3234 BuildString("]\r\n", bcast);
3235 SendClientsMsg(pCEServing, bcast->string);
3236
3237 BuildString((char *)0, pCLServing->msg);
3238 pCLServing->iState = S_NORMAL;
32393330 continue;
32403331
32413332 case S_QUOTE: /* send octal code */
34853576 "no drop line]\r\n", -1);
34863577 break;
34873578
3488 #define DEPRECATED FileWrite(pCLServing->fd, FLAGFALSE, "<use of DEPRECATED (and undocumented) key> ", -1)
3489 case 'B':
3490 DEPRECATED;
3491 case 'b': /* broadcast message */
3492 FileWrite(pCLServing->fd, FLAGFALSE,
3493 "Enter message: ", -1);
3494 pCLServing->iState = S_BCAST;
3495 break;
3496
3497 case 'A':
3498 DEPRECATED;
34993579 case 'a': /* attach */
35003580 CommandAttach(pGE, pCLServing, pCEServing,
35013581 tyme);
35023582 break;
35033583
3504 case 'C':
3505 DEPRECATED;
3584 case 'b': /* broadcast message */
3585 FileWrite(pCLServing->fd, FLAGFALSE,
3586 "Enter message: ", -1);
3587 BuildString((char *)0, pCLServing->accmd);
3588 pCLServing->iState = S_BCAST;
3589 break;
3590
35063591 case 'c':
35073592 CommandChangeFlow(pGE, pCLServing,
35083593 pCEServing, tyme);
35093594 break;
35103595
3511 case 'D':
3512 DEPRECATED;
35133596 case 'd': /* down a console */
35143597 CommandDown(pGE, pCLServing, pCEServing,
35153598 tyme);
35163599 break;
35173600
3518 case 'E':
3519 DEPRECATED;
35203601 case 'e': /* redefine escape keys */
35213602 pCLServing->iState = S_CATTN;
35223603 FileWrite(pCLServing->fd, FLAGFALSE,
35233604 "redef: ", -1);
35243605 break;
35253606
3526 case 'F':
3527 DEPRECATED;
35283607 case 'f': /* force attach */
35293608 CommandForce(pGE, pCLServing, pCEServing,
35303609 tyme);
35313610 break;
35323611
3533 case 'G':
3534 DEPRECATED;
35353612 case 'g': /* group info */
35363613 FilePrint(pCLServing->fd, FLAGFALSE,
35373614 "group %s]\r\n",
35403617 tyme, (char *)0);
35413618 break;
35423619
3543 case 'H':
3544 case 'P': /* DEC vt100 pf1 */
3545 DEPRECATED;
35463620 case 'h': /* help */
35473621 case '?':
35483622 HelpUser(pCLServing);
35493623 break;
35503624
3551 case 'I':
3552 DEPRECATED;
35533625 case 'i':
35543626 FileWrite(pCLServing->fd, FLAGFALSE,
35553627 "info]\r\n", -1);
35843656 pCEServing->motd);
35853657 break;
35863658
3587 case 'O':
3588 DEPRECATED;
35893659 case 'o': /* close and re-open line */
35903660 CommandOpen(pGE, pCLServing, pCEServing,
35913661 tyme);
3662 break;
3663
3664 case 'P': /* broadcast message */
3665 FilePrint(pCLServing->fd, FLAGFALSE,
3666 "set playback (%d): ",
3667 pCLServing->playback);
3668 BuildString((char *)0, pCLServing->accmd);
3669 pCLServing->iState = S_PLAYBACK;
3670 break;
3671
3672 case 'p': /* replay lines (longer, in theory) */
3673 FileWrite(pCLServing->fd, FLAGFALSE,
3674 "playback]\r\n", -1);
3675 Replay(pCEServing, pCLServing->fd,
3676 pCLServing->playback);
35923677 break;
35933678
35943679 case '\022': /* ^R */
35973682 Replay(pCEServing, pCLServing->fd, 1);
35983683 break;
35993684
3600 case 'R': /* DEC vt100 pf3 */
3601 DEPRECATED;
3602 case 'r': /* replay 20 lines */
3685 case 'R': /* broadcast message */
3686 FilePrint(pCLServing->fd, FLAGFALSE,
3687 "set replay (%d): ",
3688 pCLServing->replay);
3689 BuildString((char *)0, pCLServing->accmd);
3690 pCLServing->iState = S_REPLAY;
3691 break;
3692
3693 case 'r': /* replay lines */
36033694 FileWrite(pCLServing->fd, FLAGFALSE,
36043695 "replay]\r\n", -1);
3605 Replay(pCEServing, pCLServing->fd, 20);
3696 Replay(pCEServing, pCLServing->fd,
3697 pCLServing->replay);
36063698 break;
36073699
3608 case 'p': /* replay 60 lines */
3609 FileWrite(pCLServing->fd, FLAGFALSE,
3610 "long replay]\r\n", -1);
3611 Replay(pCEServing, pCLServing->fd, 60);
3612 break;
3613
3614 case 'S': /* DEC vt100 pf4 */
3615 DEPRECATED;
36163700 case 's': /* spy mode */
36173701 pCLServing->fwantwr = 0;
36183702 if (!pCLServing->fwr) {
36283712 "spying]\r\n", -1);
36293713 break;
36303714
3631 case 'U':
3632 DEPRECATED;
36333715 case 'u': /* hosts on server this */
36343716 FileWrite(pCLServing->fd, FLAGFALSE,
36353717 "hosts]\r\n", -1);
36373719 tyme, (char *)0);
36383720 break;
36393721
3640 case 'V':
3641 DEPRECATED;
36423722 case 'v': /* version */
36433723 FilePrint(pCLServing->fd, FLAGFALSE,
36443724 "version `%s']\r\n",
3645 THIS_VERSION);
3725 MyVersion());
36463726 break;
36473727
3648 case 'W':
3649 DEPRECATED;
36503728 case 'w': /* who */
36513729 FilePrint(pCLServing->fd, FLAGFALSE,
36523730 "who %s]\r\n",
36553733 tyme);
36563734 break;
36573735
3658 case 'X':
3659 DEPRECATED;
36603736 case 'x':
36613737 FileWrite(pCLServing->fd, FLAGFALSE,
36623738 "examine]\r\n", -1);
36643740 tyme, (char *)0);
36653741 break;
36663742
3667 case '|': /* wait for client */
3668 if (ConsentUserOk
3669 (pLUList,
3670 pCLServing->username->string) == 1)
3671 goto unknownchar;
3672 if (!pCLServing->fwr) {
3673 FileWrite(pCLServing->fd, FLAGFALSE,
3674 "attach to run local command]\r\n",
3675 -1);
3676 continue;
3677 }
3678 FileSetQuoteIAC(pCLServing->fd, FLAGFALSE);
3679 FilePrint(pCLServing->fd, FLAGFALSE,
3680 "%c%c", OB_IAC, OB_EXEC);
3681 FileSetQuoteIAC(pCLServing->fd, FLAGTRUE);
3682 pCLServing->fcon = 0;
3683 pCLServing->iState = S_CWAIT;
3684 break;
3685
3686 case 'Z':
3687 DEPRECATED;
36883743 case 'z': /* suspend the client */
36893744 case '\032':
36903745 if (ConsentUserOk
37083763 }
37093764 break;
37103765
3766 case '|': /* wait for client */
3767 if (ConsentUserOk
3768 (pLUList,
3769 pCLServing->username->string) == 1)
3770 goto unknownchar;
3771 if (!pCLServing->fwr) {
3772 FileWrite(pCLServing->fd, FLAGFALSE,
3773 "attach to run local command]\r\n",
3774 -1);
3775 continue;
3776 }
3777 FileSetQuoteIAC(pCLServing->fd, FLAGFALSE);
3778 FilePrint(pCLServing->fd, FLAGFALSE,
3779 "%c%c", OB_IAC, OB_EXEC);
3780 FileSetQuoteIAC(pCLServing->fd, FLAGTRUE);
3781 pCLServing->fcon = 0;
3782 pCLServing->iState = S_CWAIT;
3783 break;
3784
37113785 case '\t': /* toggle tab expand */
37123786 if (!pCLServing->fwr) {
37133787 FileWrite(pCLServing->fd, FLAGFALSE,
37293803 "failed]\r\n", -1);
37303804 continue;
37313805 }
3732 # if !defined(XTABS) /* XXX hack */
3733 # define XTABS TAB3
3734 # endif
3735 if (XTABS == (TABDLY & sbuf.c_oflag)) {
3806 if (TAB3 == (TABDLY & sbuf.c_oflag)) {
37363807 sbuf.c_oflag &= ~TABDLY;
37373808 sbuf.c_oflag |= TAB0;
37383809 } else {
37393810 sbuf.c_oflag &= ~TABDLY;
3740 sbuf.c_oflag |= XTABS;
3811 sbuf.c_oflag |= TAB3;
37413812 }
37423813 if (-1 ==
37433814 tcsetattr(FileFDNum
37473818 "failed]\r\n", -1);
37483819 continue;
37493820 }
3750 if (XTABS == (TABDLY & sbuf.c_oflag))
3821 if (TAB3 == (TABDLY & sbuf.c_oflag))
37513822 FileWrite(pCLServing->fd, FLAGFALSE,
37523823 "tabs OFF]\r\n", -1);
37533824 else
37553826 "tabs ON]\r\n", -1);
37563827 break;
37573828
3758 case 'Q': /* DEC vt100 PF2 */
3759 DEPRECATED;
37603829 case '.': /* disconnect */
37613830 case '\004':
37623831 case '\003':
37903859 pCLServing->iState = S_QUOTE;
37913860 FileWrite(pCLServing->fd, FLAGFALSE,
37923861 "quote \\", -1);
3862 break;
3863
3864 case 0xD6: /* 'v' with high bit set */
3865 /* this is really just used "behind the scenes",
3866 * but of someone wants to type it, fine...we
3867 * just need a way to query the server for what
3868 * version it is so the client can determine
3869 * functionality
3870 */
3871 FilePrint(pCLServing->fd, FLAGFALSE,
3872 "%u]\r\n", VERSION_UINT);
37933873 break;
37943874
37953875 default: /* unknown sequence */
41894269 pGE->pCLfree->username = AllocString();
41904270 pGE->pCLfree->peername = AllocString();
41914271 pGE->pCLfree->accmd = AllocString();
4192 pGE->pCLfree->msg = AllocString();
41934272
41944273 /* on a SIGHUP we should close and reopen our log files and
41954274 * reread the config file
43844463 /* anything on a console? */
43854464 for (pCEServing = pGE->pCElist; pCEServing != (CONSENT *)0;
43864465 pCEServing = pCEServing->pCEnext) {
4387 if (!pCEServing->fup)
4466 if (!pCEServing->fup || pCEServing->type == NOOP)
43884467 continue;
43894468 switch (pCEServing->ioState) {
43904469 case INCONNECT:
46294708 BuildString("<unknown>@", pCL->acid);
46304709 BuildString((char *)0, pCL->username);
46314710 BuildString("<unknown>", pCL->username);
4632 strcpy(pCL->actym, StrTime(&(pCL->tym)));
4711 StrCpy(pCL->actym, StrTime(&(pCL->tym)), sizeof(pCL->actym));
46334712 pCL->typetym = pCL->tym;
46344713
46354714 /* link into the control list for the dummy console
46614740 pCL->iState = S_IDENT;
46624741 pCL->ic[0] = DEFATTN;
46634742 pCL->ic[1] = DEFESC;
4743 pCL->replay = DEFREPLAY;
4744 pCL->playback = DEFPLAYBACK;
46644745 BuildString((char *)0, pCL->accmd);
46654746
46664747 /* mark as stopped (no output from console)
46824763 pGE->pCLfree->username = AllocString();
46834764 pGE->pCLfree->peername = AllocString();
46844765 pGE->pCLfree->accmd = AllocString();
4685 pGE->pCLfree->msg = AllocString();
46864766 }
46874767
46884768 if (ClientAccessOk(pCL)) {
47404820 Error("Spawn(): path to socket too long: %s", portPath->string);
47414821 Bye(EX_OSERR);
47424822 }
4743 strcpy(lstn_port.sun_path, portPath->string);
4823 StrCpy(lstn_port.sun_path, portPath->string,
4824 sizeof(lstn_port.sun_path));
47444825
47454826 /* create a socket to listen on
47464827 * (prepared by master so he can see the port number of the kid)
00 /*
1 * $Id: group.h,v 5.48 2005/05/21 17:56:14 bryan Exp $
1 * $Id: group.h,v 5.49 2006/04/07 15:36:09 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
8181 extern int CheckPasswd PARAMS((CONSCLIENT *, char *));
8282 extern void DeUtmp PARAMS((GRPENT *, int));
8383 extern void ClientWantsWrite PARAMS((CONSCLIENT *));
84 extern void SendIWaitClientsMsg PARAMS((CONSENT *, char *));
8485 #if HAVE_OPENSSL
8586 extern int AttemptSSL PARAMS((CONSCLIENT *));
8687 #endif
00 /*
1 * $Id: main.c,v 5.196 2005/06/11 02:31:05 bryan Exp $
1 * $Id: main.c,v 5.200 2006/04/03 13:32:08 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
417417 close(2);
418418 dup(1);
419419 if (isMaster && tag) {
420 Msg("%s", THIS_VERSION);
421 Msg("%s", startedMsg->string);
420 Msg(MyVersion());
421 Msg(startedMsg->string);
422422 }
423423 tag = 0;
424424 }
618618
619619 isMultiProc = 0;
620620
621 Msg("%s", THIS_VERSION);
621 Msg(MyVersion());
622622 Msg("default access type `%c'", defConfig.defaultaccess);
623623 Msg("default escape sequence `%s%s'", FmtCtl(DEFATTN, acA1),
624624 FmtCtl(DEFESC, acA2));
912912 EMPTYSTR(pCE->host), FLAGSTR(pCE->raw),
913913 pCE->netport, pCE->port, pCE->telnetState));
914914 break;
915 case NOOP:
916 CONDDEBUG((1,
917 "DumpDataStructures(): server=%s, type=NOOP",
918 EMPTYSTR(pCE->server)));
919 break;
920 case UDS:
921 CONDDEBUG((1,
922 "DumpDataStructures(): server=%s, type=UDS",
923 EMPTYSTR(pCE->server)));
924 CONDDEBUG((1, "DumpDataStructures(): uds=%s",
925 EMPTYSTR(pCE->uds)));
926 break;
915927 case UNKNOWNTYPE:
916928 CONDDEBUG((1,
917929 "DumpDataStructures(): server=%s, type=UNKNOWNTYPE",
952964 CONDDEBUG((1,
953965 "DumpDataStructures(): reinitoncc=%s, striphigh=%s",
954966 FLAGSTR(pCE->reinitoncc), FLAGSTR(pCE->striphigh)));
955 CONDDEBUG((1, "DumpDataStructures(): unloved=%s",
956 FLAGSTR(pCE->unloved)));
967 CONDDEBUG((1, "DumpDataStructures(): unloved=%s, login=%s",
968 FLAGSTR(pCE->unloved), FLAGSTR(pCE->login)));
957969 CONDDEBUG((1,
958970 "DumpDataStructures(): initpid=%lu, initcmd=%s, initfile=%d",
959971 (unsigned long)pCE->initpid, EMPTYSTR(pCE->initcmd),
12711283 Bye(EX_OK);
12721284 }
12731285
1274 Msg("%s", THIS_VERSION);
1286 Msg(MyVersion());
12751287
12761288 #if HAVE_GETLOGIN
12771289 origuser = getlogin();
00 /*
1 * $Id: master.c,v 5.132 2005/09/05 22:22:53 bryan Exp $
1 * $Id: master.c,v 5.135 2006/04/07 15:47:20 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
3535 #include <access.h>
3636 #include <master.h>
3737 #include <readcfg.h>
38 #include <version.h>
3938 #include <main.h>
4039
4140
614613 } else if (pCLServing->iState == S_NORMAL &&
615614 strcmp(pcCmd, "version") == 0) {
616615 FilePrint(pCLServing->fd, FLAGFALSE, "version `%s'\r\n",
617 THIS_VERSION);
616 MyVersion());
618617 } else if (pCLServing->iState == S_NORMAL &&
619618 strcmp(pcCmd, "quit") == 0) {
620619 if (ConsentUserOk(pADList, pCLServing->username->string) ==
783782 Error("Master(): path to socket too long: %s", portPath->string);
784783 return;
785784 }
786 strcpy(master_port.sun_path, portPath->string);
785 StrCpy(master_port.sun_path, portPath->string,
786 sizeof(master_port.sun_path));
787787
788788 if ((msfd = socket(AF_UNIX, SOCK_STREAM, 0)) < 0) {
789789 Error("Master(): socket(AF_UNIX,SOCK_STREAM): %s",
00 /*
1 * $Id: readcfg.c,v 5.189 2005/09/05 21:55:49 bryan Exp $
1 * $Id: readcfg.c,v 5.192 2006/03/20 16:47:03 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
566566 free(c->server);
567567 if (c->host != (char *)0)
568568 free(c->host);
569 if (c->uds != (char *)0)
570 free(c->uds);
571 if (c->udssubst != (char *)0)
572 free(c->udssubst);
569573 if (c->master != (char *)0)
570574 free(c->master);
571575 if (c->exec != (char *)0)
692696 c->autoreinit = d->autoreinit;
693697 if (d->unloved != FLAGUNKNOWN)
694698 c->unloved = d->unloved;
699 if (d->login != FLAGUNKNOWN)
700 c->login = d->login;
695701 if (d->host != (char *)0) {
696702 if (c->host != (char *)0)
697703 free(c->host);
698704 if ((c->host = StrDup(d->host)) == (char *)0)
705 OutOfMem();
706 }
707 if (d->uds != (char *)0) {
708 if (c->uds != (char *)0)
709 free(c->uds);
710 if ((c->uds = StrDup(d->uds)) == (char *)0)
711 OutOfMem();
712 }
713 if (d->udssubst != (char *)0) {
714 if (c->udssubst != (char *)0)
715 free(c->udssubst);
716 if ((c->udssubst = StrDup(d->udssubst)) == (char *)0)
699717 OutOfMem();
700718 }
701719 if (d->master != (char *)0) {
952970
953971 int
954972 #if PROTOTYPES
955 SubstCallback(char c, char **s, int *i)
956 #else
957 SubstCallback(c, s, i)
973 SubstValue(char c, char **s, int *i)
974 #else
975 SubstValue(c, s, i)
958976 char c;
959977 char **s;
960978 int *i;
961979 #endif
962980 {
963981 int retval = 0;
964
965 if (substData == (SUBST *)0) {
966 if ((substData = (SUBST *)calloc(1, sizeof(SUBST))) == (SUBST *)0)
967 OutOfMem();
968 substData->callback = &SubstCallback;
969 substData->tokens['p'] = ISNUMBER;
970 substData->tokens['P'] = ISNUMBER;
971 substData->tokens['h'] = ISSTRING;
972 substData->tokens['c'] = ISSTRING;
973 }
974982
975983 if (s != (char **)0) {
976984 CONSENT *pCE;
10041012 return retval;
10051013 }
10061014
1015 int substTokenCount[255];
1016
1017 int
1018 #if PROTOTYPES
1019 SubstTokenCount(char c)
1020 #else
1021 SubstTokenCount(c)
1022 char c;
1023 #endif
1024 {
1025 return substTokenCount[(unsigned)c];
1026 }
1027
1028 void
1029 #if PROTOTYPES
1030 ZeroSubstTokenCount(void)
1031 #else
1032 ZeroSubstTokenCount()
1033 #endif
1034 {
1035 #if HAVE_MEMSET
1036 memset((void *)&substTokenCount, 0, sizeof(substTokenCount));
1037 #else
1038 bzero((char *)&substTokenCount, sizeof(substTokenCount));
1039 #endif
1040 }
1041
1042 SUBSTTOKEN
1043 #if PROTOTYPES
1044 SubstToken(char c)
1045 #else
1046 SubstToken(c)
1047 char c;
1048 #endif
1049 {
1050 switch (c) {
1051 case 'p':
1052 case 'P':
1053 substTokenCount[(unsigned)c]++;
1054 return ISNUMBER;
1055 case 'h':
1056 case 'c':
1057 substTokenCount[(unsigned)c]++;
1058 return ISSTRING;
1059 default:
1060 return ISNOTHING;
1061 }
1062 }
1063
1064 void
1065 #if PROTOTYPES
1066 InitSubstCallback(void)
1067 #else
1068 InitSubstCallback()
1069 #endif
1070 {
1071 if (substData == (SUBST *)0) {
1072 if ((substData = (SUBST *)calloc(1, sizeof(SUBST))) == (SUBST *)0)
1073 OutOfMem();
1074 substData->value = &SubstValue;
1075 substData->token = &SubstToken;
1076 ZeroSubstTokenCount();
1077 }
1078 }
1079
10071080 void
10081081 #if PROTOTYPES
10091082 DefaultItemDevicesubst(char *id)
10281101 CONDDEBUG((1, "DefaultItemExecsubst(%s) [%s:%d]", id, file, line));
10291102 ProcessSubst(substData, (char **)0, &(parserDefaultTemp->execsubst),
10301103 "execsubst", id);
1104 }
1105
1106 void
1107 #if PROTOTYPES
1108 DefaultItemUdssubst(char *id)
1109 #else
1110 DefaultItemUdssubst(id)
1111 char *id;
1112 #endif
1113 {
1114 CONDDEBUG((1, "DefaultItemUdssubst(%s) [%s:%d]", id, file, line));
1115 ProcessSubst(substData, (char **)0, &(parserDefaultTemp->udssubst),
1116 "udssubst", id);
10311117 }
10321118
10331119 void
12561342
12571343 void
12581344 #if PROTOTYPES
1345 ProcessUds(CONSENT *c, char *id)
1346 #else
1347 ProcessUds(c, id)
1348 CONSENT *c;
1349 char *id;
1350 #endif
1351 {
1352 if (c->uds != (char *)0) {
1353 free(c->uds);
1354 c->uds = (char *)0;
1355 }
1356 if ((id == (char *)0) || (*id == '\000'))
1357 return;
1358 if ((c->uds = StrDup(id))
1359 == (char *)0)
1360 OutOfMem();
1361 }
1362
1363 void
1364 #if PROTOTYPES
1365 DefaultItemUds(char *id)
1366 #else
1367 DefaultItemUds(id)
1368 char *id;
1369 #endif
1370 {
1371 CONDDEBUG((1, "DefaultItemUds(%s) [%s:%d]", id, file, line));
1372 ProcessUds(parserDefaultTemp, id);
1373 }
1374
1375 void
1376 #if PROTOTYPES
12591377 ProcessInclude(CONSENT *c, char *id)
12601378 #else
12611379 ProcessInclude(c, id)
15361654 c->reinitoncc = FLAGUNKNOWN;
15371655 c->autoreinit = FLAGUNKNOWN;
15381656 c->unloved = FLAGUNKNOWN;
1657 c->login = FLAGUNKNOWN;
15391658 return;
15401659 }
15411660
15711690 c->autoreinit = negative ? FLAGFALSE : FLAGTRUE;
15721691 else if (strcasecmp("unloved", token) == 0)
15731692 c->unloved = negative ? FLAGFALSE : FLAGTRUE;
1693 else if (strcasecmp("login", token) == 0)
1694 c->login = negative ? FLAGFALSE : FLAGTRUE;
15741695 else if (isMaster)
15751696 Error("invalid option `%s' [%s:%d]", token, file, line);
15761697 }
21632284 t = EXEC;
21642285 else if (strcasecmp("host", id) == 0)
21652286 t = HOST;
2287 else if (strcasecmp("noop", id) == 0)
2288 t = NOOP;
2289 else if (strcasecmp("uds", id) == 0)
2290 t = UDS;
21662291 if (t == UNKNOWNTYPE) {
21672292 if (isMaster)
21682293 Error("invalid console type `%s' [%s:%d]", id, file, line);
22212346 OutOfMem();
22222347 }
22232348
2349 /* returns 1 if there's an error, otherwise 0 */
2350 int
2351 #if PROTOTYPES
2352 CheckSubst(char *label, char *subst)
2353 #else
2354 CheckSubst(label, subst)
2355 char *label;
2356 char *subst;
2357 #endif
2358 {
2359 int invalid = 0;
2360
2361 ZeroSubstTokenCount();
2362 ProcessSubst(substData, (char **)0, (char **)0, label, subst);
2363
2364 if (SubstTokenCount('p') && parserConsoleTemp->port == 0) {
2365 if (isMaster)
2366 Error
2367 ("[%s] console references 'port' in '%s' without defining 'port' attribute (ignoring %s) [%s:%d]",
2368 parserConsoleTemp->server, label, label, file, line);
2369 invalid = 1;
2370 }
2371
2372 if (SubstTokenCount('h') && parserConsoleTemp->host == (char *)0) {
2373 if (isMaster)
2374 Error
2375 ("[%s] console references 'host' in '%s' without defining 'host' attribute (ignoring %s) [%s:%d]",
2376 parserConsoleTemp->server, label, label, file, line);
2377 invalid = 1;
2378 }
2379
2380 return invalid;
2381 }
2382
22242383 void
22252384 #if PROTOTYPES
22262385 ConsoleEnd(void)
22442403 switch (parserConsoleTemp->type) {
22452404 case EXEC:
22462405 if (parserConsoleTemp->execsubst != (char *)0) {
2247 if (parserConsoleTemp->port == 0 ||
2248 parserConsoleTemp->host == (char *)0) {
2249 if (parserConsoleTemp->port == 0) {
2250 if (isMaster)
2251 Error
2252 ("[%s] console has 'execsubst' attribute without 'port' attribute (ignoring) [%s:%d]",
2253 parserConsoleTemp->server, file, line);
2254 }
2255 if (parserConsoleTemp->host == (char *)0) {
2256 if (isMaster)
2257 Error
2258 ("[%s] console has 'execsubst' attribute without 'host' attribute (ignoring) [%s:%d]",
2259 parserConsoleTemp->server, file, line);
2260 }
2406 if (CheckSubst("execsubst", parserConsoleTemp->execsubst)) {
22612407 free(parserConsoleTemp->execsubst);
22622408 parserConsoleTemp->execsubst = (char *)0;
22632409 }
22712417 parserConsoleTemp->server, file, line);
22722418 invalid = 1;
22732419 }
2274 if (parserConsoleTemp->devicesubst != (char *)0) {
2275 if (parserConsoleTemp->port == 0 ||
2276 parserConsoleTemp->host == (char *)0) {
2277 if (parserConsoleTemp->port == 0) {
2278 if (isMaster)
2279 Error
2280 ("[%s] console has 'devicesubst' attribute without 'port' attribute (ignoring) [%s:%d]",
2281 parserConsoleTemp->server, file, line);
2282 }
2283 if (parserConsoleTemp->host == (char *)0) {
2284 if (isMaster)
2285 Error
2286 ("[%s] console has 'devicesubst' attribute without 'host' attribute (ignoring) [%s:%d]",
2287 parserConsoleTemp->server, file, line);
2288 }
2289 free(parserConsoleTemp->devicesubst);
2290 parserConsoleTemp->devicesubst = (char *)0;
2291 }
2292 }
22932420 if (parserConsoleTemp->baud == (BAUD *)0) {
22942421 if (isMaster)
22952422 Error("[%s] console missing 'baud' attribute [%s:%d]",
23022429 ("[%s] console missing 'parity' attribute [%s:%d]",
23032430 parserConsoleTemp->server, file, line);
23042431 invalid = 1;
2432 }
2433 if (parserConsoleTemp->devicesubst != (char *)0) {
2434 if (CheckSubst
2435 ("devicesubst", parserConsoleTemp->devicesubst)) {
2436 free(parserConsoleTemp->devicesubst);
2437 parserConsoleTemp->devicesubst = (char *)0;
2438 }
23052439 }
23062440 break;
23072441 case HOST:
23182452 invalid = 1;
23192453 }
23202454 break;
2455 case NOOP:
2456 break;
2457 case UDS:
2458 if (parserConsoleTemp->uds == (char *)0) {
2459 if (isMaster)
2460 Error("[%s] console missing 'uds' attribute [%s:%d]",
2461 parserConsoleTemp->server, file, line);
2462 invalid = 1;
2463 }
2464 if (parserConsoleTemp->udssubst != (char *)0) {
2465 if (CheckSubst("udssubst", parserConsoleTemp->udssubst)) {
2466 free(parserConsoleTemp->udssubst);
2467 parserConsoleTemp->udssubst = (char *)0;
2468 }
2469 }
2470 break;
23212471 case UNKNOWNTYPE:
23222472 if (isMaster)
23232473 Error("[%s] console type unknown [%s:%d]",
23272477 }
23282478 if (parserConsoleTemp->initsubst != (char *)0 &&
23292479 parserConsoleTemp->initcmd != (char *)0) {
2330 if (parserConsoleTemp->port == 0 ||
2331 parserConsoleTemp->host == (char *)0) {
2332 if (parserConsoleTemp->port == 0) {
2333 if (isMaster)
2334 Error
2335 ("[%s] console has 'initsubst' attribute without 'port' attribute (ignoring) [%s:%d]",
2336 parserConsoleTemp->server, file, line);
2337 }
2338 if (parserConsoleTemp->host == (char *)0) {
2339 if (isMaster)
2340 Error
2341 ("[%s] console has 'initsubst' attribute without 'host' attribute (ignoring) [%s:%d]",
2342 parserConsoleTemp->server, file, line);
2343 }
2480 if (CheckSubst("initsubst", parserConsoleTemp->initsubst)) {
23442481 free(parserConsoleTemp->initsubst);
23452482 parserConsoleTemp->initsubst = (char *)0;
23462483 }
28202957 closeMatch = 0;
28212958 }
28222959 break;
2960 case NOOP:
2961 break;
2962 case UDS:
2963 if (pCEmatch->uds != (char *)0 && c->uds != (char *)0) {
2964 if (strcasecmp(pCEmatch->uds, c->uds) != 0) {
2965 SwapStr(&pCEmatch->uds, &c->uds);
2966 closeMatch = 0;
2967 }
2968 } else if (pCEmatch->uds != (char *)0 ||
2969 c->uds != (char *)0) {
2970 SwapStr(&pCEmatch->uds, &c->uds);
2971 closeMatch = 0;
2972 }
2973 break;
28232974 case UNKNOWNTYPE:
28242975 break;
28252976 }
28543005 pCEmatch->reinitoncc = c->reinitoncc;
28553006 pCEmatch->autoreinit = c->autoreinit;
28563007 pCEmatch->unloved = c->unloved;
3008 pCEmatch->login = c->login;
28573009 pCEmatch->inituid = c->inituid;
28583010 pCEmatch->initgid = c->initgid;
28593011 while (pCEmatch->aliases != (NAMES *)0) {
29683120 */
29693121 c->netport = c->portbase + c->portinc * c->port;
29703122
3123 /* prepare for substitutions */
29713124 substData->data = (void *)c;
3125
29723126 /* check for substitutions */
29733127 if (c->type == DEVICE && c->devicesubst != (char *)0)
29743128 ProcessSubst(substData, &(c->device), (char **)0, (char *)0,
29773131 if (c->type == EXEC && c->execsubst != (char *)0)
29783132 ProcessSubst(substData, &(c->exec), (char **)0, (char *)0,
29793133 c->execsubst);
3134
3135 if (c->type == UDS && c->udssubst != (char *)0)
3136 ProcessSubst(substData, &(c->uds), (char **)0, (char *)0,
3137 c->udssubst);
29803138
29813139 if (c->initcmd != (char *)0 && c->initsubst != (char *)0)
29823140 ProcessSubst(substData, &(c->initcmd), (char **)0, (char *)0,
30323190 c->striphigh = FLAGFALSE;
30333191 if (c->unloved == FLAGUNKNOWN)
30343192 c->unloved = FLAGFALSE;
3193 if (c->login == FLAGUNKNOWN)
3194 c->login = FLAGTRUE;
3195
3196 /* set some forced options, based on situations */
3197 if (c->type == NOOP) {
3198 c->login = FLAGFALSE;
3199 ProcessLogfile(c, (char *)0);
3200 }
30353201
30363202 /* now let command-line args override things */
30373203 if (fNoautoreup)
30473213
30483214 /* now remember where we're headed and do the dirty work */
30493215 cNext = c->pCEnext;
3216
3217 /* perform all post-processing checks */
3218 if (c->type == UDS) {
3219 struct sockaddr_un port;
3220 int limit, len;
3221
3222 limit = sizeof(port.sun_path);
3223 len = strlen(c->uds);
3224
3225 if (len >= limit) {
3226 if (isMaster)
3227 Error("[%s] 'uds' path too large (%d >= %d) [%s:%d]",
3228 c->server, len, limit, file, line);
3229 continue;
3230 }
3231 }
3232
30503233 if (fSyntaxOnly > 1) {
30513234 static STRING *s = (STRING *)0;
30523235
30753258 case HOST:
30763259 BuildString(BuildTmpStringPrint
30773260 ("!:%s,%hu", c->host, c->netport), s);
3261 break;
3262 case NOOP:
3263 BuildString("#:", s);
3264 break;
3265 case UDS:
3266 BuildString(BuildTmpStringPrint("%%:%s", c->uds), s);
30783267 break;
30793268 case DEVICE:
30803269 BuildString(BuildTmpStringPrint
33003489
33013490 void
33023491 #if PROTOTYPES
3492 ConsoleItemUdssubst(char *id)
3493 #else
3494 ConsoleItemUdssubst(id)
3495 char *id;
3496 #endif
3497 {
3498 CONDDEBUG((1, "ConsoleItemUdssubst(%s) [%s:%d]", id, file, line));
3499 ProcessSubst(substData, (char **)0, &(parserConsoleTemp->udssubst),
3500 "udssubst", id);
3501 }
3502
3503 void
3504 #if PROTOTYPES
33033505 ConsoleItemInitsubst(char *id)
33043506 #else
33053507 ConsoleItemInitsubst(id)
33693571 {
33703572 CONDDEBUG((1, "ConsoleItemHost(%s) [%s:%d]", id, file, line));
33713573 ProcessHost(parserConsoleTemp, id);
3574 }
3575
3576 void
3577 #if PROTOTYPES
3578 ConsoleItemUds(char *id)
3579 #else
3580 ConsoleItemUds(id)
3581 char *id;
3582 #endif
3583 {
3584 CONDDEBUG((1, "ConsoleItemUds(%s) [%s:%d]", id, file, line));
3585 ProcessUds(parserConsoleTemp, id);
33723586 }
33733587
33743588 void
46204834 {"rw", DefaultItemRw},
46214835 {"timestamp", DefaultItemTimestamp},
46224836 {"type", DefaultItemType},
4837 {"uds", DefaultItemUds},
4838 {"udssubst", DefaultItemUdssubst},
46234839 {(char *)0, (void *)0}
46244840 };
46254841
46564872 {"rw", ConsoleItemRw},
46574873 {"timestamp", ConsoleItemTimestamp},
46584874 {"type", ConsoleItemType},
4875 {"uds", ConsoleItemUds},
4876 {"udssubst", ConsoleItemUdssubst},
46594877 {(char *)0, (void *)0}
46604878 };
46614879
47484966 OutOfMem();
47494967
47504968 /* initialize the substition bits */
4751 SubstCallback('\000', (char **)0, (int *)0);
4969 InitSubstCallback();
47524970
47534971 /* ready to read in the data */
47544972 ParseFile(filename, fp, 0);
00 /*
1 * $Id: version.h,v 1.72 2006/01/15 17:10:44 bryan Exp $
1 * $Id: version.h,v 1.73 2006/04/03 13:32:08 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
1313 @(#) Copyright 2000 conserver.com.\n\
1414 All rights reserved.\n"
1515
16 #define THIS_VERSION "conserver.com version 8.1.13"
16 #define VERSION_MAJOR 8
17 #define VERSION_MINOR 1
18 #define VERSION_REV 14
19 #define VERSION_TEXT "conserver.com version"
20 #define VERSION_UINT (VERSION_MAJOR * 1000000 + VERSION_MINOR * 1000 + VERSION_REV)
0 .\" $Id: conserver.cf.man,v 1.73 2005/06/09 07:09:31 bryan Exp $
1 .TH CONSERVER.CF 5 "2005/06/09" "conserver-8.1.13" "conserver"
0 .\" $Id: conserver.cf.man,v 1.76 2006/03/20 16:47:03 bryan Exp $
1 .TH CONSERVER.CF 5 "2006/03/20" "conserver-8.1.14" "conserver"
22 .SH NAME
33 conserver.cf \- console configuration file for
44 .BR conserver (8)
464464 .br
465465 Assign the serial device
466466 .I filename
467 as the access to the console.
467 as the path to the console.
468468 Only consoles of type ``device'' will use this value.
469469 .TP
470470 \f3devicesubst\fP \f2c\fP\f3=\fP\f2t\fP[\f2n\fP]\f2f\fP[\f3,\fP...]|\f3""\fP
884884 will set this flag for all consoles.
885885 Default is
886886 .BR !unloved .
887 .TP
888 .B login
889 Allow users to log into this console.
890 If logins are not allowed, conserver will send a generic message to the
891 client saying so and terminate the connection.
892 You can override the generic message by setting the
893 .B motd
894 message.
895 Default is
896 .BR login .
887897 .PD
888898 .RE
889899 .TP
10451055 .RB ` b '
10461056 can be specified to add logging of break sequences sent to the console.
10471057 .TP
1048 \f3type\fP \f3device\fP|\f3exec\fP|\f3host\fP
1058 \f3type\fP \f3device\fP|\f3exec\fP|\f3host\fP|\f3noop\fP|\f3uds\fP
10491059 .br
10501060 Set the type of console.
1051 The type
1061 A type of
10521062 .RB `` device ''
10531063 should be used for local serial ports (also set the
10541064 .B device
1055 option), the type
1065 value).
1066 A type of
10561067 .RB `` exec ''
10571068 should be used for command invocations (perhaps also set the
10581069 .B exec
1059 option), and the type
1070 value).
1071 A type of
10601072 .RB `` host ''
1061 should be used for terminal servers and other socket-based
1073 should be used for terminal servers and other TCP socket-based
10621074 interaction (also set the
10631075 .B host
10641076 and
10651077 .B port
1066 options).
1078 values).
1079 A type of
1080 .RB `` noop ''
1081 should be used as a placeholder - it does nothing, ignores any
1082 .B logfile
1083 value and forces the
1084 .B !nologin
1085 option (so you might want to set the
1086 .B motd
1087 value).
1088 A type of
1089 .RB `` uds ''
1090 should be used for Unix domain sockets (also set the
1091 .B uds
1092 option).
1093 .TP
1094 \f3uds\fP \f2filename\fP
1095 .br
1096 Assign the Unix domain socket
1097 .I filename
1098 as the path to the console.
1099 Only consoles of type ``uds'' will use this value.
1100 .TP
1101 \f3udssubst\fP \f2c\fP\f3=\fP\f2t\fP[\f2n\fP]\f2f\fP[\f3,\fP...]|\f3""\fP
1102 .br
1103 Perform character substitutions on the
1104 .B uds
1105 value.
1106 See the
1107 .B devicesubst
1108 option for an explanation of the format string.
1109 If the null string (``\f3""\fP'') is used, no replacements will be done.
10671110 .RE
10681111 .TP
10691112 \f3group\fP \f2name\fP
00 .\" $Id: conserver.passwd.man,v 1.10 2004/01/08 16:12:33 bryan Exp $
1 .TH CONSERVER.PASSWD 5 "2004/01/08" "conserver-8.1.13" "conserver"
1 .TH CONSERVER.PASSWD 5 "2004/01/08" "conserver-8.1.14" "conserver"
22 .SH NAME
33 conserver.passwd \- user access information for
44 .BR conserver (8)
3535 <TD colspan="2" align="center">Please pick your closest
3636 mirror: &nbsp;&nbsp;<A href=
3737 "http://planetmirror.com/pub/conserver/">Australia</A>
38 &nbsp;&nbsp;<A href=
39 "http://conserver.linux-mirror.org/">Germany</A>
40 &nbsp;&nbsp;<A href=
41 "http://conserver.oss-mirror.org/">Ireland</A>
3842 &nbsp;&nbsp;<A href="http://conserver.rinet.ru/">Russia</A>
3943 &nbsp;&nbsp;<A href="http://www.conserver.com/">US-West
4044 (Primary)</A><BR>
181185
182186 <H3>Downloading</H3>
183187
184 <P>The current version, released on Jan 15, 2006, is <A
185 href="8.1.13.tar.gz">8.1.13.tar.gz</A>. You can get it
188 <P>The current version, released on Apr 9, 2006, is <A
189 href="8.1.14.tar.gz">8.1.14.tar.gz</A>. You can get it
186190 via <A href=
187 "ftp://ftp.conserver.com/conserver/8.1.13.tar.gz">FTP</A>
188 or <A href="8.1.13.tar.gz">HTTP</A>. See the <A href=
191 "ftp://ftp.conserver.com/conserver/8.1.14.tar.gz">FTP</A>
192 or <A href="8.1.14.tar.gz">HTTP</A>. See the <A href=
189193 "CHANGES">CHANGES</A> file for information on the latest
190194 updates.</P>
191195
229233
230234 <LI>DEC Tru64 4.0/5.1, native cc</LI>
231235
232 <LI>FreeBSD 4.2/4.8/5.1 (x86), gcc</LI>
236 <LI>FreeBSD 4.x (i386) gcc</LI>
237
238 <LI>FreeBSD 5.x (i386/amd64/sparc64) gcc</LI>
239
240 <LI>FreeBSD 6.x/7.x (i386/amd64/sparc64/ia64) gcc</LI>
233241
234242 <LI>HP-UX 10.20, gcc</LI>
235243
00 /*
1 * $Id: console.c,v 5.176 2005/09/05 22:34:39 bryan Exp $
1 * $Id: console.c,v 5.179 2006/04/07 15:47:20 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
3232
3333 #include <getpassword.h>
3434 #include <cutil.h>
35 #include <readconf.h>
3536 #include <version.h>
36 #include <readconf.h>
3737 #if HAVE_OPENSSL
3838 #include <openssl/ssl.h>
3939 #include <openssl/err.h>
5757 CONFIG *optConf = (CONFIG *)0;
5858 CONFIG *config = (CONFIG *)0;
5959 FLAG interact = FLAGFALSE;
60 unsigned int sversion = 0;
61 #if defined(TIOCGWINSZ)
62 struct winsize ws;
63 #endif
6064
6165 #if HAVE_OPENSSL
6266 SSL_CTX *ctx = (SSL_CTX *)0;
280284 if (acA2 == (STRING *)0)
281285 acA2 = AllocString();
282286
283 Msg("%s", THIS_VERSION);
287 Msg(MyVersion());
284288 #if USE_UNIX_DOMAIN_SOCKETS
285289 Msg("default socket directory `%s\'", UDSDIR);
286290 #else
472476 Error("GetPort: path to socket too long: %s", portPath->string);
473477 return (CONSFILE *)0;
474478 }
475 strcpy(port.sun_path, portPath->string);
479 StrCpy(port.sun_path, portPath->string, sizeof(port.sun_path));
476480
477481 CONDDEBUG((1, "GetPort: socket=%s", port.sun_path));
478482
623627
624628 char *
625629 #if PROTOTYPES
626 ReadReply(CONSFILE *fd, int toEOF)
627 #else
628 ReadReply(fd)
630 ReadReply(CONSFILE *fd, FLAG toEOF)
631 #else
632 ReadReply(fd, toEOF)
629633 CONSFILE *fd;
630 int toEOF;
634 FLAG toEOF;
631635 #endif
632636 {
633637 int nr;
645649 case 0:
646650 /* fall through */
647651 case -1:
648 if (result->used > 1 || toEOF)
652 if (result->used > 1 || toEOF == FLAGTRUE)
649653 break;
650654 C2Cooked();
651655 Error("lost connection");
659663 MemMove(buf, buf + l, nr);
660664 }
661665 BuildStringN(buf, nr, result);
662 if (toEOF) /* if toEOF, read until EOF */
666 if (toEOF == FLAGTRUE) /* if toEOF, read until EOF */
663667 continue;
664668 if ((result->used > 1) &&
665669 strchr(result->string, '\n') != (char *)0)
930934 FileSetQuoteIAC(pcf, FLAGFALSE);
931935 FilePrint(pcf, FLAGFALSE, "%c%c", OB_IAC, OB_EXEC);
932936 FileSetQuoteIAC(pcf, FLAGTRUE);
933 r = ReadReply(pcf, 0);
937 r = ReadReply(pcf, FLAGFALSE);
934938 /* now back to non-blocking, now that we've got reply */
935939 SetFlags(FileFDNum(pcf), O_NONBLOCK, 0);
936940 /* if we aren't still r/w, abort */
13891393 */
13901394 FilePrint(pcf, FLAGFALSE, "%c%ce%c%c", DEFATTN, DEFESC, chAttn,
13911395 chEsc);
1392 r = ReadReply(pcf, 0);
1396 r = ReadReply(pcf, FLAGFALSE);
13931397 if (strncmp(r, "[redef:", 7) != 0) {
13941398 Error("protocol botch on redef of escape sequence");
13951399 Bye(EX_UNAVAILABLE);
13981402
13991403 /* try to grok the state of the console */
14001404 FilePrint(pcf, FLAGFALSE, "%c%c=", chAttn, chEsc);
1401 r = ReadReply(pcf, 0);
1405 r = ReadReply(pcf, FLAGFALSE);
14021406 if (strncmp(r, "[unknown", 8) != 0 && strncmp(r, "[up]", 4) != 0)
14031407 FileWrite(cfstdout, FLAGFALSE, r, -1);
1408
1409 /* try to grok the version of the server */
1410 FilePrint(pcf, FLAGFALSE, "%c%c%c", chAttn, chEsc, 0xD6);
1411 r = ReadReply(pcf, FLAGFALSE);
1412 if (strncmp(r, "[unknown", 8) != 0)
1413 sversion = AtoU(r + 1);
14041414
14051415 printf("[Enter `");
14061416 PutCtlc(chAttn, stdout);
14091419
14101420 /* try and display the MOTD */
14111421 FilePrint(pcf, FLAGFALSE, "%c%cm", chAttn, chEsc);
1412 r = ReadReply(pcf, 0);
1422 r = ReadReply(pcf, FLAGFALSE);
14131423 if (strncmp(r, "[unknown", 8) != 0 &&
14141424 strncmp(r, "[-- MOTD --]", 12) != 0)
14151425 FileWrite(cfstdout, FLAGFALSE, r, -1);
14161426
1427 if (sversion >= 8001014) {
1428 if (config->playback) {
1429 FilePrint(pcf, FLAGFALSE, "%c%cP%hu\r", chAttn, chEsc,
1430 #if defined(TIOCGWINSZ)
1431 config->playback == 1 ? ws.ws_row :
1432 #endif
1433 config->playback - 1);
1434 r = ReadReply(pcf, FLAGFALSE);
1435 }
1436
1437 if (config->replay) {
1438 FilePrint(pcf, FLAGFALSE, "%c%cR%hu\r", chAttn, chEsc,
1439 #if defined(TIOCGWINSZ)
1440 config->replay == 1 ? ws.ws_row :
1441 #endif
1442 config->replay - 1);
1443 r = ReadReply(pcf, FLAGFALSE);
1444 }
1445 }
1446
14171447 FilePrint(pcf, FLAGFALSE, "%c%c;", chAttn, chEsc);
1418 r = ReadReply(pcf, 0);
1448 r = ReadReply(pcf, FLAGFALSE);
14191449 if (strncmp(r, "[unknown", 8) != 0 &&
14201450 strncmp(r, "[connected]", 11) != 0)
14211451 FileWrite(cfstdout, FLAGFALSE, r, -1);
15271557
15281558 FileSetQuoteIAC(pcf, FLAGTRUE);
15291559
1530 t = ReadReply(pcf, 0);
1560 t = ReadReply(pcf, FLAGFALSE);
15311561 if (strcmp(t, "ok\r\n") != 0) {
15321562 FileClose(&pcf);
15331563 FilePrint(cfstdout, FLAGFALSE, "%s: %s", serverName, t);
15361566 #if HAVE_OPENSSL
15371567 if (config->sslenabled == FLAGTRUE) {
15381568 FileWrite(pcf, FLAGFALSE, "ssl\r\n", 5);
1539 t = ReadReply(pcf, 0);
1569 t = ReadReply(pcf, FLAGFALSE);
15401570 if (strcmp(t, "ok\r\n") == 0) {
15411571 AttemptSSL(pcf);
15421572 if (FileGetType(pcf) != SSLSocket) {
15561586
15571587 FilePrint(pcf, FLAGFALSE, "login %s\r\n", config->username);
15581588
1559 t = ReadReply(pcf, 0);
1589 t = ReadReply(pcf, FLAGFALSE);
15601590 if (strncmp(t, "passwd?", 7) == 0) {
15611591 static int count = 0;
15621592 static STRING *tmpString = (STRING *)0;
15871617 }
15881618 FileWrite(pcf, FLAGFALSE, tmpString->string,
15891619 tmpString->used - 1);
1590 t = ReadReply(pcf, 0);
1620 t = ReadReply(pcf, FLAGFALSE);
15911621 if (strcmp(t, "ok\r\n") != 0) {
15921622 FilePrint(cfstdout, FLAGFALSE, "%s: %s", serverName, t);
15931623 if (++count < 3) {
16201650 * that the ReadReply can stop once the socket closes.
16211651 */
16221652 if (cmdi != 0) {
1623 t = ReadReply(pcf, 0);
1653 t = ReadReply(pcf, FLAGFALSE);
16241654 /* save the result */
16251655 if (result != (char *)0)
16261656 free(result);
16381668 Bye(EX_SOFTWARE);
16391669 }
16401670 FileWrite(pcf, FLAGFALSE, "exit\r\n", 6);
1641 t = ReadReply(pcf, 1);
1671 t = ReadReply(pcf, FLAGTRUE);
16421672 } else {
16431673 /* if we're not trying to connect to a console */
16441674 if (interact == FLAGFALSE) {
16631693 }
16641694 } else if (cmds[cmdi][0] == 'q') {
16651695 if (cmdi == 0) {
1666 t = ReadReply(pcf, 0);
1696 t = ReadReply(pcf, FLAGFALSE);
16671697 FilePrint(cfstdout, FLAGFALSE, "%s: %s", serverName, t);
16681698 } else {
16691699 FilePrint(cfstdout, FLAGFALSE, "%s: %s", serverName,
16721702 /* only say 'exit' if 'quit' failed...since it's dying anyway */
16731703 if (t[0] != 'o' || t[1] != 'k') {
16741704 FileWrite(pcf, FLAGFALSE, "exit\r\n", 6);
1675 t = ReadReply(pcf, 1);
1705 t = ReadReply(pcf, FLAGTRUE);
16761706 }
16771707 } else {
16781708 /* all done */
16841714 * like i said. wacky.
16851715 */
16861716 FileWrite(pcf, FLAGFALSE, "exit\r\n", 6);
1687 t = ReadReply(pcf, cmdi == 0 ? 1 : 0);
1717 t = ReadReply(pcf, cmdi == 0 ? FLAGTRUE : FLAGFALSE);
16881718
16891719 if (cmdi == 0) {
16901720 int len;
21312161 if (config->port == (char *)0)
21322162 OutOfMem();
21332163
2164 if (optConf->replay != 0)
2165 config->replay = optConf->replay;
2166 else if (pConfig->replay != 0)
2167 config->replay = pConfig->replay;
2168 else
2169 config->replay = 0;
2170
2171 if (optConf->playback != 0)
2172 config->playback = optConf->playback;
2173 else if (pConfig->playback != 0)
2174 config->playback = pConfig->playback;
2175 else
2176 config->playback = 0;
2177
21342178 #if HAVE_OPENSSL
21352179 if (optConf->sslcredentials != (char *)0 &&
21362180 optConf->sslcredentials[0] != '\000')
22132257 Error("getservbyname(%s) failed", config->port);
22142258 Bye(EX_UNAVAILABLE);
22152259 } else {
2216 bindPort = ntohs((u_short) pSE->s_port);
2260 bindPort = ntohs((unsigned short)pSE->s_port);
22172261 }
22182262 }
22192263 #endif
22782322 if (!fLocal)
22792323 cmds[++cmdi] = "master";
22802324 }
2325
2326 #if defined(TIOCGWINSZ)
2327 if (interact == FLAGTRUE) {
2328 int fd;
2329 #if HAVE_MEMSET
2330 memset((void *)(&ws), '\000', sizeof(ws));
2331 #else
2332 bzero((char *)(&ws), sizeof(ws));
2333 #endif
2334 if ((fd = open("/dev/tty", O_RDONLY)) != -1) {
2335 ioctl(fd, TIOCGWINSZ, &ws);
2336 }
2337 close(fd);
2338 }
2339 #endif
22812340
22822341 for (;;) {
22832342 if (gotoConsole == (CONSFILE *)0)
0 .\" $Id: console.man,v 1.58 2005/09/05 22:17:33 bryan Exp $
1 .TH CONSOLE 1 "2005/09/05" "conserver-8.1.13" "conserver"
0 .\" $Id: console.man,v 1.61 2006/04/03 13:32:12 bryan Exp $
1 .TH CONSOLE 1 "2006/04/03" "conserver-8.1.14" "conserver"
22 .SH NAME
33 console \- console server client program
44 .SH SYNOPSIS
425425 .I type
426426 The type of console.
427427 Values will be a `/' for a local device, `|' for
428 a command, or `!' for a remote port.
428 a command, `!' for a remote port, `%' for a Unix domain socket,
429 and `#' for a noop console.
429430 .TP
430431 .I console-details
431432 The details regarding the console.
436437 pseudo-tty, and file descriptor for the pseudo-tty.
437438 Remote ports will have values of the remote hostname, remote port number,
438439 ``raw'' or ``telnet'' protocol, and file descriptor for the socket connection.
440 Unix domain sockets will have the path to the socket and the file
441 descriptor for the socket connection.
442 Noop consoles will have nothing.
439443 .TP
440444 .I users-list
441445 The details of each user connected to the console.
529533 .B \-M
530534 command-line flag).
531535 .TP
536 \f3playback\fP \f2num\fP|\f3""\fP
537 .br
538 Override the playback length for the
539 .B p
540 escape command to
541 .I num
542 lines (if the server supports it).
543 Using the special value of ``0'' will cause the client to use the number
544 of lines of the current terminal (if that can be determined).
545 If the null string (``""'') is used, the playback length will not be overridden.
546 .TP
532547 \f3port\fP \f2port\fP
533548 .br
534549 Set the default port to
536551 (see the
537552 .B \-p
538553 command-line flag).
554 .TP
555 \f3replay\fP \f2num\fP|\f3""\fP
556 .br
557 Override the replay length for the
558 .B r
559 escape command to
560 .I num
561 lines (if the server supports it).
562 Using the special value of ``0'' will cause the client to use the number
563 of lines of the current terminal (if that can be determined).
564 If the null string (``""'') is used, the replay length will not be overridden.
539565 .TP
540566 \f3sslcredentials\fP \f2filename\fP
541567 .br
829855 and the log file
830856 .TP
831857 .B p
832 replay the last 60 lines of output
858 playback the last 60 lines of output
859 .TP
860 .B P
861 set number of playback lines
833862 .TP
834863 .B r
835864 replay the last 20 lines of output
865 .TP
866 .B R
867 set number of replay lines
836868 .TP
837869 .B s
838870 switch to spy mode (read-only)
00 /*
1 * $Id: readconf.c,v 5.3 2005/06/11 02:32:21 bryan Exp $
1 * $Id: readconf.c,v 5.5 2006/04/03 13:32:12 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
8080 }
8181 if (parserConfigDefault->striphigh != FLAGUNKNOWN)
8282 c->striphigh = parserConfigDefault->striphigh;
83 if (parserConfigDefault->replay != FLAGUNKNOWN)
84 c->replay = parserConfigDefault->replay;
85 if (parserConfigDefault->playback != FLAGUNKNOWN)
86 c->playback = parserConfigDefault->playback;
8387 #if HAVE_OPENSSL
8488 if (parserConfigDefault->sslcredentials != (char *)0) {
8589 if (c->sslcredentials != (char *)0)
396400
397401 void
398402 #if PROTOTYPES
403 ConfigItemPlayback(char *id)
404 #else
405 ConfigItemPlayback(id)
406 char *id;
407 #endif
408 {
409 int i;
410
411 CONDDEBUG((1, "ConfigItemPlayback(%s) [%s:%d]", id, file, line));
412
413 if ((id == (char *)0) || (*id == '\000')) {
414 parserConfigTemp->playback = 0;
415 return;
416 }
417 for (i = 0; id[i] != '\000'; i++) {
418 if (!isdigit((int)id[i])) {
419 Error("invalid playback value [%s:%d]", file, line);
420 return;
421 }
422 }
423 if (i > 4) {
424 Error("playback value too large [%s:%d]", file, line);
425 return;
426 }
427 parserConfigTemp->playback = (unsigned short)atoi(id) + 1;
428 }
429
430 void
431 #if PROTOTYPES
399432 ConfigItemPort(char *id)
400433 #else
401434 ConfigItemPort(id)
413446 }
414447 if ((parserConfigTemp->port = StrDup(id)) == (char *)0)
415448 OutOfMem();
449 }
450
451 void
452 #if PROTOTYPES
453 ConfigItemReplay(char *id)
454 #else
455 ConfigItemReplay(id)
456 char *id;
457 #endif
458 {
459 int i;
460
461 CONDDEBUG((1, "ConfigItemReplay(%s) [%s:%d]", id, file, line));
462
463 if ((id == (char *)0) || (*id == '\000')) {
464 parserConfigTemp->replay = 0;
465 return;
466 }
467 for (i = 0; id[i] != '\000'; i++) {
468 if (!isdigit((int)id[i])) {
469 Error("invalid replay value [%s:%d]", file, line);
470 return;
471 }
472 }
473 if (i > 4) {
474 Error("replay value too large [%s:%d]", file, line);
475 return;
476 }
477 parserConfigTemp->replay = (unsigned short)atoi(id) + 1;
416478 }
417479
418480 void
511573
512574 SUBST *substData = (SUBST *)0;
513575
576 SUBSTTOKEN
577 #if PROTOTYPES
578 SubstToken(char c)
579 #else
580 SubstToken(c)
581 char c;
582 #endif
583 {
584 switch (c) {
585 case 'u':
586 case 'c':
587 return ISSTRING;
588 default:
589 return ISNOTHING;
590 }
591 }
592
514593 int
515594 #if PROTOTYPES
516 SubstCallback(char c, char **s, int *i)
517 #else
518 SubstCallback(c, s, i)
595 SubstValue(char c, char **s, int *i)
596 #else
597 SubstValue(c, s, i)
519598 char c;
520599 char **s;
521600 int *i;
522601 #endif
523602 {
524603 int retval = 0;
525
526 if (substData == (SUBST *)0) {
527 if ((substData = (SUBST *)calloc(1, sizeof(SUBST))) == (SUBST *)0)
528 OutOfMem();
529 substData->callback = &SubstCallback;
530 substData->tokens['u'] = ISSTRING;
531 substData->tokens['c'] = ISSTRING;
532 }
533604
534605 if (s != (char **)0) {
535606 CONFIG *pc;
551622
552623 void
553624 #if PROTOTYPES
625 InitSubstCallback(void)
626 #else
627 InitSubstCallback()
628 #endif
629 {
630 if (substData == (SUBST *)0) {
631 if ((substData = (SUBST *)calloc(1, sizeof(SUBST))) == (SUBST *)0)
632 OutOfMem();
633 substData->value = &SubstValue;
634 substData->token = &SubstToken;
635 }
636 }
637
638
639 void
640 #if PROTOTYPES
554641 TerminalItemAttach(char *id)
555642 #else
556643 TerminalItemAttach(id)
620707 ITEM keyConfig[] = {
621708 {"escape", ConfigItemEscape},
622709 {"master", ConfigItemMaster},
710 {"playback", ConfigItemPlayback},
623711 {"port", ConfigItemPort},
712 {"replay", ConfigItemReplay},
624713 {"sslcredentials", ConfigItemSslcredentials},
625714 {"sslrequired", ConfigItemSslrequired},
626715 {"sslenabled", ConfigItemSslenabled},
663752 }
664753
665754 /* initialize the substition bits */
666 SubstCallback('\000', (char **)0, (int *)0);
755 InitSubstCallback();
667756
668757 parserConfigDefault = pConfig;
669758 pConfig = (CONFIG *)0;
698787 CONDDEBUG((1, "pConfig->escape = %s", EMPTYSTR(pConfig->escape)));
699788 CONDDEBUG((1, "pConfig->striphigh = %s",
700789 FLAGSTR(pConfig->striphigh)));
790 CONDDEBUG((1, "pConfig->replay = %hu", pConfig->replay));
791 CONDDEBUG((1, "pConfig->playback = %hu", pConfig->playback));
701792 #if HAVE_OPENSSL
702793 CONDDEBUG((1, "pConfig->sslcredentials = %s",
703794 EMPTYSTR(pConfig->sslcredentials)));
00 /*
1 * $Id: readconf.h,v 5.3 2004/05/25 23:03:25 bryan Exp $
1 * $Id: readconf.h,v 5.4 2006/04/03 13:32:12 bryan Exp $
22 *
33 * Copyright conserver.com, 2000
44 *
1313 char *port;
1414 char *escape;
1515 FLAG striphigh;
16 unsigned short replay;
17 unsigned short playback;
1618 #if HAVE_OPENSSL
1719 char *sslcredentials;
1820 FLAG sslrequired;
33 #
44
55 %define pkg conserver
6 %define ver 8.1.13
6 %define ver 8.1.14
77
88 # define the name of the machine on which the main conserver
99 # daemon will be running if you don't want to use the default
1111 %define master console
1212
1313 # what red hat (or other distibution) version are you running?
14 %define distver 6
14 %define distver 1
1515
1616 Summary: Serial console server daemon/client
1717 Name: %{pkg}
1818 Version: %{ver}
19 Release: 1.%{distver}
20 Copyright: distributable
19 Release: %{distver}
20 License: BSD
2121 Group: System Environment/Daemons
2222 URL: http://www.conserver.com/
2323 Source: http://www.conserver.com/%{pkg}-%{ver}.tar.gz
9595 %config(noreplace) %{_sysconfdir}/conserver.passwd
9696 %attr(555,root,root) %{_initrddir}/conserver
9797 %{prefix}/bin/console
98 %{prefix}/lib/conserver/convert
9899 %{prefix}/share/man/man1/console.1.gz
99100 %{prefix}/share/man/man8/conserver.8.gz
100101 %{prefix}/share/man/man5/conserver.cf.5.gz
00 PKG="conserver"
11 NAME="Console server and client"
22 CATEGORY="system"
3 VERSION="8.1.13"
3 VERSION="8.1.14"
44 DESC="Console server and client"
55 CLASSES=none
66 ARCH=sparc
77 L toggle logging on/off l? break sequence list
88 l0 send break per config file l1-9 send specific break sequence
99 m display the message of the day o (re)open the tty and log file
10 p replay the last 60 lines r replay the last 20 lines
11 s spy read only u show host status
10 p playback the last 60 lines P set number of playback lines
11 r replay the last 20 lines R set number of replay lines
12 s spy mode (read only) u show host status
1213 v show version info w who is on this console
1314 x show console baud info z suspend the connection
1415 | attach local command ? print this message
77 L toggle logging on/off l? break sequence list
88 l0 send break per config file l1-9 send specific break sequence
99 m display the message of the day o (re)open the tty and log file
10 p replay the last 60 lines r replay the last 20 lines
11 s spy read only u show host status
10 p playback the last 60 lines P set number of playback lines
11 r replay the last 20 lines R set number of replay lines
12 s spy mode (read only) u show host status
1213 v show version info w who is on this console
1314 x show console baud info z suspend the connection
1415 | attach local command ? print this message