2007-05-03 19:09:41 +04:00
|
|
|
/* $NetBSD: comsat.c,v 1.36 2007/05/03 15:09:41 christos Exp $ */
|
1997-10-07 14:57:08 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
1994-08-07 03:26:31 +04:00
|
|
|
* Copyright (c) 1980, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-03-21 12:45:37 +03:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
2003-08-07 13:46:37 +04:00
|
|
|
* 3. Neither the name of the University nor the names of its contributors
|
1993-03-21 12:45:37 +03:00
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
1997-10-07 14:57:08 +04:00
|
|
|
#include <sys/cdefs.h>
|
1993-03-21 12:45:37 +03:00
|
|
|
#ifndef lint
|
1997-10-07 14:57:08 +04:00
|
|
|
__COPYRIGHT("@(#) Copyright (c) 1980, 1993\n\
|
|
|
|
The Regents of the University of California. All rights reserved.\n");
|
|
|
|
#if 0
|
|
|
|
static char sccsid[] = "from: @(#)comsat.c 8.1 (Berkeley) 6/4/93";
|
|
|
|
#else
|
2007-05-03 19:09:41 +04:00
|
|
|
__RCSID("$NetBSD: comsat.c,v 1.36 2007/05/03 15:09:41 christos Exp $");
|
1997-10-07 14:57:08 +04:00
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
#endif /* not lint */
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <sys/file.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
|
|
|
#include <netinet/in.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <netdb.h>
|
1994-08-07 03:26:31 +04:00
|
|
|
#include <paths.h>
|
1994-02-01 03:32:22 +03:00
|
|
|
#include <pwd.h>
|
2004-06-25 21:34:38 +04:00
|
|
|
#include <err.h>
|
1994-08-07 03:26:31 +04:00
|
|
|
#include <signal.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <syslog.h>
|
1995-05-02 06:05:47 +04:00
|
|
|
#include <termios.h>
|
1998-04-01 18:29:08 +04:00
|
|
|
#include <time.h>
|
1998-07-03 06:27:58 +04:00
|
|
|
#include <vis.h>
|
1994-08-05 05:01:16 +04:00
|
|
|
#include <unistd.h>
|
2004-06-25 21:34:38 +04:00
|
|
|
#ifdef SUPPORT_UTMP
|
1994-08-07 03:26:31 +04:00
|
|
|
#include <utmp.h>
|
2004-06-25 21:34:38 +04:00
|
|
|
#endif
|
|
|
|
#ifdef SUPPORT_UTMPX
|
|
|
|
#include <utmpx.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "utmpentry.h"
|
|
|
|
|
|
|
|
#if !defined(SUPPORT_UTMP) && !defined(SUPPORT_UTMPX)
|
|
|
|
#error "SUPPORT_UTMP and/or SUPPORT_UTMPX must be defined"
|
|
|
|
#endif
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
#define dsyslog if (debug) syslog
|
|
|
|
|
|
|
|
#define MAXIDLE 120
|
|
|
|
|
2004-06-25 21:34:38 +04:00
|
|
|
static int logging;
|
2005-07-18 08:01:33 +04:00
|
|
|
static int debug;
|
2004-07-10 11:11:38 +04:00
|
|
|
static char hostname[MAXHOSTNAMELEN + 1];
|
2004-06-25 21:34:38 +04:00
|
|
|
static time_t utmpmtime; /* last modification time for utmp/x */
|
|
|
|
static int nutmp;
|
|
|
|
static struct utmpentry *utmp = NULL;
|
|
|
|
static time_t lastmsgtime;
|
2005-07-18 08:01:33 +04:00
|
|
|
static volatile sig_atomic_t needupdate;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2004-06-25 21:34:38 +04:00
|
|
|
int main(int, char *[]);
|
|
|
|
static void jkfprintf(FILE *, const char *, off_t, const char *);
|
|
|
|
static void mailfor(const char *);
|
|
|
|
static void notify(const struct utmpentry *, off_t);
|
|
|
|
static void onalrm(int);
|
2005-07-18 08:01:33 +04:00
|
|
|
static void checkutmp(void);
|
1994-08-07 03:26:31 +04:00
|
|
|
|
|
|
|
int
|
2000-10-04 22:52:50 +04:00
|
|
|
main(int argc, char *argv[])
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2000-08-22 20:42:37 +04:00
|
|
|
struct sockaddr_storage from;
|
1998-07-04 23:38:39 +04:00
|
|
|
int cc, ch;
|
2004-06-25 21:34:38 +04:00
|
|
|
socklen_t fromlen;
|
1994-08-07 03:26:31 +04:00
|
|
|
char msgbuf[100];
|
2004-06-25 21:34:38 +04:00
|
|
|
sigset_t nsigset, osigset;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
|
|
|
/* verify proper invocation */
|
|
|
|
fromlen = sizeof(from);
|
2004-06-25 21:34:38 +04:00
|
|
|
if (getsockname(0, (struct sockaddr *)(void *)&from, &fromlen) == -1)
|
2004-07-10 04:00:58 +04:00
|
|
|
err(1, "getsockname");
|
1998-07-04 23:38:39 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
openlog("comsat", LOG_PID, LOG_DAEMON);
|
1998-07-04 23:38:39 +04:00
|
|
|
while ((ch = getopt(argc, argv, "l")) != -1)
|
|
|
|
switch (ch) {
|
|
|
|
case 'l':
|
|
|
|
logging = 1;
|
|
|
|
break;
|
|
|
|
default:
|
2001-02-20 01:43:42 +03:00
|
|
|
syslog(LOG_ERR, "Usage: %s [-l]", getprogname());
|
1998-07-04 23:38:39 +04:00
|
|
|
exit(1);
|
|
|
|
}
|
2004-06-25 21:34:38 +04:00
|
|
|
if (chdir(_PATH_MAILDIR) == -1) {
|
1993-03-21 12:45:37 +03:00
|
|
|
syslog(LOG_ERR, "chdir: %s: %m", _PATH_MAILDIR);
|
1998-07-03 06:27:58 +04:00
|
|
|
(void)recv(0, msgbuf, sizeof(msgbuf) - 1, 0);
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
(void)time(&lastmsgtime);
|
|
|
|
(void)gethostname(hostname, sizeof(hostname));
|
1998-07-06 10:45:41 +04:00
|
|
|
hostname[sizeof(hostname) - 1] = '\0';
|
1993-03-21 12:45:37 +03:00
|
|
|
(void)signal(SIGALRM, onalrm);
|
|
|
|
(void)signal(SIGTTOU, SIG_IGN);
|
2005-07-18 08:01:33 +04:00
|
|
|
(void)signal(SIGCHLD, SIG_IGN);
|
2004-06-25 21:34:38 +04:00
|
|
|
(void)sigemptyset(&nsigset);
|
|
|
|
(void)sigaddset(&nsigset, SIGALRM);
|
|
|
|
if (sigprocmask(SIG_SETMASK, NULL, &osigset) == -1) {
|
|
|
|
syslog(LOG_ERR, "sigprocmask get failed (%m)");
|
|
|
|
exit(1);
|
|
|
|
}
|
2007-05-03 19:09:41 +04:00
|
|
|
needupdate = 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
for (;;) {
|
|
|
|
cc = recv(0, msgbuf, sizeof(msgbuf) - 1, 0);
|
|
|
|
if (cc <= 0) {
|
|
|
|
if (errno != EINTR)
|
|
|
|
sleep(1);
|
|
|
|
errno = 0;
|
2005-07-18 08:01:33 +04:00
|
|
|
checkutmp();
|
1993-03-21 12:45:37 +03:00
|
|
|
continue;
|
2005-07-18 08:01:33 +04:00
|
|
|
} else
|
|
|
|
checkutmp();
|
1993-03-21 12:45:37 +03:00
|
|
|
if (!nutmp) /* no one has logged in yet */
|
|
|
|
continue;
|
2004-06-25 21:34:38 +04:00
|
|
|
if (sigprocmask(SIG_SETMASK, &nsigset, NULL) == -1) {
|
|
|
|
syslog(LOG_ERR, "sigprocmask set failed (%m)");
|
|
|
|
exit(1);
|
|
|
|
}
|
1994-02-01 03:32:22 +03:00
|
|
|
msgbuf[cc] = '\0';
|
1993-03-21 12:45:37 +03:00
|
|
|
(void)time(&lastmsgtime);
|
|
|
|
mailfor(msgbuf);
|
2004-06-25 21:34:38 +04:00
|
|
|
if (sigprocmask(SIG_SETMASK, &osigset, NULL) == -1) {
|
|
|
|
syslog(LOG_ERR, "sigprocmask restore failed (%m)");
|
|
|
|
exit(1);
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-25 21:34:38 +04:00
|
|
|
static void
|
|
|
|
/*ARGSUSED*/
|
2005-07-18 08:01:33 +04:00
|
|
|
onalrm(int signo)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2007-05-03 19:09:41 +04:00
|
|
|
needupdate = 1;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2004-06-25 21:34:38 +04:00
|
|
|
static void
|
2005-07-18 08:01:33 +04:00
|
|
|
checkutmp(void)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
struct stat statbf;
|
2004-06-25 21:34:38 +04:00
|
|
|
time_t newtime = 0;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2005-07-18 08:01:33 +04:00
|
|
|
if (!needupdate)
|
|
|
|
return;
|
|
|
|
needupdate = 0;
|
|
|
|
|
1994-08-07 03:26:31 +04:00
|
|
|
if (time(NULL) - lastmsgtime >= MAXIDLE)
|
1993-03-21 12:45:37 +03:00
|
|
|
exit(0);
|
|
|
|
(void)alarm((u_int)15);
|
2004-06-25 21:34:38 +04:00
|
|
|
#ifdef SUPPORT_UTMP
|
|
|
|
if (stat(_PATH_UTMP, &statbf) != -1)
|
|
|
|
if (statbf.st_mtime > newtime)
|
|
|
|
newtime = statbf.st_mtime;
|
|
|
|
#endif
|
|
|
|
#ifdef SUPPORT_UTMPX
|
2004-07-10 08:00:09 +04:00
|
|
|
if (stat(_PATH_UTMPX, &statbf) != -1)
|
2004-06-25 21:34:38 +04:00
|
|
|
if (statbf.st_mtime > newtime)
|
|
|
|
newtime = statbf.st_mtime;
|
|
|
|
#endif
|
|
|
|
if (newtime > utmpmtime) {
|
|
|
|
freeutentries(utmp);
|
|
|
|
nutmp = getutentries(NULL, &utmp);
|
|
|
|
utmpmtime = newtime;
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-06-25 21:34:38 +04:00
|
|
|
static void
|
|
|
|
mailfor(const char *name)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
2004-06-25 21:34:38 +04:00
|
|
|
struct utmpentry *ep;
|
2001-03-17 00:39:08 +03:00
|
|
|
char *cp, *fn;
|
1993-03-21 12:45:37 +03:00
|
|
|
off_t offset;
|
2004-07-10 11:10:43 +04:00
|
|
|
intmax_t val;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
1994-08-07 03:26:31 +04:00
|
|
|
if (!(cp = strchr(name, '@')))
|
1993-03-21 12:45:37 +03:00
|
|
|
return;
|
|
|
|
*cp = '\0';
|
2001-03-17 00:39:08 +03:00
|
|
|
errno = 0;
|
2004-07-10 11:10:43 +04:00
|
|
|
offset = val = strtoimax(cp + 1, &fn, 10);
|
|
|
|
if (errno == ERANGE || offset != val)
|
2001-03-17 00:39:08 +03:00
|
|
|
return;
|
2001-04-02 18:57:37 +04:00
|
|
|
if (fn && *fn && *fn != '\n') {
|
2001-03-17 00:39:08 +03:00
|
|
|
/*
|
|
|
|
* Procmail sends messages to comsat with a trailing colon
|
|
|
|
* and a pathname to the folder where the new message was
|
|
|
|
* deposited. Since we can't reliably open only regular
|
|
|
|
* files, we need to ignore these. With one exception:
|
|
|
|
* if it mentions the user's system mailbox.
|
|
|
|
*/
|
2004-06-25 21:34:38 +04:00
|
|
|
char maildir[MAXPATHLEN];
|
2001-03-17 00:39:08 +03:00
|
|
|
int l = snprintf(maildir, sizeof(maildir), ":%s/%s",
|
2004-07-10 11:11:38 +04:00
|
|
|
_PATH_MAILDIR, name);
|
2004-09-15 12:44:02 +04:00
|
|
|
if (l >= sizeof(maildir) || strcmp(maildir, fn) != 0)
|
2001-03-17 00:39:08 +03:00
|
|
|
return;
|
|
|
|
}
|
2004-06-25 21:34:38 +04:00
|
|
|
for (ep = utmp; ep != NULL; ep = ep->next)
|
|
|
|
if (strcmp(ep->name, name) == 0)
|
|
|
|
notify(ep, offset);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
|
|
|
|
2004-06-25 21:34:38 +04:00
|
|
|
static void
|
|
|
|
notify(const struct utmpentry *ep, off_t offset)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
|
|
|
FILE *tp;
|
1998-07-03 06:27:58 +04:00
|
|
|
struct passwd *p;
|
1994-02-01 03:32:22 +03:00
|
|
|
struct stat stb;
|
1995-05-02 06:05:47 +04:00
|
|
|
struct termios ttybuf;
|
2004-06-25 21:34:38 +04:00
|
|
|
char tty[sizeof(_PATH_DEV) + sizeof(ep->line) + 1];
|
2005-05-08 03:37:59 +04:00
|
|
|
const char *cr = ep->line;
|
1993-03-21 12:45:37 +03:00
|
|
|
|
2005-05-08 03:37:59 +04:00
|
|
|
if (strncmp(cr, "pts/", 4) == 0)
|
|
|
|
cr += 4;
|
|
|
|
if (strchr(cr, '/')) {
|
1994-02-01 03:32:22 +03:00
|
|
|
/* A slash is an attempt to break security... */
|
2005-05-08 03:37:59 +04:00
|
|
|
syslog(LOG_AUTH | LOG_NOTICE, "Unexpected `/' in `%s'",
|
|
|
|
ep->line);
|
1994-02-01 03:32:22 +03:00
|
|
|
return;
|
|
|
|
}
|
2005-05-08 03:37:59 +04:00
|
|
|
(void)snprintf(tty, sizeof(tty), "%s%s", _PATH_DEV, ep->line);
|
|
|
|
if (stat(tty, &stb) == -1 || !(stb.st_mode & S_IEXEC)) {
|
2004-06-25 21:34:38 +04:00
|
|
|
dsyslog(LOG_DEBUG, "%s: wrong mode on %s", ep->name, tty);
|
1993-03-21 12:45:37 +03:00
|
|
|
return;
|
|
|
|
}
|
2004-06-25 21:34:38 +04:00
|
|
|
dsyslog(LOG_DEBUG, "notify %s on %s", ep->name, tty);
|
2005-05-08 03:37:59 +04:00
|
|
|
switch (fork()) {
|
|
|
|
case -1:
|
|
|
|
syslog(LOG_NOTICE, "fork failed (%m)");
|
|
|
|
return;
|
|
|
|
case 0:
|
|
|
|
break;
|
|
|
|
default:
|
1993-03-21 12:45:37 +03:00
|
|
|
return;
|
2005-05-08 03:37:59 +04:00
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
(void)signal(SIGALRM, SIG_DFL);
|
|
|
|
(void)alarm((u_int)30);
|
|
|
|
if ((tp = fopen(tty, "w")) == NULL) {
|
2004-06-25 21:34:38 +04:00
|
|
|
dsyslog(LOG_ERR, "open `%s' (%s)", tty, strerror(errno));
|
|
|
|
_exit(1);
|
|
|
|
}
|
|
|
|
if (tcgetattr(fileno(tp), &ttybuf) == -1) {
|
|
|
|
dsyslog(LOG_ERR, "tcgetattr `%s' (%s)", tty, strerror(errno));
|
2000-10-04 22:24:03 +04:00
|
|
|
_exit(1);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|
1995-05-02 06:05:47 +04:00
|
|
|
cr = (ttybuf.c_oflag & ONLCR) && (ttybuf.c_oflag & OPOST) ?
|
1993-03-21 12:45:37 +03:00
|
|
|
"\n" : "\n\r";
|
1998-07-03 06:27:58 +04:00
|
|
|
/* Set uid/gid/groups to users in case mail drop is on nfs */
|
2004-06-25 21:34:38 +04:00
|
|
|
if ((p = getpwnam(ep->name)) == NULL ||
|
|
|
|
initgroups(p->pw_name, p->pw_gid) == -1 ||
|
|
|
|
setgid(p->pw_gid) == -1 ||
|
|
|
|
setuid(p->pw_uid) == -1)
|
2000-10-04 22:24:03 +04:00
|
|
|
_exit(1);
|
1998-07-03 06:27:58 +04:00
|
|
|
|
1998-07-04 23:38:39 +04:00
|
|
|
if (logging)
|
2004-06-25 21:34:38 +04:00
|
|
|
syslog(LOG_INFO, "biff message for %s", ep->name);
|
1998-07-04 23:38:39 +04:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
(void)fprintf(tp, "%s\007New mail for %s@%.*s\007 has arrived:%s----%s",
|
2004-06-25 21:34:38 +04:00
|
|
|
cr, ep->name, (int)sizeof(hostname), hostname, cr, cr);
|
|
|
|
jkfprintf(tp, ep->name, offset, cr);
|
1993-03-21 12:45:37 +03:00
|
|
|
(void)fclose(tp);
|
|
|
|
_exit(0);
|
|
|
|
}
|
|
|
|
|
2004-06-25 21:34:38 +04:00
|
|
|
static void
|
|
|
|
jkfprintf(FILE *tp, const char *name, off_t offset, const char *cr)
|
1993-03-21 12:45:37 +03:00
|
|
|
{
|
1998-07-03 06:27:58 +04:00
|
|
|
FILE *fi;
|
|
|
|
int linecnt, charcnt, inheader;
|
2004-06-25 21:34:38 +04:00
|
|
|
char line[BUFSIZ], visline[BUFSIZ * 4 + 1], *nl;
|
1994-02-01 03:32:22 +03:00
|
|
|
|
1993-03-21 12:45:37 +03:00
|
|
|
if ((fi = fopen(name, "r")) == NULL)
|
|
|
|
return;
|
1994-08-07 03:26:31 +04:00
|
|
|
|
2004-06-25 21:34:38 +04:00
|
|
|
(void)fseeko(fi, offset, SEEK_SET);
|
1993-03-21 12:45:37 +03:00
|
|
|
/*
|
|
|
|
* Print the first 7 lines or 560 characters of the new mail
|
|
|
|
* (whichever comes first). Skip header crap other than
|
|
|
|
* From, Subject, To, and Date.
|
|
|
|
*/
|
|
|
|
linecnt = 7;
|
|
|
|
charcnt = 560;
|
|
|
|
inheader = 1;
|
|
|
|
while (fgets(line, sizeof(line), fi) != NULL) {
|
2001-03-14 07:39:42 +03:00
|
|
|
line[sizeof(line) - 1] = '\0';
|
1993-03-21 12:45:37 +03:00
|
|
|
if (inheader) {
|
|
|
|
if (line[0] == '\n') {
|
|
|
|
inheader = 0;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (line[0] == ' ' || line[0] == '\t' ||
|
1998-07-03 06:27:58 +04:00
|
|
|
(strncasecmp(line, "From:", 5) &&
|
|
|
|
strncasecmp(line, "Subject:", 8)))
|
1993-03-21 12:45:37 +03:00
|
|
|
continue;
|
|
|
|
}
|
2001-03-17 00:39:08 +03:00
|
|
|
if (strncmp(line, "From ", 5) == 0) {
|
|
|
|
(void)fprintf(tp, "----%s", cr);
|
|
|
|
(void)fclose(fi);
|
|
|
|
return;
|
|
|
|
}
|
1993-03-21 12:45:37 +03:00
|
|
|
if (linecnt <= 0 || charcnt <= 0) {
|
|
|
|
(void)fprintf(tp, "...more...%s", cr);
|
1994-08-07 03:26:31 +04:00
|
|
|
(void)fclose(fi);
|
1993-03-21 12:45:37 +03:00
|
|
|
return;
|
|
|
|
}
|
2001-03-14 07:39:42 +03:00
|
|
|
if ((nl = strchr(line, '\n')) != NULL)
|
|
|
|
*nl = '\0';
|
1993-03-21 12:45:37 +03:00
|
|
|
/* strip weird stuff so can't trojan horse stupid terminals */
|
1998-07-03 06:27:58 +04:00
|
|
|
(void)strvis(visline, line, VIS_CSTYLE);
|
2001-03-14 07:39:42 +03:00
|
|
|
(void)fputs(visline, tp);
|
|
|
|
(void)fputs(cr, tp);
|
1993-03-21 12:45:37 +03:00
|
|
|
--linecnt;
|
|
|
|
}
|
|
|
|
(void)fprintf(tp, "----%s\n", cr);
|
1994-08-07 03:26:31 +04:00
|
|
|
(void)fclose(fi);
|
1993-03-21 12:45:37 +03:00
|
|
|
}
|