1 #include <u.h> 2 #include <libc.h> 3 #include <auth.h> 4 #include "authsrv.h" 5 6 static int 7 getkey(char *authkey) 8 { 9 int fd; 10 int n; 11 12 fd = open("/dev/key", OREAD); 13 if(fd < 0) 14 return -1; 15 n = read(fd, authkey, DESKEYLEN); 16 close(fd); 17 return n != DESKEYLEN ? -1 : 0; 18 } 19 20 int 21 getauthkey(char *authkey) 22 { 23 if(getkey(authkey) == 0) 24 return 1; 25 print("can't read /dev/key, please enter machine key\n"); 26 getpass(authkey, 0); 27 return 1; 28 } 29