summaryrefslogtreecommitdiff
path: root/appl/cmd
diff options
context:
space:
mode:
authorforsyth <forsyth@vitanuova.com>2011-04-03 15:03:05 +0100
committerforsyth <forsyth@vitanuova.com>2011-04-03 15:03:05 +0100
commit728860af799ffd5aa8b3b90576ae582b11b7f5a5 (patch)
treeb6e969a01af2a3d56d7296b96002476dd116fa8d /appl/cmd
parent41858f31398f2a5187173202c165df7717217c89 (diff)
20110403-1502
Diffstat (limited to 'appl/cmd')
-rw-r--r--appl/cmd/auth/mkfile1
-rw-r--r--appl/cmd/auth/secstore.b28
2 files changed, 28 insertions, 1 deletions
diff --git a/appl/cmd/auth/mkfile b/appl/cmd/auth/mkfile
index 71d31533..40eaf557 100644
--- a/appl/cmd/auth/mkfile
+++ b/appl/cmd/auth/mkfile
@@ -17,6 +17,7 @@ TARG=\
mkauthinfo.dis\
passwd.dis\
rsagen.dis\
+ secstore.dis\
signer.dis\
verify.dis\
diff --git a/appl/cmd/auth/secstore.b b/appl/cmd/auth/secstore.b
index e26e132d..3bebd29b 100644
--- a/appl/cmd/auth/secstore.b
+++ b/appl/cmd/auth/secstore.b
@@ -199,7 +199,25 @@ Auth:
secstore->erasekey(file);
file = nil;
verb('x', fname);
- 'r' or * =>
+ 'r' =>
+ checkname(fname, 1);
+ fd := sys->open(fname, sys->OREAD);
+ if(fd == nil)
+ error(sys->sprint("open %q: %r", fname));
+ (ok, dir) := sys->fstat(fd);
+ if(ok != 0)
+ error(sys->sprint("stat %q: %r", fname));
+ if(int dir.length > Maxfilesize)
+ error(sys->sprint("length %bd > Maxfilesize %d", dir.length, Maxfilesize));
+ file = array[int dir.length] of byte;
+ if(sys->readn(fd, file, len file) != len file)
+ error(sys->sprint("short read: %r"));
+ if(putfile(conn, fname, file, filekey) < 0)
+ error(sys->sprint("putfile: %r"));
+ secstore->erasekey(file);
+ file = nil;
+ verb('r', fname);
+ * =>
error(sys->sprint("op %c not implemented", op));
}
}
@@ -242,6 +260,14 @@ getfile(conn: ref Dial->Connection, fname: string, key: array of byte): array of
return f;
}
+putfile(conn: ref Dial->Connection, fname: string, data, key: array of byte): int
+{
+ data = secstore->encrypt(data, key);
+ if(data == nil)
+ return -1;
+ return secstore->putfile(conn, fname, data);
+}
+
erase()
{
if(secstore != nil){