summaryrefslogtreecommitdiff
path: root/sys/src
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@felloff.net>2015-03-01 11:17:21 +0100
committercinap_lenrek <cinap_lenrek@felloff.net>2015-03-01 11:17:21 +0100
commit3f869a689403c385ca761be5535a5de2db054db4 (patch)
treed0d3cfed68db6ff7ce5800b60826a6ef3449222a /sys/src
parent0467b41972b62604c8a22b355569413890b9757c (diff)
factotum: cleanup getnvramkey()
- remove secstore password code, it is not used anymore. - zero the Nvrsafe structure on the stack before returning. - use smprint(), can't overflow.
Diffstat (limited to 'sys/src')
-rw-r--r--sys/src/cmd/auth/factotum/dat.h2
-rw-r--r--sys/src/cmd/auth/factotum/fs.c2
-rw-r--r--sys/src/cmd/auth/factotum/util.c18
3 files changed, 6 insertions, 16 deletions
diff --git a/sys/src/cmd/auth/factotum/dat.h b/sys/src/cmd/auth/factotum/dat.h
index 10cdc9a34..5cc0c1b8b 100644
--- a/sys/src/cmd/auth/factotum/dat.h
+++ b/sys/src/cmd/auth/factotum/dat.h
@@ -201,7 +201,7 @@ Keyinfo* mkkeyinfo(Keyinfo*, Fsstate*, Attr*);
int findkey(Key**, Keyinfo*, char*, ...);
int findp9authkey(Key**, Fsstate*);
Proto *findproto(char*);
-char *getnvramkey(int, char**);
+char *getnvramkey(int);
void initcap(void);
int isclient(char*);
int matchattr(Attr*, Attr*, Attr*);
diff --git a/sys/src/cmd/auth/factotum/fs.c b/sys/src/cmd/auth/factotum/fs.c
index b9a51d383..7d195ac01 100644
--- a/sys/src/cmd/auth/factotum/fs.c
+++ b/sys/src/cmd/auth/factotum/fs.c
@@ -148,7 +148,7 @@ main(int argc, char **argv)
}
if(sflag){
- s = getnvramkey(kflag ? NVwrite : NVwriteonerr, nil);
+ s = getnvramkey(kflag ? NVwrite : NVwriteonerr);
if(s == nil)
fprint(2, "factotum warning: cannot read nvram: %r\n");
else if(ctlwrite(s, 0) < 0)
diff --git a/sys/src/cmd/auth/factotum/util.c b/sys/src/cmd/auth/factotum/util.c
index a8eab1db7..411935bc1 100644
--- a/sys/src/cmd/auth/factotum/util.c
+++ b/sys/src/cmd/auth/factotum/util.c
@@ -472,11 +472,10 @@ findproto(char *name)
}
char*
-getnvramkey(int flag, char **secstorepw)
+getnvramkey(int flag)
{
- char *s;
Nvrsafe safe;
- char spw[CONFIGLEN+1];
+ char *s;
int i;
memset(&safe, 0, sizeof safe);
@@ -488,15 +487,6 @@ getnvramkey(int flag, char **secstorepw)
return nil;
/*
- * we're using the config area to hold the secstore
- * password. if there's anything there, return it.
- */
- memmove(spw, safe.config, CONFIGLEN);
- spw[CONFIGLEN] = 0;
- if(spw[0] != 0 && secstorepw != nil)
- *secstorepw = estrdup(spw);
-
- /*
* only use nvram key if it is non-zero
*/
for(i = 0; i < DESKEYLEN; i++)
@@ -505,11 +495,11 @@ getnvramkey(int flag, char **secstorepw)
if(i == DESKEYLEN)
return nil;
- s = emalloc(512);
fmtinstall('H', encodefmt);
- sprint(s, "key proto=p9sk1 user=%q dom=%q !hex=%.*H !password=______",
+ s = smprint("key proto=p9sk1 user=%q dom=%q !hex=%.*H !password=______",
safe.authid, safe.authdom, DESKEYLEN, safe.machkey);
writehostowner(safe.authid);
+ memset(&safe, 0, sizeof safe);
return s;
}