1 #include <u.h> 2 #include <libc.h> 3 #include <authsrv.h> 4 #include "authcmdlib.h" 5 6 static int 7 getkey(char *authkey) 8 { 9 Nvrsafe safe; 10 11 if(readnvram(&safe, 0) < 0) 12 return -1; 13 memmove(authkey, safe.machkey, DESKEYLEN); 14 memset(&safe, 0, sizeof safe); 15 return 0; 16 } 17 18 int 19 getauthkey(char *authkey) 20 { 21 if(getkey(authkey) == 0) 22 return 1; 23 print("can't read /dev/key, please enter machine key\n"); 24 getpass(authkey, nil, 0, 1); 25 return 1; 26 } 27