File: 12_multiple_mailbox.dpatch

package info (click to toggle)
solid-pop3d 0.15-14
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 868 kB
  • ctags: 443
  • sloc: ansic: 6,085; sh: 4,268; makefile: 519
file content (231 lines) | stat: -rw-r--r-- 7,148 bytes parent folder | download
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#!/bin/sh -e
## 12_multiple_mailbox.dpatch by Adam D. Barratt
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Add support for multiple mailboxes per user (bug#77711)

if [ $# -lt 1 ]; then
    echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
    exit 1
fi

[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch}"

case "$1" in
       -patch) patch $patch_opts -p1 < $0;;
       -unpatch) patch $patch_opts -p1 -R < $0;;
        *)
                echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
                exit 1;;
esac

exit 0

@DPATCH@
diff -urNad solid-pop3d.old/man/dot-spop3d.5 solid-pop3d/man/dot-spop3d.5
--- solid-pop3d.old/man/dot-spop3d.5	2004-11-21 16:36:49.000000000 +0100
+++ solid-pop3d/man/dot-spop3d.5	2004-11-21 19:39:42.000000000 +0100
@@ -26,30 +26,41 @@
 dot-spop3d \- user configuration data for The Solid POP3 Server.
 .SH DESCRIPTION
 .PP
-User can specify his maildrop (location and type) and APOP secret in ~/.spop3d
-configuration file. You must set right mode (0600 - -rw-------) 
-for ~/.spop3d!!!
-Maildrop specification consists of 3 parts, separated
-by white space character:
+A user can specify their maildrop location, type and associated APOP 
+secret in the configuration file ~/.spop3d.
+.PP
+The file must be set to mode 0600 (-rw-------) or the server will not 
+honour its content.
+.PP
+Maildrop specification consists of three parts, separated
+by white space characters:
 .TP
 \fIMailDrop\fP \fBpath type\fP
 .PP
-\fBPath\fP argument should be specified in the same format as \fI-n\fP 
-option in
+\fBPath\fP should be specified in the same format as the \fI-n\fP option in
 .BR spop3d (8).
-\fBType\fP argument should be \fImailbox\fP or \fImaildir\fP.
+\fBType\fP should be \fImailbox\fP or \fImaildir\fP.
 .PP
-APOP secret specification contains word \fIAPOPSecret\fP followed by encrypted 
-secret. You shouldn't change this secret manually. Use
-.BR pop_auth (1)
-to do this. See
+APOP secret specification consists of the word \fIAPOPSecret\fP followed 
+by an encrypted secret. You shouldn't change this secret manually. Use
 .BR pop_auth (1)
-manual for more details on secret encryption!!!
+to do this.
+.PP
+Both maildrop and APOP secret specifications may optionally be followed 
+by a mailbox name. This allows, for instance, user+boxA and user+boxB to 
+be used as login names to access different mailboxes.
+.PP
+The APOP secret associated with a particular maildrop should be followed 
+with the same mailbox name (or lack thereof). If no secret is specified 
+for a maildrop then the user's standard POP password should be used to 
+authenticate instead.
 .SH EXAMPLE
 .RS
 .nf
 MailDrop  	Mail/bugtraq	mailbox
 APOPSecret	0123456789
+MailDrop  	Mail/private	mailbox private
+APOPSecret	9876543210	private
 .fi
 .RE
 .SH FILES
diff -urNad solid-pop3d.old/src/main.c solid-pop3d/src/main.c
--- solid-pop3d.old/src/main.c	2004-11-21 19:39:42.000000000 +0100
+++ solid-pop3d/src/main.c	2004-11-21 19:39:42.000000000 +0100
@@ -197,6 +197,7 @@
 int connection_state;
 char username[MAXARGLN + 1];
 char password[MAXARGLN + 1];
+char usersuffix[MAXARGLN + 1];
 char buf[MAXCMDLN + 1];
 size_t count = 0;
 struct str_maildrop *maildrop;
@@ -1034,8 +1035,9 @@
 	socklen_t addrln;
 	struct rlimit corelimit = {0, 0};
 	struct passwd *spop3d, *userentry;
-	int tmp, tmp2;
+	int tmp, tmp2, tmp3;
 	gid_t tmpgid;
+	char *suffix;
 #ifdef APOP
 	int useapop;
 #endif
@@ -1064,6 +1066,7 @@
 	signal(SIGUSR2, sig_handler);
 	memset(username, 0, sizeof(username));
 	memset(password, 0, sizeof(password));
+	memset(usersuffix, 0, sizeof(usersuffix));
 #ifdef MAPPING
 	memset(mapusername, 0, sizeof(mapusername));
 	memset(origusername, 0, sizeof(origusername));
@@ -1231,6 +1234,13 @@
 					};
 			};
 #endif
+			suffix = strchr(username, '+');
+			if (suffix != NULL) {
+				tmp3 = suffix - username + 1;
+				strncpy (usersuffix, suffix + 1, sizeof(usersuffix));
+				username[tmp3-1] = 0;
+				tmp3 = 0;
+			};
 #ifdef MAPPING
 			mapusername[0] = 0;
 			if (domapping) {
@@ -1369,6 +1379,13 @@
 			close(tunnel[0]);
 			wait(NULL);
 			check_logpriority(logpriority);
+			suffix = strchr(username, '+');
+			if (suffix != NULL) {
+				tmp3 = suffix - username + 1;
+				strncpy (usersuffix, suffix + 1, sizeof(usersuffix));
+				username[tmp3-1] = 0;
+				tmp3 = 0;
+			};
 #ifdef MAPPING
 			if (domapping) {	
 				strcpy(origusername,username);
diff -urNad solid-pop3d.old/src/userconfig.c solid-pop3d/src/userconfig.c
--- solid-pop3d.old/src/userconfig.c	2004-11-21 16:47:12.000000000 +0100
+++ solid-pop3d/src/userconfig.c	2004-11-21 19:39:42.000000000 +0100
@@ -30,6 +30,7 @@
 
 extern char maildrop_name[];
 extern char maildrop_type[];
+extern char usersuffix[];
 #ifdef APOP
 extern char apop_secret[];
 #endif
@@ -121,12 +122,6 @@
 			buf[tmp - 1] = 0;
 		strtok(buf, " \t");
 		if (strcasecmp(buf, "maildrop") == 0) {
-			if (md_set == 1) {
-				memset(buf, 0, sizeof(buf));
-				close(fd);
-				pop_log(pop_priority, "user config: maildrop already set in user config file");
-				return;
-			};
 			if ((tmp2 = strtok(NULL, " \t")) == NULL) {
 				memset(buf, 0, sizeof(buf));
 				close(fd);
@@ -165,17 +160,24 @@
 				return;
 			};
 			strcpy(tmpmaildrop_type, tmp2);
-			md_set = 1;
+			if ((((tmp2 = strtok(NULL, " \t")) == NULL) && (usersuffix[0] == 0)) ||
+			 ((tmp2 != NULL) && (usersuffix[0] != 0) && (strcasecmp(tmp2,usersuffix) == 0))) {
+				if (md_set == 1) {
+					memset(buf, 0, sizeof(buf));
+					close(fd);
+					pop_log(pop_priority, "user config: maildrop already set in user config file");
+					return;
+				};
+
+				md_set = 1;
+				strcpy(maildrop_name, tmpmaildrop_name);
+				strcpy(maildrop_type, tmpmaildrop_type);
+			};
+
 			continue;
 		};
 #ifdef APOP
 		if (strcasecmp(buf, "APOPsecret") == 0) {
-			if (as_set == 1) {
-				memset(buf, 0, sizeof(buf));
-				close(fd);
-				pop_log(pop_priority, "user config: APOP secret already set in user config file");
-				return;
-			};
 			if ((tmp2 = strtok(NULL, " \t")) == NULL) {
 				memset(buf, 0, sizeof(buf));
 				close(fd);
@@ -215,7 +217,19 @@
 					tmpapop_secret[tmp3] |= (tmp2[(tmp3 * 2) + 1] - 'a' + 10);
 				tmpapop_secret[tmp3] ^= 0xff;
 			};
-			as_set = 1;
+			if ((((tmp2 = strtok(NULL, " \t")) == NULL) && (usersuffix[0] == 0)) 
+			 || ((tmp2 != NULL) && (usersuffix[0] != 0) && (strcasecmp(tmp2,usersuffix) == 0))) {
+				if (as_set == 1) {
+					memset(buf, 0, sizeof(buf));
+					close(fd);
+					pop_log(pop_priority, "user config: APOP secret already set in user config file");
+					return;
+				};
+
+				strcpy(apop_secret, tmpapop_secret);
+				as_set = 1;
+			};
+
 			continue;
 		};
 		memset(tmpapop_secret, 0, sizeof(tmpapop_secret));
@@ -227,12 +241,8 @@
 	};
 	close(fd);
 	if (md_set == 1) {
-		strcpy(maildrop_name, tmpmaildrop_name);
-		strcpy(maildrop_type, tmpmaildrop_type);
 	};
 #ifdef APOP
-	if (as_set == 1)
-		strcpy(apop_secret, tmpapop_secret);
 	memset(tmpapop_secret, 0, sizeof(tmpapop_secret));
 #endif
 	return;