static char sccsid
[] = "@(#)logent.c 5.8 (Berkeley) %G%";
#if defined(USG) || defined(BSD4_2)
static char LogRmtname
[64];
/* Open the log file if necessary */
if (strcmp(Rmtname
, LogRmtname
)) {
savemask
= umask(LOGMASK
);
(void) sprintf(lfile
, "%s/%s/%s", LOGBYSITE
, Progname
, Rmtname
);
strcpy(LogRmtname
, Rmtname
);
Lp
= fopen (LOGFILE
, "a");
flags
= fcntl(fileno(Lp
), F_GETFL
, 0);
fcntl(fileno(Lp
), F_SETFL
, flags
|O_APPEND
);
/* make entry in existing temp log file */
mlogent(Lp
, status
, text
);
mlogent(fp
, status
, text
)
extern struct tm
*localtime();
tp
= localtime(&Now
.time
);
fprintf(fp
, "%s %s (%d/%d-%2.2d:%2.2d-%d) ",
fprintf(fp
, "%s %s (%d/%d-%02d:%02d-%d) ",
User
, Rmtname
, tp
->tm_mon
+ 1, tp
->tm_mday
,
tp
->tm_hour
, tp
->tm_min
, pid
);
fprintf(fp
, "%s (%s)\n", status
, text
);
/* Since it's buffered */
lseek (fileno(fp
), (long)0, 2);
fprintf(stderr
, "%s %s ", User
, Rmtname
);
fprintf(stderr
, "(%d/%d-%2.2d:%2.2d-%d) ", tp
->tm_mon
+ 1,
tp
->tm_mday
, tp
->tm_hour
, tp
->tm_min
, pid
);
fprintf(stderr
, "(%d/%d-%02d:%02d-%d) ", tp
->tm_mon
+ 1,
tp
->tm_mday
, tp
->tm_hour
, tp
->tm_min
, pid
);
fprintf(stderr
, "%s (%s)\n", status
, text
);
extern struct tm
*localtime();
static char SLogRmtname
[64];
if (strcmp(Rmtname
, SLogRmtname
)) {
savemask
= umask(LOGMASK
);
(void) sprintf(lfile
, "%s/xferstats/%s", LOGBYSITE
, Rmtname
);
strcpy(SLogRmtname
, Rmtname
);
Sp
= fopen (SYSLOG
, "a");
flags
= fcntl(fileno(Sp
), F_GETFL
, 0);
fcntl(fileno(Sp
), F_SETFL
, flags
|O_APPEND
);
tp
= localtime(&Now
.time
);
fprintf(Sp
, "%s %s ", User
, Rmtname
);
fprintf(Sp
, "(%d/%d-%2.2d:%2.2d-%d) ", tp
->tm_mon
+ 1,
tp
->tm_mday
, tp
->tm_hour
, tp
->tm_min
, pid
);
fprintf(Sp
, "(%ld) %s\n", Now
.time
, text
);
fprintf(Sp
, "(%d/%d-%02d:%02d-%d) ", tp
->tm_mon
+ 1,
tp
->tm_mday
, tp
->tm_hour
, tp
->tm_min
, pid
);
fprintf(Sp
, "(%ld.%02u) %s\n", Now
.time
, Now
.millitm
/10, text
);
/* Position at end and flush */
lseek (fileno(Sp
), (long)0, 2);
* Arrange to close fd on exec(II).
* Otherwise unwanted file descriptors are inherited
* by other programs. And that may be a security hole.
#if defined(USG) || defined(BSD4_2)
ret
= fcntl(fd
, F_SETFD
, 1); /* Steve Bellovin says this does it */
ret
= ioctl(fd
, FIOCLEX
, STBNULL
);
DEBUG(2, "CAN'T FIOCLEX %d\n", fd
);