From 7f51f90cb36b248269cea2f6ac8f3da918fa834f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Fri, 22 Jun 2007 22:06:34 +0000 Subject: [PATCH] various fixes --- Make.unix | 2 +- cpu.c | 25 ++++++++++++++++++++----- gui-x11/screen.c | 18 ++++++++++++++---- include/unix.h | 13 +++++++++++++ 4 files changed, 48 insertions(+), 10 deletions(-) diff --git a/Make.unix b/Make.unix index eaec93d..303c019 100644 --- a/Make.unix +++ b/Make.unix @@ -19,5 +19,5 @@ AUDIO=unix all: default libmachdep.a: - arch=`uname -m|sed 's/i.86/386/;s/Power Macintosh/power/'`; \ + arch=`uname -m|sed 's/i.86/386/;s/Power Macintosh/power/; s/x86_64/amd64/'`; \ (cd posix-$$arch && make) diff --git a/cpu.c b/cpu.c index 65ba1f4..666d493 100644 --- a/cpu.c +++ b/cpu.c @@ -548,7 +548,7 @@ p9any(int fd) char tbuf[TICKETLEN+TICKETLEN+AUTHENTLEN], trbuf[TICKREQLEN]; char authkey[DESKEYLEN]; Authenticator auth; - int afd, i, v2; + int afd, i, n, v2; Ticketreq tr; Ticket t; AuthInfo *ai; @@ -623,11 +623,26 @@ p9any(int fd) auth.id = 0; convA2M(&auth, tbuf+TICKETLEN, t.key); - if(write(fd, tbuf, TICKETLEN+AUTHENTLEN) != TICKETLEN+AUTHENTLEN) + if(write(fd, tbuf+1, TICKETLEN+AUTHENTLEN) != TICKETLEN+AUTHENTLEN) fatal(1, "cannot send ticket and authenticator back in p9sk1"); - if(readn(fd, tbuf, AUTHENTLEN) != AUTHENTLEN) - fatal(1, "cannot read authenticator in p9sk1"); + if((n=readn(fd, tbuf, AUTHENTLEN)) != AUTHENTLEN || + memcmp(tbuf, "cpu:", 4) == 0){ + if(n <= 4) + fatal(1, "cannot read authenticator in p9sk1"); + + /* + * didn't send back authenticator: + * sent back fatal error message. + */ + memmove(buf, tbuf, n); + i = readn(fd, buf+n, sizeof buf-n-1); + if(i > 0) + n += i; + buf[n] = 0; + werrstr(""); + fatal(0, "server says: %s", buf); + } convM2A(tbuf, &auth, t.key); if(auth.num != AuthAs @@ -635,7 +650,7 @@ p9any(int fd) || auth.id != 0){ print("?you and auth server agree about password.\n"); print("?server is confused.\n"); - fatal(1, "server lies got %llux.%d want %llux.%d", *(vlong*)auth.chal, auth.id, *(vlong*)cchal, 0); + fatal(0, "server lies got %llux.%d want %llux.%d", *(vlong*)auth.chal, auth.id, *(vlong*)cchal, 0); } //print("i am %s there.\n", t.suid); ai = mallocz(sizeof(AuthInfo), 1); diff --git a/gui-x11/screen.c b/gui-x11/screen.c index 8bf6004..d014c3f 100644 --- a/gui-x11/screen.c +++ b/gui-x11/screen.c @@ -1126,18 +1126,28 @@ if(0) iprint("xselect target=%d requestor=%d property=%d selection=%d\n", XChangeProperty(xd, xe->requestor, xe->property, xe->target, 8, PropModeReplace, (uchar*)a, sizeof a); }else if(xe->target == XA_STRING || xe->target == utf8string || xe->target == text || xe->target == compoundtext){ + text: /* if the target is STRING we're supposed to reply with Latin1 XXX */ qlock(&clip.lk); XChangeProperty(xd, xe->requestor, xe->property, xe->target, 8, PropModeReplace, (uchar*)clip.buf, strlen(clip.buf)); qunlock(&clip.lk); }else{ - iprint("get %d\n", xe->target); name = XGetAtomName(xd, xe->target); if(name == nil) - iprint("XGetAtomName failed\n"); - else if(strcmp(name, "TIMESTAMP") != 0) - iprint("%s: cannot handle selection request for '%s' (%d)\n", argv0, name, (int)xe->target); + iprint("XGetAtomName %d failed\n", xe->target); + if(name){ + if(strcmp(name, "TIMESTAMP") == 0){ + /* nothing */ + }else if(strncmp(name, "image/", 6) == 0){ + /* nothing */ + }else if(strcmp(name, "text/html") == 0){ + /* nothing */ + }else if(strcmp(name, "text/plain") == 0 || strcmp(name, "text/plain;charset=UTF-8") == 0){ + goto text; + }else + iprint("%s: cannot handle selection request for '%s' (%d)\n", argv0, name, (int)xe->target); + } r.xselection.property = None; } diff --git a/include/unix.h b/include/unix.h index 81764ad..95f6bcc 100644 --- a/include/unix.h +++ b/include/unix.h @@ -1,9 +1,22 @@ +#define __BSD_VISIBLE 1 /* FreeBSD 5.x */ +#define _BSD_SOURCE 1 +#define _NETBSD_SOURCE 1 /* NetBSD */ +#define _SVID_SOURCE 1 +#if !defined(__APPLE__) && !defined(__OpenBSD__) +# define _XOPEN_SOURCE 1000 +# define _XOPEN_SOURCE_EXTENDED 1 +#endif +#define _LARGEFILE64_SOURCE 1 +#define _FILE_OFFSET_BITS 64 + + #include #include #include #include #include #include +#include #include #include #include