add windows specific code back into method moved from auth.c to auth2-pubkeyfile.c

This commit is contained in:
Tess Gauthier 2022-10-12 11:55:55 -04:00
parent 5e2b081a49
commit 9b344f4466

View File

@ -448,6 +448,23 @@ auth_openfile(const char *file, struct passwd *pw, int strict_modes,
int fd;
FILE *f;
#ifdef WINDOWS
/* Windows POSIX adapter does not support fdopen() on open(file)*/
if ((f = fopen(file, "r")) == NULL) {
debug("Could not open %s '%s': %s", file_type, file,
strerror(errno));
return NULL;
}
// read permissions for non-admin/non-system accounts are allowed.
// Unix does safe_path_fd() which allows 022 file permissions i.e., allowing read for other users.
if (strict_modes && check_secure_file_permission(file, pw, 1) != 0) {
fclose(f);
logit("Authentication refused.");
auth_debug_add("Ignored %s", file_type);
return NULL;
}
#else /* !WINDOWS */
if ((fd = open(file, O_RDONLY|O_NONBLOCK)) == -1) {
if (errno != ENOENT) {
logit("Could not open user '%s' %s '%s': %s",
@ -481,6 +498,7 @@ auth_openfile(const char *file, struct passwd *pw, int strict_modes,
auth_debug_add("Ignored %s: %s", file_type, line);
return NULL;
}
#endif /* !WINDOWS */
return f;
}