Ejemplo n.º 1
0
Archivo: auth.c Proyecto: bhanug/harvey
int
vncsrvauth(Vnc *v)
{
	Chalstate *c;
	AuthInfo *ai;

	if((c = auth_challenge("proto=vnc role=server user=%q", getuser()))==nil)
		sysfatal("vncchal: %r");
	if(c->nchal != VncChalLen)
		sysfatal("vncchal got %d bytes wanted %d", c->nchal, VncChalLen);
	vncwrlong(v, AVncAuth);
	vncwrbytes(v, c->chal, VncChalLen);
	vncflush(v);

	vncrdbytes(v, c->chal, VncChalLen);
	c->resp = c->chal;
	c->nresp = VncChalLen;
	ai = auth_response(c);
	auth_freechal(c);
	if(ai == nil){
		fprint(2, "vnc auth failed: server factotum: %r\n");
		vncwrlong(v, VncAuthFailed);
		vncflush(v);
		return -1;
	}
	auth_freeAI(ai);
	vncwrlong(v, VncAuthOK);
	vncflush(v);

	return 0;
}
Ejemplo n.º 2
0
void
vncwrstring(Vnc *v, char *s)
{
	ulong len;

	len = strlen(s);
	vncwrlong(v, len);
	vncwrbytes(v, s, len);
}
Ejemplo n.º 3
0
void
checksnarf(Vnc *v)
{
    Dir *dir;
    char *snarf;
    int len;

    if(snarffd < 0) {
        snarffd = open("/dev/snarf", OREAD);
        if(snarffd < 0)
            sysfatal("can't open /dev/snarf: %r");
    }

    for(;;) {
        sleep(1000);

        dir = dirstat("/dev/snarf");
        if(dir == nil)	/* this happens under old drawterm */
            continue;
        if(dir->qid.vers > snarfvers) {
            snarf = getsnarf(&len);

            vnclock(v);
            vncwrchar(v, MCCut);
            vncwrbytes(v, "pad", 3);
            vncwrlong(v, len);
            vncwrbytes(v, snarf, len);
            vncflush(v);
            vncunlock(v);

            free(snarf);

            snarfvers = dir->qid.vers;
        }
        free(dir);
    }
}