Mercurial > dropbear
diff svr-authpubkey.c @ 293:9d110777f345 contrib-blacklist
propagate from branch 'au.asn.ucc.matt.dropbear' (head 7ad1775ed65e75dbece27fe6b65bf1a234db386a)
to branch 'au.asn.ucc.matt.dropbear.contrib.blacklist' (head 1d86a4f0a401cc68c2670d821a2f6366c37af143)
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Fri, 10 Mar 2006 06:31:29 +0000 |
parents | bf64e666f99b |
children | 7282370416a0 |
line wrap: on
line diff
--- a/svr-authpubkey.c Tue Sep 06 04:57:14 2005 +0000 +++ b/svr-authpubkey.c Fri Mar 10 06:31:29 2006 +0000 @@ -311,6 +311,7 @@ /* 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 @@ /* 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; }