Update libedit from NetBSD.
[dragonfly.git] / secure / usr.sbin / sshd / auth2.c.patch
1 $DragonFly: src/secure/usr.sbin/sshd/Attic/auth2.c.patch,v 1.1 2004/07/31 20:05:00 geekgod Exp $
2 --- auth2.c.orig        2004-07-23 14:26:51.000000000 +0200
3 +++ auth2.c     2004-07-23 14:20:00.000000000 +0200
4 @@ -25,6 +25,7 @@
5  #include "includes.h"
6  RCSID("$OpenBSD: auth2.c,v 1.104 2003/11/04 08:54:09 djm Exp $");
7  
8 +#include "canohost.h"
9  #include "ssh2.h"
10  #include "xmalloc.h"
11  #include "packet.h"
12 @@ -134,6 +135,13 @@
13         Authmethod *m = NULL;
14         char *user, *service, *method, *style = NULL;
15         int authenticated = 0;
16 +#ifdef HAVE_LOGIN_CAP
17 +       login_cap_t *lc;
18 +       const char *from_host, *from_ip;
19 +
20 +        from_host = get_canonical_hostname(options.use_dns);
21 +        from_ip = get_remote_ipaddr();
22 +#endif
23  
24         if (authctxt == NULL)
25                 fatal("input_userauth_request: no authctxt");
26 @@ -178,6 +186,27 @@
27                     "(%s,%s) -> (%s,%s)",
28                     authctxt->user, authctxt->service, user, service);
29         }
30 +
31 +#ifdef HAVE_LOGIN_CAP
32 +        if (authctxt->pw != NULL) {
33 +                lc = login_getpwclass(authctxt->pw);
34 +                if (lc == NULL)
35 +                        lc = login_getclassbyname(NULL, authctxt->pw);
36 +                if (!auth_hostok(lc, from_host, from_ip)) {
37 +                        logit("Denied connection for %.200s from %.200s [%.200s].",
38 +                            authctxt->pw->pw_name, from_host, from_ip);
39 +                        packet_disconnect("Sorry, you are not allowed to connect.");
40 +                }
41 +                if (!auth_timeok(lc, time(NULL))) {
42 +                        logit("LOGIN %.200s REFUSED (TIME) FROM %.200s",
43 +                            authctxt->pw->pw_name, from_host);
44 +                        packet_disconnect("Logins not available right now.");
45 +                }
46 +                login_close(lc);
47 +                lc = NULL;
48 +        }
49 +#endif  /* HAVE_LOGIN_CAP */
50 +
51         /* reset state */
52         auth2_challenge_stop(authctxt);
53