printnetkey.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. #include <u.h>
  10. #include <libc.h>
  11. #include <authsrv.h>
  12. #include <bio.h>
  13. #include "authcmdlib.h"
  14. void install(char*, char*, int);
  15. void usage(void);
  16. void
  17. main(int argc, char *argv[])
  18. {
  19. char *key;
  20. char *u;
  21. char keybuf[DESKEYLEN];
  22. argv0 = "printnetkey";
  23. fmtinstall('K', keyfmt);
  24. ARGBEGIN{
  25. default:
  26. usage();
  27. }ARGEND
  28. if(argc != 1)
  29. usage();
  30. u = argv[0];
  31. fmtinstall('K', keyfmt);
  32. if(memchr(u, '\0', ANAMELEN) == 0)
  33. error("bad user name");
  34. key = findkey(NETKEYDB, u, keybuf);
  35. if(!key)
  36. error("%s has no netkey\n", u);
  37. print("user %s: net key %K\n", u, key);
  38. exits(0);
  39. }
  40. void
  41. usage(void)
  42. {
  43. fprint(2, "usage: printnetkey user\n");
  44. exits("usage");
  45. }