100-pubkey_path.patch 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. Index: dropbear-0.50/svr-authpubkey.c
  2. ===================================================================
  3. --- dropbear-0.50.orig/svr-authpubkey.c 2007-08-10 23:47:48.000000000 +0200
  4. +++ dropbear-0.50/svr-authpubkey.c 2007-08-10 23:47:48.000000000 +0200
  5. @@ -176,6 +176,8 @@
  6. goto out;
  7. }
  8. + if (ses.authstate.pw->pw_uid != 0) {
  9. +
  10. /* we don't need to check pw and pw_dir for validity, since
  11. * its been done in checkpubkeyperms. */
  12. len = strlen(ses.authstate.pw->pw_dir);
  13. @@ -187,6 +189,9 @@
  14. /* open the file */
  15. authfile = fopen(filename, "r");
  16. + } else {
  17. + authfile = fopen("/etc/dropbear/authorized_keys","r");
  18. + }
  19. if (authfile == NULL) {
  20. goto out;
  21. }
  22. @@ -274,6 +279,8 @@
  23. goto out;
  24. }
  25. + if (ses.authstate.pw->pw_uid != 0) {
  26. +
  27. /* allocate max required pathname storage,
  28. * = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
  29. filename = m_malloc(len + 22);
  30. @@ -295,6 +302,14 @@
  31. if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
  32. goto out;
  33. }
  34. + } else {
  35. + if (checkfileperm("/etc/dropbear") != DROPBEAR_SUCCESS) {
  36. + goto out;
  37. + }
  38. + if (checkfileperm("/etc/dropbear/authorized_keys") != DROPBEAR_SUCCESS) {
  39. + goto out;
  40. + }
  41. + }
  42. /* file looks ok, return success */
  43. ret = DROPBEAR_SUCCESS;