fix fuckup

This commit is contained in:
glenda 2015-08-25 09:35:10 +00:00
parent 6b402b83cf
commit c4fdc6bfdb
42 changed files with 218 additions and 359 deletions

View file

@ -1,10 +1,39 @@
bind /cfg /usr/web/cfg # we start with the namespace of the console...
bind /386 /usr/web/386
bind /amd64 /usr/web/amd64
bind /sys/src/9 /usr/web/sys/src/9 # man2html expects man pages under /sys/man
mount #s/boot /n/emelieother other
bind /n/emelieother/plan9/sys/man /usr/web/sys/man
#bind /n/emelieother/plan9/sys/doc /usr/web/sys/doc
#bind /sys/man /usr/web/sys/man
bind /sys/doc /usr/web/sys/doc
mount #s/etcd /n/etcd # just so people will find something under plan9
bind /n/etcd/www /usr/web/etc bind /usr/web/plan9dist /usr/web/plan9
# users
bind /usr/mike/www /usr/web/incoming/mike
# netlib
bind /netlib/pub /usr/web/netlib
mount -b #s/netlib.depend.pub /usr/web/netlib.depend
# don't need to bind to /usr/web/math etc. because of /sys/lib/http-rewrite
# who what why when where
mount /srv/alice /n/alice
bind -b /n/alice/cm /usr/web/cm
bind /usr/web/cm/who /usr/web/who
bind -b /usr/web/cm/physics/who /usr/web/who
bind -b /usr/web/cm/blrsv/who /usr/web/who
bind -b /usr/web/cm/ss/who /usr/web/who
bind -b /usr/web/cm/ms/who /usr/web/who
bind -b /usr/web/cm/china/who /usr/web/who
bind -b /usr/web/cm/cs/who /usr/web/who
bind /usr/web/cm/ms/what/wavelet /usr/web/wavelet
# formerly ftp.research.bell-labs.com
bind -b /n/alice/usr/ftp /usr/web/dist
# wiki (questions to rsc)
mount -b #s/wiki.plan9 /usr/web/wiki/plan9
# httpd will bind /usr/web onto / # httpd will bind /usr/web onto /

View file

@ -435,7 +435,6 @@ ctlr
ctlr=geode linear=1 ctlr=geode linear=1
ctlr ctlr
vid=0x8086 did=0x0126 # Intel 2nd Gen Core
vid=0x8086 did=0x0166 # Intel 3rd Gen Core vid=0x8086 did=0x0166 # Intel 3rd Gen Core
vid=0x8086 did=0x2a42 # Intel 4 Series Mobile vid=0x8086 did=0x2a42 # Intel 4 Series Mobile
link=vga link=vga
@ -1695,16 +1694,6 @@ s2231wD=1680x1050
vrs=1053 vre=1059 vt=1080 vrs=1053 vre=1059 vt=1080
hsync=+ vsync=- hsync=+ vsync=-
#
# Lenovo T420 (LCD) LVDS
#
#t420=1366x768 # 60Hz
# clock=69.3
# shb=1398 ehb=1430 ht=1470
# vrs=771 vre=776 vt=786
# hsync=- vsync=-
# lcd=1
# #
# Lenovo X230 (LCD) LVDS # Lenovo X230 (LCD) LVDS
# #

View file

@ -71,12 +71,6 @@ case *.vac
vacfs -m /n/`{basename $1 .vac} `{cat $score} vacfs -m /n/`{basename $1 .vac} `{cat $score}
case wiki case wiki
srv -m 'net!plan9.bell-labs.com!wiki' wiki /mnt/wiki srv -m 'net!plan9.bell-labs.com!wiki' wiki /mnt/wiki
case ingenic
ftpfs -qKm /n/ingenic -a $user@$sysname ftp.ingenic.com
case kernel
ftpfs -qKm /n/kernel -a $user@sysname ftp.kernel.org
case qrstuv
srv -nqmC tcp!fs.9paste.net qrstuv
case * case *
switch($#*){ switch($#*){
case 1 case 1

View file

@ -1,16 +0,0 @@
#!/bin/rc
# E file - B file, wait until it changes, exit
rfork e
if (! ~ $#* 1) {
echo usage: $0 file >[1=2]
exit usage
}
if (! test -e $1) {
echo $0: $1: no such file >[1=2]
exit no-file
}
otm = `{mtime $1 | awk '{print $1}'}
B $1
while (~ $otm `{mtime $1 | awk '{print $1}'})
sleep 1
exit ''

View file

@ -1,2 +1,2 @@
#!/bin/rc #!/bin/rc
exec /$objtype/bin/ape/grep -E $* exec /rc/bin/ape/grep $*

View file

@ -1,2 +1,2 @@
#!/bin/rc #!/bin/rc
exec /$objtype/bin/ape/grep -F $* exec /rc/bin/ape/grep $*

View file

@ -20,4 +20,4 @@ if(~ $force n && test -e $2){
exit 'usage' exit 'usage'
} }
exec cp -R $1 $2 exec cp -gux $1 $2

View file

@ -55,22 +55,18 @@ if(test -r /net/ipselftab){
} }
} }
if(! test -e /net/dns){ if(! test -e /net/dns)
echo dns...
ndb/dns -r ndb/dns -r
}
echo timesync...
if(! ps|grep -s timesync){ if(! ps|grep -s timesync){
if(~ $#ntp 0) if(~ $#ntp 0)
. <{ndb/ipquery sys $sysname ntp | sed 's, +,\n,g'} . <{ndb/ipquery sys $sysname ntp | sed 's, +,\n,g'}
if(~ $#ntp 0) if(~ $#ntp 0)
ntp=pool.ntp.org ntp=pool.ntp.org
#aux/timesync -n $ntp aux/timesync -n $ntp
sleep 2 sleep 2
} }
echo listen...
if(~ $#auth 0){ if(~ $#auth 0){
auth=`{ndb/query sys $sysname auth} auth=`{ndb/query sys $sysname auth}
. <{ndb/ipquery sys $sysname auth | sed 's, +,\n,g'} . <{ndb/ipquery sys $sysname auth | sed 's, +,\n,g'}
@ -93,7 +89,6 @@ case *
if(test -f /dev/apm) if(test -f /dev/apm)
aux/apm aux/apm
echo cpustart...
if(test -e /cfg/$sysname/cpustart) if(test -e /cfg/$sysname/cpustart)
. /cfg/$sysname/cpustart . /cfg/$sysname/cpustart

View file

@ -1,4 +1,3 @@
#!/bin/rc #!/bin/rc
#netdir=`{echo $3 | sed 's;/[0-9]+$;!*!0;'} netdir=`{echo $3 | sed 's;/[0-9]+$;!*!0;'}
#exec /bin/cpu -A $netdir -R exec /bin/cpu -A $netdir -R
exec /bin/cpu -R

View file

@ -1,6 +1,6 @@
#!/bin/rc #!/bin/rc
rfork en rfork en
source=https://code.9front.org/hg/plan9front
cd / cd /
if(! test -d .hg) if(! test -d .hg)
bind -ac /dist/plan9front / bind -ac /dist/plan9front /

View file

@ -403,16 +403,6 @@ PEMChain*readcertchain(char *filename);
int aes_xts_encrypt(ulong tweak[], ulong ecb[], vlong sectorNumber, uchar *input, uchar *output, ulong len) ; int aes_xts_encrypt(ulong tweak[], ulong ecb[], vlong sectorNumber, uchar *input, uchar *output, ulong len) ;
int aes_xts_decrypt(ulong tweak[], ulong ecb[], vlong sectorNumber, uchar *input, uchar *output, ulong len); int aes_xts_decrypt(ulong tweak[], ulong ecb[], vlong sectorNumber, uchar *input, uchar *output, ulong len);
/*
* ECC
*/
/* ids for ecnamedcurve */
enum
{
Secp256r1 = 23,
};
typedef struct ECpoint{ typedef struct ECpoint{
int inf; int inf;
mpint *x; mpint *x;
@ -434,15 +424,10 @@ typedef struct ECdomain{
mpint *h; mpint *h;
} ECdomain; } ECdomain;
ECdomain* ecnamedcurve(int);
void ecfreepoint(ECpoint*);
void ecfreepriv(ECpriv*);
void ecfreedomain(ECdomain*);
void ecassign(ECdomain *, ECpoint *old, ECpoint *new); void ecassign(ECdomain *, ECpoint *old, ECpoint *new);
void ecadd(ECdomain *, ECpoint *a, ECpoint *b, ECpoint *s); void ecadd(ECdomain *, ECpoint *a, ECpoint *b, ECpoint *s);
void ecmul(ECdomain *, ECpoint *a, mpint *k, ECpoint *s); void ecmul(ECdomain *, ECpoint *a, mpint *k, ECpoint *s);
ECpoint* betoec(ECdomain*, uchar*, int, ECpoint*); ECpoint* strtoec(ECdomain *, char *, char **, ECpoint *);
ECpoint* strtoec(ECdomain *, char *, char **, ECpoint*);
ECpriv* ecgen(ECdomain *, ECpriv*); ECpriv* ecgen(ECdomain *, ECpriv*);
int ecverify(ECdomain *, ECpoint *); int ecverify(ECdomain *, ECpoint *);
int ecpubverify(ECdomain *, ECpub *); int ecpubverify(ECdomain *, ECpub *);
@ -472,8 +457,5 @@ mpint* dh_new(DHstate *dh, mpint *p, mpint *g);
/* calculate shared key: k = pub ^ x % p */ /* calculate shared key: k = pub ^ x % p */
mpint* dh_finish(DHstate *dh, mpint *pub); mpint* dh_finish(DHstate *dh, mpint *pub);
/* constant-time comparison similar to memcmp(2) */
int constcmp(uchar *x, uchar *y, int len);
/* password-based key derivation function 2 (RFC 2898) */ /* password-based key derivation function 2 (RFC 2898) */
void pbkdf2_hmac_sha1(uchar *p, ulong plen, uchar *s, ulong slen, ulong rounds, uchar *d, ulong dlen); void pbkdf2_hmac_sha1(uchar *p, ulong plen, uchar *s, ulong slen, ulong rounds, uchar *d, ulong dlen);

View file

@ -246,7 +246,7 @@ class fncache(object):
'''fill the entries from the fncache file''' '''fill the entries from the fncache file'''
self.entries = set() self.entries = set()
try: try:
fp = self.opener('fncache', mode='r') fp = self.opener('fncache', mode='rb')
except IOError: except IOError:
# skip nonexistent file # skip nonexistent file
return return

View file

@ -763,7 +763,7 @@ def mktempcopy(name, emptyok=False, createmode=None):
return temp return temp
try: try:
try: try:
ifp = posixfile(name, "r") ifp = posixfile(name, "rb")
except IOError, inst: except IOError, inst:
if inst.errno == errno.ENOENT: if inst.errno == errno.ENOENT:
return temp return temp

View file

@ -1,5 +1,5 @@
enum { enum {
Debug = 1, Debug = 0,
}; };
extern void fatal(char*); extern void fatal(char*);

View file

@ -30,15 +30,12 @@ $objtype
ndb ndb
dnsgetip dnsgetip
hjfs hjfs
p
ps
rc rc
rm rm
sed sed
sleep sleep
srv srv
test test
tlsclient
unmount unmount
nusb nusb
usbd usbd

View file

@ -66,7 +66,7 @@ fn main{
if(~ $#nobootprompt 0){ if(~ $#nobootprompt 0){
echo echo
showlocaldevs showlocaldevs
ask bootargs ' is (tcp, tcptls, il, local!device)' $"bootargs ask bootargs ' is (tcp, il, local!device)' $"bootargs
} }
if not bootargs=$nobootprompt if not bootargs=$nobootprompt
nobootprompt=() nobootprompt=()

View file

@ -48,12 +48,6 @@ fn connecttcp{
fs=$fs(1) fs=$fs(1)
} }
fn connecttcptls{
while(! ~ $#fs 0 && ! srv -qe 'tlsclient -t <{echo $fsthumb} tcp!'^$fs(1)^!5564 boot)
fs=$fs(2-);
fs=$fs(1)
}
fn connectil{ fn connectil{
while(! ~ $#fs 0 && ! srv -q il!$fs(1)^!17008 boot) while(! ~ $#fs 0 && ! srv -q il!$fs(1)^!17008 boot)
fs=$fs(2-); fs=$fs(2-);
@ -61,7 +55,5 @@ fn connectil{
} }
mtcp=(confignet connecttcp) mtcp=(confignet connecttcp)
mtcptls=(confignet connecttcptls)
mil=(confignet connectil) mil=(confignet connectil)
mt=(mtcp mtcptls mil $mt) mt=(mtcp mil $mt)

View file

@ -2164,10 +2164,8 @@ iwlrecover(void *arg)
if(ctlr->power) if(ctlr->power)
poweroff(ctlr); poweroff(ctlr);
if((csr32r(ctlr, Gpc) & RfKill) == 0){ if((csr32r(ctlr, Gpc) & RfKill) == 0)
print("#l%d: rfkill on, not resetting\n", edev->ctlrno);
break; break;
}
if(reset(ctlr) != nil) if(reset(ctlr) != nil)
break; break;
@ -2449,7 +2447,6 @@ iwlpci(void)
case 0x4238: /* Centrino Ultimate-N 6300 variant 2 */ case 0x4238: /* Centrino Ultimate-N 6300 variant 2 */
case 0x08ae: /* Centrino Wireless-N 100 */ case 0x08ae: /* Centrino Wireless-N 100 */
case 0x0083: /* Centrino Wireless-N 1000 */ case 0x0083: /* Centrino Wireless-N 1000 */
case 0x0891: /* Centrino Wireless-N 2200 */
case 0x0887: /* Centrino Wireless-N 2230 */ case 0x0887: /* Centrino Wireless-N 2230 */
case 0x0888: /* Centrino Wireless-N 2230 */ case 0x0888: /* Centrino Wireless-N 2230 */
break; break;

View file

@ -152,10 +152,8 @@ chandevreset(void)
int i; int i;
todinit(); /* avoid later reentry causing infinite recursion */ todinit(); /* avoid later reentry causing infinite recursion */
for(i=0; devtab[i] != nil; i++){ for(i=0; devtab[i] != nil; i++)
//print("%c: %s: reset\n", devtab[i]->dc, devtab[i]->name);
devtab[i]->reset(); devtab[i]->reset();
}
} }
static void closeproc(void*); static void closeproc(void*);

View file

@ -1439,7 +1439,7 @@ checkdigestb(Dstate *s, Block *bin)
*p = n; *p = n;
(*s->hf)(msgid, 4, digest, &ss); (*s->hf)(msgid, 4, digest, &ss);
if(constcmp(digest, bin->rp, s->diglen) != 0) if(memcmp(digest, bin->rp, s->diglen) != 0)
error("bad digest"); error("bad digest");
} }

View file

@ -825,7 +825,7 @@ if(tr->debug) pdump(unpad_len, p, "decrypted:");
(*tr->packMac)(in->sec, in->sec->mackey, seq, header, p, len, hmac); (*tr->packMac)(in->sec, in->sec->mackey, seq, header, p, len, hmac);
if(unpad_len < in->sec->maclen) if(unpad_len < in->sec->maclen)
rcvError(tr, EBadRecordMac, "short record mac"); rcvError(tr, EBadRecordMac, "short record mac");
if(constcmp(hmac, p+len, in->sec->maclen) != 0) if(memcmp(hmac, p+len, in->sec->maclen) != 0)
rcvError(tr, EBadRecordMac, "record mac mismatch"); rcvError(tr, EBadRecordMac, "record mac mismatch");
b->rp = p; b->rp = p;
b->wp = p+len; b->wp = p+len;

View file

@ -173,9 +173,6 @@ sched(void)
up->state = Running; up->state = Running;
up->mach = MACHP(m->machno); up->mach = MACHP(m->machno);
m->proc = up; m->proc = up;
//print("poolcheck sched %s\n", p->text);
//#include <pool.h>
//poolcheck(mainmem);
mmuswitch(up); mmuswitch(up);
gotolabel(&up->sched); gotolabel(&up->sched);
} }

View file

@ -114,7 +114,7 @@ syscallfmt(ulong syscallno, uintptr pc, va_list list)
a = va_arg(list, char*); a = va_arg(list, char*);
fmtuserstring(&fmt, a, ""); fmtuserstring(&fmt, a, "");
argv = va_arg(list, char**); argv = va_arg(list, char**);
evenaddr((uintptr)argv); evenaddr(PTR2UINT(argv));
for(;;){ for(;;){
validaddr((uintptr)argv, sizeof(char**), 0); validaddr((uintptr)argv, sizeof(char**), 0);
a = *(char **)argv; a = *(char **)argv;

View file

@ -10,6 +10,7 @@ char *trivial[] = {
"change me", "change me",
"passwd", "passwd",
"no passwd", "no passwd",
"anonymous",
0 0
}; };

View file

@ -5,7 +5,6 @@
#include <bio.h> #include <bio.h>
#include <ndb.h> #include <ndb.h>
#include <thread.h> #include <thread.h>
#include <9p.h>
/* /*
* This fs presents a 1 level file system. It contains * This fs presents a 1 level file system. It contains
@ -13,7 +12,7 @@
*/ */
typedef struct Console Console; typedef struct Console Console;
typedef struct Aux Aux; typedef struct Fid Fid;
typedef struct Request Request; typedef struct Request Request;
typedef struct Reqlist Reqlist; typedef struct Reqlist Reqlist;
typedef struct Fs Fs; typedef struct Fs Fs;
@ -29,7 +28,7 @@ enum
Bufsize= 32*1024, /* chars buffered per reader */ Bufsize= 32*1024, /* chars buffered per reader */
Maxcons= 64, /* maximum consoles */ Maxcons= 64, /* maximum consoles */
Nhash= 64, /* Aux hash buckets */ Nhash= 64, /* Fid hash buckets */
}; };
#define TYPE(x) (((ulong)x.path) & 0xf) #define TYPE(x) (((ulong)x.path) & 0xf)
@ -39,7 +38,7 @@ enum
struct Request struct Request
{ {
Request *next; Request *next;
Aux *fid; Fid *fid;
Fs *fs; Fs *fs;
Fcall f; Fcall f;
uchar buf[1]; uchar buf[1];
@ -52,11 +51,11 @@ struct Reqlist
Request *last; Request *last;
}; };
struct Aux struct Fid
{ {
Lock; Lock;
Aux *next; /* hash list */ Fid *next; /* hash list */
Aux *cnext; /* list of Aux's on a console */ Fid *cnext; /* list of Fid's on a console */
int fid; int fid;
int ref; int ref;
@ -94,7 +93,7 @@ struct Console
int cfd; int cfd;
int sfd; int sfd;
Aux *flist; /* open fids to broadcast to */ Fid *flist; /* open fids to broadcast to */
}; };
struct Fs struct Fs
@ -103,7 +102,7 @@ struct Fs
int fd; /* to kernel mount point */ int fd; /* to kernel mount point */
int messagesize; int messagesize;
Aux *hash[Nhash]; Fid *hash[Nhash];
Console *cons[Maxcons]; Console *cons[Maxcons];
int ncons; int ncons;
}; };
@ -113,30 +112,30 @@ extern Fs* fsmount(char*);
extern void fsreader(void*); extern void fsreader(void*);
extern void fsrun(void*); extern void fsrun(void*);
extern Aux* fsgetfid(Fs*, int); extern Fid* fsgetfid(Fs*, int);
extern void fsputfid(Fs*, Aux*); extern void fsputfid(Fs*, Fid*);
extern int fsdirgen(Fs*, Qid, int, Dir*, uchar*, int); extern int fsdirgen(Fs*, Qid, int, Dir*, uchar*, int);
extern void fsreply(Fs*, Request*, char*); extern void fsreply(Fs*, Request*, char*);
extern void fskick(Fs*, Aux*); extern void fskick(Fs*, Fid*);
extern int fsreopen(Fs*, Console*); extern int fsreopen(Fs*, Console*);
extern void fsversion(Fs*, Request*, Aux*); extern void fsversion(Fs*, Request*, Fid*);
extern void fsflush(Fs*, Request*, Aux*); extern void fsflush(Fs*, Request*, Fid*);
extern void fsauth(Fs*, Request*, Aux*); extern void fsauth(Fs*, Request*, Fid*);
extern void fsattach(Fs*, Request*, Aux*); extern void fsattach(Fs*, Request*, Fid*);
extern void fswalk(Fs*, Request*, Aux*); extern void fswalk(Fs*, Request*, Fid*);
extern void fsclwalk(Fs*, Request*, Aux*); extern void fsclwalk(Fs*, Request*, Fid*);
extern void fsopen(Fs*, Request*, Aux*); extern void fsopen(Fs*, Request*, Fid*);
extern void fscreate(Fs*, Request*, Aux*); extern void fscreate(Fs*, Request*, Fid*);
extern void fsread(Fs*, Request*, Aux*); extern void fsread(Fs*, Request*, Fid*);
extern void fswrite(Fs*, Request*, Aux*); extern void fswrite(Fs*, Request*, Fid*);
extern void fsclunk(Fs*, Request*, Aux*); extern void fsclunk(Fs*, Request*, Fid*);
extern void fsremove(Fs*, Request*, Aux*); extern void fsremove(Fs*, Request*, Fid*);
extern void fsstat(Fs*, Request*, Aux*); extern void fsstat(Fs*, Request*, Fid*);
extern void fswstat(Fs*, Request*, Aux*); extern void fswstat(Fs*, Request*, Fid*);
void (*fcall[])(Fs*, Request*, Aux*) = void (*fcall[])(Fs*, Request*, Fid*) =
{ {
[Tflush] fsflush, [Tflush] fsflush,
[Tversion] fsversion, [Tversion] fsversion,
@ -200,7 +199,7 @@ Ndb *db;
* any request that can get queued for a delayed reply * any request that can get queued for a delayed reply
*/ */
Request* Request*
alloccreq(Fs *fs, int bufsize) allocreq(Fs *fs, int bufsize)
{ {
Request *r; Request *r;
@ -344,10 +343,10 @@ fsdirgen(Fs *fs, Qid parent, int i, Dir *d, uchar *buf, int nbuf)
Fs* Fs*
fsmount(char *mntpt) fsmount(char *mntpt)
{ {
int pfd[2];
Fs *fs; Fs *fs;
Dir d; int pfd[2], srv;
char buf[32];
int n;
static void *v[2]; static void *v[2];
fs = emalloc(sizeof(Fs)); fs = emalloc(sizeof(Fs));
@ -360,19 +359,21 @@ fsmount(char *mntpt)
v[1] = pfd; v[1] = pfd;
proccreate(fsrun, v, 16*1024); proccreate(fsrun, v, 16*1024);
if(postfd("consoles", pfd[1]) < 0) /* Typically mounted before /srv exists */
sysfatal("post: %r"); if(access("#s/consoles", AEXIST) < 0){
srv = create("#s/consoles", OWRITE, 0666);
if(srv < 0)
fatal("post: %r");
nulldir(&d); n = sprint(buf, "%d", pfd[1]);
d.mode = 0666; if(write(srv, buf, n) < 0)
dirwstat("/srv/consoles", &d); fatal("write srv: %r");
if(mntpt){ close(srv);
if(amount(pfd[1], mntpt, MBEFORE, "") == -1) }
sysfatal("mount %s: %r", mntpt);
}else mount(pfd[1], -1, mntpt, MBEFORE, "");
close(pfd[1]); close(pfd[1]);
return fs; return fs;
} }
@ -515,7 +516,7 @@ console(Fs* fs, char *name, char *dev, int speed, int cronly, int ondemand)
* the reader may miss data but always sees an in order sequence. * the reader may miss data but always sees an in order sequence.
*/ */
void void
fromconsole(Aux *f, char *p, int n) fromconsole(Fid *f, char *p, int n)
{ {
char *rp, *wp, *ep; char *rp, *wp, *ep;
int pass; int pass;
@ -551,10 +552,10 @@ fromconsole(Aux *f, char *p, int n)
* broadcast a list of members to all listeners * broadcast a list of members to all listeners
*/ */
void void
bcastmembers(Fs *fs, Console *c, char *msg, Aux *f) bcastmembers(Fs *fs, Console *c, char *msg, Fid *f)
{ {
int n; int n;
Aux *fl; Fid *fl;
char buf[512]; char buf[512];
sprint(buf, "[%s%s", msg, f->user); sprint(buf, "[%s%s", msg, f->user);
@ -589,7 +590,7 @@ void
fsreader(void *v) fsreader(void *v)
{ {
int n; int n;
Aux *fl; Fid *fl;
char buf[1024]; char buf[1024];
Fs *fs; Fs *fs;
Console *c; Console *c;
@ -652,6 +653,8 @@ readdb(Fs *fs)
} }
} }
int dbmtime;
/* /*
* a request processor (one per Fs) * a request processor (one per Fs)
*/ */
@ -660,7 +663,8 @@ fsrun(void *v)
{ {
int n, t; int n, t;
Request *r; Request *r;
Aux *f; Fid *f;
Dir *d;
void **a = v; void **a = v;
Fs* fs; Fs* fs;
int *pfd; int *pfd;
@ -668,12 +672,15 @@ fsrun(void *v)
fs = a[0]; fs = a[0];
pfd = a[1]; pfd = a[1];
fs->fd = pfd[0]; fs->fd = pfd[0];
readdb(fs);
notify(handler); notify(handler);
for(;;){ for(;;){
if(ndbchanged(db)) d = dirstat(consoledb);
if(d != nil && d->mtime != dbmtime){
dbmtime = d->mtime;
readdb(fs); readdb(fs);
r = alloccreq(fs, messagesize); }
free(d);
r = allocreq(fs, messagesize);
while((n = read9pmsg(fs->fd, r->buf, messagesize)) == 0) while((n = read9pmsg(fs->fd, r->buf, messagesize)) == 0)
; ;
if(n < 0) if(n < 0)
@ -698,10 +705,10 @@ fsrun(void *v)
} }
} }
Aux* Fid*
fsgetfid(Fs *fs, int fid) fsgetfid(Fs *fs, int fid)
{ {
Aux *f, *nf; Fid *f, *nf;
lock(fs); lock(fs);
for(f = fs->hash[fid%Nhash]; f; f = f->next){ for(f = fs->hash[fid%Nhash]; f; f = f->next){
@ -712,7 +719,7 @@ fsgetfid(Fs *fs, int fid)
} }
} }
nf = emalloc(sizeof(Aux)); nf = emalloc(sizeof(Fid));
nf->next = fs->hash[fid%Nhash]; nf->next = fs->hash[fid%Nhash];
fs->hash[fid%Nhash] = nf; fs->hash[fid%Nhash] = nf;
nf->fid = fid; nf->fid = fid;
@ -724,9 +731,9 @@ fsgetfid(Fs *fs, int fid)
} }
void void
fsputfid(Fs *fs, Aux *f) fsputfid(Fs *fs, Fid *f)
{ {
Aux **l, *nf; Fid **l, *nf;
lock(fs); lock(fs);
if(--f->ref > 0){ if(--f->ref > 0){
@ -744,13 +751,13 @@ fsputfid(Fs *fs, Aux *f)
} }
void void
fsauth(Fs *fs, Request *r, Aux*) fsauth(Fs *fs, Request *r, Fid*)
{ {
fsreply(fs, r, "consolefs: authentication not required"); fsreply(fs, r, "consolefs: authentication not required");
} }
void void
fsversion(Fs *fs, Request *r, Aux*) fsversion(Fs *fs, Request *r, Fid*)
{ {
if(r->f.msize < 256){ if(r->f.msize < 256){
@ -771,7 +778,7 @@ fsversion(Fs *fs, Request *r, Aux*)
} }
void void
fsflush(Fs *fs, Request *r, Aux *f) fsflush(Fs *fs, Request *r, Fid *f)
{ {
Request *or; Request *or;
@ -779,15 +786,12 @@ fsflush(Fs *fs, Request *r, Aux *f)
if(or != nil){ if(or != nil){
fsputfid(fs, or->fid); fsputfid(fs, or->fid);
free(or); free(or);
fsreply(fs, r, nil);
} else {
fsputfid(fs, f);
free(r);
} }
fsreply(fs, r, nil);
} }
void void
fsattach(Fs *fs, Request *r, Aux *f) fsattach(Fs *fs, Request *r, Fid *f)
{ {
f->qid.type = QTDIR; f->qid.type = QTDIR;
f->qid.path = QID(0, Ttopdir); f->qid.path = QID(0, Ttopdir);
@ -809,13 +813,13 @@ fsattach(Fs *fs, Request *r, Aux *f)
} }
void void
fswalk(Fs *fs, Request *r, Aux *f) fswalk(Fs *fs, Request *r, Fid *f)
{ {
char *name; char *name;
Dir d; Dir d;
int i, n, nqid, nwname; int i, n, nqid, nwname;
Qid qid, wqid[MAXWELEM]; Qid qid, wqid[MAXWELEM];
Aux *nf; Fid *nf;
char *err; char *err;
if(f->attached == 0){ if(f->attached == 0){
@ -928,7 +932,7 @@ int m2p[] ={
void void
bcastmsg(Fs *fs, Console *c, char *msg, int n) bcastmsg(Fs *fs, Console *c, char *msg, int n)
{ {
Aux *fl; Fid *fl;
for(fl = c->flist; fl; fl = fl->cnext){ for(fl = c->flist; fl; fl = fl->cnext){
fromconsole(fl, msg, n); fromconsole(fl, msg, n);
@ -937,7 +941,7 @@ bcastmsg(Fs *fs, Console *c, char *msg, int n)
} }
void void
fsopen(Fs *fs, Request *r, Aux *f) fsopen(Fs *fs, Request *r, Fid *f)
{ {
int mode; int mode;
Console *c; Console *c;
@ -1005,13 +1009,13 @@ fsopen(Fs *fs, Request *r, Aux *f)
} }
void void
fscreate(Fs *fs, Request *r, Aux*) fscreate(Fs *fs, Request *r, Fid*)
{ {
fsreply(fs, r, Eperm); fsreply(fs, r, Eperm);
} }
void void
fsread(Fs *fs, Request *r, Aux *f) fsread(Fs *fs, Request *r, Fid *f)
{ {
uchar *p, *e; uchar *p, *e;
int i, m, off; int i, m, off;
@ -1074,7 +1078,7 @@ fsread(Fs *fs, Request *r, Aux *f)
} }
void void
fswrite(Fs *fs, Request *r, Aux *f) fswrite(Fs *fs, Request *r, Fid *f)
{ {
int i, eol = 0; int i, eol = 0;
@ -1137,9 +1141,9 @@ fswrite(Fs *fs, Request *r, Aux *f)
} }
void void
fsclunk(Fs *fs, Request *r, Aux *f) fsclunk(Fs *fs, Request *r, Fid *f)
{ {
Aux **l, *fl; Fid **l, *fl;
Request *nr; Request *nr;
if(f->open && TYPE(f->qid) == Qdata){ if(f->open && TYPE(f->qid) == Qdata){
@ -1166,13 +1170,13 @@ fsclunk(Fs *fs, Request *r, Aux *f)
} }
void void
fsremove(Fs *fs, Request *r, Aux*) fsremove(Fs *fs, Request *r, Fid*)
{ {
fsreply(fs, r, Eperm); fsreply(fs, r, Eperm);
} }
void void
fsstat(Fs *fs, Request *r, Aux *f) fsstat(Fs *fs, Request *r, Fid *f)
{ {
int i, n; int i, n;
Qid q; Qid q;
@ -1194,7 +1198,7 @@ fsstat(Fs *fs, Request *r, Aux *f)
} }
void void
fswstat(Fs *fs, Request *r, Aux*) fswstat(Fs *fs, Request *r, Fid*)
{ {
fsreply(fs, r, Eperm); fsreply(fs, r, Eperm);
} }
@ -1222,7 +1226,7 @@ fsreply(Fs *fs, Request *r, char *err)
* called whenever input or a read request has been received * called whenever input or a read request has been received
*/ */
void void
fskick(Fs *fs, Aux *f) fskick(Fs *fs, Fid *f)
{ {
Request *r; Request *r;
char *p, *rp, *wp, *ep; char *p, *rp, *wp, *ep;

View file

@ -224,7 +224,7 @@ main(int argc, char **argv)
if(system == nil) { if(system == nil) {
p = getenv("cpu"); p = getenv("cpu");
if(p == 0) if(p == 0)
p = "$cpu"; fatal("set $cpu");
system = p; system = p;
} }

View file

@ -33,13 +33,13 @@
/* ---------------- Cache sizes ---------------- */ /* ---------------- Cache sizes ---------------- */
#define ARCH_CACHE1_SIZE 2097152 #define ARCH_CACHE1_SIZE 131072
#define ARCH_CACHE2_SIZE 4194304 #define ARCH_CACHE2_SIZE 4194304
/* ---------------- Miscellaneous ---------------- */ /* ---------------- Miscellaneous ---------------- */
#define ARCH_IS_BIG_ENDIAN 0 #define ARCH_IS_BIG_ENDIAN 0
#define ARCH_PTRS_ARE_SIGNED 1 #define ARCH_PTRS_ARE_SIGNED 0
#define ARCH_FLOATS_ARE_IEEE 1 #define ARCH_FLOATS_ARE_IEEE 1
#define ARCH_ARITH_RSHIFT 2 #define ARCH_ARITH_RSHIFT 2
#define ARCH_CAN_SHIFT_FULL_LONG 0 #define ARCH_CAN_SHIFT_FULL_LONG 0

View file

@ -240,10 +240,10 @@ static void
printtype(Hio *hout, HContent *type, HContent *enc) printtype(Hio *hout, HContent *type, HContent *enc)
{ {
hprint(hout, "Content-Type: %s/%s", type->generic, type->specific); hprint(hout, "Content-Type: %s/%s", type->generic, type->specific);
/*
if(cistrcmp(type->generic, "text") == 0) if(cistrcmp(type->generic, "text") == 0)
hprint(hout, ";charset=utf-8"); hprint(hout, ";charset=utf-8");
*/
hprint(hout, "\r\n"); hprint(hout, "\r\n");
if(enc != nil) if(enc != nil)
hprint(hout, "Content-Encoding: %s\r\n", enc->generic); hprint(hout, "Content-Encoding: %s\r\n", enc->generic);
@ -351,8 +351,6 @@ checkreq(HConnect *c, HContent *type, HContent *enc, long mtime, char *etag)
if(c->req.vermaj >= 1 && c->req.vermin >= 1 && !hcheckcontent(enc, c->head.okencode, "Content-Encoding", 0)) if(c->req.vermaj >= 1 && c->req.vermin >= 1 && !hcheckcontent(enc, c->head.okencode, "Content-Encoding", 0))
return notaccept(c, type, enc, "Content-Encoding"); return notaccept(c, type, enc, "Content-Encoding");
return 1;
/* /*
* can use weak match only with get or head; * can use weak match only with get or head;
* this always uses strong matches * this always uses strong matches

View file

@ -54,7 +54,6 @@ enum
*/ */
Bandtblksz = Bandtmtu - 40 - 8, Bandtblksz = Bandtmtu - 40 - 8,
Bcavium = 1432, /* cavium's u-boot demands this size */ Bcavium = 1432, /* cavium's u-boot demands this size */
Bci20 = 1468, /* ci20 u-boot */
}; };
typedef struct Opt Opt; typedef struct Opt Opt;
@ -330,7 +329,7 @@ options(int fd, char *buf, int bufsz, char *file, ushort oper, char *p, int dlen
syslog(dbg, flog, "tftpd %d %s tsize is %,lld", syslog(dbg, flog, "tftpd %d %s tsize is %,lld",
pid, file, size); pid, file, size);
} else if (oper == Tftp_READ && cistrcmp(p, "blksize") == 0 && } else if (oper == Tftp_READ && cistrcmp(p, "blksize") == 0 &&
blksize > Bandtblksz && blksize != Bcavium && blksize != Bci20) { blksize > Bandtblksz && blksize != Bcavium) {
*op->valp = blksize = Bandtblksz; *op->valp = blksize = Bandtblksz;
olen = emitn(blksize, bp, ep); olen = emitn(blksize, bp, ep);
syslog(dbg, flog, "tftpd %d overriding blksize to %d", syslog(dbg, flog, "tftpd %d overriding blksize to %d",

View file

@ -163,7 +163,7 @@ again: /* rogue processes */
uarg = 1; uarg = 1;
} else { } else {
jobs = 0; jobs = 0;
sysfatal("%s", buf); Exit();
} }
} }
for(w = j->t; w; w = w->next){ for(w = j->t; w; w = w->next){

View file

@ -12,3 +12,4 @@ snprint(char *buf, int len, char *fmt, ...)
va_end(args); va_end(args);
return n; return n;
} }

View file

@ -164,7 +164,7 @@ controlsetthread(void *v)
Rune buf[2][20], *rp; Rune buf[2][20], *rp;
cs = v; cs = v;
threadsetname("controlsetthread %#p", cs); threadsetname("controlsetthread 0x%p", cs);
alts[AKey].c = cs->kbdc; alts[AKey].c = cs->kbdc;
alts[AKey].v = &rp; alts[AKey].v = &rp;
@ -324,7 +324,6 @@ ctlerror(char *fmt, ...)
vfprint(2, fmt, arg); vfprint(2, fmt, arg);
va_end(arg); va_end(arg);
write(2, "\n", 1); write(2, "\n", 1);
abort();
threadexitsall(buf); threadexitsall(buf);
} }
@ -377,8 +376,6 @@ ctlstrdup(char *s)
t = strdup(s); t = strdup(s);
if(t == nil) if(t == nil)
ctlerror("control strdup(%q) failed: %r", s); ctlerror("control strdup(%q) failed: %r", s);
setmalloctag(t, getcallerpc(&s));
return t; return t;
} }

View file

@ -29,3 +29,4 @@ newwindow(char *str)
return mount(fd, -1, "/dev", MBEFORE, buf); return mount(fd, -1, "/dev", MBEFORE, buf);
return bind("/mnt/wsys", "/dev", MBEFORE); return bind("/mnt/wsys", "/dev", MBEFORE);
} }

View file

@ -836,9 +836,6 @@ format(char *mnemonic, Instr *i, char *f)
break; break;
case 'm': case 'm':
if(i->function != 0)
bprint(i, "M(%s),%d", cop0regs[i->rd], i->function);
else
bprint(i, "M(%s)", cop0regs[i->rd]); bprint(i, "M(%s)", cop0regs[i->rd]);
break; break;

View file

@ -1,18 +0,0 @@
#include <u.h>
/*
* returns 0 if the the len bytes in x are equal to len bytes in y,
* otherwise returns -1.
*/
int
constcmp(uchar *x, uchar *y, int len)
{
uint z;
int i;
for(z = 0, i = 0; i < len; i++) {
z |= x[i] ^ y[i];
}
return (1 & ((z - 1) >> 8)) - 1;
}

View file

@ -3,76 +3,6 @@
#include <libsec.h> #include <libsec.h>
#include <ctype.h> #include <ctype.h>
ECdomain *
ecnamedcurve(int id)
{
ECdomain *dom;
dom = malloc(sizeof(ECdomain));
if(dom == nil)
return nil;
switch(id) {
default:
free(dom);
return nil;
case Secp256r1:
dom->p = strtomp("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFF", nil, 16, nil);
dom->a = strtomp("FFFFFFFF00000001000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFC", nil, 16, nil);
dom->b = strtomp("5AC635D8AA3A93E7B3EBBD55769886BC651D06B0CC53B0F63BCE3C3E27D2604B", nil, 16, nil);
dom->G = strtoec(dom, "036B17D1F2E12C4247F8BCE6E563A440F277037D812DEB33A0F4A13945D898C296", nil, nil);
dom->n = strtomp("FFFFFFFF00000000FFFFFFFFFFFFFFFFBCE6FAADA7179E84F3B9CAC2FC632551", nil, 16, nil);
dom->h = uitomp(1, nil);
break;
}
if(dom->p == nil || dom->a == nil || dom->b == nil || dom->G == nil || dom->n == nil || dom->h == nil) {
ecfreedomain(dom);
return nil;
}
return dom;
}
void
ecfreepoint(ECpoint *pt)
{
if(pt != nil) {
mpfree(pt->x);
mpfree(pt->y);
}
free(pt);
}
void
ecfreepriv(ECpriv *priv)
{
if(priv != nil) {
mpfree(priv->x);
mpfree(priv->y);
mpfree(priv->d);
}
free(priv);
}
void
ecfreedomain(ECdomain *dom)
{
if(dom != nil) {
mpfree(dom->p);
mpfree(dom->a);
mpfree(dom->b);
if(dom->G != nil) {
ecfreepoint(dom->G);
}
mpfree(dom->n);
mpfree(dom->h);
}
free(dom);
}
void void
ecassign(ECdomain *, ECpoint *a, ECpoint *b) ecassign(ECdomain *, ECpoint *a, ECpoint *b)
{ {
@ -399,54 +329,6 @@ mpsqrt(mpint *n, mpint *p, mpint *r)
return 1; return 1;
} }
// converts the bytes in buf to an ECpoint x y pair.
// the domain is used to determine the number of bytes in x and y in the buffer.
ECpoint*
betoec(ECdomain *dom, uchar *buf, int blen, ECpoint *ret)
{
int allocd, bytelen;
allocd = 0;
bytelen = (mpsignif(dom->p)+7) >> 3;
// sanity check arguments
if(dom == nil || buf == nil)
return nil;
// check if input is too short for two mpints
if(blen != 1+2*bytelen)
return nil;
// check that point is in uncompressed format
if(buf[0] != 4)
return nil;
if(ret == nil) {
// allocate return pointer and mpints
allocd = 1;
ret = mallocz(sizeof(*ret), 1);
if(ret == nil)
return nil;
ret->x = mpnew(0);
ret->y = mpnew(0);
}
// uncompressed form
if(betomp(buf+1, bytelen, ret->x) == nil)
goto err;
if(betomp(buf+1+bytelen, bytelen, ret->y) == nil)
goto err;
if(!ecverify(dom, ret))
goto err;
return ret;
err:
if(allocd){
ecfreepoint(ret);
}
return nil;
}
ECpoint* ECpoint*
strtoec(ECdomain *dom, char *s, char **rptr, ECpoint *ret) strtoec(ECdomain *dom, char *s, char **rptr, ECpoint *ret)
{ {
@ -500,8 +382,11 @@ strtoec(ECdomain *dom, char *s, char **rptr, ECpoint *ret)
err: err:
if(rptr) if(rptr)
*rptr = s; *rptr = s;
if(allocd) if(allocd){
ecfreepoint(ret); mpfree(ret->x);
mpfree(ret->y);
free(ret);
}
return nil; return nil;
} }

View file

@ -22,7 +22,6 @@ CFILES = des.c desmodes.c desECB.c desCBC.c des3ECB.c des3CBC.c\
ripemd.c\ ripemd.c\
dh.c\ dh.c\
pbkdf2.c\ pbkdf2.c\
const.c\
ALLOFILES=${CFILES:%.c=%.$O} ALLOFILES=${CFILES:%.c=%.$O}

View file

@ -38,7 +38,7 @@ okThumbprint(uchar *sum, Thumbprint *table)
return 0; return 0;
hd = tablehead(sum, table); hd = tablehead(sum, table);
for(p = hd->next; p; p = p->next){ for(p = hd->next; p; p = p->next){
if(constcmp(sum, p->sha1, SHA1dlen) == 0) if(memcmp(sum, p->sha1, SHA1dlen) == 0)
return 1; return 1;
if(p == hd) if(p == hd)
break; break;

View file

@ -854,57 +854,99 @@ ectobytes(int type, ECpoint *p)
static Bytes* static Bytes*
tlsSecECDHEc(TlsSec *sec, uchar *srandom, int vers, int curve, Bytes *Ys) tlsSecECDHEc(TlsSec *sec, uchar *srandom, int vers, int curve, Bytes *Ys)
{ {
Namedcurve *nc, *enc;
Bytes *epm; Bytes *epm;
ECdomain *dom; ECdomain dom;
ECpoint K, *Y; ECpoint G, K, Y;
ECpriv *Q; ECpriv Q;
epm = nil;
Y = nil;
Q = nil;
if(Ys == nil) if(Ys == nil)
return nil; return nil;
enc = &namedcurves[nelem(namedcurves)];
for(nc = namedcurves; nc != enc; nc++)
if(nc->tlsid == curve)
break;
if(nc == enc)
return nil;
memmove(sec->srandom, srandom, RandomSize); memmove(sec->srandom, srandom, RandomSize);
if(setVers(sec, vers) < 0) if(setVers(sec, vers) < 0)
return nil; return nil;
dom = ecnamedcurve(curve); epm = nil;
if(dom == nil)
return nil;
memset(&dom, 0, sizeof(dom));
dom.p = strtomp(nc->p, nil, 16, nil);
dom.a = strtomp(nc->a, nil, 16, nil);
dom.b = strtomp(nc->b, nil, 16, nil);
dom.n = strtomp(nc->n, nil, 16, nil);
dom.h = strtomp(nc->h, nil, 16, nil);
memset(&G, 0, sizeof(G));
G.x = mpnew(0);
G.y = mpnew(0);
memset(&Q, 0, sizeof(Q));
Q.x = mpnew(0);
Q.y = mpnew(0);
Q.d = mpnew(0);
memset(&K, 0, sizeof(K)); memset(&K, 0, sizeof(K));
K.x = mpnew(0); K.x = mpnew(0);
K.y = mpnew(0); K.y = mpnew(0);
memset(&Y, 0, sizeof(Y));
Y.x = mpnew(0);
Y.y = mpnew(0);
if(dom.p == nil || dom.a == nil || dom.b == nil || dom.n == nil || dom.h == nil)
goto Out;
if(Q.x == nil || Q.y == nil || Q.d == nil)
goto Out;
if(G.x == nil || G.y == nil)
goto Out;
if(K.x == nil || K.y == nil) if(K.x == nil || K.y == nil)
goto Out; goto Out;
if(Y.x == nil || Y.y == nil)
Y = betoec(dom, Ys->data, Ys->len, nil);
if(Y == nil)
goto Out; goto Out;
Q = ecgen(dom, nil); dom.G = strtoec(&dom, nc->G, nil, &G);
if(Q == nil) if(dom.G == nil)
goto Out; goto Out;
ecmul(dom, Y, Q->d, &K); if(bytestoec(&dom, Ys, &Y) == nil)
goto Out;
if(ecgen(&dom, &Q) == nil)
goto Out;
ecmul(&dom, &Y, Q.d, &K);
setMasterSecret(sec, mptobytes(K.x)); setMasterSecret(sec, mptobytes(K.x));
/* 0x04 = uncompressed public key */ /* 0x04 = uncompressed public key */
epm = ectobytes(0x04, Q); epm = ectobytes(0x04, &Q);
Out: Out:
ecfreepriv(Q); mpfree(Y.x);
mpfree(Y.y);
ecfreepoint(Y);
mpfree(K.x); mpfree(K.x);
mpfree(K.y); mpfree(K.y);
ecfreedomain(dom); mpfree(Q.x);
mpfree(Q.y);
mpfree(Q.d);
mpfree(G.x);
mpfree(G.y);
mpfree(dom.p);
mpfree(dom.a);
mpfree(dom.b);
mpfree(dom.n);
mpfree(dom.h);
return epm; return epm;
} }
@ -1915,7 +1957,7 @@ setVersion(TlsConnection *c, int version)
static int static int
finishedMatch(TlsConnection *c, Finished *f) finishedMatch(TlsConnection *c, Finished *f)
{ {
return constcmp(f->verify, c->finished.verify, f->n) == 0; return memcmp(f->verify, c->finished.verify, f->n) == 0;
} }
// free memory associated with TlsConnection struct // free memory associated with TlsConnection struct

View file

@ -2212,7 +2212,7 @@ verify_signature(Bytes* signature, RSApub *pk, uchar *edigest, int edigestlen, E
err = "bad digest length"; err = "bad digest length";
goto end; goto end;
} }
if(constcmp(digest->data, edigest, edigestlen) != 0) if(memcmp(digest->data, edigest, edigestlen) != 0)
err = "digests did not match"; err = "digests did not match";
end: end:

View file

@ -71,7 +71,7 @@ threadsetname(char *fmt, ...)
va_start(arg, fmt); va_start(arg, fmt);
t->cmdname = vsmprint(fmt, arg); t->cmdname = vsmprint(fmt, arg);
va_end(arg); va_end(arg);
if(t->cmdname){ if(t->cmdname && p->nthreads == 1){
snprint(buf, sizeof buf, "#p/%lud/args", _tos->pid); //getpid()); snprint(buf, sizeof buf, "#p/%lud/args", _tos->pid); //getpid());
if((fd = open(buf, OWRITE)) >= 0){ if((fd = open(buf, OWRITE)) >= 0){
write(fd, t->cmdname, strlen(t->cmdname)+1); write(fd, t->cmdname, strlen(t->cmdname)+1);

View file

@ -31,7 +31,7 @@ main(int argc, char **argv)
if(setjmp(_mainjmp)) if(setjmp(_mainjmp))
_schedinit(p); _schedinit(p);
//_threaddebuglevel = (DBGSCHED|DBGCHAN|DBGREND); //_threaddebuglevel = (DBGSCHED|DBGCHAN|DBGREND)^~0;
_systhreadinit(); _systhreadinit();
_qlockinit(_threadrendezvous); _qlockinit(_threadrendezvous);
_sysfatal = _threadsysfatal; _sysfatal = _threadsysfatal;