Update build infrastructure for openssh-4.4p1
[dragonfly.git] / secure / usr.sbin / sshd / auth2.c.patch
1 $DragonFly: src/secure/usr.sbin/sshd/Attic/auth2.c.patch,v 1.2 2006/09/28 18:42:50 corecode Exp $
2 --- auth2.c     2006-08-05 04:39:39.000000000 +0200
3 +++ auth2.c     2006-09-28 19:53:14.000000000 +0200
4 @@ -32,6 +32,7 @@
5  #include <string.h>
6  
7  #include "xmalloc.h"
8 +#include "canohost.h"
9  #include "ssh2.h"
10  #include "packet.h"
11  #include "log.h"
12 @@ -147,6 +148,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 @@ -190,6 +198,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