Browse Source

Plan 9 from Bell Labs 2005-01-25

David du Colombier 16 years ago
parent
commit
f574cb47ad

+ 11 - 8
dist/replica/_plan9.db

@@ -5495,7 +5495,7 @@ sys/src/9/port/devmouse.c - 664 sys sys 1099760452 12504
 sys/src/9/port/devnmouse.c - 664 sys sys 1036812999 3738
 sys/src/9/port/devpipe.c - 664 sys sys 1077055016 5825
 sys/src/9/port/devpnp.c - 664 sys sys 1088560907 13624
-sys/src/9/port/devproc.c - 664 sys sys 1084475128 28427
+sys/src/9/port/devproc.c - 664 sys sys 1106585362 28465
 sys/src/9/port/devroot.c - 664 sys sys 1067722764 4254
 sys/src/9/port/devsd.c - 664 sys sys 1071245428 28564
 sys/src/9/port/devsdp.c - 664 sys sys 1057323393 44800
@@ -6928,16 +6928,15 @@ sys/src/cmd/auth/secstore/SConn.c - 664 sys sys 1064789003 4419
 sys/src/cmd/auth/secstore/SConn.h - 664 sys sys 1015008431 955
 sys/src/cmd/auth/secstore/aescbc.c - 664 sys sys 1103929625 4334
 sys/src/cmd/auth/secstore/dirls.c - 664 sys sys 1062277640 1842
-sys/src/cmd/auth/secstore/mkfile - 664 sys sys 1048615193 844
+sys/src/cmd/auth/secstore/mkfile - 664 sys sys 1106577499 836
 sys/src/cmd/auth/secstore/pak.c - 664 sys sys 1101135278 9290
-sys/src/cmd/auth/secstore/password.c - 664 sys sys 1062277640 2770
-sys/src/cmd/auth/secstore/secacct.c - 644 sys sys 1015008431 755
+sys/src/cmd/auth/secstore/password.c - 664 sys sys 1106577427 2929
 sys/src/cmd/auth/secstore/secchk.c - 664 sys sys 1055698993 560
 sys/src/cmd/auth/secstore/secstore.c - 664 sys sys 1104176417 12526
-sys/src/cmd/auth/secstore/secstore.h - 664 sys sys 1103929624 830
-sys/src/cmd/auth/secstore/secstored.c - 664 sys sys 1089058000 8328
+sys/src/cmd/auth/secstore/secstore.h - 664 sys sys 1106575526 859
+sys/src/cmd/auth/secstore/secstored.c - 664 sys sys 1106575527 8065
 sys/src/cmd/auth/secstore/secuser.c - 664 sys sys 1103929625 5128
-sys/src/cmd/auth/secstore/util.c - 664 sys sys 1103929624 1478
+sys/src/cmd/auth/secstore/util.c - 664 sys sys 1106575527 1819
 sys/src/cmd/auth/secureidcheck.c - 664 sys sys 1078840013 9007
 sys/src/cmd/auth/status - 775 sys sys 1015008430 738
 sys/src/cmd/auth/uniq.c - 664 sys sys 1015008430 1429
@@ -9548,7 +9547,7 @@ sys/src/cmd/ip/snoopy/udp.c - 664 sys sys 1089299190 1990
 sys/src/cmd/ip/telnet.c - 664 sys sys 1080058033 8535
 sys/src/cmd/ip/telnet.h - 664 sys sys 1015090250 5902
 sys/src/cmd/ip/telnetd.c - 664 sys sys 1032060109 11731
-sys/src/cmd/ip/tftpd.c - 664 sys sys 1093453000 7604
+sys/src/cmd/ip/tftpd.c - 664 sys sys 1106624712 7642
 sys/src/cmd/ip/traceroute.c - 664 sys sys 1032060124 9370
 sys/src/cmd/ip/udpecho.c - 664 sys sys 1050714674 855
 sys/src/cmd/join.c - 664 sys sys 944961364 7488
@@ -12457,3 +12456,7 @@ usr/glenda/lib/profile - 664 glenda glenda 1105128663 890
 usr/glenda/readme.acme - 664 glenda glenda 1019860628 4753
 usr/glenda/readme.rio - 664 glenda glenda 1019860628 6370
 usr/glenda/tmp - 20000000775 glenda glenda 1018802620 0
+386/bin/auth/aescbc - 775 sys sys 1106625920 140626
+386/bin/auth/secstore - 775 sys sys 1106625920 195166
+386/bin/auth/secstored - 775 sys sys 1106625920 196858
+386/bin/auth/secuser - 775 sys sys 1106625921 152808

+ 11 - 12
dist/replica/plan9.db

@@ -43,7 +43,7 @@
 386/bin/ascii - 775 sys sys 1104121959 64668
 386/bin/astro - 775 sys sys 1104121959 138803
 386/bin/auth - 20000000775 sys sys 1016920815 0
-386/bin/auth/aescbc - 775 sys sys 1106107674 133292
+386/bin/auth/aescbc - 775 sys sys 1106625920 140626
 386/bin/auth/asn12rsa - 775 sys sys 1104121960 119644
 386/bin/auth/authsrv - 775 sys sys 1104121961 165463
 386/bin/auth/changeuser - 775 sys sys 1104121961 97026
@@ -71,9 +71,9 @@
 386/bin/auth/rsafill - 775 sys sys 1104121968 143416
 386/bin/auth/rsagen - 775 sys sys 1104121969 153041
 386/bin/auth/secretpem - 775 sys sys 1045537944 118526
-386/bin/auth/secstore - 775 sys sys 1106107676 189627
-386/bin/auth/secstored - 775 sys sys 1104121970 196626
-386/bin/auth/secuser - 775 sys sys 1104121971 152299
+386/bin/auth/secstore - 775 sys sys 1106625920 195166
+386/bin/auth/secstored - 775 sys sys 1106625920 196858
+386/bin/auth/secuser - 775 sys sys 1106625921 152808
 386/bin/auth/status - 775 sys sys 1020319060 738
 386/bin/auth/uniq - 775 sys sys 1104121971 63052
 386/bin/auth/warning - 775 sys sys 1104121971 99559
@@ -5495,7 +5495,7 @@ sys/src/9/port/devmouse.c - 664 sys sys 1099760452 12504
 sys/src/9/port/devnmouse.c - 664 sys sys 1036812999 3738
 sys/src/9/port/devpipe.c - 664 sys sys 1077055016 5825
 sys/src/9/port/devpnp.c - 664 sys sys 1088560907 13624
-sys/src/9/port/devproc.c - 664 sys sys 1084475128 28427
+sys/src/9/port/devproc.c - 664 sys sys 1106585362 28465
 sys/src/9/port/devroot.c - 664 sys sys 1067722764 4254
 sys/src/9/port/devsd.c - 664 sys sys 1071245428 28564
 sys/src/9/port/devsdp.c - 664 sys sys 1057323393 44800
@@ -6928,16 +6928,15 @@ sys/src/cmd/auth/secstore/SConn.c - 664 sys sys 1064789003 4419
 sys/src/cmd/auth/secstore/SConn.h - 664 sys sys 1015008431 955
 sys/src/cmd/auth/secstore/aescbc.c - 664 sys sys 1103929625 4334
 sys/src/cmd/auth/secstore/dirls.c - 664 sys sys 1062277640 1842
-sys/src/cmd/auth/secstore/mkfile - 664 sys sys 1048615193 844
+sys/src/cmd/auth/secstore/mkfile - 664 sys sys 1106577499 836
 sys/src/cmd/auth/secstore/pak.c - 664 sys sys 1101135278 9290
-sys/src/cmd/auth/secstore/password.c - 664 sys sys 1062277640 2770
-sys/src/cmd/auth/secstore/secacct.c - 644 sys sys 1015008431 755
+sys/src/cmd/auth/secstore/password.c - 664 sys sys 1106577427 2929
 sys/src/cmd/auth/secstore/secchk.c - 664 sys sys 1055698993 560
 sys/src/cmd/auth/secstore/secstore.c - 664 sys sys 1104176417 12526
-sys/src/cmd/auth/secstore/secstore.h - 664 sys sys 1103929624 830
-sys/src/cmd/auth/secstore/secstored.c - 664 sys sys 1089058000 8328
+sys/src/cmd/auth/secstore/secstore.h - 664 sys sys 1106575526 859
+sys/src/cmd/auth/secstore/secstored.c - 664 sys sys 1106575527 8065
 sys/src/cmd/auth/secstore/secuser.c - 664 sys sys 1103929625 5128
-sys/src/cmd/auth/secstore/util.c - 664 sys sys 1103929624 1478
+sys/src/cmd/auth/secstore/util.c - 664 sys sys 1106575527 1819
 sys/src/cmd/auth/secureidcheck.c - 664 sys sys 1078840013 9007
 sys/src/cmd/auth/status - 775 sys sys 1015008430 738
 sys/src/cmd/auth/uniq.c - 664 sys sys 1015008430 1429
@@ -9548,7 +9547,7 @@ sys/src/cmd/ip/snoopy/udp.c - 664 sys sys 1089299190 1990
 sys/src/cmd/ip/telnet.c - 664 sys sys 1080058033 8535
 sys/src/cmd/ip/telnet.h - 664 sys sys 1015090250 5902
 sys/src/cmd/ip/telnetd.c - 664 sys sys 1032060109 11731
-sys/src/cmd/ip/tftpd.c - 664 sys sys 1093453000 7604
+sys/src/cmd/ip/tftpd.c - 664 sys sys 1106624712 7642
 sys/src/cmd/ip/traceroute.c - 664 sys sys 1032060124 9370
 sys/src/cmd/ip/udpecho.c - 664 sys sys 1050714674 855
 sys/src/cmd/join.c - 664 sys sys 944961364 7488

+ 13 - 0
dist/replica/plan9.log

@@ -13286,3 +13286,16 @@
 1106454670 10 c 386/bin/mntgen - 775 sys sys 1106453227 139193
 1106454670 11 c 386/bin/tprof - 775 sys sys 1106453230 255090
 1106454670 12 c 386/lib/libmach.a - 664 sys sys 1106453232 652292
+1106577094 0 c sys/src/cmd/auth/secstore/password.c - 664 sys sys 1106575527 2818
+1106577094 1 c sys/src/cmd/auth/secstore/secstore.h - 664 sys sys 1106575526 859
+1106577094 2 c sys/src/cmd/auth/secstore/secstored.c - 664 sys sys 1106575527 8065
+1106577094 3 c sys/src/cmd/auth/secstore/util.c - 664 sys sys 1106575527 1819
+1106577094 4 d sys/src/cmd/auth/secstore/secacct.c - 644 sys sys 1015008431 0
+1106578896 0 c sys/src/cmd/auth/secstore/mkfile - 664 sys sys 1106577499 836
+1106578896 1 c sys/src/cmd/auth/secstore/password.c - 664 sys sys 1106577427 2929
+1106586095 0 c sys/src/9/port/devproc.c - 664 sys sys 1106585362 28465
+1106625703 0 c sys/src/cmd/ip/tftpd.c - 664 sys sys 1106624712 7642
+1106627504 0 c 386/bin/auth/aescbc - 775 sys sys 1106625920 140626
+1106627504 1 c 386/bin/auth/secstore - 775 sys sys 1106625920 195166
+1106627504 2 c 386/bin/auth/secstored - 775 sys sys 1106625920 196858
+1106627504 3 c 386/bin/auth/secuser - 775 sys sys 1106625921 152808

+ 2 - 0
sys/src/9/port/devproc.c

@@ -1097,6 +1097,8 @@ procwrite(Chan *c, void *va, long n, vlong off)
 		}
 		t = proctab(0);
 		for(et = t+conf.nproc; t < et; t++) {
+			if(t->state == Dead)
+				continue;
 			if(id == t->noteid) {
 				if(strcmp(p->user, t->user) != 0)
 					error(Eperm);

+ 1 - 1
sys/src/cmd/auth/secstore/mkfile

@@ -13,7 +13,7 @@ OFILES =\
 
 
 TARG = secstore secstored secuser aescbc
-DEBUG = secacct secchk
+DEBUG = secchk
 
 UPDATE=\
 	$HFILES\

+ 9 - 1
sys/src/cmd/auth/secstore/password.c

@@ -12,8 +12,11 @@ openPW(char *id, int mode)
 {
 	Biobuf *b;
 	int nfn = strlen(SECSTORE_DIR)+strlen(id)+20;
-	char *fn = emalloc(nfn);
+	char *fn;
 
+	if(validatefile(id) == nil || strcmp(id,".") == 0)
+		return nil;
+	fn = emalloc(nfn);
 	snprint(fn, nfn, "%s/who/%s", SECSTORE_DIR, id);
 	b = Bopen(fn, mode);
 	free(fn);
@@ -74,6 +77,11 @@ getPW(char *id, int dead_or_alive)
 		}
 	}
 	Bterm(bin);
+	if(pw->Hi == nil){
+		werrstr("corrupted account file");
+		freePW(pw);
+		return nil;
+	}
 	if(dead_or_alive)
 		return pw;  // return PW entry for editing, whether currently valid or not
 	if(pw->expire <= now){

+ 0 - 35
sys/src/cmd/auth/secstore/secacct.c

@@ -1,35 +0,0 @@
-#include <u.h>
-#include <libc.h>
-#include <ip.h>
-
-int verbose = 1;
-static char testmess[] = "__secstore\tPAK\nC=%s\nm=0\n";
-
-void
-main(int argc, char **argv)
-{
-	int n, m, fd;
-	uchar buf[500];
-
-	if(argc != 2)
-		exits("usage: secacct userid");
-
-	n = snprint((char*)buf, sizeof buf, testmess, argv[1]);
-	hnputs(buf, 0x8000+n-2);
-
-	fd = dial("tcp!ruble.cs.bell-labs.com!5356", 0, 0, 0);
-	if(fd < 0)
-		exits("cannot dial ruble");
-	if(write(fd, buf, n) != n || readn(fd, buf, 2) != 2)
-		exits("cannot exchange first round");
-	n = ((buf[0]&0x7f)<<8) + buf[1];
-	if(n+1 > sizeof buf)
-		exits("implausibly large count");
-	m = readn(fd, buf, n);
-	close(fd);
-	if(m != n)
-		fprint(2,"short read from secstore\n");
-	buf[m] = 0;
-	print("%s\n", (char*)buf);
-	exits(0);
-}

+ 1 - 0
sys/src/cmd/auth/secstore/secstore.h

@@ -18,6 +18,7 @@ PW *getPW(char *, int);
 int putPW(PW *);
 void freePW(PW *);
 char* getpassm(char*);
+char *validatefile(char *f);
 
 // *client: SConn, client name, passphrase
 // *server: SConn, (partial) 1st msg, PW entry

+ 0 - 16
sys/src/cmd/auth/secstore/secstored.c

@@ -54,22 +54,6 @@ getdir(SConn *conn, char *id)
 	return 0;
 }
 
-char *
-validatefile(char *f)
-{
-	char *nl;
-
-	if(f==nil || *f==0)
-		return nil;
-	if(nl = strchr(f, '\n'))
-		*nl = 0;
-	if(strchr(f,'/') != nil || strcmp(f,"..")==0 || strlen(f) >= 300){
-		syslog(0, LOG, "no slashes allowed: %s\n", f);
-		return nil;
-	}
-	return f;
-}
-
 static int
 getfile(SConn *conn, char *id, char *gf)
 {

+ 21 - 0
sys/src/cmd/auth/secstore/util.c

@@ -1,5 +1,9 @@
 #include <u.h>
 #include <libc.h>
+#include <mp.h>
+#include <libsec.h>
+#include "SConn.h"
+#include "secstore.h"
 
 void *
 emalloc(ulong n)
@@ -86,3 +90,20 @@ getpassm(char *prompt)
 	}
 	return nil;  // NOT REACHED
 }
+
+char *
+validatefile(char *f)
+{
+	char *nl;
+
+	if(f==nil || *f==0)
+		return nil;
+	if(nl = strchr(f, '\n'))
+		*nl = 0;
+	if(strchr(f,'/') != nil || strcmp(f,"..")==0 || strlen(f) >= 300){
+		syslog(0, LOG, "no slashes allowed: %s\n", f);
+		return nil;
+	}
+	return f;
+}
+

+ 2 - 1
sys/src/cmd/ip/tftpd.c

@@ -107,7 +107,7 @@ main(int argc, char **argv)
 	if (cfd < 0)
 		sysfatal("announcing on %s: %r", buf);
 	syslog(dbg, flog, "tftpd started on %s dir %s", buf, adir);
-	setuser();
+//	setuser();	Moved to doserve [sape]
 	for(;;) {
 		lcfd = listen(adir, ldir);
 		if(lcfd < 0)
@@ -140,6 +140,7 @@ doserve(int fd)
 	char *mode, *p;
 	short op;
 
+	setuser();
 	dlen = read(fd, bigbuf, sizeof(bigbuf));
 	if(dlen < 0)
 		sysfatal("listen read: %r");