diff options
author | Ben Lindstrom <mouring@eviladmin.org> | 2001-06-25 04:30:16 +0000 |
---|---|---|
committer | Ben Lindstrom <mouring@eviladmin.org> | 2001-06-25 04:30:16 +0000 |
commit | 83647ce474c37c8533e2aaf02f7366fbc0602ad9 (patch) | |
tree | 940fb5b1b82e7714a67188b8758d05674f935697 /auth.c | |
parent | 7d5ed3a07b0f00e961d636514ac42d4f1bc57a3e (diff) |
- markus@cvs.openbsd.org 2001/06/23 00:20:57
[auth2.c auth.c auth.h auth-rh-rsa.c]
*known_hosts2 is obsolete for hostbased authentication and
only used for backward compat. merge ssh1/2 hostkey check
and move it to auth.c
Diffstat (limited to 'auth.c')
-rw-r--r-- | auth.c | 43 |
1 files changed, 42 insertions, 1 deletions
@@ -23,7 +23,7 @@ | |||
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "includes.h" | 25 | #include "includes.h" |
26 | RCSID("$OpenBSD: auth.c,v 1.23 2001/05/24 11:12:42 markus Exp $"); | 26 | RCSID("$OpenBSD: auth.c,v 1.24 2001/06/23 00:20:57 markus Exp $"); |
27 | 27 | ||
28 | #ifdef HAVE_LOGIN_H | 28 | #ifdef HAVE_LOGIN_H |
29 | #include <login.h> | 29 | #include <login.h> |
@@ -46,6 +46,8 @@ RCSID("$OpenBSD: auth.c,v 1.23 2001/05/24 11:12:42 markus Exp $"); | |||
46 | #include "canohost.h" | 46 | #include "canohost.h" |
47 | #include "buffer.h" | 47 | #include "buffer.h" |
48 | #include "bufaux.h" | 48 | #include "bufaux.h" |
49 | #include "uidswap.h" | ||
50 | #include "tildexpand.h" | ||
49 | 51 | ||
50 | /* import */ | 52 | /* import */ |
51 | extern ServerOptions options; | 53 | extern ServerOptions options; |
@@ -297,6 +299,45 @@ authorized_keys_file2(struct passwd *pw) | |||
297 | return expand_filename(options.authorized_keys_file2, pw); | 299 | return expand_filename(options.authorized_keys_file2, pw); |
298 | } | 300 | } |
299 | 301 | ||
302 | /* return ok if key exists in sysfile or userfile */ | ||
303 | HostStatus | ||
304 | check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host, | ||
305 | const char *sysfile, const char *userfile) | ||
306 | { | ||
307 | Key *found; | ||
308 | char *user_hostfile; | ||
309 | struct stat st; | ||
310 | int host_status; | ||
311 | |||
312 | /* Check if we know the host and its host key. */ | ||
313 | found = key_new(key->type); | ||
314 | host_status = check_host_in_hostfile(sysfile, host, key, found, NULL); | ||
315 | |||
316 | if (host_status != HOST_OK && userfile != NULL) { | ||
317 | user_hostfile = tilde_expand_filename(userfile, pw->pw_uid); | ||
318 | if (options.strict_modes && | ||
319 | (stat(user_hostfile, &st) == 0) && | ||
320 | ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || | ||
321 | (st.st_mode & 022) != 0)) { | ||
322 | log("Authentication refused for %.100s: " | ||
323 | "bad owner or modes for %.200s", | ||
324 | pw->pw_name, user_hostfile); | ||
325 | } else { | ||
326 | temporarily_use_uid(pw); | ||
327 | host_status = check_host_in_hostfile(user_hostfile, | ||
328 | host, key, found, NULL); | ||
329 | restore_uid(); | ||
330 | } | ||
331 | xfree(user_hostfile); | ||
332 | } | ||
333 | key_free(found); | ||
334 | |||
335 | debug2("check_key_in_hostfiles: key %s for %s", host_status == HOST_OK ? | ||
336 | "ok" : "not found", host); | ||
337 | return host_status; | ||
338 | } | ||
339 | |||
340 | |||
300 | /* | 341 | /* |
301 | * Check a given file for security. This is defined as all components | 342 | * Check a given file for security. This is defined as all components |
302 | * of the path to the file must either be owned by either the owner of | 343 | * of the path to the file must either be owned by either the owner of |