mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-24 11:41:58 +00:00
build changes
This commit is contained in:
parent
7d59ed7114
commit
6c0209f6f0
9 changed files with 63 additions and 148 deletions
|
@ -4,6 +4,11 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef PLAN9PORT
|
||||
#pragma lib "libventi.a"
|
||||
#pragma src "/sys/src/libventi"
|
||||
#endif
|
||||
|
||||
AUTOLIB(venti)
|
||||
|
||||
/* XXX should be own library? */
|
||||
|
@ -38,12 +43,38 @@ int packetcmp(Packet*, Packet*);
|
|||
void packetstats(void);
|
||||
void packetsha1(Packet*, uchar sha1[20]);
|
||||
|
||||
/* XXX begin actual venti.h */
|
||||
/* XXX should be own library? */
|
||||
/*
|
||||
* Logging
|
||||
*/
|
||||
typedef struct VtLog VtLog;
|
||||
typedef struct VtLogChunk VtLogChunk;
|
||||
|
||||
#ifndef PLAN9PORT
|
||||
#pragma lib "libventi.a"
|
||||
#pragma src "/sys/src/libventi"
|
||||
#endif
|
||||
struct VtLog
|
||||
{
|
||||
VtLog *next; /* in hash table */
|
||||
VtLogChunk *chunk;
|
||||
uint nchunk;
|
||||
VtLogChunk *w;
|
||||
QLock lk;
|
||||
int ref;
|
||||
};
|
||||
|
||||
struct VtLogchunk
|
||||
{
|
||||
char *buf;
|
||||
uint nbuf;
|
||||
char *w;
|
||||
};
|
||||
|
||||
VtLog *vtlogopen(char *name, uint size);
|
||||
void vtlogprint(VtLog *log, char *fmt, ...);
|
||||
void vtlog(char *name, char *fmt, ...);
|
||||
void vtlogclose(char *name);
|
||||
void vtlogremove(char *name);
|
||||
int vtlogdump(int fd, VtLog*);
|
||||
|
||||
/* XXX begin actual venti.h */
|
||||
|
||||
typedef struct VtFcall VtFcall;
|
||||
typedef struct VtConn VtConn;
|
||||
|
|
|
@ -130,6 +130,7 @@ attrnamefmt(Fmt *fmt)
|
|||
return fmtstrcpy(fmt, buf+1);
|
||||
}
|
||||
|
||||
/*
|
||||
static int
|
||||
hasqueries(Attr *a)
|
||||
{
|
||||
|
@ -138,6 +139,7 @@ hasqueries(Attr *a)
|
|||
return 1;
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
char *ignored[] = {
|
||||
"role",
|
||||
|
|
|
@ -12,73 +12,10 @@ memrandom(void *p, int n)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* create a change uid capability
|
||||
*/
|
||||
static int caphashfd = -1;
|
||||
|
||||
static char*
|
||||
mkcap(char *from, char *to)
|
||||
{
|
||||
uchar rand[20];
|
||||
char *cap;
|
||||
char *key;
|
||||
int nfrom, nto;
|
||||
uchar hash[SHA1dlen];
|
||||
|
||||
if(caphashfd < 0)
|
||||
return nil;
|
||||
|
||||
/* create the capability */
|
||||
nto = strlen(to);
|
||||
nfrom = strlen(from);
|
||||
cap = emalloc(nfrom+1+nto+1+sizeof(rand)*3+1);
|
||||
sprint(cap, "%s@%s", from, to);
|
||||
memrandom(rand, sizeof(rand));
|
||||
key = cap+nfrom+1+nto+1;
|
||||
enc64(key, sizeof(rand)*3, rand, sizeof(rand));
|
||||
|
||||
/* hash the capability */
|
||||
hmac_sha1((uchar*)cap, strlen(cap), (uchar*)key, strlen(key), hash, nil);
|
||||
|
||||
/* give the kernel the hash */
|
||||
key[-1] = '@';
|
||||
if(write(caphashfd, hash, SHA1dlen) < 0){
|
||||
free(cap);
|
||||
return nil;
|
||||
}
|
||||
|
||||
return cap;
|
||||
}
|
||||
|
||||
Attr*
|
||||
addcap(Attr *a, char *from, Ticket *t)
|
||||
{
|
||||
char *cap;
|
||||
|
||||
cap = mkcap(from, t->suid);
|
||||
return addattr(a, "cuid=%q suid=%q cap=%q", t->cuid, t->suid, cap);
|
||||
}
|
||||
|
||||
/* bind in the default network and cs */
|
||||
static int
|
||||
bindnetcs(void)
|
||||
{
|
||||
int srvfd;
|
||||
|
||||
if(access("/net/tcp", AEXIST) < 0)
|
||||
bind("#I", "/net", MBEFORE);
|
||||
|
||||
if(access("/net/cs", AEXIST) < 0){
|
||||
if((srvfd = open("#s/cs", ORDWR)) >= 0){
|
||||
/* mount closes srvfd on success */
|
||||
if(mount(srvfd, -1, "/net", MBEFORE, "") >= 0)
|
||||
return 0;
|
||||
close(srvfd);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
return addattr(a, "cuid=%q suid=%q cap=''", t->cuid, t->suid);
|
||||
}
|
||||
|
||||
int
|
||||
|
|
|
@ -90,7 +90,7 @@ typedef union {
|
|||
};
|
||||
} Hdr;
|
||||
|
||||
static int debug;
|
||||
int debug;
|
||||
static int verb;
|
||||
static int posix = 1;
|
||||
static int creat;
|
||||
|
|
|
@ -400,6 +400,8 @@ vacfile(DirSink *dsink, char *lname, char *sname, VacFile *vf)
|
|||
|
||||
if((dir = dirstat(sname)) == nil){
|
||||
warn("could not stat file %s: %r", lname);
|
||||
return;
|
||||
}
|
||||
if(dir->mode&(DMSYMLINK|DMDEVICE|DMNAMEDPIPE|DMSOCKET)){
|
||||
free(dir);
|
||||
return;
|
||||
|
|
|
@ -10,7 +10,6 @@ OFILES=\
|
|||
mem.$O\
|
||||
req.$O\
|
||||
parse.$O\
|
||||
post.$O\
|
||||
srv.$O\
|
||||
tpost.$O\
|
||||
uid.$O\
|
||||
|
|
|
@ -41,80 +41,20 @@ static struct {
|
|||
"debug", "/tmp/nvram", 0, sizeof(Nvrsafe),
|
||||
};
|
||||
|
||||
static char*
|
||||
readcons(char *prompt, char *def, int raw, char *buf, int nbuf)
|
||||
char*
|
||||
xreadcons(char *prompt, char *def, int secret, char *buf, int nbuf)
|
||||
{
|
||||
int fdin, fdout, ctl, n, m;
|
||||
char line[10];
|
||||
|
||||
fdin = open("/dev/cons", OREAD);
|
||||
if(fdin < 0)
|
||||
fdin = 0;
|
||||
fdout = open("/dev/cons", OWRITE);
|
||||
if(fdout < 0)
|
||||
fdout = 1;
|
||||
if(def != nil)
|
||||
fprint(fdout, "%s[%s]: ", prompt, def);
|
||||
else
|
||||
fprint(fdout, "%s: ", prompt);
|
||||
if(raw){
|
||||
ctl = open("/dev/consctl", OWRITE);
|
||||
if(ctl >= 0)
|
||||
write(ctl, "rawon", 5);
|
||||
} else
|
||||
ctl = -1;
|
||||
|
||||
m = 0;
|
||||
for(;;){
|
||||
n = read(fdin, line, 1);
|
||||
if(n == 0){
|
||||
close(ctl);
|
||||
werrstr("readcons: EOF");
|
||||
return nil;
|
||||
}
|
||||
if(n < 0){
|
||||
close(ctl);
|
||||
werrstr("can't read cons");
|
||||
return nil;
|
||||
}
|
||||
if(line[0] == 0x7f)
|
||||
exits(0);
|
||||
if(n == 0 || line[0] == '\n' || line[0] == '\r'){
|
||||
if(raw){
|
||||
write(ctl, "rawoff", 6);
|
||||
write(fdout, "\n", 1);
|
||||
close(ctl);
|
||||
}
|
||||
buf[m] = '\0';
|
||||
if(buf[0]=='\0' && def)
|
||||
strcpy(buf, def);
|
||||
return buf;
|
||||
}
|
||||
if(line[0] == '\b'){
|
||||
if(m > 0)
|
||||
m--;
|
||||
}else if(line[0] == 0x15){ /* ^U: line kill */
|
||||
m = 0;
|
||||
if(def != nil)
|
||||
fprint(fdout, "%s[%s]: ", prompt, def);
|
||||
else
|
||||
fprint(fdout, "%s: ", prompt);
|
||||
}else{
|
||||
if(m >= nbuf-1){
|
||||
fprint(fdout, "line too long\n");
|
||||
m = 0;
|
||||
if(def != nil)
|
||||
fprint(fdout, "%s[%s]: ", prompt, def);
|
||||
else
|
||||
fprint(fdout, "%s: ", prompt);
|
||||
}else
|
||||
buf[m++] = line[0];
|
||||
}
|
||||
}
|
||||
return buf; /* how does this happen */
|
||||
char *p;
|
||||
|
||||
p = readcons(prompt, def, secret);
|
||||
if(p == nil)
|
||||
return nil;
|
||||
strecpy(buf, buf+nbuf, p);
|
||||
memset(p, 0, strlen(p));
|
||||
free(p);
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* get key info out of nvram. since there isn't room in the PC's nvram use
|
||||
* a disk partition there.
|
||||
|
@ -210,11 +150,11 @@ readnvram(Nvrsafe *safep, int flag)
|
|||
}
|
||||
|
||||
if((flag&NVwrite) || (err && (flag&NVwriteonerr))){
|
||||
readcons("authid", nil, 0, safe->authid, sizeof(safe->authid));
|
||||
readcons("authdom", nil, 0, safe->authdom, sizeof(safe->authdom));
|
||||
readcons("secstore key", nil, 1, safe->config, sizeof(safe->config));
|
||||
xreadcons("authid", nil, 0, safe->authid, sizeof(safe->authid));
|
||||
xreadcons("authdom", nil, 0, safe->authdom, sizeof(safe->authdom));
|
||||
xreadcons("secstore key", nil, 1, safe->config, sizeof(safe->config));
|
||||
for(;;){
|
||||
if(readcons("password", nil, 1, in, sizeof in) == nil)
|
||||
if(xreadcons("password", nil, 1, in, sizeof in) == nil)
|
||||
goto Out;
|
||||
if(passtokey(safe->machkey, in))
|
||||
break;
|
||||
|
|
|
@ -14,7 +14,6 @@ enum
|
|||
static Ndbtuple* filter(Ndb *db, Ndbtuple *t, Ndbtuple *f);
|
||||
static Ndbtuple* mkfilter(int argc, char **argv);
|
||||
static int filtercomplete(Ndbtuple *f);
|
||||
static Ndbtuple* toipaddr(Ndb *db, Ndbtuple *t);
|
||||
static int prefixlen(uchar *ip);
|
||||
static Ndbtuple* subnet(Ndb *db, uchar *net, Ndbtuple *f, int prefix);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ cd lib9
|
|||
9c convM2S.c
|
||||
9c convS2M.c
|
||||
9c create.c
|
||||
9c crypt.c
|
||||
9c ctime.c
|
||||
9c date.c
|
||||
9c dial.c
|
||||
|
@ -51,6 +52,7 @@ cd lib9
|
|||
9c nan.c
|
||||
9c needsrcquote.c
|
||||
9c needstack.c
|
||||
9c netcrypt.c
|
||||
9c netmkaddr.c
|
||||
9c notify.c
|
||||
9c nrand.c
|
||||
|
@ -64,14 +66,17 @@ cd lib9
|
|||
9c quote.c
|
||||
9c rand.c
|
||||
9c read9pmsg.c
|
||||
9c readcons.c
|
||||
9c readn.c
|
||||
9c rfork.c
|
||||
9c searchpath.c
|
||||
9c seek.c
|
||||
9c sendfd.c
|
||||
9c sleep.c
|
||||
9c strdup.c
|
||||
9c strecpy.c
|
||||
9c sysfatal.c
|
||||
9c syslog.c
|
||||
9c sysname.c
|
||||
9c time.c
|
||||
9c tokenize.c
|
||||
|
@ -135,7 +140,7 @@ cd lib9
|
|||
9c utf/utfrrune.c
|
||||
9c utf/utfrune.c
|
||||
9c utf/utfutf.c
|
||||
9ar rvc $PLAN9/lib/lib9.a _exits.o _p9dialparse.o _p9dir.o announce.o argv0.o atexit.o atoi.o atol.o atoll.o atnotify.o await.o cistrcmp.o cistrncmp.o cistrstr.o cleanname.o convD2M.o convM2D.o convM2S.o convS2M.o create.o ctime.o date.o dial.o dirfstat.o dirfwstat.o dirmodefmt.o dirread.o dirstat.o dirwstat.o dup.o encodefmt.o errstr.o exec.o execl.o fcallfmt.o get9root.o getcallerpc-$OBJTYPE.o getenv.o getfields.o getns.o getuser.o getwd.o jmp.o lrand.o lnrand.o main.o malloc.o malloctag.o mallocz.o nan.o needsrcquote.o needstack.o netmkaddr.o notify.o nrand.o nulldir.o open.o opentemp.o pipe.o post9p.o postnote.o qlock.o quote.o rand.o read9pmsg.o readn.o rfork.o seek.o sendfd.o sleep.o strdup.o strecpy.o sysfatal.o sysname.o time.o tokenize.o truerand.o u16.o u32.o u64.o unsharp.o wait.o waitpid.o dofmt.o fltfmt.o fmt.o fmtfd.o fmtfdflush.o fmtlock2.o fmtprint.o fmtquote.o fmtrune.o fmtstr.o fmtvprint.o fprint.o nan64.o print.o runefmtstr.o runeseprint.o runesmprint.o runesnprint.o runesprint.o runevseprint.o runevsmprint.o runevsnprint.o seprint.o smprint.o snprint.o sprint.o strtod.o vfprint.o vseprint.o vsmprint.o vsnprint.o charstod.o pow10.o rune.o runestrcat.o runestrchr.o runestrcmp.o runestrcpy.o runestrdup.o runestrlen.o runestrecpy.o runestrncat.o runestrncmp.o runestrncpy.o runestrrchr.o runestrstr.o runetype.o utfecpy.o utflen.o utfnlen.o utfrrune.o utfrune.o utfutf.o
|
||||
9ar rvc $PLAN9/lib/lib9.a _exits.o _p9dialparse.o _p9dir.o announce.o argv0.o atexit.o atoi.o atol.o atoll.o atnotify.o await.o cistrcmp.o cistrncmp.o cistrstr.o cleanname.o convD2M.o convM2D.o convM2S.o convS2M.o create.o crypt.o ctime.o date.o dial.o dirfstat.o dirfwstat.o dirmodefmt.o dirread.o dirstat.o dirwstat.o dup.o encodefmt.o errstr.o exec.o execl.o fcallfmt.o get9root.o getcallerpc-$OBJTYPE.o getenv.o getfields.o getns.o getuser.o getwd.o jmp.o lrand.o lnrand.o main.o malloc.o malloctag.o mallocz.o nan.o needsrcquote.o needstack.o netcrypt.o netmkaddr.o notify.o nrand.o nulldir.o open.o opentemp.o pipe.o post9p.o postnote.o qlock.o quote.o rand.o read9pmsg.o readcons.o readn.o rfork.o searchpath.o seek.o sendfd.o sleep.o strdup.o strecpy.o sysfatal.o syslog.o sysname.o time.o tokenize.o truerand.o u16.o u32.o u64.o unsharp.o wait.o waitpid.o dofmt.o fltfmt.o fmt.o fmtfd.o fmtfdflush.o fmtlock2.o fmtprint.o fmtquote.o fmtrune.o fmtstr.o fmtvprint.o fprint.o nan64.o print.o runefmtstr.o runeseprint.o runesmprint.o runesnprint.o runesprint.o runevseprint.o runevsmprint.o runevsnprint.o seprint.o smprint.o snprint.o sprint.o strtod.o vfprint.o vseprint.o vsmprint.o vsnprint.o charstod.o pow10.o rune.o runestrcat.o runestrchr.o runestrcmp.o runestrcpy.o runestrdup.o runestrlen.o runestrecpy.o runestrncat.o runestrncmp.o runestrncpy.o runestrrchr.o runestrstr.o runetype.o utfecpy.o utflen.o utfnlen.o utfrrune.o utfrune.o utfutf.o
|
||||
cd ..
|
||||
cd libbio
|
||||
9c bbuffered.c
|
||||
|
|
Loading…
Reference in a new issue