Example #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);
}
Example #2
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();

}