|
|
1.1 ! root 1: #include <string.h> ! 2: #include <stdio.h> ! 3: #include <ipc.h> ! 4: ! 5: extern char *getkey(); ! 6: extern char *pexpw(); ! 7: extern char *xs(); ! 8: extern void exit(); ! 9: ! 10: char * ! 11: getkey(s) ! 12: char *s; ! 13: { ! 14: s = pexpw(3, s); ! 15: if(s==0) { ! 16: printf("cannot pex for key; quitting\n"); ! 17: exit(1); ! 18: } ! 19: return s; ! 20: } ! 21: ! 22: static pexipc(name) ! 23: char *name; ! 24: { ! 25: char *x; ! 26: int fd; ! 27: /* struct pexclude pexbuf; */ ! 28: ! 29: x = ipcpath("astro/giacobini", "dk", name); ! 30: if((fd = ipcopen(x, "light"))==-1){ ! 31: return -1; ! 32: } ! 33: /* ! 34: if(pex(fd, 60, &pexbuf)!=0 ! 35: ||pexbuf.farpid<=0 ! 36: ||pexbuf.farcap==0) { ! 37: close(fd); ! 38: return -1; ! 39: } ! 40: */ ! 41: return fd; ! 42: } ! 43: ! 44: static yesno(fd) ! 45: { ! 46: char buf[4]; ! 47: int i; ! 48: ! 49: strncpy(buf,"",4); ! 50: for(i=0; i<4; i++) { ! 51: if(read(fd,&buf[i],1)!=1)break; ! 52: if(strncmp(buf, "yes\n",4)==0)return 1; ! 53: if(strncmp(buf, "no\n",3)==0)return 0; ! 54: } ! 55: return -1; ! 56: } ! 57: ! 58: #ifndef SIGN ! 59: keynotary(k1, k2) ! 60: char *k1, *k2; ! 61: { ! 62: int fd = ipcopen("/cs/mcert!key","light"); ! 63: if(fd != -1) ! 64: fprint(fd, "%s\n%s\n", k1, k2); ! 65: return fd; ! 66: } ! 67: ! 68: rverify(name, xsum, body, n) ! 69: char *name, *xsum, *body; ! 70: { ! 71: static int vfd = 0; ! 72: ! 73: if(name==0) { ! 74: if(vfd>0)close(vfd); ! 75: vfd = 0; ! 76: return -1; ! 77: } ! 78: if(vfd == 0) ! 79: vfd = pexipc("mcert"); ! 80: if(vfd == -1) return -1; ! 81: ! 82: fprint(vfd, "%s\n%s\n%d\n", name, xsum, n); ! 83: if(write(vfd, body,n)!=n) ! 84: return -1; ! 85: return yesno(vfd); ! 86: } ! 87: ! 88: #endif ! 89: verify(name, xsum, body, n) ! 90: char *name, *xsum, *body; ! 91: { ! 92: char s[100]; ! 93: int r, fd = pexipc("mcert"); ! 94: ! 95: if(fd==-1)return -1; ! 96: sprintf(s, "%s\n%s\n%d\n", name, xsum, n); ! 97: if(write(fd,s,strlen(s))!=strlen(s)) ! 98: return -1; ! 99: if(write(fd, body,n)!=n) ! 100: return -1; ! 101: r = yesno(fd); ! 102: close(fd); ! 103: return r; ! 104: } ! 105: ! 106: enroll(name, opw, npw) ! 107: char *name, *opw, *npw; ! 108: { ! 109: char buf[9], s[100]; ! 110: int r, fd, n = strlen(npw); ! 111: ! 112: strncpy(buf,opw,9); ! 113: fd = pexipc("mcert!register"); ! 114: if(fd==-1)return -1; ! 115: sprintf(s, "%s\n%s\n%d\n", name, xs(buf,npw,n), n); ! 116: if(write(fd,s,strlen(s))!=strlen(s)) ! 117: return -1; ! 118: if(write(fd, npw,n)!=n) ! 119: return -1; ! 120: r = yesno(fd); ! 121: close(fd); ! 122: return r; ! 123: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.