summaryrefslogtreecommitdiffhomepage
path: root/svr-authpubkey.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2005-09-20 08:59:46 +0000
committerMatt Johnston <matt@ucc.asn.au>2005-09-20 08:59:46 +0000
commitcb2cb15916497f790c1d420ccff858446772780c (patch)
treecadf02161806fd86215414d50a72f098c9552c1e /svr-authpubkey.c
parent351053168313c6bd5f9bb10b766d851b6a4b2f73 (diff)
Log when pubkey auth fails because of bad pubkey perms/ownership
--HG-- extra : convert_revision : 43e1a0c8365776577acd814d708027fcddcb02ef
Diffstat (limited to 'svr-authpubkey.c')
-rw-r--r--svr-authpubkey.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/svr-authpubkey.c b/svr-authpubkey.c
index a5520e5..3942bd5 100644
--- a/svr-authpubkey.c
+++ b/svr-authpubkey.c
@@ -311,6 +311,7 @@ out:
/* returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */
static int checkfileperm(char * filename) {
struct stat filestat;
+ int badperm = 0;
TRACE(("enter checkfileperm(%s)", filename))
@@ -321,14 +322,23 @@ static int checkfileperm(char * filename) {
/* check ownership - user or root only*/
if (filestat.st_uid != ses.authstate.pw->pw_uid
&& filestat.st_uid != 0) {
- TRACE(("leave checkfileperm: wrong ownership"))
- return DROPBEAR_FAILURE;
+ badperm = 1;
+ TRACE(("wrong ownership"))
}
/* check permissions - don't want group or others +w */
if (filestat.st_mode & (S_IWGRP | S_IWOTH)) {
- TRACE(("leave checkfileperm: wrong perms"))
+ badperm = 1;
+ TRACE(("wrong perms"))
+ }
+ if (badperm) {
+ if (!ses.authstate.perm_warn) {
+ ses.authstate.perm_warn = 1;
+ dropbear_log(LOG_INFO, "%s must be owned by user or root, and not writable by others", filename);
+ }
+ TRACE(("leave checkfileperm: failure perms/owner"))
return DROPBEAR_FAILURE;
}
+
TRACE(("leave checkfileperm: success"))
return DROPBEAR_SUCCESS;
}