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