diff --git a/CHANGES b/CHANGES index f518feb..86d574c 100644 --- a/CHANGES +++ b/CHANGES @@ -1,6 +1,22 @@ CHANGES ======= +version 8.0.2 (Oct 5, 2003): + - reworked the i/o calls to better buffer data + - added console 'motd' option for holding a "message of the + day", displayed to the client on attachment to console - + suggested by Toby Gerhart + - added ^Ecm client command for displaying MOTD and integrated + it into the client console attachment sequence + - now unallocate client lists when forking new child conserver + processes + - changed strdup() to local StrDup() so dmalloc can gracefully + track changes + - added a ^Ec; sequence to let client signal server when it's + ready to see console data, otherwise a chatty console can + cause the login sequence to fail and you can never attach to + the console + version 8.0.1 (Sep 29, 2003): - fixed bug in access list parsing where multiple addresses per line can cause errors - reported by Jay McCanta @@ -540,5 +556,5 @@ before version 6.05: and enhancements of various types were applied. # -# $Id: CHANGES,v 1.109 2003-09-29 08:41:20-07 bryan Exp $ +# $Id: CHANGES,v 1.115 2003-10-05 18:04:09-07 bryan Exp $ # diff --git a/INSTALL b/INSTALL index 982b264..8a51459 100644 --- a/INSTALL +++ b/INSTALL @@ -10,6 +10,15 @@ Upgrading? new features added to the client if you're considering *not* upgrading. + Version 8.0.2 + + - I've added a '^Ec;' sequence to allow the client to signal the + server as to when it's ready to see console data. Without + this, verbose consoles will prevent clients from attaching + (the client sees unexpected data). An 8.0.2 client should be + compatible with an 8.0.1 server, but an 8.0.1 client is not + compatible with an 8.0.2 server. + Version 8.0.1 - There's a slight client/server protocol change to implement @@ -246,5 +255,5 @@ Other Information And Gotchas # -# $Id: INSTALL,v 1.33 2003-09-28 17:50:05-07 bryan Exp $ +# $Id: INSTALL,v 1.34 2003-10-03 10:52:31-07 bryan Exp $ # diff --git a/conserver.cf/conserver.cf.man b/conserver.cf/conserver.cf.man index 08a98d5..862e78b 100644 --- a/conserver.cf/conserver.cf.man +++ b/conserver.cf/conserver.cf.man @@ -1,5 +1,5 @@ -.\" $Id: conserver.cf.man,v 1.42 2003-09-28 12:23:04-07 bryan Exp $ -.TH CONSERVER.CF 5 "2003-09-28" "conserver-8.0.1" "conserver" +.\" $Id: conserver.cf.man,v 1.43 2003-10-02 19:01:05-07 bryan Exp $ +.TH CONSERVER.CF 5 "2003-10-02" "conserver-8.0.2" "conserver" .SH NAME conserver.cf \- console configuration file for .BR conserver (8) @@ -456,6 +456,16 @@ The host may be specified by or using the address .IR ipaddr . .TP +.B motd +.RI [ " message " +| "" ] +.br +Set the "message of the day" for the console to +.IR message , +which gets displayed when a client attaches to the console. +If the null string (``""'') is used, the MOTD is unset and +no message will occur. +.TP .B options .RI [ " option" ,... | "" ] diff --git a/conserver.cf/conserver.passwd.man b/conserver.cf/conserver.passwd.man index 1046116..a6d0179 100644 --- a/conserver.cf/conserver.passwd.man +++ b/conserver.cf/conserver.passwd.man @@ -1,5 +1,5 @@ .\" $Id: conserver.passwd.man,v 1.9 2003-07-04 13:20:52-07 bryan Exp $ -.TH CONSERVER.PASSWD 5 "2003-07-04" "conserver-8.0.1" "conserver" +.TH CONSERVER.PASSWD 5 "2003-07-04" "conserver-8.0.2" "conserver" .SH NAME conserver.passwd \- user access information for .BR conserver (8) diff --git a/conserver.html b/conserver.html index c7d5801..34bd208 100644 --- a/conserver.html +++ b/conserver.html @@ -183,11 +183,11 @@

Downloading

-

The current version, released on Sep 29, 2003, is 8.0.1.tar.gz. You can get it via +

The current version, released on Oct 5, 2003, is 8.0.2.tar.gz. You can get it via FTP - or HTTP. See the FTP + or HTTP. See the CHANGES file for information on the latest updates.

diff --git a/conserver/access.c b/conserver/access.c index 8413aa5..482ff63 100644 --- a/conserver/access.c +++ b/conserver/access.c @@ -1,5 +1,5 @@ /* - * $Id: access.c,v 5.66 2003-08-15 14:24:39-07 bryan Exp $ + * $Id: access.c,v 5.67 2003-10-03 06:32:34-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -241,7 +241,7 @@ SetDefAccess(pAddr, pHost) addr = inet_ntoa(*pAddr); if ((a = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0) OutOfMem(); - if ((a->pcwho = strdup(addr)) == (char *)0) + if ((a->pcwho = StrDup(addr)) == (char *)0) OutOfMem(); a->ctrust = 'a'; a->pACnext = pACList; @@ -258,7 +258,7 @@ SetDefAccess(pAddr, pHost) if ((a = (ACCESS *)calloc(1, sizeof(ACCESS))) == (ACCESS *)0) OutOfMem(); - if ((a->pcwho = strdup(pcDomain)) == (char *)0) + if ((a->pcwho = StrDup(pcDomain)) == (char *)0) OutOfMem(); a->ctrust = 'a'; a->pACnext = pACList; diff --git a/conserver/client.c b/conserver/client.c index 92240df..ab668da 100644 --- a/conserver/client.c +++ b/conserver/client.c @@ -1,5 +1,5 @@ /* - * $Id: client.c,v 5.70 2003-09-28 08:42:06-07 bryan Exp $ + * $Id: client.c,v 5.72 2003-10-02 18:49:13-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -78,9 +78,10 @@ FindWrite(pCE) pCL->fwantwr = 0; pCL->fwr = 1; if (pCE->nolog) { - FileWrite(pCL->fd, "\r\n[attached (nologging)]\r\n", -1); + FileWrite(pCL->fd, FLAGFALSE, "\r\n[attached (nologging)]\r\n", + -1); } else { - FileWrite(pCL->fd, "\r\n[attached]\r\n", -1); + FileWrite(pCL->fd, FLAGFALSE, "\r\n[attached]\r\n", -1); } TagLogfileAct(pCE, "%s attached", pCL->acid->string); pCE->pCLwr = pCL; @@ -130,7 +131,8 @@ Replay(fdLog, fdOut, iBack) #endif if ((CONSFILE *)0 == fdLog) { - FileWrite(fdOut, "[no log file on this console]\r\n", -1); + FileWrite(fdOut, FLAGFALSE, "[no log file on this console]\r\n", + -1); return; } @@ -311,8 +313,8 @@ Replay(fdLog, fdOut, iBack) if ((char *)0 != s) { *s = '\000'; } - FileWrite(fdOut, lines[i].line->string, -1); - FileWrite(fdOut, " .. ", -1); + FileWrite(fdOut, FLAGTRUE, lines[i].line->string, -1); + FileWrite(fdOut, FLAGTRUE, " .. ", -1); /* build the end string by removing the leading "[-- MARK -- " * and replacing "]\r\n" on the end with " -- MARK --]\r\n" @@ -323,12 +325,13 @@ Replay(fdLog, fdOut, iBack) if ((char *)0 != s) { *s = '\000'; } - FileWrite(fdOut, lines[i].mark_end->string + mark_len, -1); - FileWrite(fdOut, " -- MARK --]\r\n", -1); + FileWrite(fdOut, FLAGTRUE, + lines[i].mark_end->string + mark_len, -1); + FileWrite(fdOut, FLAGFALSE, " -- MARK --]\r\n", -1); u = lines[i].mark_end->used; s = lines[i].mark_end->string; } else - FileWrite(fdOut, lines[i].line->string, -1); + FileWrite(fdOut, FLAGFALSE, lines[i].line->string, -1); } common_exit: @@ -381,6 +384,7 @@ static HELP aHLTable[] = { {WHEN_ATTACH, "l? break sequence list"}, {WHEN_ATTACH, "l0 send break per config file"}, {WHEN_ATTACH, "l1-9 send specific break sequence"}, + {WHEN_ALWAYS, "m display the message of the day"}, {WHEN_ALWAYS, "o (re)open the tty and log file"}, {WHEN_ALWAYS, "p replay the last 60 lines"}, {WHEN_ALWAYS, "r replay the last 20 lines"}, @@ -424,10 +428,10 @@ HelpUser(pCL) iCmp = WHEN_ALWAYS | WHEN_SPY; if (pCL->fwr) { - FileWrite(pCL->fd, acH1, sizeof(acH1) - 1); + FileWrite(pCL->fd, FLAGTRUE, acH1, sizeof(acH1) - 1); iCmp |= WHEN_ATTACH; } else { - FileWrite(pCL->fd, acH2, sizeof(acH2) - 1); + FileWrite(pCL->fd, FLAGTRUE, acH2, sizeof(acH2) - 1); } if ('\033' == pCL->ic[0] && 'O' == pCL->ic[1]) { iCmp |= WHEN_VT100; @@ -445,12 +449,12 @@ HelpUser(pCL) } BuildString(aHLTable[i].actext, acLine); BuildString(acEoln, acLine); - FileWrite(pCL->fd, acLine->string, -1); + FileWrite(pCL->fd, FLAGTRUE, acLine->string, -1); BuildString((char *)0, acLine); continue; } else { BuildString(acEoln, acLine); - FileWrite(pCL->fd, acLine->string, -1); + FileWrite(pCL->fd, FLAGTRUE, acLine->string, -1); BuildString((char *)0, acLine); } } @@ -459,15 +463,16 @@ HelpUser(pCL) BuildString(aHLTable[i].actext, acLine); if (acLine->used > HALFLINE) { BuildString(acEoln, acLine); - FileWrite(pCL->fd, acLine->string, -1); + FileWrite(pCL->fd, FLAGTRUE, acLine->string, -1); BuildString((char *)0, acLine); } } } if (acLine->used != 0) { BuildString(acEoln, acLine); - FileWrite(pCL->fd, acLine->string, -1); + FileWrite(pCL->fd, FLAGTRUE, acLine->string, -1); } + FileWrite(pCL->fd, FLAGFALSE, (char *)0, 0); } int @@ -493,7 +498,8 @@ ClientAccessOk(pCL) request_init(&request, RQ_DAEMON, progname, RQ_FILE, cfd, 0); fromhost(&request); if (!hosts_access(&request)) { - FileWrite(pCL->fd, "access from your host refused\r\n", -1); + FileWrite(pCL->fd, FLAGFALSE, + "access from your host refused\r\n", -1); retval = 0; goto setpeer; } @@ -503,13 +509,14 @@ ClientAccessOk(pCL) so = sizeof(in_port); if (-1 == (getpeer = getpeername(cfd, (struct sockaddr *)&in_port, &so))) { - FileWrite(pCL->fd, "getpeername failed\r\n", -1); + FileWrite(pCL->fd, FLAGFALSE, "getpeername failed\r\n", -1); retval = 0; goto setpeer; } pCL->caccess = AccType(&in_port.sin_addr, &peername); if (pCL->caccess == 'r') { - FileWrite(pCL->fd, "access from your host refused\r\n", -1); + FileWrite(pCL->fd, FLAGFALSE, "access from your host refused\r\n", + -1); retval = 0; } diff --git a/conserver/consent.c b/conserver/consent.c index 5d0d9d7..7ac1a5a 100644 --- a/conserver/consent.c +++ b/conserver/consent.c @@ -1,5 +1,5 @@ /* - * $Id: consent.c,v 5.127 2003-09-28 10:37:20-07 bryan Exp $ + * $Id: consent.c,v 5.128 2003-09-30 13:14:04-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -260,12 +260,13 @@ StopInit(pCE) return; if (pCE->initpid != 0) { - Verbose("[%s] initcmd terminated: pid %lu", pCE->server, - (unsigned long)pCE->initpid); - CONDDEBUG((1, "StopInit(): sending initcmd pid %lu signal %d", - (unsigned long)pCE->initpid, SIGHUP)); kill(pCE->initpid, SIGHUP); pCE->initpid = 0; + Verbose("[%s] initcmd terminated: pid %lu", pCE->server, + (unsigned long)pCE->initpid); + TagLogfileAct(pCE, "initcmd terminated"); + CONDDEBUG((1, "StopInit(): sending initcmd pid %lu signal %d", + (unsigned long)pCE->initpid, SIGHUP)); } if (pCE->initfile != (CONSFILE *)0) { @@ -360,6 +361,7 @@ StartInit(pCE) } Verbose("[%s] initcmd started: pid %lu", pCE->server, (unsigned long)pCE->initpid); + TagLogfileAct(pCE, "initcmd started"); FD_SET(pin[0], &rinit); if (maxfd < pin[0] + 1) maxfd = pin[0] + 1; diff --git a/conserver/consent.h b/conserver/consent.h index 3cfdff5..80784ad 100644 --- a/conserver/consent.h +++ b/conserver/consent.h @@ -1,5 +1,5 @@ /* - * $Id: consent.h,v 5.47 2003-09-28 08:43:04-07 bryan Exp $ + * $Id: consent.h,v 5.48 2003-10-02 18:49:03-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -98,6 +98,7 @@ typedef struct consent { /* console information */ unsigned short breakNum; /* break type [1-9] */ char *logfile; /* logfile */ char *initcmd; /* initcmd command */ + char *motd; /* motd */ /* timestamp stuff */ int mark; /* Mark (chime) interval */ long nextMark; /* Next mark (chime) time */ diff --git a/conserver/conserver.man b/conserver/conserver.man index 1f35697..f7fc6cc 100644 --- a/conserver/conserver.man +++ b/conserver/conserver.man @@ -1,6 +1,6 @@ .\" @(#)conserver.8 01/06/91 OSU CIS; Thomas A. Fine .\" $Id: conserver.man,v 1.38 2003-09-22 08:33:41-07 bryan Exp $ -.TH CONSERVER 8 "2003-09-22" "conserver-8.0.1" "conserver" +.TH CONSERVER 8 "2003-09-22" "conserver-8.0.2" "conserver" .SH NAME conserver \- console server daemon .SH SYNOPSIS diff --git a/conserver/fallback.c b/conserver/fallback.c index ac4cc7b..0d97a7a 100644 --- a/conserver/fallback.c +++ b/conserver/fallback.c @@ -1,5 +1,5 @@ /* - * $Id: fallback.c,v 5.58 2003-08-15 08:18:26-07 bryan Exp $ + * $Id: fallback.c,v 5.59 2003-10-03 06:32:34-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -261,7 +261,7 @@ FallBack(slave, sfd) } if ((*slave) != (char *)0) free(*slave); - if (((*slave) = strdup(pcTSlave->string)) + if (((*slave) = StrDup(pcTSlave->string)) == (char *)0) OutOfMem(); return fd; diff --git a/conserver/group.c b/conserver/group.c index 57fb948..dc14886 100644 --- a/conserver/group.c +++ b/conserver/group.c @@ -1,5 +1,5 @@ /* - * $Id: group.c,v 5.256 2003-09-29 08:39:13-07 bryan Exp $ + * $Id: group.c,v 5.262 2003-10-05 17:04:02-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -69,6 +69,7 @@ #include #include #include +#include #include #if HAVE_PAM @@ -103,7 +104,7 @@ SendClientsMsg(pCE, message) for (pCL = pCE->pCLon; (CONSCLIENT *)0 != pCL; pCL = pCL->pCLnext) { if (pCL->fcon) { - FileWrite(pCL->fd, message, -1); + FileWrite(pCL->fd, FLAGFALSE, message, -1); } } } @@ -138,7 +139,7 @@ SendCertainClientsMsg(pGE, who, message) if (console != (char *)0 && strcmp(pCL->pCEto->server, console) != 0) continue; - FileWrite(pCL->fd, message, -1); + FileWrite(pCL->fd, FLAGFALSE, message, -1); } } } @@ -160,7 +161,7 @@ SendAllClientsMsg(pGE, message) for (pCL = pGE->pCLall; (CONSCLIENT *)0 != pCL; pCL = pCL->pCLscan) { if (pCL->fcon) { - FileWrite(pCL->fd, message, -1); + FileWrite(pCL->fd, FLAGFALSE, message, -1); } } } @@ -183,7 +184,7 @@ DisconnectClient(pGE, pCL, message, force) } if (pCL->fcon) { - FileWrite(pCL->fd, message, -1); + FileWrite(pCL->fd, FLAGFALSE, message, -1); } if (force != FLAGTRUE && !FileBufEmpty(pCL->fd)) { @@ -428,7 +429,7 @@ DestroyConsent(pGE, pCE) if (pCL->pCEto != pCE) continue; if (pCL->fcon) { - FileWrite(pCL->fd, + FileWrite(pCL->fd, FLAGFALSE, "[-- Conserver reconfigured - console has been (re)moved --]\r\n", -1); } @@ -484,6 +485,10 @@ DestroyConsent(pGE, pCE) free(pCE->device); if (pCE->logfile != (char *)0) free(pCE->logfile); + if (pCE->initcmd != (char *)0) + free(pCE->initcmd); + if (pCE->motd != (char *)0) + free(pCE->motd); if (pCE->execSlave != (char *)0) free(pCE->execSlave); while (pCE->aliases != (NAMES *)0) { @@ -579,12 +584,12 @@ QuietConv(num_msg, msg, resp, appdata_ptr) switch (msg[i]->msg_style) { case PAM_PROMPT_ECHO_ON: response[i].resp = - (pcUser != (char *)0 ? strdup(pcUser) : (char *)0); + (pcUser != (char *)0 ? StrDup(pcUser) : (char *)0); break; case PAM_PROMPT_ECHO_OFF: response[i].resp = - (pcWord != (char *)0 ? strdup(pcWord) : (char *)0); + (pcWord != (char *)0 ? StrDup(pcWord) : (char *)0); break; case PAM_TEXT_INFO: @@ -920,9 +925,9 @@ TagLogfile(pCE, fmt, va_alist) if ((pCE == (CONSENT *)0) || (pCE->fdlog == (CONSFILE *)0)) return; - FileWrite(pCE->fdlog, "[-- ", -1); - FileVWrite(pCE->fdlog, fmt, ap); - FilePrint(pCE->fdlog, " -- %s]\r\n", StrTime((time_t *)0)); + FileWrite(pCE->fdlog, FLAGTRUE, "[-- ", -1); + FileVWrite(pCE->fdlog, FLAGTRUE, fmt, ap); + FilePrint(pCE->fdlog, FLAGFALSE, " -- %s]\r\n", StrTime((time_t *)0)); va_end(ap); } @@ -947,9 +952,9 @@ TagLogfileAct(pCE, fmt, va_alist) (pCE->activitylog != FLAGTRUE)) return; - FileWrite(pCE->fdlog, "[-- ", -1); - FileVWrite(pCE->fdlog, fmt, ap); - FilePrint(pCE->fdlog, " -- %s]\r\n", StrTime((time_t *)0)); + FileWrite(pCE->fdlog, FLAGTRUE, "[-- ", -1); + FileVWrite(pCE->fdlog, FLAGTRUE, fmt, ap); + FilePrint(pCE->fdlog, FLAGFALSE, " -- %s]\r\n", StrTime((time_t *)0)); va_end(ap); } @@ -980,7 +985,7 @@ Mark(pGE) if ((CONSFILE *)0 != pCE->fdlog) { CONDDEBUG((1, "Mark(): [-- MARK --] stamp added to %s", pCE->logfile)); - FileWrite(pCE->fdlog, acOut, -1); + FileWrite(pCE->fdlog, FLAGFALSE, acOut, -1); } /* Add as many pCE->mark values as necessary so that we move * beyond the current time. @@ -1012,18 +1017,18 @@ WriteLog(pCE, s, len) return; } if (pCE->mark >= 0) { /* no line marking */ - FileWrite(pCE->fdlog, s, len); + FileWrite(pCE->fdlog, FLAGFALSE, s, len); return; } buf[0] = '\000'; for (j = 0; j < len; j++) { if (pCE->nextMark == 0) { - FileWrite(pCE->fdlog, s + i, j - i); + FileWrite(pCE->fdlog, FLAGTRUE, s + i, j - i); i = j; if (buf[0] == '\000') { sprintf(buf, "[%s]", StrTime((time_t *)0)); } - FileWrite(pCE->fdlog, buf, -1); + FileWrite(pCE->fdlog, FLAGTRUE, buf, -1); pCE->nextMark = pCE->mark; } if (s[j] == '\n') { @@ -1034,8 +1039,9 @@ WriteLog(pCE, s, len) } } if (i < j) { - FileWrite(pCE->fdlog, s + i, j - i); + FileWrite(pCE->fdlog, FLAGTRUE, s + i, j - i); } + FileWrite(pCE->fdlog, FLAGFALSE, (char *)0, 0); } static RETSIGTYPE @@ -1152,6 +1158,7 @@ ReapVirt(pGE) if (pid == pCE->initpid) { Verbose("[%s] initcmd terminated: pid %lu", pCE->server, (unsigned long)pCE->initpid); + TagLogfileAct(pCE, "initcmd terminated"); pCE->initpid = 0; StopInit(pCE); FindWrite(pCE); @@ -1367,7 +1374,7 @@ DoBreakWork(pCLServing, pCEServing, bt, cleanup) return; if (bt < 0 || bt > 9) { if (!cleanup) - FileWrite(pCLServing->fd, "aborted]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "aborted]\r\n", -1); return; } if (bt == 0) { @@ -1376,7 +1383,7 @@ DoBreakWork(pCLServing, pCEServing, bt, cleanup) } if (bt == 0 || breakList[bt - 1].seq->used <= 1) { if (!cleanup) - FileWrite(pCLServing->fd, "undefined]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "undefined]\r\n", -1); return; } @@ -1567,7 +1574,7 @@ DoBreakWork(pCLServing, pCEServing, bt, cleanup) BuildString((char *)0, breakList[bt - 1].seq); BuildString(cleaned->string, breakList[bt - 1].seq); } else { - FileWrite(pCLServing->fd, "sent]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "sent]\r\n", -1); if (pCEServing->breaklog == FLAGTRUE) { if (waszero) { TagLogfile(pCEServing, "break #0(%d) sent -- `%s'", bt, @@ -1654,33 +1661,38 @@ CommandAttach(pGE, pCLServing, pCEServing, tyme) CONSCLIENT *pCL; if (pCEServing->fronly) { - FileWrite(pCLServing->fd, "console is read-only]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "console is read-only]\r\n", + -1); } else if (pCEServing->initfile != (CONSFILE *)0 || pCEServing->ioState == INCONNECT) { - FileWrite(pCLServing->fd, "read-only -- initializing]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "read-only -- initializing]\r\n", -1); pCLServing->fwantwr = 1; } else if (pCLServing->fro) { - FileWrite(pCLServing->fd, "read-only]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "read-only]\r\n", -1); } else if (!(pCEServing->fup && pCEServing->ioState == ISNORMAL)) { - FileWrite(pCLServing->fd, "line to console is down]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "line to console is down]\r\n", -1); } else if ((CONSCLIENT *)0 == (pCL = pCEServing->pCLwr)) { pCEServing->pCLwr = pCLServing; pCLServing->fwr = 1; if (pCEServing->nolog) { - FileWrite(pCLServing->fd, "attached (nologging)]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "attached (nologging)]\r\n", -1); } else { - FileWrite(pCLServing->fd, "attached]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "attached]\r\n", -1); } TagLogfileAct(pCEServing, "%s attached", pCLServing->acid->string); } else if (pCL == pCLServing) { if (pCEServing->nolog) { - FileWrite(pCLServing->fd, "ok (nologging)]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok (nologging)]\r\n", + -1); } else { - FileWrite(pCLServing->fd, "ok]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok]\r\n", -1); } } else { pCLServing->fwantwr = 1; - FilePrint(pCLServing->fd, "no, %s is attached]\r\n", + FilePrint(pCLServing->fd, FLAGFALSE, "no, %s is attached]\r\n", pCL->acid->string); } } @@ -1701,16 +1713,17 @@ CommandChangeFlow(pGE, pCLServing, pCEServing, tyme) int cofile; if (!pCLServing->fwr) { - FileWrite(pCLServing->fd, "attach to change flow]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "attach to change flow]\r\n", + -1); return; } if (pCEServing->type != DEVICE && pCEServing->type != EXEC) { - FileWrite(pCLServing->fd, "ok]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok]\r\n", -1); return; } cofile = FileFDNum(pCEServing->cofile); if (-1 == tcgetattr(cofile, &sbuf)) { - FileWrite(pCLServing->fd, "failed]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "failed]\r\n", -1); return; } if (0 != (sbuf.c_iflag & IXON)) { @@ -1719,13 +1732,13 @@ CommandChangeFlow(pGE, pCLServing, pCEServing, tyme) sbuf.c_iflag |= IXON; } if (-1 == tcsetattr(cofile, TCSANOW, &sbuf)) { - FileWrite(pCLServing->fd, "failed]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "failed]\r\n", -1); return; } if ((sbuf.c_iflag & IXON) == 0) { - FileWrite(pCLServing->fd, "ixon OFF]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ixon OFF]\r\n", -1); } else { - FileWrite(pCLServing->fd, "ixon ON]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ixon ON]\r\n", -1); } } @@ -1752,11 +1765,12 @@ CommandDown(pGE, pCLServing, pCEServing, tyme) if (pCLServing->fro || pCEServing->fronly || (pCEServing->fup && pCEServing->ioState == ISNORMAL && pCEServing->initfile == (CONSFILE *)0 && !pCLServing->fwr)) { - FileWrite(pCLServing->fd, "attach to down line]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "attach to down line]\r\n", + -1); return; } if (!pCEServing->fup) { - FileWrite(pCLServing->fd, "ok]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok]\r\n", -1); return; } @@ -1764,7 +1778,7 @@ CommandDown(pGE, pCLServing, pCEServing, tyme) pCEServing->pCLwr = (CONSCLIENT *)0; TagLogfileAct(pCEServing, "%s detached", pCLServing->acid->string); ConsDown(pCEServing, FLAGFALSE, FLAGFALSE); - FileWrite(pCLServing->fd, "line down]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "line down]\r\n", -1); /* tell all who closed it */ for (pCL = pCEServing->pCLon; (CONSCLIENT *)0 != pCL; @@ -1772,7 +1786,7 @@ CommandDown(pGE, pCLServing, pCEServing, tyme) if (pCL == pCLServing) continue; if (pCL->fcon) { - FilePrint(pCL->fd, "[line down by %s]\r\n", + FilePrint(pCL->fd, FLAGFALSE, "[line down by %s]\r\n", pCLServing->acid->string); } } @@ -1822,7 +1836,7 @@ CommandExamine(pGE, pCLServing, pCEServing, tyme) } sprintf((char *)buf, " %-24.24s on %-32.32s at %6.6s%c\r\n", pCE->server, d, b, p); - FileWrite(pCLServing->fd, (char *)buf, -1); + FileWrite(pCLServing->fd, FLAGFALSE, (char *)buf, -1); } } @@ -1841,47 +1855,53 @@ CommandForce(pGE, pCLServing, pCEServing, tyme) CONSCLIENT *pCL; if (pCLServing->fro) { - FileWrite(pCLServing->fd, "read-only]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "read-only]\r\n", -1); return; } else if (pCEServing->initfile != (CONSFILE *)0 || pCEServing->ioState == INCONNECT) { - FileWrite(pCLServing->fd, "read-only -- initializing]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "read-only -- initializing]\r\n", -1); pCLServing->fwantwr = 1; return; } else if (pCEServing->fronly) { - FileWrite(pCLServing->fd, "console is read-only]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "console is read-only]\r\n", + -1); return; } else if (!(pCEServing->fup && pCEServing->ioState == ISNORMAL)) { - FileWrite(pCLServing->fd, "line to console is down]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "line to console is down]\r\n", -1); return; } if ((CONSCLIENT *)0 != (pCL = pCEServing->pCLwr)) { if (pCL == pCLServing) { if (pCEServing->nolog) { - FileWrite(pCLServing->fd, "ok (nologging)]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok (nologging)]\r\n", + -1); } else { - FileWrite(pCLServing->fd, "ok]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok]\r\n", -1); } return; } pCL->fwr = 0; pCL->fwantwr = 1; if (pCEServing->nolog) { - FilePrint(pCLServing->fd, "bumped %s (nologging)]\r\n", - pCL->acid->string); + FilePrint(pCLServing->fd, FLAGFALSE, + "bumped %s (nologging)]\r\n", pCL->acid->string); } else { - FilePrint(pCLServing->fd, "bumped %s]\r\n", pCL->acid->string); + FilePrint(pCLServing->fd, FLAGFALSE, "bumped %s]\r\n", + pCL->acid->string); } - FileWrite(pCL->fd, "\r\n[forced to `spy' mode by ", -1); - FileWrite(pCL->fd, pCLServing->acid->string, -1); - FileWrite(pCL->fd, "]\r\n", -1); + FileWrite(pCL->fd, FLAGTRUE, "\r\n[forced to `spy' mode by ", -1); + FileWrite(pCL->fd, FLAGTRUE, pCLServing->acid->string, -1); + FileWrite(pCL->fd, FLAGFALSE, "]\r\n", -1); TagLogfileAct(pCEServing, "%s bumped %s", pCLServing->acid->string, pCL->acid->string); } else { if (pCEServing->nolog) { - FileWrite(pCLServing->fd, "attached (nologging)]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "attached (nologging)]\r\n", -1); } else { - FileWrite(pCLServing->fd, "attached]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "attached]\r\n", -1); } TagLogfileAct(pCEServing, "%s attached", pCLServing->acid->string); } @@ -1914,8 +1934,8 @@ CommandGroup(pGE, pCLServing, pCEServing, tyme) pCL == pCLServing ? '*' : ' ', pCL->fcon ? (pCL->fwr ? "attach" : "spy") : "stopped", IdleTyme(tyme - pCL->typetym)); - FileWrite(pCLServing->fd, (char *)buf, -1); - FilePrint(pCLServing->fd, "%s\r\n", pCL->pCEto->server); + FilePrint(pCLServing->fd, FLAGFALSE, "%s%s\r\n", buf, + pCL->pCEto->server); } } @@ -1946,7 +1966,7 @@ CommandHosts(pGE, pCLServing, pCEServing, tyme) "down", pCE->pCLwr ? pCE->pCLwr->acid->string : pCE-> pCLon ? "" : ""); - FileWrite(pCLServing->fd, (char *)buf, -1); + FileWrite(pCLServing->fd, FLAGFALSE, (char *)buf, -1); } } @@ -1968,29 +1988,32 @@ CommandInfo(pGE, pCLServing, pCEServing, tyme) for (pCE = pGE->pCElist; pCE != (CONSENT *)0; pCE = pCE->pCEnext) { int comma = 0; char *s = (char *)0; - FilePrint(pCLServing->fd, "%s:%s,%lu,%hu:", pCE->server, + FilePrint(pCLServing->fd, FLAGTRUE, "%s:%s,%lu,%hu:", pCE->server, myHostname, (unsigned long)thepid, pGE->port); switch (pCE->type) { case EXEC: - FilePrint(pCLServing->fd, "|:%s,%lu,%s", + FilePrint(pCLServing->fd, FLAGTRUE, "|:%s,%lu,%s", (pCE->exec != (char *)0 ? pCE->exec : "/bin/sh"), (unsigned long)pCE->ipid, pCE->execSlave); break; case HOST: - FilePrint(pCLServing->fd, "!:%s,%hu", pCE->host, + FilePrint(pCLServing->fd, FLAGTRUE, "!:%s,%hu", pCE->host, pCE->port); break; case DEVICE: - FilePrint(pCLServing->fd, "/:%s,%s%c", pCE->device, + FilePrint(pCLServing->fd, FLAGTRUE, "/:%s,%s%c", + pCE->device, (pCE->baud ? pCE->baud->acrate : ""), (pCE->parity ? pCE->parity->key[0] : ' ')); break; case UNKNOWN: /* shut up gcc */ break; } - FilePrint(pCLServing->fd, ",%d:", FileFDNum(pCE->cofile)); + FilePrint(pCLServing->fd, FLAGTRUE, ",%d:", + FileFDNum(pCE->cofile)); if (pCE->pCLwr) { - FilePrint(pCLServing->fd, "w@%s@%ld", pCE->pCLwr->acid->string, + FilePrint(pCLServing->fd, FLAGTRUE, "w@%s@%ld", + pCE->pCLwr->acid->string, tyme - pCE->pCLwr->typetym); comma = 1; } @@ -1999,19 +2022,20 @@ CommandInfo(pGE, pCLServing, pCEServing, tyme) if (pCL == pCE->pCLwr) continue; if (comma) - FilePrint(pCLServing->fd, ","); + FilePrint(pCLServing->fd, FLAGTRUE, ","); if (pCL->fcon) - FilePrint(pCLServing->fd, "r@%s@%ld@%s", pCL->acid->string, - tyme - pCL->typetym, (pCL->fwantwr && - !pCL->fro) ? "rw" : "ro"); + FilePrint(pCLServing->fd, FLAGTRUE, "r@%s@%ld@%s", + pCL->acid->string, tyme - pCL->typetym, + (pCL->fwantwr && !pCL->fro) ? "rw" : "ro"); else - FilePrint(pCLServing->fd, "s@%s@%ld@%s", pCL->acid->string, - tyme - pCL->typetym, (pCL->fwantwr && - !pCL->fro) ? "rw" : "ro"); + FilePrint(pCLServing->fd, FLAGTRUE, "s@%s@%ld@%s", + pCL->acid->string, tyme - pCL->typetym, + (pCL->fwantwr && !pCL->fro) ? "rw" : "ro"); comma = 1; } - FilePrint(pCLServing->fd, ":%s:%s:%s,%s,%s,%s,%d,%d:%d:%s:", + FilePrint(pCLServing->fd, FLAGTRUE, + ":%s:%s:%s,%s,%s,%s,%d,%d:%d:%s:", ((pCE->fup && pCE->ioState == ISNORMAL) ? (pCE->initfile == (CONSFILE *)0 ? "up" : @@ -2028,8 +2052,8 @@ CommandInfo(pGE, pCLServing, pCEServing, tyme) comma = 0; for (n = pCE->aliases; n != (NAMES *)0; n = n->next) { if (comma) - FilePrint(pCLServing->fd, ","); - FilePrint(pCLServing->fd, "%s", n->name); + FilePrint(pCLServing->fd, FLAGTRUE, ","); + FilePrint(pCLServing->fd, FLAGTRUE, "%s", n->name); comma = 1; } } @@ -2057,7 +2081,7 @@ CommandInfo(pGE, pCLServing, pCEServing, tyme) s = BuildTmpString(",autoreinit"); if (pCE->unloved == FLAGTRUE) s = BuildTmpString(",unloved"); - FilePrint(pCLServing->fd, ":%s:%s\r\n", + FilePrint(pCLServing->fd, FLAGFALSE, ":%s:%s\r\n", (s == (char *)0 ? "" : s + 1), (pCE->initcmd == (char *)0 ? "" : pCE->initcmd)); BuildTmpString((char *)0); @@ -2079,16 +2103,17 @@ CommandLogging(pGE, pCLServing, pCEServing, tyme) if (pCLServing->fwr) { pCEServing->nolog = !pCEServing->nolog; if (pCEServing->nolog) { - FileWrite(pCLServing->fd, "logging off]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "logging off]\r\n", -1); TagLogfile(pCEServing, "Console logging disabled by %s", pCLServing->acid->string); } else { - FileWrite(pCLServing->fd, "logging on]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "logging on]\r\n", -1); TagLogfile(pCEServing, "Console logging restored by %s", pCLServing->acid->string); } } else { - FilePrint(pCLServing->fd, "attach to toggle logging]\r\n"); + FilePrint(pCLServing->fd, FLAGFALSE, + "attach to toggle logging]\r\n"); } } @@ -2115,7 +2140,7 @@ CommandOpen(pGE, pCLServing, pCEServing, tyme) if (pCLServing->fro || pCEServing->fronly || (pCEServing->fup && pCEServing->ioState == ISNORMAL && pCEServing->initfile == (CONSFILE *)0 && !pCLServing->fwr)) { - FileWrite(pCLServing->fd, "attach to reopen]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "attach to reopen]\r\n", -1); return; } /* with a close/re-open we might @@ -2124,21 +2149,23 @@ CommandOpen(pGE, pCLServing, pCEServing, tyme) ConsInit(pCEServing); if (pCEServing->initfile != (CONSFILE *)0 || pCEServing->ioState == INCONNECT) { - FileWrite(pCLServing->fd, "read-only -- initializing]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "read-only -- initializing]\r\n", -1); } else if (!(pCEServing->fup && pCEServing->ioState == ISNORMAL)) { - FileWrite(pCLServing->fd, "line to console is down]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "line to console is down]\r\n", -1); } else if (pCEServing->fronly) { - FileWrite(pCLServing->fd, "up read-only]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "up read-only]\r\n", -1); } else if ((CONSCLIENT *)0 == (pCL = pCEServing->pCLwr)) { pCEServing->pCLwr = pCLServing; pCLServing->fwr = 1; - FileWrite(pCLServing->fd, "up -- attached]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "up -- attached]\r\n", -1); TagLogfileAct(pCEServing, "%s attached", pCLServing->acid->string); } else if (pCL == pCLServing) { - FileWrite(pCLServing->fd, "up]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "up]\r\n", -1); TagLogfileAct(pCEServing, "%s attached", pCLServing->acid->string); } else { - FilePrint(pCLServing->fd, "up, %s is attached]\r\n", + FilePrint(pCLServing->fd, FLAGFALSE, "up, %s is attached]\r\n", pCL->acid->string); } } @@ -2164,7 +2191,7 @@ CommandWho(pGE, pCLServing, pCEServing, tyme) pCL->acid->string, pCL == pCLServing ? '*' : ' ', pCL->fcon ? (pCL->fwr ? "attach" : "spy") : "stopped", IdleTyme(tyme - pCL->typetym), pCL->actym); - FileWrite(pCLServing->fd, (char *)buf, -1); + FileWrite(pCLServing->fd, FLAGFALSE, (char *)buf, -1); } } @@ -2265,7 +2292,7 @@ DoConsoleRead(pCEServing) * allow the normal stuff to happen (so folks can watch) */ if (pCEServing->initfile != (CONSFILE *)0) - FileWrite(pCEServing->initfile, (char *)acIn, nr); + FileWrite(pCEServing->initfile, FLAGFALSE, (char *)acIn, nr); /* output all console info nobody is attached */ @@ -2294,7 +2321,7 @@ DoConsoleRead(pCEServing) for (pCL = pCEServing->pCLon; (CONSCLIENT *)0 != pCL; pCL = pCL->pCLnext) { if (pCL->fcon) { - FileWrite(pCL->fd, (char *)acIn, nr); + FileWrite(pCL->fd, FLAGFALSE, (char *)acIn, nr); } } } @@ -2398,14 +2425,15 @@ DoClientRead(pGE, pCLServing) if (pCLServing->iState == S_PASSWD) { if (CheckPasswd(pCLServing, pCLServing->accmd->string) != AUTH_SUCCESS) { - FileWrite(pCLServing->fd, "invalid password\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "invalid password\r\n", -1); BuildString((char *)0, pCLServing->accmd); DisconnectClient(pGE, pCLServing, (char *)0, FLAGFALSE); return; } Verbose(" login %s", pCLServing->acid->string); - FileWrite(pCLServing->fd, "ok\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", -1); pCLServing->iState = S_NORMAL; BuildString((char *)0, pCLServing->accmd); continue; @@ -2447,16 +2475,17 @@ DoClientRead(pGE, pCLServing) for (ppc = (pCLServing->iState == S_IDENT ? apcHelp1 : apcHelp2); (char *)0 != *ppc; ++ppc) { - FileWrite(pCLServing->fd, *ppc, -1); + FileWrite(pCLServing->fd, FLAGTRUE, *ppc, -1); } + FileWrite(pCLServing->fd, FLAGFALSE, (char *)0, 0); } else if (strcmp(pcCmd, "exit") == 0) { - FileWrite(pCLServing->fd, "goodbye\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "goodbye\r\n", -1); DisconnectClient(pGE, pCLServing, (char *)0, FLAGFALSE); return; #if HAVE_OPENSSL } else if (pCLServing->iState == S_IDENT && strcmp(pcCmd, "ssl") == 0) { - FileWrite(pCLServing->fd, "ok\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", -1); if (!AttemptSSL(pCLServing)) { DisconnectClient(pGE, pCLServing, (char *)0, FLAGFALSE); @@ -2468,12 +2497,12 @@ DoClientRead(pGE, pCLServing) #if HAVE_OPENSSL if (config->sslrequired == FLAGTRUE && FileGetType(pCLServing->fd) != SSLSocket) { - FileWrite(pCLServing->fd, "encryption required\r\n", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "encryption required\r\n", -1); } else { #endif if (pcArgs == (char *)0) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "login requires argument\r\n", -1); } else { BuildString((char *)0, pCLServing->username); @@ -2488,10 +2517,11 @@ DoClientRead(pGE, pCLServing) pCLServing->iState = S_NORMAL; Verbose(" login %s", pCLServing->acid->string); - FileWrite(pCLServing->fd, "ok\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", + -1); } else { - FilePrint(pCLServing->fd, "passwd? %s\r\n", - myHostname); + FilePrint(pCLServing->fd, FLAGFALSE, + "passwd? %s\r\n", myHostname); pCLServing->iState = S_PASSWD; } } @@ -2501,8 +2531,8 @@ DoClientRead(pGE, pCLServing) } else if (pCLServing->iState == S_NORMAL && strcmp(pcCmd, "call") == 0) { if (pcArgs == (char *)0) - FileWrite(pCLServing->fd, "call requires argument\r\n", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "call requires argument\r\n", -1); else { /* try to move to the given console * we assume all the right checks for ambiguity @@ -2550,7 +2580,7 @@ DoClientRead(pGE, pCLServing) } if (pCLServing->pCEwant == (CONSENT *)0) { - FilePrint(pCLServing->fd, + FilePrint(pCLServing->fd, FLAGFALSE, "%s: no such console\r\n", pcArgs); DisconnectClient(pGE, pCLServing, (char *)0, FLAGFALSE); @@ -2561,7 +2591,7 @@ DoClientRead(pGE, pCLServing) ClientAccess(pCLServing->pCEwant, pCLServing->username->string); if (pCLServing->fro == -1) { - FilePrint(pCLServing->fd, + FilePrint(pCLServing->fd, FLAGFALSE, "%s: permission denied\r\n", pcArgs); DisconnectClient(pGE, pCLServing, (char *)0, FLAGFALSE); @@ -2613,33 +2643,35 @@ DoClientRead(pGE, pCLServing) /* try for attach on new console */ if (pCEServing->fronly) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "[console is read-only]\r\n", -1); } else if (pCEServing->initfile != (CONSFILE *)0 || pCEServing->ioState == INCONNECT) { pCLServing->fwantwr = 1; - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "[read-only -- initializing]\r\n", -1); } else if (! (pCEServing->fup && pCEServing->ioState == ISNORMAL)) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "[line to console is down]\r\n", -1); } else if (((CONSCLIENT *)0 == pCEServing->pCLwr) && !pCLServing->fro) { pCEServing->pCLwr = pCLServing; pCLServing->fwr = 1; - FileWrite(pCLServing->fd, "[attached]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "[attached]\r\n", -1); /* this keeps the ops console neat */ pCEServing->iend = 0; TagLogfileAct(pCEServing, "%s attached", pCLServing->acid->string); } else { pCLServing->fwantwr = 1; - FileWrite(pCLServing->fd, "[spy]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "[spy]\r\n", + -1); } - pCLServing->fcon = 1; + pCLServing->fcon = 0; pCLServing->iState = S_NORMAL; } } else if (pCLServing->iState == S_NORMAL && @@ -2657,7 +2689,7 @@ DoClientRead(pGE, pCLServing) } else if (pCLServing->iState == S_NORMAL && strcmp(pcCmd, "broadcast") == 0) { if (pcArgs == (char *)0) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "broadcast requires argument\r\n", -1); } else { BuildString((char *)0, bcast); @@ -2667,20 +2699,20 @@ DoClientRead(pGE, pCLServing) BuildString(pcArgs, bcast); BuildString("]\r\n", bcast); SendAllClientsMsg(pGE, bcast->string); - FileWrite(pCLServing->fd, "ok\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", -1); } } else if (pCLServing->iState == S_NORMAL && strcmp(pcCmd, "textmsg") == 0) { char *pcMsg; if (pcArgs == (char *)0) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "textmsg requires two arguments\r\n", -1); } else { if ((pcMsg = strchr(pcArgs, ' ')) != (char *)0) { *pcMsg++ = '\000'; } if (pcMsg == (char *)0) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "textmsg requires two arguments\r\n", -1); } else { @@ -2694,13 +2726,13 @@ DoClientRead(pGE, pCLServing) BuildString("]\r\n", bcast); SendCertainClientsMsg(pGE, pcArgs, bcast->string); - FileWrite(pCLServing->fd, "ok\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", -1); } } } else if (pCLServing->iState == S_NORMAL && strcmp(pcCmd, "disconnect") == 0) { if (pcArgs == (char *)0) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "disconnect requires argument\r\n", -1); } else { if (ConsentFindUser @@ -2718,14 +2750,15 @@ DoClientRead(pGE, pCLServing) /* client expects this string to be formatted * in this way only. */ - FilePrint(pCLServing->fd, + FilePrint(pCLServing->fd, FLAGFALSE, "ok -- disconnected %d users\r\n", num); } else - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "unauthorized command\r\n", -1); } } else { - FileWrite(pCLServing->fd, "unknown command\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "unknown command\r\n", + -1); } BuildString((char *)0, pCLServing->accmd); } else @@ -2741,14 +2774,15 @@ DoClientRead(pGE, pCLServing) (acIn[i] >= ' ' && acIn[i] <= '~')) { BuildStringChar(acIn[i], pCLServing->msg); if (pGE->pCEctl != pCEServing) - FileWrite(pCLServing->fd, (char *)&acIn[i], - 1); + FileWrite(pCLServing->fd, FLAGFALSE, + (char *)&acIn[i], 1); } else if ((acIn[i] == '\b' || acIn[i] == 0x7f) && pCLServing->msg->used > 1) { if (pCLServing->msg-> string[pCLServing->msg->used - 2] != '\a' && pGE->pCEctl != pCEServing) { - FileWrite(pCLServing->fd, "\b \b", 3); + FileWrite(pCLServing->fd, FLAGFALSE, + "\b \b", 3); } pCLServing->msg->string[pCLServing->msg->used - 2] = '\000'; @@ -2756,7 +2790,7 @@ DoClientRead(pGE, pCLServing) } continue; } - FileWrite(pCLServing->fd, "]\r\n", 3); + FileWrite(pCLServing->fd, FLAGFALSE, "]\r\n", 3); BuildString((char *)0, bcast); BuildStringChar('[', bcast); BuildString(pCLServing->acid->string, bcast); @@ -2774,11 +2808,13 @@ DoClientRead(pGE, pCLServing) if (acIn[i] >= '0' && acIn[i] <= '7') { BuildStringChar(acIn[i], pCLServing->accmd); if (pCLServing->accmd->used < 4) { - FileWrite(pCLServing->fd, (char *)&acIn[i], 1); + FileWrite(pCLServing->fd, FLAGFALSE, + (char *)&acIn[i], 1); continue; } - FileWrite(pCLServing->fd, (char *)&acIn[i], 1); - FileWrite(pCLServing->fd, "]", 1); + FileWrite(pCLServing->fd, FLAGTRUE, + (char *)&acIn[i], 1); + FileWrite(pCLServing->fd, FLAGFALSE, "]", 1); pCLServing->accmd->string[0] = (((pCLServing->accmd->string[0] - '0') * 8 + @@ -2788,7 +2824,8 @@ DoClientRead(pGE, pCLServing) pCLServing->accmd->string[0], 1); BuildString((char *)0, pCLServing->accmd); } else { - FileWrite(pCLServing->fd, " aborted]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + " aborted]\r\n", -1); } pCLServing->iState = S_NORMAL; continue; @@ -2797,26 +2834,27 @@ DoClientRead(pGE, pCLServing) if (! (pCEServing->fup && pCEServing->ioState == ISNORMAL)) { - FileWrite(pCLServing->fd, " -- line down]\r\n", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + " -- line down]\r\n", -1); } else if (pCEServing->fronly) { - FileWrite(pCLServing->fd, " -- read-only]\r\n", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + " -- read-only]\r\n", -1); } else if (((CONSCLIENT *)0 == pCEServing->pCLwr) && !pCLServing->fro) { pCEServing->pCLwr = pCLServing; pCLServing->fwr = 1; if (pCEServing->nolog) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, " -- attached (nologging)]\r\n", -1); } else { - FileWrite(pCLServing->fd, " -- attached]\r\n", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + " -- attached]\r\n", -1); } TagLogfileAct(pCEServing, "%s attached", pCLServing->acid->string); } else { - FileWrite(pCLServing->fd, " -- spy mode]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + " -- spy mode]\r\n", -1); } pCLServing->fcon = 1; pCLServing->iState = S_NORMAL; @@ -2841,7 +2879,7 @@ DoClientRead(pGE, pCLServing) * than octal escapes, but....) */ if ('\r' == acIn[i] || '\n' == acIn[i]) { - FilePrint(pCLServing->fd, + FilePrint(pCLServing->fd, FLAGFALSE, "[read-only -- use %s %s ? for help]\r\n", FmtCtl(pCLServing->ic[0], acA1), FmtCtl(pCLServing->ic[1], acA2)); @@ -2851,24 +2889,26 @@ DoClientRead(pGE, pCLServing) case S_HALT1: /* halt sequence? */ pCLServing->iState = S_NORMAL; if (acIn[i] != '?' && (acIn[i] < '0' || acIn[i] > '9')) { - FileWrite(pCLServing->fd, "aborted]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "aborted]\r\n", -1); continue; } if (acIn[i] == '?') { int i; char ms[4]; - FileWrite(pCLServing->fd, "list]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "list]\r\n", + -1); i = pCEServing->breakNum; if (i == 0 || breakList[i - 1].seq->used <= 1) - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGTRUE, " 0 - 0ms, \r\n", -1); else { sprintf(ms, "%3d", breakList[i - 1].delay); FmtCtlStr(breakList[i - 1].seq->string, breakList[i - 1].seq->used - 1, acA1); - FilePrint(pCLServing->fd, + FilePrint(pCLServing->fd, FLAGTRUE, " 0 - %sms, `%s'\r\n", ms, acA1->string); } @@ -2878,17 +2918,18 @@ DoClientRead(pGE, pCLServing) FmtCtlStr(breakList[i].seq->string, breakList[i].seq->used - 1, acA1); - FilePrint(pCLServing->fd, + FilePrint(pCLServing->fd, FLAGTRUE, " %d - %sms, `%s'\r\n", i + 1, ms, acA1->string); } } + FileWrite(pCLServing->fd, FLAGFALSE, (char *)0, 0); } else { if (pCLServing->fwr) { int bt = acIn[i] - '0'; SendBreak(pCLServing, pCEServing, bt); } else - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "attach to send break]\r\n", -1); } continue; @@ -2896,7 +2937,8 @@ DoClientRead(pGE, pCLServing) case S_CATTN: /* redef escape sequence? */ pCLServing->ic[0] = acInOrig[i]; FmtCtl(acInOrig[i], acA1); - FilePrint(pCLServing->fd, "%s ", acA1->string); + FilePrint(pCLServing->fd, FLAGFALSE, "%s ", + acA1->string); pCLServing->iState = S_CESC; continue; @@ -2904,15 +2946,17 @@ DoClientRead(pGE, pCLServing) pCLServing->ic[1] = acInOrig[i]; pCLServing->iState = S_NORMAL; FmtCtl(acInOrig[i], acA1); - FilePrint(pCLServing->fd, "%s ok]\r\n", acA1->string); + FilePrint(pCLServing->fd, FLAGFALSE, "%s ok]\r\n", + acA1->string); continue; case S_ESC1: /* first char in escape sequence */ if (acInOrig[i] == pCLServing->ic[1]) { if (pCLServing->fecho) - FileWrite(pCLServing->fd, "\r\n[", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "\r\n[", + -1); else - FileWrite(pCLServing->fd, "[", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "[", -1); pCLServing->iState = S_CMD; continue; } @@ -2942,20 +2986,27 @@ DoClientRead(pGE, pCLServing) case S_CMD: /* have 1/2 of the escape sequence */ pCLServing->iState = S_NORMAL; switch (acIn[i]) { + case ';': + if (pCLServing->fcon == 1) + goto unknownchar; + FileWrite(pCLServing->fd, FLAGFALSE, + "connected]\r\n", -1); + pCLServing->fcon = 1; + break; case '+': case '-': if (0 != (pCLServing->fecho = '+' == acIn[i])) - FileWrite(pCLServing->fd, "drop line]\r\n", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "drop line]\r\n", -1); else - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "no drop line]\r\n", -1); break; case 'b': /* broadcast message */ case 'B': - FileWrite(pCLServing->fd, "Enter message: ", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "Enter message: ", -1); pCLServing->iState = S_BCAST; break; @@ -2979,7 +3030,8 @@ DoClientRead(pGE, pCLServing) case 'e': /* redefine escape keys */ case 'E': pCLServing->iState = S_CATTN; - FileWrite(pCLServing->fd, "redef: ", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "redef: ", + -1); break; case 'f': /* force attach */ @@ -2990,7 +3042,8 @@ DoClientRead(pGE, pCLServing) case 'g': /* group info */ case 'G': - FilePrint(pCLServing->fd, "group %s]\r\n", + FilePrint(pCLServing->fd, FLAGFALSE, + "group %s]\r\n", pGE->pCEctl->server); CommandGroup(pGE, pCLServing, pCEServing, tyme); @@ -3005,7 +3058,8 @@ DoClientRead(pGE, pCLServing) case 'i': case 'I': - FileWrite(pCLServing->fd, "info]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "info]\r\n", -1); CommandInfo(pGE, pCLServing, pCEServing, tyme); break; @@ -3016,13 +3070,24 @@ DoClientRead(pGE, pCLServing) case 'l': /* halt character 1 */ if (pCEServing->fronly) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "can't halt read-only console]\r\n", -1); continue; } pCLServing->iState = S_HALT1; - FileWrite(pCLServing->fd, "halt ", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "halt ", + -1); + break; + + case 'm': /* message of the day */ + if (pCEServing->motd == (char *)0) + FileWrite(pCLServing->fd, FLAGFALSE, + "-- MOTD --]\r\n", -1); + else + FilePrint(pCLServing->fd, FLAGFALSE, + "-- MOTD -- %s]\r\n", + pCEServing->motd); break; case 'o': /* close and re-open line */ @@ -3031,19 +3096,21 @@ DoClientRead(pGE, pCLServing) break; case '\022': /* ^R */ - FileWrite(pCLServing->fd, "^R]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "^R]\r\n", + -1); Replay(pCEServing->fdlog, pCLServing->fd, 1); break; case 'R': /* DEC vt100 pf3 */ case 'r': /* replay 20 lines */ - FileWrite(pCLServing->fd, "replay]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "replay]\r\n", -1); Replay(pCEServing->fdlog, pCLServing->fd, 20); break; case 'p': /* replay 60 lines */ - FileWrite(pCLServing->fd, "long replay]\r\n", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "long replay]\r\n", -1); Replay(pCEServing->fdlog, pCLServing->fd, 60); break; @@ -3051,7 +3118,8 @@ DoClientRead(pGE, pCLServing) case 's': /* spy mode */ pCLServing->fwantwr = 0; if (!pCLServing->fwr) { - FileWrite(pCLServing->fd, "ok]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "ok]\r\n", -1); break; } pCLServing->fwr = 0; @@ -3059,32 +3127,35 @@ DoClientRead(pGE, pCLServing) pCLServing->acid->string); pCEServing->pCLwr = (CONSCLIENT *)0; FindWrite(pCEServing); - FileWrite(pCLServing->fd, "spying]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "spying]\r\n", -1); break; case 'u': /* hosts on server this */ case 'U': - FileWrite(pCLServing->fd, "hosts]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "hosts]\r\n", -1); CommandHosts(pGE, pCLServing, pCEServing, tyme); break; case 'v': /* version */ case 'V': - FilePrint(pCLServing->fd, "version `%s']\r\n", - THIS_VERSION); + FilePrint(pCLServing->fd, FLAGFALSE, + "version `%s']\r\n", THIS_VERSION); break; case 'w': /* who */ case 'W': - FilePrint(pCLServing->fd, "who %s]\r\n", - pCEServing->server); + FilePrint(pCLServing->fd, FLAGFALSE, + "who %s]\r\n", pCEServing->server); CommandWho(pGE, pCLServing, pCEServing, tyme); break; case 'x': case 'X': - FileWrite(pCLServing->fd, "examine]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "examine]\r\n", -1); CommandExamine(pGE, pCLServing, pCEServing, tyme); break; @@ -3110,21 +3181,22 @@ DoClientRead(pGE, pCLServing) case '\t': /* toggle tab expand */ if (!pCLServing->fwr) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "attach to toggle tabs]\r\n", -1); continue; } if (pCEServing->type != DEVICE && pCEServing->type != EXEC) { - FileWrite(pCLServing->fd, "ok]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "ok]\r\n", -1); continue; } if (-1 == tcgetattr(FileFDNum(pCEServing->cofile), &sbuf)) { - FileWrite(pCLServing->fd, "failed]\r\n", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "failed]\r\n", -1); continue; } # if !defined(XTABS) /* XXX hack */ @@ -3140,24 +3212,24 @@ DoClientRead(pGE, pCLServing) if (-1 == tcsetattr(FileFDNum(pCEServing->cofile), TCSANOW, &sbuf)) { - FileWrite(pCLServing->fd, "failed]\r\n", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "failed]\r\n", -1); continue; } if (XTABS == (TABDLY & sbuf.c_oflag)) - FileWrite(pCLServing->fd, "tabs OFF]\r\n", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "tabs OFF]\r\n", -1); else - FileWrite(pCLServing->fd, "tabs ON]\r\n", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "tabs ON]\r\n", -1); break; case 'Q': /* DEC vt100 PF2 */ case '.': /* disconnect */ case '\004': case '\003': - FileWrite(pCLServing->fd, "disconnect]\r\n", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "disconnect]\r\n", -1); nr = 0; if (pCEServing->fup && pCEServing->type == DEVICE) { @@ -3165,7 +3237,7 @@ DoClientRead(pGE, pCLServing) tcgetattr(FileFDNum (pCEServing->cofile), &sbuf)) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "[failed]\r\n", -1); continue; } @@ -3183,29 +3255,32 @@ DoClientRead(pGE, pCLServing) case ' ': /* abort escape sequence */ case '\n': case '\r': - FileWrite(pCLServing->fd, "ignored]\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "ignored]\r\n", -1); break; case '\\': /* quote mode (send ^Q,^S) */ if (pCEServing->fronly) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "can't write to read-only console]\r\n", -1); continue; } if (!pCLServing->fwr) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "attach to send character]\r\n", -1); continue; } BuildString((char *)0, pCLServing->accmd); pCLServing->iState = S_QUOTE; - FileWrite(pCLServing->fd, "quote \\", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "quote \\", -1); break; default: /* unknown sequence */ - FileWrite(pCLServing->fd, + unknownchar: + FileWrite(pCLServing->fd, FLAGFALSE, "unknown -- use `?']\r\n", -1); break; } @@ -3309,7 +3384,7 @@ Kiddie(pGE, sfd) SimpleSignal(SIGINT, FlagGoAwayAlso); sprintf((char *)acOut, "ctl_%hu", pGE->port); - if ((pGE->pCEctl->server = strdup((char *)acOut)) + if ((pGE->pCEctl->server = StrDup((char *)acOut)) == (char *)0) OutOfMem(); @@ -3530,8 +3605,9 @@ Kiddie(pGE, sfd) FileCanWrite(pCEServing->cofile, &rmask, &wmask)) { CONDDEBUG((1, "Master(): flushing fd %d", FileFDNum(pCEServing->cofile))); - if (FileWrite(pCEServing->cofile, (char *)0, 0) < - 0) { + if (FileWrite + (pCEServing->cofile, FLAGFALSE, (char *)0, + 0) < 0) { ConsoleError(pCEServing); break; } @@ -3541,7 +3617,9 @@ Kiddie(pGE, sfd) FileCanWrite(pCEServing->fdlog, &rmask, &wmask)) { CONDDEBUG((1, "Kiddie(): flushing fd %d", FileFDNum(pCEServing->fdlog))); - if (FileWrite(pCEServing->fdlog, (char *)0, 0) < 0) { + if (FileWrite + (pCEServing->fdlog, FLAGFALSE, (char *)0, + 0) < 0) { ConsoleError(pCEServing); break; } @@ -3552,8 +3630,9 @@ Kiddie(pGE, sfd) &wmask)) { CONDDEBUG((1, "Kiddie(): flushing fd %d", FileFDNum(pCEServing->initfile))); - if (FileWrite(pCEServing->initfile, (char *)0, 0) < - 0) { + if (FileWrite + (pCEServing->initfile, FLAGFALSE, (char *)0, + 0) < 0) { ConsoleError(pCEServing); break; } @@ -3602,7 +3681,9 @@ Kiddie(pGE, sfd) FileCanWrite(pCLServing->fd, &rmask, &wmask)) { CONDDEBUG((1, "Kiddie(): flushing fd %d", FileFDNum(pCLServing->fd))); - if (FileWrite(pCLServing->fd, (char *)0, 0) < 0) { + if (FileWrite + (pCLServing->fd, FLAGFALSE, (char *)0, + 0) < 0) { DisconnectClient(pGE, pCLServing, (char *)0, FLAGTRUE); break; @@ -3648,7 +3729,8 @@ Kiddie(pGE, sfd) pCEServing->wbuf->used - 1, FileFDNum(pCEServing->cofile))); if (FileWrite - (pCEServing->cofile, pCEServing->wbuf->string, + (pCEServing->cofile, FLAGFALSE, + pCEServing->wbuf->string, pCEServing->wbuf->used - 1) < 0) { ConsoleError(pCEServing); break; @@ -3680,7 +3762,7 @@ Kiddie(pGE, sfd) pCEServing->wbufIAC - 2, FileFDNum(pCEServing->cofile))); if (FileWrite - (pCEServing->cofile, + (pCEServing->cofile, FLAGFALSE, pCEServing->wbuf->string, pCEServing->wbufIAC - 2) < 0) { ConsoleError(pCEServing); @@ -3721,7 +3803,7 @@ Kiddie(pGE, sfd) if (tcsendbreak (FileFDNum(pCEServing->cofile), 0) == -1) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "[tcsendbreak() failed]\r\n", -1); return; @@ -3829,8 +3911,8 @@ Kiddie(pGE, sfd) buf->used - 1, FileFDNum(pCEServing->cofile))); if (FileWrite - (pCEServing->cofile, buf->string, - buf->used - 1) < 0) { + (pCEServing->cofile, FLAGFALSE, + buf->string, buf->used - 1) < 0) { ConsoleError(pCEServing); break; } @@ -3975,7 +4057,7 @@ Kiddie(pGE, sfd) if (ClientAccessOk(pCL)) { pCL->ioState = ISNORMAL; /* say hi to start */ - FileWrite(pCL->fd, "ok\r\n", -1); + FileWrite(pCL->fd, FLAGFALSE, "ok\r\n", -1); } else DisconnectClient(pGE, pCLServing, (char *)0, FLAGFALSE); BuildString(pCL->peername->string, pCL->acid); @@ -4080,6 +4162,32 @@ Spawn(pGE) isMaster = 0; break; } + /* clean out the master client lists - they aren't useful here and just + * cause extra file descriptors and memory allocation to lie around, + * not a very good thing! + */ + while (pCLmall != (CONSCLIENT *)0) { + CONSCLIENT *pCL; + if (pCLmall->fd != (CONSFILE *)0) { + int fd; + fd = FileUnopen(pCLmall->fd); + pCLmall->fd = (CONSFILE *)0; + CONDDEBUG((1, "Spawn(): closing Master() client fd %d", fd)); + close(fd); + FD_CLR(fd, &rinit); + FD_CLR(fd, &winit); + } + pCL = pCLmall->pCLscan; + DestroyClient(pCLmall); + pCLmall = pCL; + } + while (pCLmfree != (CONSCLIENT *)0) { + CONSCLIENT *pCL; + pCL = pCLmfree->pCLnext; + DestroyClient(pCLmfree); + pCLmfree = pCL; + } + if (listen(sfd, SOMAXCONN) < 0) { Error("Spawn(): listen(%hu): %s", pGE->port, strerror(errno)); Bye(EX_OSERR); diff --git a/conserver/main.c b/conserver/main.c index f92c0fd..1051b23 100644 --- a/conserver/main.c +++ b/conserver/main.c @@ -1,5 +1,5 @@ /* - * $Id: main.c,v 5.160 2003-09-29 07:01:35-07 bryan Exp $ + * $Id: main.c,v 5.161 2003-10-03 06:32:34-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -1179,13 +1179,13 @@ main(argc, argv) } break; case 'b': - if ((optConf->secondaryport = strdup(optarg)) == (char *)0) + if ((optConf->secondaryport = StrDup(optarg)) == (char *)0) OutOfMem(); break; case 'c': #if HAVE_OPENSSL if ((optConf->sslcredentials = - strdup(optarg)) == (char *)0) + StrDup(optarg)) == (char *)0) OutOfMem(); #endif break; @@ -1213,7 +1213,7 @@ main(argc, argv) fNoinit = 1; break; case 'L': - if ((optConf->logfile = strdup(optarg)) == (char *)0) + if ((optConf->logfile = StrDup(optarg)) == (char *)0) OutOfMem(); break; case 'm': @@ -1239,11 +1239,11 @@ main(argc, argv) optConf->reinitcheck = atoi(optarg); break; case 'p': - if ((optConf->primaryport = strdup(optarg)) == (char *)0) + if ((optConf->primaryport = StrDup(optarg)) == (char *)0) OutOfMem(); break; case 'P': - if ((optConf->passwdfile = strdup(optarg)) == (char *)0) + if ((optConf->passwdfile = StrDup(optarg)) == (char *)0) OutOfMem(); break; case 'R': @@ -1356,11 +1356,11 @@ main(argc, argv) /* set up the port to bind to */ if (optConf->primaryport != (char *)0) - config->primaryport = strdup(optConf->primaryport); + config->primaryport = StrDup(optConf->primaryport); else if (pConfig->primaryport != (char *)0) - config->primaryport = strdup(pConfig->primaryport); + config->primaryport = StrDup(pConfig->primaryport); else - config->primaryport = strdup(DEFPORT); + config->primaryport = StrDup(DEFPORT); if (config->primaryport == (char *)0) OutOfMem(); @@ -1387,11 +1387,11 @@ main(argc, argv) /* set up the secondary port to bind to */ if (optConf->secondaryport != (char *)0) - config->secondaryport = strdup(optConf->secondaryport); + config->secondaryport = StrDup(optConf->secondaryport); else if (pConfig->secondaryport != (char *)0) - config->secondaryport = strdup(pConfig->secondaryport); + config->secondaryport = StrDup(pConfig->secondaryport); else - config->secondaryport = strdup(DEFBASEPORT); + config->secondaryport = StrDup(DEFBASEPORT); if (config->secondaryport == (char *)0) OutOfMem(); @@ -1417,20 +1417,20 @@ main(argc, argv) } if (optConf->passwdfile != (char *)0) - config->passwdfile = strdup(optConf->passwdfile); + config->passwdfile = StrDup(optConf->passwdfile); else if (pConfig->passwdfile != (char *)0) - config->passwdfile = strdup(pConfig->passwdfile); + config->passwdfile = StrDup(pConfig->passwdfile); else - config->passwdfile = strdup(PASSWDFILE); + config->passwdfile = StrDup(PASSWDFILE); if (config->passwdfile == (char *)0) OutOfMem(); if (optConf->logfile != (char *)0) - config->logfile = strdup(optConf->logfile); + config->logfile = StrDup(optConf->logfile); else if (pConfig->logfile != (char *)0) - config->logfile = strdup(pConfig->logfile); + config->logfile = StrDup(pConfig->logfile); else - config->logfile = strdup(LOGFILEPATH); + config->logfile = StrDup(LOGFILEPATH); if (config->logfile == (char *)0) OutOfMem(); diff --git a/conserver/master.c b/conserver/master.c index 0fb490f..6393be2 100644 --- a/conserver/master.c +++ b/conserver/master.c @@ -1,5 +1,5 @@ /* - * $Id: master.c,v 5.115 2003-09-29 08:39:13-07 bryan Exp $ + * $Id: master.c,v 5.117 2003-10-03 07:23:37-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -42,7 +42,8 @@ static sig_atomic_t fSawQuit = 0, fSawHUP = 0, fSawUSR2 = 0, fSawUSR1 = 0, fSawCHLD = 0; -static CONSCLIENT *pCLfree = (CONSCLIENT *)0; +CONSCLIENT *pCLmfree = (CONSCLIENT *)0; +CONSCLIENT *pCLmall = (CONSCLIENT *)0; #if HAVE_DMALLOC && DMALLOC_MARK_CLIENT_CONNECTION static unsigned long dmallocMarkClientConnection = 0; #endif @@ -331,25 +332,27 @@ CommandCall(pCL, args) } switch (found) { case 0: - FilePrint(pCL->fd, "console `%s' not found\r\n", args); + FilePrint(pCL->fd, FLAGFALSE, "console `%s' not found\r\n", + args); break; case 1: if ((REMOTE *)0 != pRCFound) { if (config->redirect != FLAGTRUE) { - FilePrint(pCL->fd, + FilePrint(pCL->fd, FLAGFALSE, "automatic redirection disabled - console on master `%s'\r\n", pRCFound->rhost); } else { - FilePrint(pCL->fd, "@%s\r\n", pRCFound->rhost); + FilePrint(pCL->fd, FLAGFALSE, "@%s\r\n", + pRCFound->rhost); } } else { - FilePrint(pCL->fd, "%hu\r\n", prnum); + FilePrint(pCL->fd, FLAGFALSE, "%hu\r\n", prnum); } break; default: found = strlen(ambiguous); ambiguous[found - 2] = '\000'; - FilePrint(pCL->fd, + FilePrint(pCL->fd, FLAGFALSE, "ambiguous console abbreviation, `%s'\r\n\tchoices are %s\r\n", args, ambiguous); break; @@ -390,8 +393,8 @@ DropMasterClient(pCLServing, force) } *(pCLServing->ppCLbscan) = pCLServing->pCLscan; /* put on the free list */ - pCLServing->pCLnext = pCLfree; - pCLfree = pCLServing; + pCLServing->pCLnext = pCLmfree; + pCLmfree = pCLServing; /* we didn't touch pCLServing->pCLscan so the loop works */ #if HAVE_DMALLOC && DMALLOC_MARK_CLIENT_CONNECTION @@ -436,13 +439,14 @@ DoNormalRead(pCLServing) if (pCLServing->iState == S_PASSWD) { if (CheckPasswd(pCLServing, pCLServing->accmd->string) != AUTH_SUCCESS) { - FileWrite(pCLServing->fd, "invalid password\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "invalid password\r\n", -1); BuildString((char *)0, pCLServing->accmd); DropMasterClient(pCLServing, FLAGFALSE); return; } Verbose(" login %s", pCLServing->acid->string); - FileWrite(pCLServing->fd, "ok\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", -1); pCLServing->iState = S_NORMAL; BuildString((char *)0, pCLServing->accmd); continue; @@ -484,16 +488,17 @@ DoNormalRead(pCLServing) for (ppc = (pCLServing->iState == S_IDENT ? apcHelp1 : apcHelp2); (char *)0 != *ppc; ++ppc) { - FileWrite(pCLServing->fd, *ppc, -1); + FileWrite(pCLServing->fd, FLAGTRUE, *ppc, -1); } + FileWrite(pCLServing->fd, FLAGFALSE, (char *)0, 0); } else if (strcmp(pcCmd, "exit") == 0) { - FileWrite(pCLServing->fd, "goodbye\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "goodbye\r\n", -1); DropMasterClient(pCLServing, FLAGFALSE); return; #if HAVE_OPENSSL } else if (pCLServing->iState == S_IDENT && strcmp(pcCmd, "ssl") == 0) { - FileWrite(pCLServing->fd, "ok\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", -1); if (!AttemptSSL(pCLServing)) { DropMasterClient(pCLServing, FLAGFALSE); return; @@ -504,11 +509,12 @@ DoNormalRead(pCLServing) #if HAVE_OPENSSL if (config->sslrequired == FLAGTRUE && FileGetType(pCLServing->fd) != SSLSocket) { - FileWrite(pCLServing->fd, "encryption required\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "encryption required\r\n", -1); } else { #endif if (pcArgs == (char *)0) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "login requires argument\r\n", -1); } else { BuildString((char *)0, pCLServing->username); @@ -523,10 +529,10 @@ DoNormalRead(pCLServing) pCLServing->iState = S_NORMAL; Verbose(" login %s", pCLServing->acid->string); - FileWrite(pCLServing->fd, "ok\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "ok\r\n", -1); } else { - FilePrint(pCLServing->fd, "passwd? %s\r\n", - myHostname); + FilePrint(pCLServing->fd, FLAGFALSE, + "passwd? %s\r\n", myHostname); pCLServing->iState = S_PASSWD; } } @@ -543,52 +549,60 @@ DoNormalRead(pCLServing) if (-1 == getsockname(FileFDNum(pCLServing->fd), (struct sockaddr *)&lcl, &so)) { - FileWrite(pCLServing->fd, + FileWrite(pCLServing->fd, FLAGFALSE, "getsockname failed, try again later\r\n", -1); Error("Master(): getsockname(%u): %s", FileFDNum(pCLServing->fd), strerror(errno)); Bye(EX_OSERR); } - FilePrint(pCLServing->fd, "@%s", inet_ntoa(lcl.sin_addr)); + FilePrint(pCLServing->fd, FLAGTRUE, "@%s", + inet_ntoa(lcl.sin_addr)); iSep = 0; } if (config->redirect == FLAGTRUE) { REMOTE *pRC; for (pRC = pRCUniq; (REMOTE *)0 != pRC; pRC = pRC->pRCuniq) { - FilePrint(pCLServing->fd, ":@%s" + iSep, pRC->rhost); + FilePrint(pCLServing->fd, FLAGTRUE, ":@%s" + iSep, + pRC->rhost); iSep = 0; } } - FileWrite(pCLServing->fd, "\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "\r\n", -1); } else if (pCLServing->iState == S_NORMAL && strcmp(pcCmd, "pid") == 0) { - FilePrint(pCLServing->fd, "%lu\r\n", (unsigned long)thepid); + FilePrint(pCLServing->fd, FLAGFALSE, "%lu\r\n", + (unsigned long)thepid); } else if (pCLServing->iState == S_NORMAL && strcmp(pcCmd, "version") == 0) { - FilePrint(pCLServing->fd, "version `%s'\r\n", THIS_VERSION); + FilePrint(pCLServing->fd, FLAGFALSE, "version `%s'\r\n", + THIS_VERSION); } else if (pCLServing->iState == S_NORMAL && strcmp(pcCmd, "quit") == 0) { if (ConsentFindUser(pADList, pCLServing->username->string) != (CONSENTUSERS *)0 || ConsentFindUser(pADList, "*") != (CONSENTUSERS *)0) { Verbose("quit command by %s", pCLServing->acid->string); - FileWrite(pCLServing->fd, "ok -- terminated\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "ok -- terminated\r\n", -1); DropMasterClient(pCLServing, FLAGFALSE); kill(thepid, SIGTERM); return; } else - FileWrite(pCLServing->fd, "unauthorized command\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "unauthorized command\r\n", -1); } else if (pCLServing->iState == S_NORMAL && strcmp(pcCmd, "restart") == 0) { if (ConsentFindUser(pADList, pCLServing->username->string) != (CONSENTUSERS *)0 || ConsentFindUser(pADList, "*") != (CONSENTUSERS *)0) { - FileWrite(pCLServing->fd, "ok -- restarting\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "ok -- restarting\r\n", -1); Verbose("restart command by %s", pCLServing->acid->string); kill(thepid, SIGHUP); } else - FileWrite(pCLServing->fd, "unauthorized command\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "unauthorized command\r\n", -1); } else if (pCLServing->iState == S_NORMAL && strcmp(pcCmd, "groups") == 0) { int iSep = 1; @@ -597,19 +611,21 @@ DoNormalRead(pCLServing) for (pGE = pGroups; pGE != (GRPENT *)0; pGE = pGE->pGEnext) { if (0 == pGE->imembers) continue; - FilePrint(pCLServing->fd, ":%hu" + iSep, pGE->port); + FilePrint(pCLServing->fd, FLAGTRUE, ":%hu" + iSep, + pGE->port); iSep = 0; } - FileWrite(pCLServing->fd, "\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "\r\n", -1); } else if (pCLServing->iState == S_NORMAL && strcmp(pcCmd, "call") == 0) { if (pcArgs == (char *)0) - FileWrite(pCLServing->fd, "call requires argument\r\n", - -1); + FileWrite(pCLServing->fd, FLAGFALSE, + "call requires argument\r\n", -1); else CommandCall(pCLServing, pcArgs); } else { - FileWrite(pCLServing->fd, "unknown command\r\n", -1); + FileWrite(pCLServing->fd, FLAGFALSE, "unknown command\r\n", + -1); } BuildString((char *)0, pCLServing->accmd); } @@ -633,7 +649,6 @@ Master() FILE *fp; CONSCLIENT *pCLServing = (CONSCLIENT *)0; CONSCLIENT *pCL = (CONSCLIENT *)0; - CONSCLIENT *pCLall = (CONSCLIENT *)0; /* set up signal handler */ @@ -656,13 +671,13 @@ Master() SimpleSignal(SIGINT, FlagSawINT); /* prime the free connection slots */ - if ((pCLfree = (CONSCLIENT *)calloc(1, sizeof(CONSCLIENT))) + if ((pCLmfree = (CONSCLIENT *)calloc(1, sizeof(CONSCLIENT))) == (CONSCLIENT *)0) OutOfMem(); - pCLfree->accmd = AllocString(); - pCLfree->peername = AllocString(); - pCLfree->username = AllocString(); - pCLfree->acid = AllocString(); + pCLmfree->accmd = AllocString(); + pCLmfree->peername = AllocString(); + pCLmfree->username = AllocString(); + pCLmfree->acid = AllocString(); /* set up port for master to listen on */ @@ -731,7 +746,7 @@ Master() ReReadCfg(msfd); /* fix up the client descriptors since ReReadCfg() doesn't * see them like it can in the child processes */ - for (pCL = pCLall; pCL != (CONSCLIENT *)0; pCL = pCL->pCLscan) { + for (pCL = pCLmall; pCL != (CONSCLIENT *)0; pCL = pCL->pCLscan) { FD_SET(FileFDNum(pCL->fd), &rinit); if (maxfd < FileFDNum(pCL->fd) + 1) maxfd = FileFDNum(pCL->fd) + 1; @@ -768,7 +783,7 @@ Master() } /* anything on a connection? */ - for (pCLServing = pCLall; (CONSCLIENT *)0 != pCLServing; + for (pCLServing = pCLmall; (CONSCLIENT *)0 != pCLServing; pCLServing = pCLServing->pCLscan) { switch (pCLServing->ioState) { #if HAVE_OPENSSL @@ -791,7 +806,9 @@ Master() FileCanWrite(pCLServing->fd, &rmask, &wmask)) { CONDDEBUG((1, "Master(): flushing fd %d", FileFDNum(pCLServing->fd))); - if (FileWrite(pCLServing->fd, (char *)0, 0) < 0) { + if (FileWrite + (pCLServing->fd, FLAGFALSE, (char *)0, + 0) < 0) { DropMasterClient(pCLServing, FLAGTRUE); break; } @@ -823,7 +840,7 @@ Master() so = sizeof(struct sockaddr_in); for (cfd = 0; cfd == 0;) { cfd = - accept(msfd, (struct sockaddr *)&pCLfree->cnct_port, &so); + accept(msfd, (struct sockaddr *)&pCLmfree->cnct_port, &so); if (cfd < 0 && errno == EINTR) cfd = 0; } @@ -838,11 +855,11 @@ Master() /* set to non-blocking and wrap in a File object */ if (SetFlags(cfd, O_NONBLOCK, 0)) - pCLfree->fd = FileOpenFD(cfd, simpleSocket); + pCLmfree->fd = FileOpenFD(cfd, simpleSocket); else - pCLfree->fd = (CONSFILE *)0; + pCLmfree->fd = (CONSFILE *)0; - if ((CONSFILE *)0 == pCLfree->fd) { + if ((CONSFILE *)0 == pCLmfree->fd) { Error("Master(): FileOpenFD(%u): %s", cfd, strerror(errno)); #if HAVE_DMALLOC && DMALLOC_MARK_CLIENT_CONNECTION CONDDEBUG((1, "Master(): dmalloc / MarkClientConnection")); @@ -852,27 +869,27 @@ Master() } /* remove from the free list */ - pCL = pCLfree; - pCLfree = pCL->pCLnext; + pCL = pCLmfree; + pCLmfree = pCL->pCLnext; /* add another if we ran out */ - if (pCLfree == (CONSCLIENT *)0) { - if ((pCLfree = (CONSCLIENT *)calloc(1, sizeof(CONSCLIENT))) + if (pCLmfree == (CONSCLIENT *)0) { + if ((pCLmfree = (CONSCLIENT *)calloc(1, sizeof(CONSCLIENT))) == (CONSCLIENT *)0) OutOfMem(); - pCLfree->accmd = AllocString(); - pCLfree->peername = AllocString(); - pCLfree->username = AllocString(); - pCLfree->acid = AllocString(); + pCLmfree->accmd = AllocString(); + pCLmfree->peername = AllocString(); + pCLmfree->username = AllocString(); + pCLmfree->acid = AllocString(); } /* link into all clients list */ - pCL->pCLscan = pCLall; - pCL->ppCLbscan = &pCLall; + pCL->pCLscan = pCLmall; + pCL->ppCLbscan = &pCLmall; if ((CONSCLIENT *)0 != pCL->pCLscan) { pCL->pCLscan->ppCLbscan = &pCL->pCLscan; } - pCLall = pCL; + pCLmall = pCL; FD_SET(cfd, &rinit); if (maxfd < cfd + 1) @@ -888,16 +905,16 @@ Master() if (ClientAccessOk(pCL)) { pCL->ioState = ISNORMAL; /* say hi to start */ - FileWrite(pCL->fd, "ok\r\n", -1); + FileWrite(pCL->fd, FLAGFALSE, "ok\r\n", -1); } else DropMasterClient(pCL, FLAGFALSE); } /* clean up the free list */ - while (pCLfree != (CONSCLIENT *)0) { - pCL = pCLfree->pCLnext; - DestroyClient(pCLfree); - pCLfree = pCL; + while (pCLmfree != (CONSCLIENT *)0) { + pCL = pCLmfree->pCLnext; + DestroyClient(pCLmfree); + pCLmfree = pCL; } unlink(PIDFILE); diff --git a/conserver/master.h b/conserver/master.h index 60c8b6e..97a3adb 100644 --- a/conserver/master.h +++ b/conserver/master.h @@ -1,5 +1,5 @@ /* - * $Id: master.h,v 5.16 2003-03-06 10:13:41-08 bryan Exp $ + * $Id: master.h,v 5.17 2003-10-03 07:23:37-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -37,5 +37,7 @@ /* * stuff the master process needs */ +extern CONSCLIENT *pCLmall; +extern CONSCLIENT *pCLmfree; extern void Master PARAMS((void)); extern void SignalKids PARAMS((int)); diff --git a/conserver/readcfg.c b/conserver/readcfg.c index f3a61a0..c9faf26 100644 --- a/conserver/readcfg.c +++ b/conserver/readcfg.c @@ -1,5 +1,5 @@ /* - * $Id: readcfg.c,v 5.140 2003-09-28 09:32:55-07 bryan Exp $ + * $Id: readcfg.c,v 5.144 2003-10-03 06:32:34-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -111,7 +111,7 @@ AddUserList(id) if ((u = (NAMES *)calloc(1, sizeof(NAMES))) == (NAMES *)0) OutOfMem(); - if ((u->name = strdup(id)) + if ((u->name = StrDup(id)) == (char *)0) OutOfMem(); u->next = userList; @@ -625,6 +625,8 @@ DestroyParserDefaultOrConsole(c, ph, pt) free(c->logfile); if (c->initcmd != (char *)0) free(c->initcmd); + if (c->motd != (char *)0) + free(c->motd); if (c->execSlave != (char *)0) free(c->execSlave); if (c->wbuf != (STRING *)0) @@ -702,37 +704,43 @@ ApplyDefault(d, c) if (d->host != (char *)0) { if (c->host != (char *)0) free(c->host); - if ((c->host = strdup(d->host)) == (char *)0) + if ((c->host = StrDup(d->host)) == (char *)0) OutOfMem(); } if (d->master != (char *)0) { if (c->master != (char *)0) free(c->master); - if ((c->master = strdup(d->master)) == (char *)0) + if ((c->master = StrDup(d->master)) == (char *)0) OutOfMem(); } if (d->exec != (char *)0) { if (c->exec != (char *)0) free(c->exec); - if ((c->exec = strdup(d->exec)) == (char *)0) + if ((c->exec = StrDup(d->exec)) == (char *)0) OutOfMem(); } if (d->device != (char *)0) { if (c->device != (char *)0) free(c->device); - if ((c->device = strdup(d->device)) == (char *)0) + if ((c->device = StrDup(d->device)) == (char *)0) OutOfMem(); } if (d->logfile != (char *)0) { if (c->logfile != (char *)0) free(c->logfile); - if ((c->logfile = strdup(d->logfile)) == (char *)0) + if ((c->logfile = StrDup(d->logfile)) == (char *)0) OutOfMem(); } if (d->initcmd != (char *)0) { if (c->initcmd != (char *)0) free(c->initcmd); - if ((c->initcmd = strdup(d->initcmd)) == (char *)0) + if ((c->initcmd = StrDup(d->initcmd)) == (char *)0) + OutOfMem(); + } + if (d->motd != (char *)0) { + if (c->motd != (char *)0) + free(c->motd); + if ((c->motd = StrDup(d->motd)) == (char *)0) OutOfMem(); } if (d->ro != (CONSENTUSERS *)0) { @@ -770,7 +778,7 @@ DefaultBegin(id) == (CONSENT *)0) OutOfMem(); - if ((parserDefaultTemp->server = strdup(id)) + if ((parserDefaultTemp->server = StrDup(id)) == (char *)0) OutOfMem(); } @@ -918,7 +926,7 @@ ProcessDevice(c, id) } if ((id == (char *)0) || (*id == '\000')) return; - if ((c->device = strdup(id)) + if ((c->device = StrDup(id)) == (char *)0) OutOfMem(); } @@ -951,7 +959,7 @@ ProcessExec(c, id) if (id == (char *)0 || id[0] == '\000') { return; } - if ((c->exec = strdup(id)) + if ((c->exec = StrDup(id)) == (char *)0) OutOfMem(); } @@ -1008,7 +1016,7 @@ ProcessHost(c, id) } if ((id == (char *)0) || (*id == '\000')) return; - if ((c->host = strdup(id)) + if ((c->host = StrDup(id)) == (char *)0) OutOfMem(); } @@ -1074,16 +1082,16 @@ ProcessLogfile(c, id) if (id == (char *)0 || id[0] == '\000') { return; } - if ((c->logfile = strdup(id)) + if ((c->logfile = StrDup(id)) == (char *)0) OutOfMem(); } void #if PROTOTYPES -ProcessRuninit(CONSENT *c, char *id) +ProcessInitcmd(CONSENT *c, char *id) #else -ProcessRuninit(c, id) +ProcessInitcmd(c, id) CONSENT *c; char *id; #endif @@ -1095,7 +1103,28 @@ ProcessRuninit(c, id) if (id == (char *)0 || id[0] == '\000') { return; } - if ((c->initcmd = strdup(id)) + if ((c->initcmd = StrDup(id)) + == (char *)0) + OutOfMem(); +} + +void +#if PROTOTYPES +ProcessMOTD(CONSENT *c, char *id) +#else +ProcessMOTD(c, id) + CONSENT *c; + char *id; +#endif +{ + if (c->motd != (char *)0) { + free(c->motd); + c->motd = (char *)0; + } + if (id == (char *)0 || id[0] == '\000') { + return; + } + if ((c->motd = StrDup(id)) == (char *)0) OutOfMem(); } @@ -1114,14 +1143,26 @@ DefaultItemLogfile(id) void #if PROTOTYPES -DefaultItemRuninit(char *id) +DefaultItemInitcmd(char *id) #else -DefaultItemRuninit(id) +DefaultItemInitcmd(id) char *id; #endif { - CONDDEBUG((1, "DefaultItemRuninit(%s) [%s:%d]", id, file, line)); - ProcessRuninit(parserDefaultTemp, id); + CONDDEBUG((1, "DefaultItemInitcmd(%s) [%s:%d]", id, file, line)); + ProcessInitcmd(parserDefaultTemp, id); +} + +void +#if PROTOTYPES +DefaultItemMOTD(char *id) +#else +DefaultItemMOTD(id) + char *id; +#endif +{ + CONDDEBUG((1, "DefaultItemMOTD(%s) [%s:%d]", id, file, line)); + ProcessMOTD(parserDefaultTemp, id); } void @@ -1139,7 +1180,7 @@ ProcessMaster(c, id) } if ((id == (char *)0) || (*id == '\000')) return; - if ((c->master = strdup(id)) + if ((c->master = StrDup(id)) == (char *)0) OutOfMem(); } @@ -1583,7 +1624,7 @@ ConsoleBegin(id) "*")) != (CONSENT *)0) { ApplyDefault(c, parserConsoleTemp); } - if ((parserConsoleTemp->server = strdup(id)) + if ((parserConsoleTemp->server = StrDup(id)) == (char *)0) OutOfMem(); } @@ -1738,7 +1779,7 @@ ExpandLogfile(c, id) *amp = '&'; } tmp = BuildTmpString(p); - if ((c->logfile = strdup(tmp)) + if ((c->logfile = StrDup(tmp)) == (char *)0) OutOfMem(); } @@ -1766,10 +1807,10 @@ ConsoleAdd(c) if ((pRCTemp = (REMOTE *)calloc(1, sizeof(REMOTE))) == (REMOTE *)0) OutOfMem(); - if ((pRCTemp->rhost = strdup(c->master)) + if ((pRCTemp->rhost = StrDup(c->master)) == (char *)0) OutOfMem(); - if ((pRCTemp->rserver = strdup(c->server)) + if ((pRCTemp->rserver = StrDup(c->server)) == (char *)0) OutOfMem(); pRCTemp->aliases = c->aliases; @@ -2127,6 +2168,7 @@ ConsoleAdd(c) } /* and now the rest (minus the "runtime" members - see below) */ + SwapStr(pCEmatch->motd, c->motd); pCEmatch->activitylog = c->activitylog; pCEmatch->breaklog = c->breaklog; pCEmatch->mark = c->mark; @@ -2316,7 +2358,7 @@ ConsoleDestroy() continue; pCL->fro = access; if (access) { - FileWrite(pCL->fd, + FileWrite(pCL->fd, FLAGFALSE, "[Conserver reconfigured - r/w access removed]\r\n", -1); if (pCL->fwr) { @@ -2333,7 +2375,7 @@ ConsoleDestroy() FindWrite(pCE); } } else { - FileWrite(pCL->fd, + FileWrite(pCL->fd, FLAGFALSE, "[Conserver reconfigured - r/w access granted]\r\n", -1); } @@ -2403,7 +2445,7 @@ ConsoleItemAliases(id) } if ((name = (NAMES *)calloc(1, sizeof(NAMES))) == (NAMES *)0) OutOfMem(); - if ((name->name = strdup(token)) == (char *)0) + if ((name->name = StrDup(token)) == (char *)0) OutOfMem(); name->next = parserConsoleTemp->aliases; parserConsoleTemp->aliases = name; @@ -2508,14 +2550,26 @@ ConsoleItemLogfile(id) void #if PROTOTYPES -ConsoleItemRuninit(char *id) +ConsoleItemInitcmd(char *id) #else -ConsoleItemRuninit(id) +ConsoleItemInitcmd(id) char *id; #endif { - CONDDEBUG((1, "ConsoleItemRuninit(%s) [%s:%d]", id, file, line)); - ProcessRuninit(parserConsoleTemp, id); + CONDDEBUG((1, "ConsoleItemInitcmd(%s) [%s:%d]", id, file, line)); + ProcessInitcmd(parserConsoleTemp, id); +} + +void +#if PROTOTYPES +ConsoleItemMOTD(char *id) +#else +ConsoleItemMOTD(id) + char *id; +#endif +{ + CONDDEBUG((1, "ConsoleItemMOTD(%s) [%s:%d]", id, file, line)); + ProcessMOTD(parserConsoleTemp, id); } void @@ -2713,7 +2767,7 @@ AccessAddACL(pa, access) == (ACCESS *)0) OutOfMem(); *new = *access; - if ((new->pcwho = strdup(access->pcwho)) + if ((new->pcwho = StrDup(access->pcwho)) == (char *)0) OutOfMem(); /* link into the list at the end */ @@ -3007,7 +3061,7 @@ AccessProcessACL(trust, acl) OutOfMem(); pa->ctrust = trust; pa->isCIDR = isCIDR; - if ((pa->pcwho = strdup(token)) + if ((pa->pcwho = StrDup(token)) == (char *)0) OutOfMem(); @@ -3078,6 +3132,8 @@ DestroyConfig(c) free(c->logfile); if (c->initcmd != (char *)0) free(c->initcmd); + if (c->motd != (char *)0) + free(c->motd); if (c->passwdfile != (char *)0) free(c->passwdfile); if (c->primaryport != (char *)0) @@ -3143,6 +3199,12 @@ ConfigEnd() pConfig->initcmd = parserConfigTemp->initcmd; parserConfigTemp->initcmd = (char *)0; } + if (parserConfigTemp->motd != (char *)0) { + if (pConfig->motd != (char *)0) + free(pConfig->motd); + pConfig->motd = parserConfigTemp->motd; + parserConfigTemp->motd = (char *)0; + } if (parserConfigTemp->passwdfile != (char *)0) { if (pConfig->passwdfile != (char *)0) free(pConfig->passwdfile); @@ -3289,7 +3351,7 @@ ConfigItemLogfile(id) } return; } - if ((parserConfigTemp->logfile = strdup(id)) + if ((parserConfigTemp->logfile = StrDup(id)) == (char *)0) OutOfMem(); } @@ -3310,7 +3372,7 @@ ConfigItemPasswordfile(id) } return; } - if ((parserConfigTemp->passwdfile = strdup(id)) + if ((parserConfigTemp->passwdfile = StrDup(id)) == (char *)0) OutOfMem(); } @@ -3331,7 +3393,7 @@ ConfigItemPrimaryport(id) } return; } - if ((parserConfigTemp->primaryport = strdup(id)) + if ((parserConfigTemp->primaryport = StrDup(id)) == (char *)0) OutOfMem(); } @@ -3395,7 +3457,7 @@ ConfigItemSecondaryport(id) } return; } - if ((parserConfigTemp->secondaryport = strdup(id)) + if ((parserConfigTemp->secondaryport = StrDup(id)) == (char *)0) OutOfMem(); } @@ -3417,7 +3479,7 @@ ConfigItemSslcredentials(id) } return; } - if ((parserConfigTemp->sslcredentials = strdup(id)) + if ((parserConfigTemp->sslcredentials = StrDup(id)) == (char *)0) OutOfMem(); } @@ -3455,13 +3517,14 @@ ITEM keyDefault[] = { /* {"flow", DefaultItemFlow}, */ {"host", DefaultItemHost}, {"include", DefaultItemInclude}, + {"initcmd", DefaultItemInitcmd}, {"logfile", DefaultItemLogfile}, {"master", DefaultItemMaster}, + {"motd", DefaultItemMOTD}, {"options", DefaultItemOptions}, {"parity", DefaultItemParity}, {"port", DefaultItemPort}, {"ro", DefaultItemRo}, - {"initcmd", DefaultItemRuninit}, {"rw", DefaultItemRw}, {"timestamp", DefaultItemTimestamp}, {"type", DefaultItemType}, @@ -3477,13 +3540,14 @@ ITEM keyConsole[] = { /* {"flow", ConsoleItemFlow}, */ {"host", ConsoleItemHost}, {"include", ConsoleItemInclude}, + {"initcmd", ConsoleItemInitcmd}, {"logfile", ConsoleItemLogfile}, {"master", ConsoleItemMaster}, + {"motd", ConsoleItemMOTD}, {"options", ConsoleItemOptions}, {"parity", ConsoleItemParity}, {"port", ConsoleItemPort}, {"ro", ConsoleItemRo}, - {"initcmd", ConsoleItemRuninit}, {"rw", ConsoleItemRw}, {"timestamp", ConsoleItemTimestamp}, {"type", ConsoleItemType}, @@ -4005,7 +4069,7 @@ ReReadCfg(fd) strcmp(pConfig->logfile, config->logfile) != 0)) { if (config->logfile != (char *)0) free(config->logfile); - if ((config->logfile = strdup(pConfig->logfile)) + if ((config->logfile = StrDup(pConfig->logfile)) == (char *)0) OutOfMem(); ReopenLogfile(); @@ -4022,7 +4086,7 @@ ReReadCfg(fd) strcmp(pConfig->passwdfile, config->passwdfile) != 0)) { if (config->passwdfile != (char *)0) free(config->passwdfile); - if ((config->passwdfile = strdup(pConfig->passwdfile)) + if ((config->passwdfile = StrDup(pConfig->passwdfile)) == (char *)0) OutOfMem(); /* gets used on-the-fly */ @@ -4071,7 +4135,7 @@ ReReadCfg(fd) strcasecmp(pConfig->primaryport, config->primaryport) != 0)) { if (config->primaryport != (char *)0) free(config->primaryport); - if ((config->primaryport = strdup(pConfig->primaryport)) + if ((config->primaryport = StrDup(pConfig->primaryport)) == (char *)0) OutOfMem(); Msg("warning: `primaryport' config option changed - you must restart for it to take effect"); @@ -4083,7 +4147,7 @@ ReReadCfg(fd) config->secondaryport) != 0)) { if (config->secondaryport != (char *)0) free(config->secondaryport); - if ((config->secondaryport = strdup(pConfig->secondaryport)) + if ((config->secondaryport = StrDup(pConfig->secondaryport)) == (char *)0) OutOfMem(); Msg("warning: `secondaryport' config option changed - you must restart for it to take effect"); @@ -4096,7 +4160,7 @@ ReReadCfg(fd) config->sslcredentials) != 0)) { if (config->sslcredentials != (char *)0) free(config->sslcredentials); - if ((config->sslcredentials = strdup(pConfig->sslcredentials)) + if ((config->sslcredentials = StrDup(pConfig->sslcredentials)) == (char *)0) OutOfMem(); Msg("warning: `sslcredentials' config option changed - you must restart for it to take effect"); diff --git a/conserver/readcfg.h b/conserver/readcfg.h index 637c79a..985ee99 100644 --- a/conserver/readcfg.h +++ b/conserver/readcfg.h @@ -1,5 +1,5 @@ /* - * $Id: readcfg.h,v 5.32 2003-09-28 08:54:16-07 bryan Exp $ + * $Id: readcfg.h,v 5.33 2003-10-02 18:53:48-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -12,6 +12,7 @@ typedef struct config { FLAG daemonmode; char *logfile; char *initcmd; + char *motd; char *passwdfile; char *primaryport; FLAG redirect; diff --git a/conserver/util.c b/conserver/util.c index 367943d..69c5114 100644 --- a/conserver/util.c +++ b/conserver/util.c @@ -1,5 +1,5 @@ /* - * $Id: util.c,v 1.99 2003-09-28 08:51:52-07 bryan Exp $ + * $Id: util.c,v 1.102 2003-10-03 06:32:34-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -1012,9 +1012,15 @@ FileRead(cfp, buf, len) if (tmpString == (STRING *)0) tmpString = AllocString(); BuildString((char *)0, tmpString); - FmtCtlStr(buf, retval > 30 ? 30 : retval, tmpString); - CONDDEBUG((2, "FileRead(): read `%s' from fd %d", - tmpString->string, cfp->fd)); + if (retval > 30) { + FmtCtlStr(buf, 30, tmpString); + CONDDEBUG((2, "FileRead(): read `%s'... from fd %d", + tmpString->string, cfp->fd)); + } else { + FmtCtlStr(buf, retval, tmpString); + CONDDEBUG((2, "FileRead(): read `%s' from fd %d", + tmpString->string, cfp->fd)); + } } } else { CONDDEBUG((2, @@ -1027,10 +1033,11 @@ FileRead(cfp, buf, len) /* returns: -1 on error or eof, >= 0 for valid reads */ int #if PROTOTYPES -FileWrite(CONSFILE *cfp, char *buf, int len) +FileWrite(CONSFILE *cfp, FLAG bufferonly, char *buf, int len) #else -FileWrite(cfp, buf, len) +FileWrite(cfp, bufferonly, buf, len) CONSFILE *cfp; + FLAG bufferonly; char *buf; int len; #endif @@ -1053,14 +1060,23 @@ FileWrite(cfp, buf, len) if (tmpString == (STRING *)0) tmpString = AllocString(); BuildString((char *)0, tmpString); - FmtCtlStr(buf, len > 30 ? 30 : len, tmpString); - CONDDEBUG((2, "FileWrite(): sending `%s' to fd %d", - tmpString->string, fdout)); + if (len > 30) { + FmtCtlStr(buf, 30, tmpString); + CONDDEBUG((2, "FileWrite(): sending `%s'... to fd %d", + tmpString->string, fdout)); + } else { + FmtCtlStr(buf, len, tmpString); + CONDDEBUG((2, "FileWrite(): sending `%s' to fd %d", + tmpString->string, fdout)); + } } /* save the data */ if (len > 0 && buf != (char *)0) BuildStringN(buf, len, cfp->wbuf); + if (bufferonly == FLAGTRUE) + return 0; + /* point at the local data */ buf = cfp->wbuf->string; len = cfp->wbuf->used - 1; @@ -1253,12 +1269,12 @@ FileBufEmpty(cfp) void #if PROTOTYPES -VWrite(CONSFILE *cfp, STRING *str, unsigned which, char *fmt, va_list ap) +VWrite(CONSFILE *cfp, FLAG bufferonly, STRING *str, char *fmt, va_list ap) #else -VWrite(cfp, str, which, fmt, ap) +VWrite(cfp, bufferonly, str, fmt, ap) CONSFILE *cfp; + FLAG bufferonly; STRING *str; - unsigned which; char *fmt; va_list ap; #endif @@ -1266,41 +1282,28 @@ VWrite(cfp, str, which, fmt, ap) int s, l, e; char c; static STRING *msg = (STRING *)0; + static STRING *output = (STRING *)0; static short flong, fneg; - if (fmt == (char *)0) + if (fmt == (char *)0 || (cfp == (CONSFILE *)0 && str == (STRING *)0)) return; - switch (which) { - case 0: - if (cfp == (CONSFILE *)0) - return; - break; - case 1: - if (str == (STRING *)0) - return; - BuildString((char *)0, str); - break; - default: - return; - } if (msg == (STRING *)0) msg = AllocString(); + if (output == (STRING *)0) + output = AllocString(); + + BuildString((char *)0, output); + fneg = flong = 0; for (e = s = l = 0; (c = fmt[s + l]) != '\000'; l++) { if (c == '%') { if (e) { e = 0; - if (which == 0) - FileWrite(cfp, "%", 1); - else if (which == 1) - BuildStringChar('%', str); + BuildStringChar('%', output); } else { e = 1; - if (which == 0) - FileWrite(cfp, fmt + s, l); - else if (which == 1) - BuildStringN(fmt + s, l, str); + BuildStringN(fmt + s, l, output); s += l; l = 0; } @@ -1320,17 +1323,11 @@ VWrite(cfp, str, which, fmt, ap) continue; case 'c': cc = (char)va_arg(ap, int); - if (which == 0) - FileWrite(cfp, &cc, 1); - else if (which == 1) - BuildStringChar(cc, str); + BuildStringChar(cc, output); break; case 's': p = va_arg(ap, char *); - if (which == 0) - FileWrite(cfp, p, -1); - else if (which == 1) - BuildString(p, str); + BuildString(p, output); break; case 'd': i = (flong ? va_arg(ap, long) : (long)va_arg(ap, int)); @@ -1361,16 +1358,10 @@ VWrite(cfp, str, which, fmt, ap) msg->string[u - i - 1] = temp; } if (fneg) { - if (which == 0) - FileWrite(cfp, "-", 1); - else if (which == 1) - BuildStringChar('-', str); + BuildStringChar('-', output); fneg = 0; } - if (which == 0) - FileWrite(cfp, msg->string, msg->used - 1); - else if (which == 1) - BuildString(msg->string, str); + BuildString(msg->string, output); break; default: Error @@ -1383,11 +1374,17 @@ VWrite(cfp, str, which, fmt, ap) e = flong = 0; } } - if (l) { - if (which == 0) - FileWrite(cfp, fmt + s, l); - else if (which == 1) - BuildStringN(fmt + s, l, str); + if (l) + BuildStringN(fmt + s, l, output); + + if (str != (STRING *)0) + BuildString((char *)0, str); + + if (output->used > 1) { + if (str != (STRING *)0) + BuildStringN(output->string, output->used - 1, str); + if (cfp != (CONSFILE *)0) + FileWrite(cfp, bufferonly, output->string, output->used - 1); } } @@ -1407,7 +1404,7 @@ BuildStringPrint(str, fmt, va_alist) #else va_start(ap); #endif - VWrite((CONSFILE *)0, str, 1, fmt, ap); + VWrite((CONSFILE *)0, FLAGFALSE, str, fmt, ap); va_end(ap); if (str == (STRING *)0) return (char *)0; @@ -1417,23 +1414,25 @@ BuildStringPrint(str, fmt, va_alist) void #if PROTOTYPES -FileVWrite(CONSFILE *cfp, char *fmt, va_list ap) +FileVWrite(CONSFILE *cfp, FLAG bufferonly, char *fmt, va_list ap) #else -FileVWrite(cfp, fmt, ap) +FileVWrite(cfp, bufferonly, fmt, ap) CONSFILE *cfp; + FLAG bufferonly; char *fmt; va_list ap; #endif { - VWrite(cfp, (STRING *)0, 0, fmt, ap); + VWrite(cfp, bufferonly, (STRING *)0, fmt, ap); } void #if PROTOTYPES -FilePrint(CONSFILE *cfp, char *fmt, ...) +FilePrint(CONSFILE *cfp, FLAG bufferonly, char *fmt, ...) #else -FilePrint(cfp, fmt, va_alist) +FilePrint(cfp, bufferonly, fmt, va_alist) CONSFILE *cfp; + FLAG bufferonly; char *fmt; va_dcl #endif @@ -1444,7 +1443,7 @@ FilePrint(cfp, fmt, va_alist) #else va_start(ap); #endif - FileVWrite(cfp, fmt, ap); + FileVWrite(cfp, bufferonly, fmt, ap); va_end(ap); } @@ -1915,3 +1914,28 @@ SetFlags(fd, s, c) } return 1; } + +char * +#if PROTOTYPES +StrDup(char *msg) +#else +StrDup(msg) + char *msg; +#endif +{ + int len; + char *buf; + + if (msg == (char *)0) + return (char *)0; + len = strlen(msg) + 1; + buf = malloc(len); + if (buf == (char *)0) + return (char *)0; +#if HAVE_MEMCPY + memcpy(buf, msg, len); +#else + bcopy(msg, buf, len); +#endif + return buf; +} diff --git a/conserver/util.h b/conserver/util.h index 8026dfc..1707bbb 100644 --- a/conserver/util.h +++ b/conserver/util.h @@ -1,5 +1,5 @@ /* - * $Id: util.h,v 1.53 2003-09-28 08:45:31-07 bryan Exp $ + * $Id: util.h,v 1.55 2003-10-03 06:32:34-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -102,9 +102,9 @@ extern CONSFILE *FileOpenPipe PARAMS((int, int)); extern CONSFILE *FileOpen PARAMS((const char *, int, int)); extern int FileClose PARAMS((CONSFILE **)); extern int FileRead PARAMS((CONSFILE *, void *, int)); -extern int FileWrite PARAMS((CONSFILE *, char *, int)); -extern void FileVWrite PARAMS((CONSFILE *, char *, va_list)); -extern void FilePrint PARAMS((CONSFILE *, char *, ...)); +extern int FileWrite PARAMS((CONSFILE *, FLAG, char *, int)); +extern void FileVWrite PARAMS((CONSFILE *, FLAG, char *, va_list)); +extern void FilePrint PARAMS((CONSFILE *, FLAG, char *, ...)); extern int FileStat PARAMS((CONSFILE *, struct stat *)); extern int FileSeek PARAMS((CONSFILE *, off_t, int)); extern int FileSend PARAMS((CONSFILE *, const void *, size_t, int)); @@ -134,6 +134,7 @@ extern int FileCanRead PARAMS((CONSFILE *, fd_set *, fd_set *)); extern int FileCanWrite PARAMS((CONSFILE *, fd_set *, fd_set *)); extern int FileBufEmpty PARAMS((CONSFILE *)); extern int SetFlags PARAMS((int, int, int)); +extern char *StrDup PARAMS((char *)); #if HAVE_OPENSSL extern SSL *FileGetSSL PARAMS((CONSFILE *)); extern void FileSetSSL PARAMS((CONSFILE *, SSL *)); diff --git a/conserver/version.h b/conserver/version.h index eb0078d..67d1924 100644 --- a/conserver/version.h +++ b/conserver/version.h @@ -1,5 +1,5 @@ /* - * $Id: version.h,v 1.47 2003-09-28 13:34:49-07 bryan Exp $ + * $Id: version.h,v 1.48 2003-10-05 17:04:09-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -14,4 +14,4 @@ @(#) Copyright 2000 conserver.com.\n\ All rights reserved.\n" -#define THIS_VERSION "conserver.com version 8.0.1" +#define THIS_VERSION "conserver.com version 8.0.2" diff --git a/console/console.c b/console/console.c index f04b539..6dfff8d 100644 --- a/console/console.c +++ b/console/console.c @@ -1,5 +1,5 @@ /* - * $Id: console.c,v 5.141 2003-09-29 08:36:06-07 bryan Exp $ + * $Id: console.c,v 5.147 2003-10-03 15:21:34-07 bryan Exp $ * * Copyright conserver.com, 2000 * @@ -586,7 +586,7 @@ ReadReply(fd) if (toEOF) /* if toEOF, read until EOF */ continue; if ((result->used > 1) && - (result->string[result->used - 2] == '\n')) + strchr(result->string, '\n') != (char *)0) break; continue; } @@ -695,6 +695,7 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result) fd_set rmask, rinit; int i; int justProcessedUrg = 0; + char *r = (char *)0; if (fVerbose) { Msg("%s to %s (on %s)", pcHow, pcMach, pcMaster); @@ -755,7 +756,7 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result) printf("o\' to open console line]\n"); } } else { - FilePrint(cfstdout, "%s: %s", pcMach, result); + FilePrint(cfstdout, FLAGFALSE, "%s: %s", pcMach, result); Bye(EX_UNAVAILABLE); } @@ -766,13 +767,11 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result) chAttn = DEFATTN; chEsc = DEFESC; } else { - char *r; /* tell the conserver to change escape sequences, assume OK * (we'll find out soon enough) */ sprintf(acMesg, "%c%ce%c%c", DEFATTN, DEFESC, chAttn, chEsc); - FileWrite(pcf, acMesg, 5); - /* -bryan */ + FileWrite(pcf, FLAGFALSE, acMesg, 5); r = ReadReply(pcf, 0); if (strncmp(r, "[redef:", 7) != 0) { Error("protocol botch on redef of escape sequence"); @@ -785,6 +784,19 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result) PutCtlc(chEsc, stdout); printf("?\' for help]\n"); + /* try and display the MOTD */ + FilePrint(pcf, FLAGFALSE, "%c%cm", chAttn, chEsc); + r = ReadReply(pcf, 0); + if (strncmp(r, "[unknown", 8) != 0 && + strncmp(r, "[-- MOTD --]", 12) != 0) + FileWrite(cfstdout, FLAGFALSE, r, -1); + + FilePrint(pcf, FLAGFALSE, "%c%c;", chAttn, chEsc); + r = ReadReply(pcf, 0); + if (strncmp(r, "[unknown", 8) != 0 && + strncmp(r, "[connected]", 11) != 0) + FileWrite(cfstdout, FLAGFALSE, r, -1); + /* if the host is not down, finish the connection, and force * the correct attachment for the user */ @@ -795,14 +807,14 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result) } } else if (fIn != (*pcHow == 'f' ? 'a' : *pcHow)) { sprintf(acMesg, "%c%c%c", chAttn, chEsc, *pcHow); - FileWrite(pcf, acMesg, 3); + FileWrite(pcf, FLAGFALSE, acMesg, 3); } if (fReplay) { sprintf(acMesg, "%c%cr", chAttn, chEsc); - FileWrite(pcf, acMesg, 3); + FileWrite(pcf, FLAGFALSE, acMesg, 3); } else if (fVerbose) { sprintf(acMesg, "%c%c\022", chAttn, chEsc); - FileWrite(pcf, acMesg, 3); + FileWrite(pcf, FLAGFALSE, acMesg, 3); } } fflush(stdout); @@ -853,7 +865,7 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result) for (i = 0; i < nc; ++i) acMesg[i] &= 127; } - FileWrite(cfstdout, acMesg, nc); + FileWrite(cfstdout, FLAGFALSE, acMesg, nc); } /* anything from stdin? */ @@ -870,7 +882,7 @@ CallUp(pcf, pcMaster, pcMach, pcHow, result) for (i = 0; i < nc; ++i) acMesg[i] &= 127; } - FileWrite(pcf, acMesg, nc); + FileWrite(pcf, FLAGFALSE, acMesg, nc); } } C2Cooked(); @@ -944,11 +956,11 @@ DoCmds(master, ports, cmdi) t = ReadReply(pcf, 0); if (strcmp(t, "ok\r\n") != 0) { FileClose(&pcf); - FilePrint(cfstdout, "%s: %s", server, t); + FilePrint(cfstdout, FLAGFALSE, "%s: %s", server, t); continue; } #if HAVE_OPENSSL - FileWrite(pcf, "ssl\r\n", 5); + FileWrite(pcf, FLAGFALSE, "ssl\r\n", 5); t = ReadReply(pcf, 0); if (strcmp(t, "ok\r\n") == 0) { AttemptSSL(pcf); @@ -964,7 +976,7 @@ DoCmds(master, ports, cmdi) BuildTmpString("login "); BuildTmpString(pcUser); t = BuildTmpString("\r\n"); - FileWrite(pcf, t, -1); + FileWrite(pcf, FLAGFALSE, t, -1); t = ReadReply(pcf, 0); if (strncmp(t, "passwd?", 7) == 0) { @@ -994,10 +1006,11 @@ DoCmds(master, ports, cmdi) BuildString(pass, tmpString); BuildString("\r\n", tmpString); } - FileWrite(pcf, tmpString->string, tmpString->used - 1); + FileWrite(pcf, FLAGFALSE, tmpString->string, + tmpString->used - 1); t = ReadReply(pcf, 0); if (strcmp(t, "ok\r\n") != 0) { - FilePrint(cfstdout, "%s: %s", server, t); + FilePrint(cfstdout, FLAGFALSE, "%s: %s", server, t); if (++count < 3) { BuildString((char *)0, tmpString); goto attemptLogin; @@ -1015,9 +1028,9 @@ DoCmds(master, ports, cmdi) * have an arg (always true if it's 'call'), then send the arg */ if ((cmdi == 0 || cmds[cmdi][0] == 'c') && cmdarg != (char *)0) - FilePrint(pcf, "%s %s\r\n", cmds[cmdi], cmdarg); + FilePrint(pcf, FLAGFALSE, "%s %s\r\n", cmds[cmdi], cmdarg); else - FilePrint(pcf, "%s\r\n", cmds[cmdi]); + FilePrint(pcf, FLAGFALSE, "%s\r\n", cmds[cmdi]); /* if we haven't gone down the stack, do "normal" stuff. * if we did hit the bottom, we send the exit\r\n now so @@ -1026,7 +1039,7 @@ DoCmds(master, ports, cmdi) if (cmdi != 0) { t = ReadReply(pcf, 0); /* save the result */ - if ((result = strdup(t)) == (char *)0) + if ((result = StrDup(t)) == (char *)0) OutOfMem(); } @@ -1040,7 +1053,7 @@ DoCmds(master, ports, cmdi) Bye(EX_SOFTWARE); } } else if (result[0] != '[') { /* did we not get a connection? */ - FilePrint(cfstdout, "%s: %s", server, result); + FilePrint(cfstdout, FLAGFALSE, "%s: %s", server, result); FileClose(&pcf); continue; } else { @@ -1054,20 +1067,20 @@ DoCmds(master, ports, cmdi) } } else if (cmds[cmdi][0] == 'q') { t = ReadReply(pcf, 0); - FileWrite(cfstdout, t, -1); + FileWrite(cfstdout, FLAGFALSE, t, -1); if (t[0] != 'o' || t[1] != 'k') { - FileWrite(pcf, "exit\r\n", 6); + FileWrite(pcf, FLAGFALSE, "exit\r\n", 6); t = ReadReply(pcf, 1); } } else { /* all done */ - FileWrite(pcf, "exit\r\n", 6); + FileWrite(pcf, FLAGFALSE, "exit\r\n", 6); t = ReadReply(pcf, cmdi == 0 ? 1 : 0); if (cmdi == 0) { int len; /* if we hit bottom, this is where we get our results */ - if ((result = strdup(t)) == (char *)0) + if ((result = StrDup(t)) == (char *)0) OutOfMem(); len = strlen(result); if (len > 8 && @@ -1081,9 +1094,9 @@ DoCmds(master, ports, cmdi) */ if (cmds[0][0] == 'd') { if (result[0] != 'o' || result[1] != 'k') { - FileWrite(cfstdout, server, -1); - FileWrite(cfstdout, ": ", 2); - FileWrite(cfstdout, result, len); + FileWrite(cfstdout, FLAGTRUE, server, -1); + FileWrite(cfstdout, FLAGTRUE, ": ", 2); + FileWrite(cfstdout, FLAGFALSE, result, len); } else { disconnectCount += atoi(result + 19); } @@ -1091,10 +1104,10 @@ DoCmds(master, ports, cmdi) (result[0] != 'o' || result[1] != 'k')) { /* did a 'master' before this or doing a 'disconnect' */ if (cmds[1][0] == 'm' || cmds[0][0] == 'd') { - FileWrite(cfstdout, server, -1); - FileWrite(cfstdout, ": ", 2); + FileWrite(cfstdout, FLAGTRUE, server, -1); + FileWrite(cfstdout, FLAGTRUE, ": ", 2); } - FileWrite(cfstdout, result, len); + FileWrite(cfstdout, FLAGFALSE, result, len); } } } @@ -1413,7 +1426,8 @@ main(argc, argv) retval = DoCmds(pcInMaster, acPorts->string, cmdi); if (*pcCmd == 'd') - FilePrint(cfstdout, "Disconnected %d users\n", disconnectCount); + FilePrint(cfstdout, FLAGFALSE, "Disconnected %d users\n", + disconnectCount); Bye(retval); return 0; /* noop - Bye() terminates us */ diff --git a/console/console.man b/console/console.man index 4b7e7e6..76cf0ab 100644 --- a/console/console.man +++ b/console/console.man @@ -1,5 +1,5 @@ -.\" $Id: console.man,v 1.36 2003-09-28 15:30:52-07 bryan Exp $ -.TH CONSOLE 1 "2003-09-28" "conserver-8.0.1" "conserver" +.\" $Id: console.man,v 1.37 2003-10-02 19:00:45-07 bryan Exp $ +.TH CONSOLE 1 "2003-10-02" "conserver-8.0.2" "conserver" .SH NAME console \- console server client program .SH SYNOPSIS @@ -414,6 +414,9 @@ send the break sequence associated with this console .B l1-9 send the specific break sequence .TP +.B m +display the "message of the day" +.TP .B o close (if open) and reopen the line (to clear errors (silo overflows)) and the log file diff --git a/contrib/redhat-rpm/conserver.spec b/contrib/redhat-rpm/conserver.spec index ae63637..1cb5b47 100644 --- a/contrib/redhat-rpm/conserver.spec +++ b/contrib/redhat-rpm/conserver.spec @@ -4,7 +4,7 @@ # %define pkg conserver -%define ver conserver-8.0.1 +%define ver conserver-8.0.2 # define the name of the machine on which the main conserver # daemon will be running if you don't want to use the default diff --git a/contrib/solaris-package/pkginfo b/contrib/solaris-package/pkginfo index 000b7a8..7244c16 100644 --- a/contrib/solaris-package/pkginfo +++ b/contrib/solaris-package/pkginfo @@ -1,7 +1,7 @@ PKG="conserver" NAME="Console server and client" CATEGORY="system" -VERSION="conserver-8.0.1" +VERSION="conserver-8.0.2" DESC="Console server and client" CLASSES=none ARCH=sparc diff --git a/test/results/test2 b/test/results/test2 index fa846ea..69a4b72 100644 --- a/test/results/test2 +++ b/test/results/test2 @@ -6,11 +6,12 @@ f force attach read/write g group info i information dump L toggle logging on/off l? break sequence list l0 send break per config file - l1-9 send specific break sequence o (re)open the tty and log file - p replay the last 60 lines r replay the last 20 lines - s spy read only u show host status - v show version info w who is on this console - x show console baud info z suspend the connection - ignore/abort command ? print this message - ^R replay the last line \ooo send character by octal code + l1-9 send specific break sequence m display the message of the day + o (re)open the tty and log file p replay the last 60 lines + r replay the last 20 lines s spy read only + u show host status v show version info + w who is on this console x show console baud info + z suspend the connection ignore/abort command + ? print this message ^R replay the last line + \ooo send character by octal code [disconnect] diff --git a/test/results/test7 b/test/results/test7 index fa846ea..69a4b72 100644 --- a/test/results/test7 +++ b/test/results/test7 @@ -6,11 +6,12 @@ f force attach read/write g group info i information dump L toggle logging on/off l? break sequence list l0 send break per config file - l1-9 send specific break sequence o (re)open the tty and log file - p replay the last 60 lines r replay the last 20 lines - s spy read only u show host status - v show version info w who is on this console - x show console baud info z suspend the connection - ignore/abort command ? print this message - ^R replay the last line \ooo send character by octal code + l1-9 send specific break sequence m display the message of the day + o (re)open the tty and log file p replay the last 60 lines + r replay the last 20 lines s spy read only + u show host status v show version info + w who is on this console x show console baud info + z suspend the connection ignore/abort command + ? print this message ^R replay the last line + \ooo send character by octal code [disconnect]