|
Lines 28-33
Link Here
|
| 28 |
#include <sys/param.h> |
28 |
#include <sys/param.h> |
| 29 |
|
29 |
|
| 30 |
#include <errno.h> |
30 |
#include <errno.h> |
|
|
31 |
#include <fcntl.h> |
| 31 |
#include <libgen.h> |
32 |
#include <libgen.h> |
| 32 |
#include <login_cap.h> |
33 |
#include <login_cap.h> |
| 33 |
#include <paths.h> |
34 |
#include <paths.h> |
|
Lines 319-325
check_key_in_hostfiles(struct passwd *pw
Link Here
|
| 319 |
* |
320 |
* |
| 320 |
* Returns 0 on success and -1 on failure |
321 |
* Returns 0 on success and -1 on failure |
| 321 |
*/ |
322 |
*/ |
| 322 |
int |
323 |
static int |
| 323 |
secure_filename(FILE *f, const char *file, struct passwd *pw, |
324 |
secure_filename(FILE *f, const char *file, struct passwd *pw, |
| 324 |
char *err, size_t errlen) |
325 |
char *err, size_t errlen) |
| 325 |
{ |
326 |
{ |
|
Lines 377-382
secure_filename(FILE *f, const char *fil
Link Here
|
| 377 |
break; |
378 |
break; |
| 378 |
} |
379 |
} |
| 379 |
return 0; |
380 |
return 0; |
|
|
381 |
} |
| 382 |
|
| 383 |
FILE * |
| 384 |
auth_openkeyfile(const char *file, struct passwd *pw, int strict_modes) |
| 385 |
{ |
| 386 |
char line[1024]; |
| 387 |
struct stat st; |
| 388 |
int fd; |
| 389 |
FILE *f; |
| 390 |
|
| 391 |
/* |
| 392 |
* Open the file containing the authorized keys |
| 393 |
* Fail quietly if file does not exist |
| 394 |
*/ |
| 395 |
if ((fd = open(file, O_RDONLY|O_NONBLOCK)) == -1) |
| 396 |
return NULL; |
| 397 |
|
| 398 |
if (fstat(fd, &st) < 0) { |
| 399 |
close(fd); |
| 400 |
return NULL; |
| 401 |
} |
| 402 |
if (!S_ISREG(st.st_mode)) { |
| 403 |
logit("User %s authorized keys %s is not a regular file", |
| 404 |
pw->pw_name, file); |
| 405 |
close(fd); |
| 406 |
return NULL; |
| 407 |
} |
| 408 |
unset_nonblock(fd); |
| 409 |
if ((f = fdopen(fd, "r")) == NULL) { |
| 410 |
close(fd); |
| 411 |
return NULL; |
| 412 |
} |
| 413 |
if (options.strict_modes && |
| 414 |
secure_filename(f, file, pw, line, sizeof(line)) != 0) { |
| 415 |
fclose(f); |
| 416 |
logit("Authentication refused: %s", line); |
| 417 |
return NULL; |
| 418 |
} |
| 419 |
|
| 420 |
return f; |
| 380 |
} |
421 |
} |
| 381 |
|
422 |
|
| 382 |
struct passwd * |
423 |
struct passwd * |