M boot/boot.c => boot/boot.c +8 -4
@@ 16,6 16,7 @@ char username[NAMELEN];
int mflag;
int fflag;
int kflag;
+int aflag;
int cache(int);
void swapproc(void);
@@ 37,6 38,9 @@ main(int argc, char *argv[])
open("#c/cons", OWRITE);
ARGBEGIN{
+ case 'a':
+ aflag = 1;
+ break;
case 'u':
strcpy(username, ARGF());
break;
@@ 112,7 116,7 @@ main(int argc, char *argv[])
swapproc();
sprint(cmd, "/%s/init", cputype);
- sprint(flags, "-%s%s", cpuflag ? "c" : "t", mflag ? "m" : "");
+ sprint(flags, "-%s%s%s", cpuflag ? "c" : "t", mflag ? "m" : "", aflag ? "a" : "");
execl(cmd, "init", flags, 0);
fatal(cmd);
}
@@ 128,6 132,7 @@ rootserver(char *arg)
Method *mp;
char *cp;
int n;
+ int notfirst;
mp = method;
n = sprint(prompt, "root is from (%s", mp->name);
@@ 139,10 144,9 @@ rootserver(char *arg)
strcpy(reply, arg);
else
strcpy(reply, method->name);
- for(;;){
- if(arg == 0 || mflag)
+ for(notfirst = 0;; notfirst = 1){
+ if(mflag || notfirst)
outin(prompt, reply, sizeof(reply));
- arg = 0;
for(mp = method; mp->name; mp++)
if(*reply == *mp->name){
cp = strchr(reply, '!');
M boot/boot.h => boot/boot.h +0 -1
@@ 31,7 31,6 @@ extern void key(int, Method*);
extern void newkernel(void);
extern void nop(int);
extern int outin(char*, char*, int);
-extern int passtokey(char*, char*, int);
extern int plumb(char*, char*, int*, char*);
extern int readenv(char*, char*, int);
extern int sendmsg(int, char*);
M boot/getpasswd.c => boot/getpasswd.c +0 -25
@@ 2,31 2,6 @@
#include <libc.h>
#include <../boot/boot.h>
-int
-passtokey(char *key, char *p, int n)
-{
- uchar t[10];
- int c;
-
- memset(t, ' ', sizeof t);
- if(n < 5)
- return 0;
- if(n > 10)
- n = 10;
- strncpy((char*)t, p, n);
- if(n >= 9){
- c = p[8] & 0xf;
- if(n == 10)
- c += p[9] << 4;
- for(n = 0; n < 8; n++)
- if(c & (1 << n))
- t[n] -= ' ';
- }
- for(n = 0; n < 7; n++)
- key[n] = (t[n] >> n) + (t[n+1] << (8 - (n+1)));
- return 1;
-}
-
void
getpasswd(char *p, int len)
{
M boot/key.c => boot/key.c +2 -1
@@ 1,5 1,6 @@
#include <u.h>
#include <libc.h>
+#include <auth.h>
#include <../boot/boot.h>
void
@@ 20,7 21,7 @@ key(int islocal, Method *mp)
if(prompt){
do
getpasswd(password, sizeof password);
- while(!passtokey(key, password, strlen(password)));
+ while(!passtokey(key, password));
}else if(seek(fd, 1024+900, 0) < 0 || read(fd, key, 7) != 7){
close(fd);
warning("can't read key from nvram");
M boot/userpasswd.c => boot/userpasswd.c +2 -4
@@ 1,5 1,6 @@
#include <u.h>
#include <libc.h>
+#include <auth.h>
#include <../boot/boot.h>
char password[NAMELEN];
@@ 21,10 22,7 @@ userpasswd(int islocal, Method *mp)
crfd = fd = -1;
while(strcmp(username, "none") != 0 && !islocal){
getpasswd(password, sizeof password);
- if(!passtokey(key, password, strlen(password))){
- print("bad password; try again\n");
- continue;
- }
+ passtokey(key, password);
fd = open("#c/key", OWRITE);
if(fd < 0)
fatal("can't open #c/key; please reboot");
M port/devip.c => port/devip.c +10 -0
@@ 529,6 529,10 @@ tcpstoput(Queue *q, Block *bp)
case Established:
case Close_wait:
qlock(tcb);
+ if(waserror()) {
+ qunlock(tcb);
+ nexterror();
+ }
tcb->sndcnt += blen(bp);
if(tcb->sndq == 0)
tcb->sndq = bp;
@@ 539,6 543,7 @@ tcpstoput(Queue *q, Block *bp)
}
tcprcvwin(s);
tcp_output(s);
+ poperror();
qunlock(tcb);
break;
@@ 707,7 712,12 @@ tcpstclose(Queue *q)
setstate(s, Last_ack);
output:
qlock(tcb);
+ if(waserror()) {
+ qunlock(tcb);
+ nexterror();
+ }
tcp_output(s);
+ poperror();
qunlock(tcb);
break;
}
M port/devlance.c => port/devlance.c +3 -0
@@ 552,6 552,9 @@ lanceattach(char *spec)
kproc("lancekproc", lancekproc, 0);/**/
l.kstarted = 1;
lancestart(0, 1);
+ print("lance ether: %.2x%.2x%.2x%.2x%.2x%.2x\n",
+ l.ea[0], l.ea[1], l.ea[2], l.ea[3], l.ea[4], l.ea[5]);
+
}
return devattach('l', spec);
}
M port/devmnt.c => port/devmnt.c +9 -8
@@ 241,7 241,7 @@ void
mntauth(Mnt *m, Mntrpc *f, char *serv, ushort fid)
{
Mntrpc *r;
- uchar chal[CHLEN];
+ uchar chal[AUTHLEN];
int i;
r = mntralloc();
@@ 254,22 254,23 @@ mntauth(Mnt *m, Mntrpc *f, char *serv, ushort fid)
r->request.fid = fid;
memmove(r->request.uname, u->p->user, NAMELEN);
chal[0] = FScchal;
- for(i = 1; i < CHLEN; i++)
+ for(i = 1; i < AUTHLEN; i++)
chal[i++] = nrand(256);
- memmove(r->request.chal, chal, CHLEN);
- strncpy(r->request.chal+CHLEN, serv, NAMELEN);
- encrypt(u->p->pgrp->crypt->key, r->request.chal, CHLEN+NAMELEN);
+ memmove(r->request.chal, chal, AUTHLEN);
+ strncpy(r->request.chal+AUTHLEN, serv, NAMELEN);
+ encrypt(u->p->pgrp->crypt->key, r->request.chal, AUTHLEN+NAMELEN);
mountrpc(m, r);
- decrypt(u->p->pgrp->crypt->key, r->reply.chal, 2*CHLEN+2*DESKEYLEN);
+
+ decrypt(u->p->pgrp->crypt->key, r->reply.chal, 2*AUTHLEN+2*DESKEYLEN);
chal[0] = FSctick;
poperror();
- if(memcmp(chal, r->reply.chal, CHLEN) != 0) {
+ if(memcmp(chal, r->reply.chal, AUTHLEN) != 0) {
mntfree(r);
error(Eperm);
}
- memmove(f->request.auth, r->reply.chal+CHLEN+DESKEYLEN, CHLEN+DESKEYLEN);
+ memmove(f->request.auth, r->reply.chal+AUTHLEN+DESKEYLEN, AUTHLEN+DESKEYLEN);
mntfree(r);
}
M port/portdat.h => port/portdat.h +1 -1
@@ 705,7 705,7 @@ extern char sysname[NAMELEN];
/*
* auth messages
*/
-#define CHLEN 8
+#define AUTHLEN 8
enum{
FScchal = 1,
FSschal,
M port/tcpif.c => port/tcpif.c +10 -0
@@ 42,10 42,15 @@ state_upcall(Ipconv *s, char oldstate, char newstate)
bp->flags |= S_DELIM;
bp->type = M_HANGUP;
qlock(s);
+ if(waserror()) {
+ qunlock(s);
+ nexterror();
+ }
if(s->readq == 0)
freeb(bp);
else
PUTNEXT(s->readq, bp);
+ poperror();
qunlock(s);
break;
}
@@ 81,9 86,14 @@ tcpstart(Ipconv *s, int mode, ushort window, char tos)
/* Send SYN, go into SYN_SENT state */
tcb->flags |= ACTIVE;
qlock(tcb);
+ if(waserror()) {
+ qunlock(tcb);
+ nexterror();
+ }
send_syn(tcb);
setstate(s, Syn_sent);
tcp_output(s);
+ poperror();
qunlock(tcb);
sleep(&tcb->syner, notsyner, tcb);
if(tcb->state != Established && tcb->state != Syn_received)
M power/bboot.c => power/bboot.c +4 -5
@@ 61,7 61,7 @@ main(int argc, char *argv[])
char cmd[64];
char flags[6];
int islocal;
- char *bootfile;
+ char bootfile[NAMELEN];
sleep(1000);
@@ 88,9 88,9 @@ main(int argc, char *argv[])
readenv("terminal", terminal, sizeof(cputype));
readenv("sysname", sysname, sizeof(sysname));
if(argc > 1)
- bootfile = argv[1];
+ strcpy(bootfile, argv[1]);
else
- bootfile = DEFFILE;
+ strcpy(bootfile, DEFFILE);
/*
* pick a method and initialize it
@@ 166,9 166,8 @@ rootserver(char *arg)
else
strcpy(reply, method->name);
for(;;){
- if(arg == 0 || mflag)
+ if(mflag)
outin(prompt, reply, sizeof(reply));
- arg = 0;
for(mp = method; mp->name; mp++)
if(*reply == *mp->name){
cp = strchr(reply, '!');