Example #1
0
void
checkpassword(void)
{
	int fd, consctl, must;
	char buf[256];
	AuthInfo *ai;
	static int opened;

	must = 1;
	if(!opened){
		fd = open("/dev/cons", OREAD);
		if(fd == -1)
			error("can't open cons: %r");
		dup(fd, 0);
		close(fd);
		fd = open("/dev/cons", OWRITE);
		if(fd == -1)
			error("can't open cons: %r");
		dup(fd, 1);
		dup(1, 2);
		close(fd);
		consctl = open("/dev/consctl", OWRITE);
		if(consctl == -1)
			error("can't open consctl: %r");
		if(write(consctl, "rawon", 5) != 5)
			error("can't turn off echo\n");
		opened = 1;
	}

	for(;;){
		if(chatty || !must)
			fprint(2, "%s's screenlock password: "******"\n");
		if(buf[0] == '\0' || buf[0] == '\04'){
			if(must)
				continue;
			error("no password typed");
		}

		/* authenticate */
		ai = auth_userpasswd(user, buf);
		if(ai != nil && ai->cap != nil)
			break;
		auth_freeAI(ai);

		if(chatty || !must)
			fprint(2, "password mismatch\n");
		doblank = 1;
	}
	memset(buf, 0, sizeof buf);
	blankscreen(0);
}
Example #2
0
File: suspend.c Project: 8l/inferno
void
powersuspend(void)
{
	extern void suspenditall(void);
	GpioReg *g;
	ulong back = 0x43219990;	/* check that the stack's right */
	ulong pwer, gplr;
	ulong *rp;
	int i, s;

	s = splfhi();
	archpowerdown();	/* sets PMGR and PPC appropriately */
	if(DEBUG)
		dumpitall();
	blankscreen(1);
	chandevpower(0);
	gplr = GPIOREG->gplr;
	for(i=0; (rp = coreregs[i]) != nil; i++)
		corestate[i] = *rp;
	pwer = PMGRREG->pwer;
	if(pwer == 0)
		pwer = 1<<0;
	g = GPIOREG;
	g->grer &= pwer;	/* just the ones archpowerdown requested */
	g->gfer &= pwer;
	g->gedr = g->gedr;
	RESETREG->rcsr = 0xF;	/* reset all status */
	minidcflush();
	if(DEBUG)
		iprint("suspenditall...\n");

	suspenditall();	/* keep us in suspense */

	PMGRREG->pspr = 0;
	archpowerup();
	trapstacks();
	/* set output latches before gpdr restored */
	GPIOREG->gpsr = gplr;
	GPIOREG->gpcr = ~gplr;
	for(i=0; (rp = coreregs[i]) != nil; i++)
		*rp = corestate[i];
	GPIOREG->gedr = GPIOREG->gedr;	/* reset GPIO interrupts (should we?) */
	PMGRREG->pssr = PSSR_ph;	/* cancel peripheral hold */
	chandevpower(1);
	if(back != 0x43219990){
		iprint("back %8.8lux\n", back);
		panic("powersuspend");
	}
	blankscreen(0);
	if(DEBUG)
		dumpitall();
	splx(s);
}
Example #3
0
void
blanker(void *)
{
	int tics;

	tics = 0;
	for(;;){
		if(doblank > 0){
			doblank = 0;
			tics = 10;
		}
		if(tics > 0 && --tics == 0)
			blankscreen(1);
		sleep(1000);
	}
}
Example #4
0
void
screenpower(int on)
{
	blankscreen(on == 0);
}