Mercurial > dropbear
comparison 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 |
comparison
equal
deleted
inserted
replaced
247:c07de41b53d7 | 293:9d110777f345 |
---|---|
309 /* Checks that a file is owned by the user or root, and isn't writable by | 309 /* Checks that a file is owned by the user or root, and isn't writable by |
310 * group or other */ | 310 * group or other */ |
311 /* returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ | 311 /* returns DROPBEAR_SUCCESS or DROPBEAR_FAILURE */ |
312 static int checkfileperm(char * filename) { | 312 static int checkfileperm(char * filename) { |
313 struct stat filestat; | 313 struct stat filestat; |
314 int badperm = 0; | |
314 | 315 |
315 TRACE(("enter checkfileperm(%s)", filename)) | 316 TRACE(("enter checkfileperm(%s)", filename)) |
316 | 317 |
317 if (stat(filename, &filestat) != 0) { | 318 if (stat(filename, &filestat) != 0) { |
318 TRACE(("leave checkfileperm: stat() != 0")) | 319 TRACE(("leave checkfileperm: stat() != 0")) |
319 return DROPBEAR_FAILURE; | 320 return DROPBEAR_FAILURE; |
320 } | 321 } |
321 /* check ownership - user or root only*/ | 322 /* check ownership - user or root only*/ |
322 if (filestat.st_uid != ses.authstate.pw->pw_uid | 323 if (filestat.st_uid != ses.authstate.pw->pw_uid |
323 && filestat.st_uid != 0) { | 324 && filestat.st_uid != 0) { |
324 TRACE(("leave checkfileperm: wrong ownership")) | 325 badperm = 1; |
325 return DROPBEAR_FAILURE; | 326 TRACE(("wrong ownership")) |
326 } | 327 } |
327 /* check permissions - don't want group or others +w */ | 328 /* check permissions - don't want group or others +w */ |
328 if (filestat.st_mode & (S_IWGRP | S_IWOTH)) { | 329 if (filestat.st_mode & (S_IWGRP | S_IWOTH)) { |
329 TRACE(("leave checkfileperm: wrong perms")) | 330 badperm = 1; |
331 TRACE(("wrong perms")) | |
332 } | |
333 if (badperm) { | |
334 if (!ses.authstate.perm_warn) { | |
335 ses.authstate.perm_warn = 1; | |
336 dropbear_log(LOG_INFO, "%s must be owned by user or root, and not writable by others", filename); | |
337 } | |
338 TRACE(("leave checkfileperm: failure perms/owner")) | |
330 return DROPBEAR_FAILURE; | 339 return DROPBEAR_FAILURE; |
331 } | 340 } |
341 | |
332 TRACE(("leave checkfileperm: success")) | 342 TRACE(("leave checkfileperm: success")) |
333 return DROPBEAR_SUCCESS; | 343 return DROPBEAR_SUCCESS; |
334 } | 344 } |
335 | 345 |
336 | 346 |