コード例 #1
0
ファイル: aerr.C プロジェクト: Sidnicious/sfslite
void
_err_output_async (suio *uio, int flags)
{
  int saved_errno = errno;
  
  if (flags & warnobj::panicflag) {
    erruio->copyu (uio);
    make_sync (errfd);
    erruio->output (errfd);
    myabort ();
  }

  /* Start new iovecs after newlines so as to output entire lines when
   * possible. */
  if (erruio->resid ()) {
    const iovec *iovp = erruio->iov () + erruio->iovcnt () - 1;
    if (((char *) iovp->iov_base)[iovp->iov_len - 1] == '\n')
      erruio->breakiov ();
  }
  erruio->copyu (uio);

  if (flags & warnobj::fatalflag) {
    err_flush ();
    exit (1);
  }

  err_wcb ();
  errno = saved_errno;
}
コード例 #2
0
ファイル: aerr.C プロジェクト: Sidnicious/sfslite
static void
exitflush ()
{
  if (_err_output != _err_output_async) {
    err_flush ();
    err_reset ();
  }
}
コード例 #3
0
ファイル: test_srp.C プロジェクト: Sidnicious/sfslite
int
main (int argc, char **argv)
{
  setprogname (argv[0]);
  srp_hash sessid;

  bigint N, g;
#if 1
  //warnx << "Generating SRP parameters...";
  err_flush ();
  srp_base::genparam (512, &N, &g);
  //warnx << "done\n";
#else
  N = "0xb554bc791c15de289b4e46b013f5802933408b3b7c5c6622b91802056a25b436acd645ab35c94718800e7409e77e9237c92fcdcdd88b07c3a5277febb81a764ac0038420b61a4b44cfc058dc34f642b0f8bc13c66da17ea624c4eb808242708a09393e85b50b8b20f59cbd3790caa291f8c7e186c175c4bc7bbf1177f066ec33";
  g = 2;
#endif

  srpmsg m;
  srp_client srpc;
  srp_server srps;

  str V = srpc.create (N, g, "Geheim", "ny.lcs.mit.edu", 5);

  u_int32_t testl = TESTL, testr = TESTR;
  srpc.eksb.encipher (&testl, &testr);

  if (srpc.init (&m, sessid, "dm", "Geheim") != SRP_NEXT)
    panic ("srp_client::init failed\n");
  if (srps.init (&m, &m, sessid, "dm", V) != SRP_NEXT)
    panic ("srp_server::init failed\n");
  if (srpc.next (&m, &m) != SRP_NEXT)
    panic ("srp_client::phase1 failed\n");
  if (srps.next (&m, &m) != SRP_NEXT)
    panic ("srp_server::phase2 failed\n");
  if (srpc.next (&m, &m) != SRP_NEXT)
    panic ("srp_client::phase3 failed\n");
  if (srps.next (&m, &m) != SRP_LAST)
    panic ("srp_server::phase4 failed\n");
  if (srpc.next (&m, &m) != SRP_DONE)
    panic ("srp_client::phase5 failed\n");

  if (srpc.host != "ny.lcs.mit.edu")
    panic ("client got the wrong host name: %s\n", srpc.host.cstr ());

  srpc.eksb.decipher (&testl, &testr);
  if (testl != TESTL || testr != TESTR)
    panic ("could not decrypt message after SRP\n");

  return 0;
}
コード例 #4
0
ファイル: daemonize.C プロジェクト: maxtaco/sfslite
void
start_logger ()
{
  vec<str> logger_argv;
  if (get_syslog_logger (&logger_argv)) {
    const char **av = vec2argv (logger_argv);
    int fds[2];
    
    close (0);
    if (int fd = open ("/dev/null", O_RDONLY))
      close (fd);
    
    if (socketpair (AF_UNIX, SOCK_STREAM, 0, fds) < 0)
      fatal ("socketpair: %m\n");
    close_on_exec (fds[0]);
    if (fds[1] != 0)
      close_on_exec (fds[1]);
    
    //
    // MK 2011/9/16
    //
    // The logger should not output to anywhere other than where
    // it's supposed to log to.  However, in the case that it's
    // buggy, give it sensible pipes to output to, in this case,
    // the stdout and the stderr that okld was started with.
    // To do otherwise might break the logger, and suprisingly,
    // the rest of OKWS, whose processes might get stuck in 
    // so_snd state waiting to write to stderr.
    //
    if (spawn (av[0], av, fds[1], 1, errfd) >= 0) {
      close (fds[1]);
      if (fds[0] != errfd) {
	err_flush ();		// XXX - we shouldn't depend on aerr.C
	if (dup2 (fds[0], errfd) < 0)
	  fatal ("dup2: %m\n");
	close (fds[0]);
      }
      if (errfd != 1)
	dup2 (errfd, 1);
      return;
    }
    else
      warn ("%s: %m\n", av[0]);
    delete [] av;
  }
  
  /* No logger, at least send chatter to stdout rather than stderr, so
   * that it can be redirected. */
  dup2 (errfd, 1);
}
コード例 #5
0
ファイル: output.c プロジェクト: TuZZiX/ROS_IDE_inc
void out_action
(
    char const * const action,
    char const * const target,
    char const * const command,
    char const * const out_d,
    char const * const err_d,
    int const exit_reason
)
{
    /* Print out the action + target line, if the action is quiet the action
     * should be null.
     */
    if ( action )
        out_printf( "%s %s\n", action, target );

    /* Print out the command executed if given -d+2. */
    if ( DEBUG_EXEC )
    {
        out_puts( command );
        out_putc( '\n' );
    }

    /* If the process expired, make user aware with an explicit message, but do
     * this only for non-quiet actions.
     */
    if ( exit_reason == EXIT_TIMEOUT && action )
        out_printf( "%ld second time limit exceeded\n", globs.timeout );

    /* Print out the command output, if requested, or if the program failed, but
     * only output for non-quiet actions.
     */
    if ( action || exit_reason != EXIT_OK )
    {
        if ( out_d &&
           ( ( globs.pipe_action & 1 /* STDOUT_FILENO */ ) ||
             ( globs.pipe_action == 0 ) ) )
            out_data( out_d );
        if ( err_d && ( globs.pipe_action & 2 /* STDERR_FILENO */ ) )
            err_data( err_d );
    }

    out_flush();
    err_flush();
}
コード例 #6
0
ファイル: core.C プロジェクト: gildafnai82/craq
void
async_init::stop ()
{
  err_flush ();
}
コード例 #7
0
ファイル: getkbdnoise.C プロジェクト: Sidnicious/sfslite
 kbdinput (datasink *d)
   : kbdfd (getkbdfd ()), dst (d), lnext (false), tok (false),
     fdreset (false), gotsig (false)
   { err_flush (); }