1 diff -ur dropbear-0.52.orig/svr-authpubkey.c dropbear-0.52/svr-authpubkey.c
2 --- dropbear-0.52.orig/svr-authpubkey.c 2009-04-08 00:32:16.000000000 +0200
3 +++ dropbear-0.52/svr-authpubkey.c 2009-04-08 00:44:11.000000000 +0200
8 - /* we don't need to check pw and pw_dir for validity, since
9 - * its been done in checkpubkeyperms. */
10 - len = strlen(ses.authstate.pw_dir);
11 - /* allocate max required pathname storage,
12 - * = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
13 - filename = m_malloc(len + 22);
14 - snprintf(filename, len + 22, "%s/.ssh/authorized_keys",
15 - ses.authstate.pw_dir);
18 - authfile = fopen(filename, "r");
19 + if (ses.authstate.pw_uid != 0) {
20 + /* we don't need to check pw and pw_dir for validity, since
21 + * its been done in checkpubkeyperms. */
22 + len = strlen(ses.authstate.pw_dir);
23 + /* allocate max required pathname storage,
24 + * = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
25 + filename = m_malloc(len + 22);
26 + snprintf(filename, len + 22, "%s/.ssh/authorized_keys",
27 + ses.authstate.pw_dir);
30 + authfile = fopen(filename, "r");
32 + authfile = fopen("/etc/dropbear/authorized_keys","r");
34 if (authfile == NULL) {
41 - /* allocate max required pathname storage,
42 - * = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
43 - filename = m_malloc(len + 22);
44 - strncpy(filename, ses.authstate.pw_dir, len+1);
47 - if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
52 - strncat(filename, "/.ssh", 5); /* strlen("/.ssh") == 5 */
53 - if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
57 - /* now check ~/.ssh/authorized_keys */
58 - strncat(filename, "/authorized_keys", 16);
59 - if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
61 + if (ses.authstate.pw_uid == 0) {
62 + if (checkfileperm("/etc/dropbear") != DROPBEAR_SUCCESS) {
65 + if (checkfileperm("/etc/dropbear/authorized_keys") != DROPBEAR_SUCCESS) {
69 + /* allocate max required pathname storage,
70 + * = path + "/.ssh/authorized_keys" + '\0' = pathlen + 22 */
71 + filename = m_malloc(len + 22);
72 + strncpy(filename, ses.authstate.pw_dir, len+1);
75 + if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
80 + strncat(filename, "/.ssh", 5); /* strlen("/.ssh") == 5 */
81 + if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
85 + /* now check ~/.ssh/authorized_keys */
86 + strncat(filename, "/authorized_keys", 16);
87 + if (checkfileperm(filename) != DROPBEAR_SUCCESS) {
92 /* file looks ok, return success */