Beispiel #1
0
/*
 * Initialize the system. 
 */
void
init_system(void)
{
char    myhost[65];
char    host[80];
int     howbad;
char *hp;
unsigned char *lockoutp;
unsigned char *p;
int size;
register int i;


  tty = isatty(0);
  pid = getpid();

  signal(SIGTSTP, SIG_IGN);
  signal(SIGINT, SIG_IGN);
  signal(SIGIO, s_sigio);
  signal(SIGALRM, s_sigalrm);
  signal(SIGQUIT, s_sigquit);
  signal(SIGTERM, s_sigdie);
  signal(SIGPIPE, s_sigdie);
  signal(SIGHUP, tty ? s_sigdie : s_sigquit);

  alarm(300);

  if (!strncmp(*ARGV, "_clientbbs", 10))
    client = 1;

  if (!tty)
    init_states();

  if (tty)
    myecho(OFF);

  /* Make sure the site is not locked out */
  size = 0;
  if ((lockoutp = p = (unsigned char *)mymmap(LOCKOUT, &size, 0)))
  {
    strcpy(myhost, ARGV[1] ? ARGV[1] : "local");
    for (hp = myhost; *hp; hp++)
      if (*hp >= 'A' && *hp <= 'Z')
        *hp += 32;
    while (p - lockoutp < size)
    {
      for (i = 0; p - lockoutp < size && *p != '\n'; i++, p++)
	host[i] = *p;
      host[i] = 0;
      p++;
      if (*host && *host != '#' && host[strlen(host) - 2] == ' ')
      {
	howbad = host[strlen(host) - 1] - '0' + 1;
	host[strlen(host) - 2] = 0;
        for (hp = host; *hp; hp++)
          if (*hp >= 'A' && *hp <= 'Z')
            *hp += 32;
        hp = strchr(host, '*');
        if ((hp && !strncmp(host, myhost, (int)(hp - host)) && hp++ &&
             !strcmp(hp, myhost + strlen(myhost) - strlen(hp))) ||
            (!hp && !strcmp(host, myhost)))
	  if ((nonew = howbad) == 1)
	  {
            printf("\n\nThe site you are connecting from has been locked out of the BBS.  E-mail any\ninquiries about this to [email protected].\n\n\n");
            my_exit(10);
	  }
      }
    }
    munmap((void *)lockoutp, size);
  }

  lastbcast = msg->lastbcast;
}
Beispiel #2
0
/*
 * Exit the program in an orderly way. 
 */
void
my_exit(register int doflush)
{
  register int save = f_death;

  if (lockflags)
  {
    f_death = 2;
    return;
  }

  f_alarm = 0;
  if (doflush)
    f_death = -1;
  else
    f_death = -2;
  alarm(120);

  if (mybtmp)
    mybtmp->nox = -1;

  if (save == 1 && doflush)
    printf("\a\n\n\n\n\nYou have been logged off.\n\n\n\n\n");

  if (ouruser)
  {
    int f;
    struct tm *ltm;
    char junk[80];

    if (doflush)
      checkx(-1);

    locks(SEM_USER);
    if (ouruser->btmpindex >= 0 && mybtmp == &bigbtmp->btmp[ouruser->btmpindex])
      ouruser->btmpindex = -1;
    unlocks(SEM_USER);
    ouruser->timeoff = msg->t = time(0);

    strcpy(junk, ETC);
    strcat(junk, "uselog");
    if ((f = open(junk, O_WRONLY | O_CREAT | O_APPEND, 0640)) >= 0)
    {
      ltm = localtime(&ouruser->time);
      sprintf(junk, "%02d%02d%02d:%02d%02d:%04ld:%s\n", ltm->tm_year % 100, ltm->tm_mon + 1, ltm->tm_mday, ltm->tm_hour, ltm->tm_min, (ouruser->timeoff - ouruser->time) / 60 + 1, ouruser->name);
      write(f, junk, strlen(junk));
      close(f);
    }

    msync((caddr_t)ouruser, sizeof(struct user), MS_ASYNC);
    ouruser = NULL;
  }

  if (bigbtmp)
  {
    remove_loggedin(pid);
    bigbtmp = 0;
  }

  if (doflush)
  {
    if (ansi)
      printf("\033[0m");
    fflush(stdout);
    if (doflush > 1)
      mysleep(doflush);
    if (tty)
      myecho(ON);
    else
    {
      int fdr = 1;
      struct timeval tv = {30, 0};

      shutdown(0, 1);
      select(1, (fd_set *)&fdr, 0, 0, &tv);
    }
  }

  _exit(0);
}
Beispiel #3
0
void main(void){
  myecho();
  exit(0);
}