aboutsummaryrefslogtreecommitdiffstats
path: root/mail/imap-uw/files/patch-ah
blob: 0de7fd9498fdf5422339ad7b1d16d42e049fa4ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
--- src/ipopd/ipop3d.c.orig Tue Dec 18 13:41:46 2001
+++ src/ipopd/ipop3d.c  Tue Nov 26 02:15:13 2002
@@ -28,6 +28,11 @@
 #include <time.h>
 #include "c-client.h"
 
+#ifdef DRAC_AUTH
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <stdlib.h>
+#endif /* DRAC_AUTH */
 
 #define CRLF PSOUT ("\015\012")    /* primary output terpri */
 
@@ -54,6 +59,13 @@
 #define STATUS "Status: %s%s\015\012"
 #define SLEN (sizeof (STATUS)-3)
 
+#ifdef DRAC_AUTH
+#define DRACTIMEOUT 10*60  /* check every 10 minutes */
+time_t lastdrac = 0;       /* time of last drac check */
+extern char *getenv ();
+#endif /* DRAC_AUTH */
+
+
 
 /* Global storage */
 
@@ -696,6 +708,46 @@
       }
       sprintf (tmp,"+OK Mailbox open, %lu messages\015\012",nmsgs);
       PSOUT (tmp);
+             {
+               #ifdef DRAC_AUTH
+                   if (time (0) > lastdrac + DRACTIMEOUT)
+                   {
+                       FILE *dracconf;
+                       char host[100];
+                       char *drachost;
+                       char *err;
+                       char *p;
+ 
+                       if ( (dracconf = fopen(ETC_DIR "/dracd.host", "r")) == NULL)
+                       {
+                         syslog (LOG_INFO, "dracd: error opening %s/dracd.host config file",ETC_DIR);
+                         exit(1);
+                       }
+ 
+                       fgets(host, 100, dracconf);
+                       p = strchr(host, '\n');
+                       if(p != NULL)
+                         *p = '\0';
+                       fclose(dracconf);
+ 
+                       if( drachost = (host) )
+                       {
+                           struct sockaddr_in sin;
+                           int sinlen = sizeof (struct sockaddr_in);
+                           char *client = getpeername (0,(struct sockaddr *) &sin,(void *) &sinlen) ?
+                             "UNKNOWN" : inet_ntoa (sin.sin_addr);
+ 
+                           lastdrac = time(0);
+ 
+                           if (dracauth(drachost, inet_addr(client), &err) != 0)
+                               syslog (LOG_INFO, err);
+                           else
+                               syslog (LOG_INFO, "dracd: authorized ip %s", client);
+                       }
+                   }
+               #endif /* DRAC_AUTH */
+             }
+
       return TRANSACTION;
     }
     else sayonara = "-ERR Can't get lock.  Mailbox in use\015\012";