getauthkey.c 451 B

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