Ejemplo n.º 1
0
END_TEST

START_TEST (pidfile_remove_test) {
  int res;

  res = pr_pidfile_remove();
  fail_unless(res < 0, "Removed nonexistent file unexpectedly");
  fail_unless(errno == ENOENT, "Failed to set errno to ENOENT, got %d (%s)",
    errno, strerror(errno));
}
Ejemplo n.º 2
0
END_TEST

START_TEST (pidfile_write_test) {
  int res;

  res = pr_pidfile_set(pidfile_path);
  fail_unless(res == 0, "Failed to set path '%s': %s", pidfile_path,
    strerror(errno));

  res = pr_pidfile_write();
  fail_unless(res == 0, "Failed to write to path '%s': %s", pidfile_path,
    strerror(errno));

  res = pr_pidfile_remove();
  fail_unless(res == 0, "Failed to remove path '%s': %s", pidfile_path,
    strerror(errno));

  res = pr_pidfile_remove();
  fail_unless(res < 0, "Removed nonexistent file unexpectedly");
  fail_unless(errno == ENOENT, "Failed to set errno to ENOENT, got %d (%s)",
    errno, strerror(errno));
}
Ejemplo n.º 3
0
static void finish_terminate(void) {
  if (is_master &&
      mpid == getpid()) {
    PRIVS_ROOT

    /* Do not need the pidfile any longer. */
    if (ServerType == SERVER_STANDALONE &&
        !nodaemon) {
      pr_pidfile_remove();
    }

    /* Run any exit handlers registered in the master process here, so that
     * they may have the benefit of root privs.  More than likely these
     * exit handlers were registered by modules' module initialization
     * functions, which also occur under root priv conditions.
     *
     * If an exit handler is registered after the fork(), it won't be run here;
     * that registration occurs in a different process space.
     */
    pr_event_generate("core.exit", NULL);
    pr_event_generate("core.shutdown", NULL);

    /* Remove the registered exit handlers now, so that the ensuing
     * pr_session_end() call (outside the root privs condition) does not call
     * the exit handlers for the master process again.
     */
    pr_event_unregister(NULL, "core.exit", NULL);
    pr_event_unregister(NULL, "core.shutdown", NULL);

    PRIVS_RELINQUISH

    if (ServerType == SERVER_STANDALONE) {
      pr_log_pri(PR_LOG_NOTICE, "ProFTPD " PROFTPD_VERSION_TEXT
        " standalone mode SHUTDOWN");

      /* Clean up the scoreboard */
      PRIVS_ROOT
      pr_delete_scoreboard();
      PRIVS_RELINQUISH
    }