int
main (int argc, char **argv)
{
  bool opt_nodaemon = false;
  setprogname (argv[0]);

  int ch;
  while ((ch = getopt (argc, argv, "df:S:")) != -1)
    switch (ch) {
    case 'd':
      opt_nodaemon = true;
      break;
    case 'f':
      if (configfile)
	usage ();
      configfile = optarg;
      break;
    case 'S':
      {
	str sfsconf (strbuf ("SFS_CONFIG=%s", optarg));
	xputenv (const_cast<char*>(sfsconf.cstr()));
      }
    case '?':
    default:
      usage ();
    }
  argc -= optind;
  argv += optind;
  if (argc > 1)
    usage ();

  sfsconst_init ();
  if (!configfile)
    configfile = sfsconst_etcfile_required ("sfssd_config");

  parseconfig ();
  if (!revocationdir)
    revocationdir = sfsdir << "srvrevoke";
  if (!opt_nodaemon && !builddir) {
    daemonize ();
    sigcb (SIGINT, wrap (termsig, SIGINT));
    sigcb (SIGTERM, wrap (termsig, SIGTERM));
  }
  warn ("version %s, pid %d\n", VERSION, int (getpid ()));
  sigcb (SIGHUP, wrap (restart));
  launchservers ();

  amain ();
}
Exemple #2
0
int
main (int argc, char *argv[])
{
  sigcb (SIGALRM, wrap (timer_event));
  set_timer ();
  amain ();
}
Exemple #3
0
int 
main (int argc, char **argv) 
{
  mp_set_memory_functions (NULL, simple_realloc, NULL);

  str lsdsock = "/tmp/lsdctl-sock";
  char ch;

  setprogname (argv[0]);
  random_init ();

  dbdir = "/tmp/";
  
  while ((ch = getopt (argc, argv, "C:L:td:"))!=-1)
    switch (ch) {
    case 'C':
      lsdsock = optarg;
      break;
    case 'L':
      logfname = optarg;
      break;
    case 't':
      modlogger::setmaxprio (modlogger::TRACE);
      break;
    case 'd':
      dbdir = optarg;
      break;
    default:
      usage ();
      break;
    }

  start_logs ();

  sigcb(SIGHUP, wrap (&start_logs));
  sigcb(SIGINT, wrap (&halt));
  sigcb(SIGTERM, wrap (&halt));

  ptr<aclnt> c = lsdctl_connect (lsdsock);
  ptr<lsdctl_lsdparameters> p = New refcounted<lsdctl_lsdparameters> ();
  c->timedcall (5, LSDCTL_GETLSDPARAMETERS, NULL, p,
		wrap (&start, p));

  amain ();
}
Exemple #4
0
void
afs_init (cbv cb)
{
  tzset ();
  sfs_hosttab_init ();

  afsnode::sbp2aid = sbp2aid;

  afs_root = afsroot::alloc ();
  afs_root.Xleak ();		// Avoid global destruction order worries
  afs_sfsroot = afsusrdir::alloc (afs_root, sfsaid_sfs);
  afs_sfsroot.Xleak ();
  afs_naroot = afsusrroot::alloc (afs_root, sfsaid_nobody);
  afs_naroot.Xleak ();

  afs_mnt = afs_root->mkdir (".mnt");
  afs_wait = afsdir::alloc ();
  afs_wait.Xleak ();

  afs_mnt->mkdir ("wait");
  afs_sfsroot->link (afsreg::alloc (), ".root");
  afs_root->link (afsreg::alloc (VERSION "\n"), ".version");
  afs_root->link (afsreg::alloc (strbuf ("%d\n", int (getpid ()))), ".pid");
#if FIX_MNTPOINT
  if (opt_fix_mntpoint)
    afs_linuxbug = afs_root->mkdir (".linuxmnt");
#endif /* FIX_MNTPOINT */

  afsfd = inetsocket (SOCK_DGRAM, nomounting ? 2490 : 0, INADDR_LOOPBACK);
  if (afsfd < 0)
    fatal ("afs_init: inetsocket: %m\n");
  ref<axprt> x (axprt_dgram::alloc (afsfd));
  afssrv = asrv::alloc (x, nfs_program_2, wrap (afs_dispatch));
  afssrv3 = asrv::alloc (x, nfs_program_3, wrap (afs_dispatch));

  sigcb (SIGINT, wrap (afs_shutdown, true));
  sigcb (SIGTERM, wrap (afs_shutdown, true));

  nfs_fh fh;
  afs_root->mkfh (&fh);
  mnt_mount (dup (afsfd), "(sfs)", sfsroot,
	     v3flag | NMOPT_NOAC | NMOPT_SOFT,
	     nfs_fh2tobytes (fh), wrap (afs_init2, cb));
}
Exemple #5
0
static PyObject *
Core_sigcb (PyObject *self, PyObject *args)
{
  int sig = 0;
  int flags = 0;
  PyObject *cb = NULL;

  if (!PyArg_ParseTuple (args, "i|Oi", &sig, &cb, &flags))
    return NULL;

  if (!cb) {
    sigcb (sig, NULL, flags);
  } else {
    if (!PyCallable_Check (cb)) {
      PyErr_SetString (PyExc_TypeError, "callable object expected");
      return NULL;
    }
    sigcb (sig, wrap (Core_cb, pop_t::alloc (cb)), flags);
  }

  Py_INCREF (Py_None);
  return Py_None;
}
Exemple #6
0
static void
ainit ()
{
  if (sigpipes[0] == -1) {
    if (pipe (sigpipes) < 0)
      fatal ("could not create sigpipes: %m\n");

    _make_async (sigpipes[0]);
    _make_async (sigpipes[1]);
    close_on_exec (sigpipes[0]);
    close_on_exec (sigpipes[1]);
    fdcb (sigpipes[0], selread, wrap (sigcb_set_checkbit));

    /* Set SA_RESTART for SIGCHLD, primarily for the benefit of
     * stdio-using code like lex/flex scanners.  These tend to flip out
     * if read ever returns EINTR. */
    sigcb (SIGCHLD, wrap (chldcb_check), (SA_NOCLDSTOP
#ifdef SA_RESTART
					  | SA_RESTART
#endif /* SA_RESTART */
					  ));
    sigcatch (SIGCHLD);
  }
}