Exemple #1
0
void    smtp_chat_notify(SMTP_SESSION *session)
{
    const char *myname = "smtp_chat_notify";
    VSTREAM *notice;
    char  **cpp;

    /*
     * Sanity checks.
     */
    if (session->history == 0)
	msg_panic("%s: no conversation history", myname);
    if (msg_verbose)
	msg_info("%s: notify postmaster", myname);

    /*
     * Construct a message for the postmaster, explaining what this is all
     * about. This is junk mail: don't send it when the mail posting service
     * is unavailable, and use the double bounce sender address, to prevent
     * mail bounce wars. Always prepend one space to message content that we
     * generate from untrusted data.
     */
#define NULL_TRACE_FLAGS	0
#define NO_QUEUE_ID		((VSTRING *) 0)
#define LENGTH	78
#define INDENT	4

    notice = post_mail_fopen_nowait(mail_addr_double_bounce(),
				    var_error_rcpt,
				    MAIL_SRC_MASK_NOTIFY, NULL_TRACE_FLAGS,
				    SMTPUTF8_FLAG_NONE, NO_QUEUE_ID);
    if (notice == 0) {
	msg_warn("postmaster notify: %m");
	return;
    }
    post_mail_fprintf(notice, "From: %s (Mail Delivery System)",
		      mail_addr_mail_daemon());
    post_mail_fprintf(notice, "To: %s (Postmaster)", var_error_rcpt);
    post_mail_fprintf(notice, "Subject: %s %s client: errors from %s",
		      var_mail_name, smtp_mode ? "SMTP" : "LMTP",
		      session->namaddrport);
    post_mail_fputs(notice, "");
    post_mail_fprintf(notice, "Unexpected response from %s.",
		      session->namaddrport);
    post_mail_fputs(notice, "");
    post_mail_fputs(notice, "Transcript of session follows.");
    post_mail_fputs(notice, "");
    argv_terminate(session->history);
    for (cpp = session->history->argv; *cpp; cpp++)
	line_wrap(printable(*cpp, '?'), LENGTH, INDENT, print_line,
		  (void *) notice);
    post_mail_fputs(notice, "");
    post_mail_fprintf(notice, "For other details, see the local mail logfile");
    (void) post_mail_fclose(notice);
}
void kprintf(char *msg)
{
    int i = 0;
    for (i = 0; msg[i] != '\0'; i++)
    {
        if ( msg[i] == '\n' || msg[i] == '\r' )
        {
            line_wrap();
            continue;
        }

        printc(msg[i]);
    }
}
Exemple #3
0
void    smtpd_chat_notify(SMTPD_STATE *state)
{
    char   *myname = "smtpd_chat_notify";
    VSTREAM *notice;
    char  **cpp;

    /*
     * Sanity checks.
     */
    if (state->history == 0)
	msg_panic("%s: no conversation history", myname);
    if (msg_verbose)
	msg_info("%s: notify postmaster", myname);

    /*
     * Construct a message for the postmaster, explaining what this is all
     * about. This is junk mail: don't send it when the mail posting service
     * is unavailable, and use the double bounce sender address to prevent
     * mail bounce wars. Always prepend one space to message content that we
     * generate from untrusted data.
     */
#define NULL_TRACE_FLAGS	0
#define LENGTH	78
#define INDENT	4

    notice = post_mail_fopen_nowait(mail_addr_double_bounce(),
				    var_error_rcpt,
				    CLEANUP_FLAG_MASK_INTERNAL,
				    NULL_TRACE_FLAGS);
    if (notice == 0) {
	msg_warn("postmaster notify: %m");
	return;
    }
    post_mail_fprintf(notice, "From: %s (Mail Delivery System)",
		      mail_addr_mail_daemon());
    post_mail_fprintf(notice, "To: %s (Postmaster)", var_error_rcpt);
    post_mail_fprintf(notice, "Subject: %s SMTP server: errors from %s[%s]",
		      var_mail_name, state->name, state->addr);
    post_mail_fputs(notice, "");
    post_mail_fputs(notice, "Transcript of session follows.");
    post_mail_fputs(notice, "");
    argv_terminate(state->history);
    for (cpp = state->history->argv; *cpp; cpp++)
	line_wrap(printable(*cpp, '?'), LENGTH, INDENT, print_line,
		  (char *) notice);
    post_mail_fputs(notice, "");
    if (state->reason)
	post_mail_fprintf(notice, "Session aborted, reason: %s", state->reason);
    (void) post_mail_fclose(notice);
}
Exemple #4
0
static QStringList iceblock_create(const IceOffer &in)
{
	QStringList out;
	out += "-----BEGIN ICE-----";
	{
		QStringList body;
		QStringList userpass;
		userpass += urlishEncode(in.user);
		userpass += urlishEncode(in.pass);
		body += userpass.join(",");
		foreach(const XMPP::Ice176::Candidate &c, in.candidates)
			body += candidate_to_line(c);
		out += line_wrap(body.join(";"), 78);
	}
	out += "-----END ICE-----";
	return out;
}
int main(

  int   argc,
  char *argv[])

  {
  /* Array for the log entries for the specified job */
  FILE *fp;
  int i, j;
  int file_count;
  char *filenames[MAX_LOG_FILES_PER_DAY];  /* full path of logfiles to read */

  struct tm *tm_ptr;
  time_t t, t_save;
  signed char c;
  char *prefix_path = NULL;
  int number_of_days = 1;
  char *endp;
  short error = 0;
  int opt;
  char no_acct = 0, no_svr = 0, no_mom = 0, no_schd = 0;
  char verbosity = 1;
  int wrap = -1;
  int log_filter = 0;
  int event_type;
  char filter_excessive = 0;
  int excessive_count;

#if defined(FILTER_EXCESSIVE)
  filter_excessive = 1;
#endif

#if defined(EXCESSIVE_COUNT)
  excessive_count = EXCESSIVE_COUNT;
#endif

  while ((c = getopt(argc, argv, "qzvamslw:p:n:f:c:")) != EOF)
    {
    switch (c)
      {

      case 'q':

        verbosity = 0;

        break;

      case 'v':

        verbosity = 2;

        break;

      case 'a':

        no_acct = 1;

        break;

      case 's':

        no_svr = 1;

        break;

      case 'm':

        no_mom = 1;

        break;

      case 'l':

        no_schd = 1;

        break;

      case 'z':

        filter_excessive = filter_excessive ? 0 : 1;

        break;

      case 'c':

        excessive_count = strtol(optarg, &endp, 10);

        if (*endp != '\0')
          error = 1;

        break;

      case 'w':

        wrap = strtol(optarg, &endp, 10);

        if (*endp != '\0')
          error = 1;

        break;

      case 'p':

        prefix_path = optarg;

        break;

      case 'n':

        number_of_days = strtol(optarg, &endp, 10);

        if (*endp != '\0')
          error = 1;

        break;

      case 'f':

        if (!strcmp(optarg, "error"))
          log_filter |= PBSEVENT_ERROR;
        else if (!strcmp(optarg, "system"))
          log_filter |= PBSEVENT_SYSTEM;
        else if (!strcmp(optarg, "admin"))
          log_filter |= PBSEVENT_ADMIN;
        else if (!strcmp(optarg, "job"))
          log_filter |= PBSEVENT_JOB;
        else if (!strcmp(optarg, "job_usage"))
          log_filter |= PBSEVENT_JOB_USAGE;
        else if (!strcmp(optarg, "security"))
          log_filter |= PBSEVENT_SECURITY;
        else if (!strcmp(optarg, "sched"))
          log_filter |= PBSEVENT_SCHED;
        else if (!strcmp(optarg, "debug"))
          log_filter |= PBSEVENT_DEBUG;
        else if (!strcmp(optarg, "debug2"))
          log_filter |= PBSEVENT_DEBUG2;
        else if (isdigit(optarg[0]))
          {
          log_filter = strtol(optarg, &endp, 16);

          if (*endp != '\0')
            error = 1;
          }
        else
          error = 1;

        break;

      default:

        error = 1;

        break;
      }
    }    /* END while ((c = getopt(argc,argv,"zvamslw:p:n:f:c:")) != EOF) */


  /* no jobs */

  if ((error != 0) || (argc == optind))
    {
    printf("USAGE: %s [-a|s|l|m|q|v|z] [-c count] [-w size] [-p path] [-n days] [-f filter_type] <JOBID>\n",
           strip_path(argv[0]));

    printf(
      "   -p : path to PBS_SERVER_HOME\n"
      "   -w : number of columns of your terminal\n"
      "   -n : number of days in the past to look for job(s) [default 1]\n"
      "   -f : filter out types of log entries, multiple -f's can be specified\n"
      "        error, system, admin, job, job_usage, security, sched, debug, \n"
      "        debug2, or absolute numeric hex equivalent\n"
      "   -z : toggle filtering excessive messages\n");
    printf(
      "   -c : what message count is considered excessive\n"
      "   -a : don't use accounting log files\n"
      "   -s : don't use server log files\n"
      "   -l : don't use scheduler log files\n"
      "   -m : don't use mom log files\n"
      "   -q : quiet mode - hide all error messages\n"
      "   -v : verbose mode - show more error messages\n");

    printf("default prefix path = %s\n",
           PBS_SERVER_HOME);

#if defined(FILTER_EXCESSIVE)
    printf("filter_excessive: ON\n");
#else
    printf("filter_excessive: OFF\n");
#endif
    return(1);
    }  /* END if ((error != 0) || (argc == optind)) */

  if (wrap == -1)
    wrap = get_cols();

  time(&t);

  t_save = t;

  for (opt = optind;opt < argc;opt++)
    {
    for (i = 0, t = t_save;i < number_of_days;i++, t -= SECONDS_IN_DAY)
      {
      tm_ptr = localtime(&t);

      for (j = 0;j < 4;j++)
        {
        if ((j == IND_ACCT && no_acct) || (j == IND_SERVER && no_svr) ||
            (j == IND_MOM && no_mom)   || (j == IND_SCHED && no_schd))
          continue;

        file_count = log_path(prefix_path, j, tm_ptr, filenames);
        
        /* there can be multiple server and mom log files per day */
        /* traverse filenames until we have got them all */
        
        if (file_count < 0)
          {
          printf("Error getting file names\n");
          continue;
          }

        for (; file_count > 0; file_count--)
          {
          if ((fp = fopen(filenames[file_count-1], "r")) == NULL)
            {
            if (verbosity >= 1)
              perror(filenames[file_count-1]);

            continue;
            }

          if (parse_log(fp, argv[opt], j) < 0)
            {
            /* no valid entries located in file */

            if (verbosity >= 1)
              {
              fprintf(stderr, "%s: No matching job records located\n",
                      filenames[file_count-1]);
              }
            }
          else if (verbosity >= 2)
            {
            fprintf(stderr, "%s: Successfully located matching job records\n",
                    filenames[file_count-1]);
            }

          fclose(fp);
          free(filenames[file_count-1]);
          } /* end of for file_count */
        }
      }    /* END for (i) */

    if (filter_excessive)
      filter_excess(excessive_count);

    qsort(log_lines, ll_cur_amm, sizeof(struct log_entry), sort_by_date);

    if (ll_cur_amm != 0)
      {
      printf("\nJob: %s\n\n",
             log_lines[0].name);
      }

    for (i = 0;i < ll_cur_amm;i++)
      {
      if (log_lines[i].log_file == 'A')
        event_type = 0;
      else
        event_type = strtol(log_lines[i].event, &endp, 16);

      if (!(log_filter & event_type) && !(log_lines[i].no_print))
        {
        printf("%-20s %-5c",
               log_lines[i].date,
               log_lines[i].log_file);

        line_wrap(log_lines[i].msg, 26, wrap);
        }
      }
    }    /* END for (opt) */

  return(0);
  }  /* END main() */