Esempio n. 1
0
void
libinit(char *imod)
{
	struct passwd *pw;
	Proc *p;
	void *tos;
	char sys[64];

	setsid();

	gethostname(sys, sizeof(sys));
	kstrdup(&ossysname, sys);
	getnobody();

	if(dflag == 0)
		termset();

	setsigs();

	p = newproc();
	p->kstack = stackalloc(p, &tos);

	pw = getpwuid(getuid());
	if(pw != nil)
		kstrdup(&eve, pw->pw_name);
	else
		print("cannot getpwuid\n");
 
	p->env->uid = getuid();
	p->env->gid = getgid();

	executeonnewstack(tos, emuinit, imod);
}
Esempio n. 2
0
File: os.c Progetto: 8l/inferno
void
libinit(char *imod)
{
	WSADATA wasdat;
	DWORD lasterror, namelen;
	OSVERSIONINFO os;
	char sys[64], uname[64];
	wchar_t wuname[64];
	char *uns;

	os.dwOSVersionInfoSize = sizeof(os);
	if(!GetVersionEx(&os))
		panic("can't get os version");
	PlatformId = os.dwPlatformId;
	if (PlatformId == VER_PLATFORM_WIN32_NT) {	/* true for NT and 2000 */
		rebootok = 1;
	} else {
		rebootok = 0;
	}
	termset();

	if((int)INVALID_HANDLE_VALUE != -1 || sizeof(HANDLE) != sizeof(int))
		panic("invalid handle value or size");

	if(WSAStartup(MAKEWORD(1, 1), &wasdat) != 0)
		panic("no winsock.dll");

	gethostname(sys, sizeof(sys));
	kstrdup(&ossysname, sys);
	if(sflag == 0)
		SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)TrapHandler);

	path = getenv("PATH");
	if(path == nil)
		path = ".";

	up = newproc();
	if(up == nil)
		panic("cannot create kernel process");

	strcpy(uname, "inferno");
	namelen = sizeof(wuname);
	if(GetUserName(wuname, &namelen) != TRUE) {
		lasterror = GetLastError();	
		if(PlatformId == VER_PLATFORM_WIN32_NT || lasterror != ERROR_NOT_LOGGED_ON)
			print("cannot GetUserName: %d\n", lasterror);
	}else{
		uns = narrowen(wuname);
		snprint(uname, sizeof(uname), "%s", uns);
		free(uns);
	}
	kstrdup(&eve, uname);

	emuinit(imod);
}
Esempio n. 3
0
void
host_init()
{
    char sys[64];
    struct passwd *pw;

    trace(TRACE_DEBUG, "node9/kernel: becoming host os process leader ");

    /* init system stack */
    setsid();

    trace(TRACE_DEBUG, "node9/kernel: collecting system info");

    /* setup base system personality and user details */
        gethostname(sys, sizeof(sys));
        kstrdup(&ossysname, sys);
        getnobody();

    /* initialize signals and eventing system */

    /* if not a daemon, initialize the terminal */

    if(dflag == 0) {
        trace(TRACE_INFO, "node9/kernel: initializing terminal");
        termset();
    }

    trace(TRACE_DEBUG, "node9/kernel: initializing signals");
    setsigs();

    trace(TRACE_DEBUG, "node9/kernel: initializing event and req watchers");
    setwatchers();

    trace(TRACE_DEBUG, "node9/kernel: establishing host username, uid, pid");

    pw = getpwuid(getuid());
    if(pw != nil)
            kstrdup(&eve, pw->pw_name);
    else
            print("cannot getpwuid\n");

    /* and record the current host user uid/gid */
    hostuid = getuid();
    hostgid = getgid();

}
Esempio n. 4
0
File: os.c Progetto: 8l/inferno
int
write(int fd, void *buf, uint n)
{
	HANDLE h;

	if(fd == 1 || fd == 2){
		if(!donetermset)
			termset();
		if(fd == 1)
			h = conh;
		else
			h = errh;
		if(h == INVALID_HANDLE_VALUE)
			return -1;
		if(!WriteFile(h, buf, n, &n, NULL))
			return -1;
		return n;
	}
	if(!WriteFile(ntfd2h(fd), buf, n, &n, NULL))
		return -1;
	return n;
}
Esempio n. 5
0
File: os.c Progetto: 8l/inferno
void
libinit(char *imod)
{
	struct termios t;
	struct sigaction act;
	sigset_t mask;
	struct passwd *pw;
	Proc *p;
	void *tos;
	char sys[64];

	setsid();

	gethostname(sys, sizeof(sys));
	kstrdup(&ossysname, sys);

	pw = getpwnam("nobody");
	if(pw != nil) {
		uidnobody = pw->pw_uid;
		gidnobody = pw->pw_gid;
	}

	if(dflag == 0)
		termset();

	memset(&act, 0 , sizeof(act));
	act.sa_handler = trapUSR1;
	sigaction(SIGUSR1, &act, nil);

	sigemptyset(&mask);
	sigaddset(&mask, SIGUSR2);
	sigprocmask(SIG_BLOCK, &mask, NULL);

	memset(&act, 0 , sizeof(act));
	act.sa_handler = trapUSR2;
	sigaction(SIGUSR2, &act, nil);

	act.sa_handler = SIG_IGN;
	sigaction(SIGCHLD, &act, nil);

	/*
	 * For the correct functioning of devcmd in the
	 * face of exiting slaves
	 */
	signal(SIGPIPE, SIG_IGN);
	if(signal(SIGTERM, SIG_IGN) != SIG_IGN)
		signal(SIGTERM, cleanexit);
	if(signal(SIGINT, SIG_IGN) != SIG_IGN)
		signal(SIGINT, cleanexit);

	if(sflag == 0) {
		act.sa_handler = trapBUS;
		sigaction(SIGBUS, &act, nil);
		act.sa_handler = trapILL;
		sigaction(SIGILL, &act, nil);
		act.sa_handler = trapSEGV;
		sigaction(SIGSEGV, &act, nil);
		act.sa_handler = trapFPE;
		sigaction(SIGFPE, &act, nil);
	}

	p = newproc();
	p->kstack = stackalloc(p, &tos);

	pw = getpwuid(getuid());
	if(pw != nil)
		kstrdup(&eve, pw->pw_name);
	else
		print("cannot getpwuid\n");

	p->env->uid = getuid();
	p->env->gid = getgid();

	executeonnewstack(tos, emuinit, imod);
}
Esempio n. 6
0
void
do_login(void)
{
register int i;
register int users;
register char *name;
register struct tm *ltm;
register struct user *tmpuser = 0;
register int wrong = 0;
register char *bbsname;
char pas[9];
char temp[128];
char myname[MAXALIAS + 1];

  printf("\nDOC (Dave's Own version of Citadel) Version 1.71\n\nWelcome to the ISCA BBS.\n\n%s", (bbsname = getenv("BBSNAME")) ? "" : "\nLogin as 'Guest' to just look around, or 'New' to create a new account.\n\n");

  for (;;)
  {
    guest = 0;

    if (!bbsname)
      name = get_name("Name: ", 1);
    else
      strcpy(name = myname, bbsname);

    if (strcmp(name, "New"))
    {
      if ((tmpuser = getuser(name)))
        freeuser(tmpuser);
      if (tmpuser && (!bbsname || tty) && strcmp(name, "Guest"))
        get_string("Password: "******"Incorrect login.\n");
	else
	  printf("There is no user %s on this BBS.\n", name);
        if (++wrong > 3 || bbsname)
        {
	  if (!bbsname)
            printf("\n\nToo many attempts.  Goodbye.\n");
          my_exit(3);
        }
        flush_input(wrong);
        continue;
      }
      else
      {
        xinit();
	if (ouruser->keytime)
	{     
	  printf("\n\n\nYou have not yet registered your validation key...\n\n");
	  dokey(ouruser);
	  if (ouruser->keytime && ouruser->f_trouble)
	  {
	    printf("\n\nYou will need to enter your validation key before you may gain access to the\nBBS.  If you have not yet received your key and think you should, you may send\nE-mail to [email protected].  Please include your BBS username in this\nE-mail so the sysop who receives it knows who you are.  Remember that it can\ntake several days from the time your account was originally created for the\nsysops to validate the information you have provided, if it has been less than\nfour days since you created your account please do not send E-mail yet, as it\nlikely they haven't finished with your account yet.  Impatience won't make them\nwork any faster, and quite likely will make them decide to make you a special\ncase and work slower!  Remember, this BBS is a privilege, not a right.\n\n\n");
	    my_exit(15);
	  }
	}

	printf("\nIowa Student Computer Association BBS.\n");

	if (ouruser->f_deleted)
        {
	  if (ouruser->f_namechanged)
	    printf("\a\nThis account has been marked for deletion because of a request to change the\nusername from '%s' to '%s'.\n\nYou may login as '%s' using the same password.\n\n", ouruser->name, ouruser->reminder, ouruser->reminder);
          else
            printf("\a\nThis account has been marked for deletion, either through your choice or\nbecause you violated ISCA BBS rules by doing something such as providing\nobviously bogus profile info.  You will be logged off.\n\n");
          my_exit(10);
        }
	else if (ouruser->f_inactive)
        {
          printf("You seem to have been denied access to the message system.\n");
          printf("Please contact ISCA (e-mail address [email protected]) for more.\n");
          my_exit(10);
        }


	i = ouruser->time;
        ltm = localtime(&ouruser->time);
        users = add_loggedin(ouruser);

        if (!guest && ouruser->time)
        {
	  printf("Last on: %d/%d/%d %d:%02d ", ltm->tm_mon + 1,
                 ltm->tm_mday, 1900 + ltm->tm_year, ltm->tm_hour, ltm->tm_min);
          ltm = localtime(&ouruser->timeoff);
	  if (ouruser->timeoff >= i)
            printf("until %d:%02d from %s\n", ltm->tm_hour, ltm->tm_min, ouruser->remote);
	  else
	    printf("from %s\n", ouruser->remote);
        }

        strcpy(ouruser->loginname, ARGV[1] && ARGV[2] ? ARGV[2] : "");
        strncpy(ouruser->remote, ARGV[1] ? ARGV[1] : "local", sizeof ouruser->remote - 1);

        if (ouruser->f_noclient)
	{
	  printf("\n\nYou have been disallowed use of the BBS client, you must login using telnet.\n\n");
	  my_exit(10);
	}

	sprintf(temp, "%s %s%s%s/%d", client ? "CLIENT" : "LOGIN", ARGV[1] && ARGV[2] ? ARGV[2] : "", ARGV[1] && ARGV[2] ? "@" : "", ouruser->remote, mybtmp->remport);
	logevent(temp);

	++ouruser->timescalled;

	if (!guest)
	  printf("This is call %d.  There are %d users.\n", ouruser->timescalled, users);
        if (ouruser->f_aide)
           validate_users(0);

	/*
	 * Turn off expresses and tell the user this was done if user is
	 * configured for this 
	 */
	if (!guest && mybtmp->xstat)
	  printf("\nNOTE:  You have eXpress messages turned OFF as a default!\n");
        if (mybtmp->elf)
          printf("\nYou are marked as available to help others.\n");

	checkmail(FALSE);

	termset();

        if (*ouruser->reminder)
        {
          printf("\n\aREMINDER:\n%s\n\n", ouruser->reminder);
          printf("Please hit 'Y' to acknowledge having seen this reminder -> ");
          get_single_quiet("yY");
        }

	if (ouruser->f_badinfo || ouruser->f_duplicate)
	{
	  help("badinfo", NO);
	  mysleep(300);
	}

	if (guest)
	{
	  help("guestwelcome", NO);
	  hit_return_now();
	}
	return;
      }
    }
    else
      if (!(i = new_user()))
      {
	printf("\n\nSorry, there was some problem setting up your BBS account.\n\nPlease try again later.\n\n");
        my_exit(10);
      }
      else if (i > 0)
        return;
  }
}