src/ssh-honeypot.c
/* log_entry() -- adds timestamped log entry
 *             -- displays output to stdout if console_output is true
 *             -- returns 0 on success, 1 on failure
 */
- adds timestamped log entry
displays output to stdout if console_output is true
returns 0 on success, 1 on failure
- adds timestamped log entry displays output to stdout if console_output is true returns 0 on success 1 on failure
int log_entry (const char *fmt, ...) {
  int n;
  FILE *fp;
  time_t t;
  va_list va;
  char *timestr;
  char buf[1024];
  time (&t);
  timestr = strtok (ctime (&t), "\n"); 
  if ((fp = fopen (logfile, "a+")) == NULL) {
    fprintf (stderr, "Unable to open logfile %s: %s\n",
	     logfile,
	     strerror (errno));
    return 1;
  }
  va_start (va, fmt);
  vsprintf (buf, fmt, va);
  va_end (va);
  n = fprintf (fp, "[%s] %s\n", timestr, buf);
  if (console_output)
    printf ("[%s] %s\n", timestr, buf);
  fclose (fp);
  return n;
}
int log_entry ( const char * fmt , ... ) { int n ; FILE * fp ; time_t t ; va_list va ; char * timestr ; char buf [ 1024 ] ; time ( & t ) ; timestr = strtok ( ctime ( & t ) , " \n " ) ; if ( ( fp = fopen ( logfile , " " ) ) == NULL ) { fprintf ( stderr , " \n " , logfile , strerror ( errno ) ) ; return 1 ; } va_start ( va , fmt ) ; vsprintf ( buf , fmt , va ) ; va_end ( va ) ; n = fprintf ( fp , " \n " , timestr , buf ) ; if ( console_output ) printf ( " \n " , timestr , buf ) ; fclose ( fp ) ; return n ; }
log_entry() -- adds timestamped log entry
             -- displays output to stdout if console_output is true
             -- returns 0 on success, 1 on failure
log_entry () -- adds timestamped log entry -- displays output to stdout if console_output is true -- returns 0 on success 1 on failure
// banish newline character to the land // of wind and ghosts