aboutsummaryrefslogtreecommitdiff
path: root/mail/mdpop3d/files/patch-mdpop3d.c
blob: 8b96d69dc1e295647d1a2ee814a093d30bb54cfa (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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
--- mdpop3d.c.orig	Tue Feb 27 00:12:50 2001
+++ mdpop3d.c	Sun Jul  2 10:31:40 2006
@@ -67,8 +67,8 @@
 #ifdef USE_APOP
 # error APOP requires PAM
 #endif
-#include <shadow.h>
-#include <crypt.h>
+#include <pwd.h>
+#include <unistd.h>
 #endif
 
 static const char *rhost; /* = NULL; remote host/addr for logging */
@@ -258,7 +258,7 @@
 }
 
 static void info() {
-  putline(OK "maildir: %d message(s) %ld octet(s)", cmsg, msgsz);
+  putline(OK "maildir: %d message(s) %ld octet(s)", cmsg, (long int)msgsz);
 }
 
 static char *msgfn(int n) {
@@ -397,7 +397,8 @@
   int r;
   struct popdata d;
   const char *u = NULL;
-
+  const char **ptr_u = &u;
+  
   d.pass = pass;
   d.msg = NULL;
   convstruct.appdata_ptr = &d;
@@ -416,7 +417,7 @@
 	PAMOK(pam_set_item(pamh, PAM_RHOST, rhost)) &&
 	PAMOK(pam_authenticate(pamh, 0)) &&
 	PAMOK(pam_acct_mgmt(pamh, 0)) &&
-	PAMOK(pam_get_item(pamh, PAM_USER, (const void **)&u))) {
+	PAMOK(pam_get_item(pamh, PAM_USER, (const void **)ptr_u))) {
     pw = getpwnam(u && *u ? u : user); /* use username from pam if any */
     if (!maildir) /* try to get MAILDIR from PAM */
       maildir = pam_getenv(pamh, maildirenv);
@@ -450,22 +451,17 @@
   return NULL;
 
 #else /* !USE_PAM */
-
-  char *p;
-  if ((pw = getpwnam(user)) != NULL) {
-    p = pw->pw_passwd;
-    if (!p || !strcmp(p, "x")) {
-      struct spwd *sp = getspnam(user);
-      p = sp ? sp->sp_pwdp : NULL;
-      endspent();
-    }
-    if (p && strcmp(crypt(pass, p), p) == 0)
+    
+  pw = getpwnam(user);
+  endpwent();
+  if (pw != NULL)
+   {
+    if (pw->pw_passwd && strcmp(crypt(pass, pw->pw_passwd), pw->pw_passwd) == 0)
       return pw;
     syslog(LOG_INFO, "[%s] login incorrect for [%s]", rhost, user);
   }
   else
     syslog(LOG_INFO, "[%s] user unknown: [%s]", rhost, user);
-  sleep(3);
   putline(ERR "login incorrect");
   return NULL;
 
@@ -565,7 +561,7 @@
       *s = ':';
   }
   else
-    putmline("%s%d %ld", code, n+1, msgp[n]->size);
+    putmline("%s%d %ld", code, n+1, (long int)msgp[n]->size);
 }
 
 static void finalupdate() {
@@ -621,7 +617,7 @@
 
 static void finallog(const char *why) {
   syslog(LOG_INFO, "[%s][%s] %s (%d/%ld msgs/bytes left, %d/%ld deleted)",
-         rhost, user, why, cmsg, msgsz, o_nmsg - cmsg, o_msgsz - msgsz);
+         rhost, user, why, cmsg, (long int)msgsz, o_nmsg - cmsg, (long int)o_msgsz - (long int)msgsz);
 }
 
 static void die(const char *why) {
@@ -932,7 +928,7 @@
       else if (a)
 	extraarg(), --junk;
       else
-	putline(OK "%d %ld", cmsg, msgsz);
+	putline(OK "%d %ld", cmsg, (long int)msgsz);
     }
 
     else if (!strcmp(line, "top") || !strcmp(line, "retr")) {