summaryrefslogtreecommitdiff
blob: 3cb9b9a1fae09f9cfc4a070ec087202078e75189 (plain)
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
diff -aur web-cyradm-0.5.4-1/change_password.php web-cyradm/change_password.php
--- change_password.php	2004-03-21 11:02:01.000000000 -0800
+++ change_password.php	2004-11-09 14:15:33.000000000 -0800
@@ -13,20 +13,31 @@
 
 	if ($authorized AND $new_password == $confirm_password){
 
-		$query = "select * from virtual where alias='$alias'";
-		$handle = DB::connect($DB['DSN'], true);
-		if (DB::isError($handle)){
-			die (_("Database error"));
-		}
+		//With ENABLE_FQUN there are no usernames in virtual
+		if(! $ENABLE_FQUN ) {
+			$query = "select * from virtual where alias='$alias'";
+			$handle = DB::connect($DB['DSN'], true);
+			if (DB::isError($handle)){
+				die (_("Database error"));
+			}
 
-		$result = $handle->query($query);
-		$row = $result->fetchRow(DB_FETCHMODE_ASSOC, 0);
-		$alias = $row['alias'];
-		$dest = $row['dest'];
-		$username = $row['username'];
+			$result = $handle->query($query);
+			$row = $result->fetchRow(DB_FETCHMODE_ASSOC, 0);
+			$alias = $row['alias'];
+			$dest = $row['dest'];
+			$username = $row['username'];
+		}
 		if (! empty($confirmed) && ("true" == $confirmed)){
 			if ($new_password == $confirm_password && $new_password != ""){
-				$query = "select * from accountuser where username='$dest'";
+				//With ENABLE_FQUN there is no dest, only username
+				if( $ENABLE_FQUN )
+				{
+					$query = "select * from accountuser where username='$username'";
+				}
+				else
+				{
+					$query = "select * from accountuser where username='$dest'";
+				}
 				$handle = DB::connect($DB['DSN'], true);
 				if (DB::isError($handle)) {
 					die (_("Database error"));
@@ -57,6 +68,11 @@
 					include WC_BASE . "/browseaccounts.php";
 				} elseif ($PASSWORD_CHANGE_METHOD=="poppassd"){
 					include WC_BASE . '/lib/poppassd.php';
+					if( $ENABLE_FQUN )
+					{
+						//username is the username
+						$dest = $username;
+					}
 					$daemon = new poppassd;
 					if ($daemon->change_password($dest, $password, $new_password)) {
 						print  "<em><big>"._("Password changed")."</big></em><p><p>";
@@ -68,7 +84,7 @@
 					print "<b>"._("New passwords are not equal. Password not changed")."</b>";
 				}
 			}
-		}
+		} // end confirmed
 		if (empty($confirmed) || ($confirmed != "true")){
 //			$test = ereg ("",$alias,$result_array);
 
@@ -80,7 +96,9 @@
 			<h3>
 				<?php print _("Change password for account");?>
 				<span style="color: red;">
-					<?php echo $dest;?>
+					<?
+					if ($ENABLE_FQUN) {echo $username;} else {echo $dest;}
+					?>
 				</span>
 			</h3>
 
diff -aur web-cyradm-0.5.4-1/config/conf.php.dist web-cyradm/config/conf.php.dist
--- config/conf.php	2004-04-04 10:17:02.000000000 -0700
+++ config/conf.php	2004-11-09 20:07:09.000000000 -0800
@@ -72,6 +72,24 @@
 ####
 $DOMAIN_AS_PREFIX = 0;
 
+# if you want to use cyrus 2.2.x's virtual domains support with fully
+# qualified usernames in the mailbox name you can set this option
+# ENABLE_FQUN to '1'.
+# NOTE: you must also set $CRYPT = "plain" unless you patch your sasl library
+# using the patch from http://frost.ath.cx/software/cyrus-sasl-patches/
+# with sasl auxprop's sql/mysql plugin in which case you can use "crypt".
+# In your sasl smtpd.conf and your imapd.conf make your sql_statement and 
+# sasl_sql_statement look like this:
+# select password from accountuser where username='%u@%r' or (username='%u' and domain_name='')
+# This will allow you to use a user with a non fully qualified username for
+# the admin user.
+# and add this line to your imapd.conf.
+#### imapd.conf: ####
+# virtdomains: yes
+
+####
+$ENABLE_FQUN = 0;
+
 # At the moment, web-cyradm supports two methods of password change:
 # - through sql
 # - poppassd
@@ -104,4 +122,3 @@
 
 # Define reserved Emailadresses (Separated by comma):
 $RESERVED="postmaster,root";
-
diff -aur web-cyradm-0.5.4-1/newaccount.php web-cyradm/newaccount.php
--- newaccount.php	2003-08-14 11:58:12.000000000 -0700
+++ newaccount.php	2004-11-09 16:10:13.000000000 -0800
@@ -99,7 +99,7 @@
 
 					<table>
 						<?php
-						if (!$DOMAIN_AS_PREFIX){
+						if (!($DOMAIN_AS_PREFIX || $ENABLE_FQUN)){
 							?>
 							<tr>
 								<td>
@@ -129,7 +129,7 @@
 								</td>
 								<!-- END Andreas Kreisl : freenames -->
 							</tr>
-							<?php
+						<?php
 						} // End of if (!$DOMAIN_AS_PREFIX)
 
 						$_fields = array(
@@ -193,17 +193,28 @@
 			} else {
 				$seperator	= '.';
 			}
+			if ($ENABLE_FQUN){
+				$username       = $email;
+				$username       = $username . "@" . $domain;
+			}	
 		    // check to see if there's an account with the same username
 		    $query3="select * from accountuser where username='$username'";
 		    $result3=$handle->query($query3);
 		    $cnt3=$result3->numRows();
-		    if ($cnt3!=0) {
+		if ($cnt3!=0) {
 			print "<h3>" .
 			       _("Sorry, the username already exists") .
 			       "</h3><br>";
 			include WC_BASE . "/browseaccounts.php";
 		} else {
-			if ($password == $confirm_password){
+			// No Empty Password
+			if ( empty($password) && empty($confirm_password) )
+			{
+				print "<h3>" .
+					_("Sorry, the password must not be empty") .
+					"</h3><br>";
+					include WC_BASE . "/browseaccounts.php";
+			} elseif ($password == $confirm_password){
 				$pwd = new password;
 			        $password = $pwd->encrypt($password, $CRYPT);
 			    	$query3="INSERT INTO accountuser (username, password, prefix, domain_name) VALUES ('" . $username . "','" . $password . "','" . $prefix . "','" . $domain . "')";
@@ -217,10 +228,15 @@
 
 				$result=$handle->query($query3);
 
-				$query4 = "INSERT INTO virtual (alias, dest, username, status) values ( '" . $email . "@" . $domain . "' , '$username' , '$username' , '1')";
-
-				$result2 = $handle->query($query4);
-
+				// No need for virtual with the new
+				// virtual hosting capabilities in cyrus
+				if (!$ENABLE_FQUN){
+					$query4 = "INSERT INTO virtual (alias, dest, username, status) values ( '" . $email . "@" . $domain . "' , '$username' , '$username' , '1')";
+
+					$result2 = $handle->query($query4);
+				} else {
+					$result2=$result;
+				}
 				if ($result and $result2){
 					?>
 					<h3>
diff -aur web-cyradm-0.5.4-1/search.php web-cyradm/search.php
--- search.php	2003-11-30 04:13:43.000000000 -0800
+++ search.php	2004-11-09 14:17:06.000000000 -0800
@@ -31,7 +31,15 @@
 }
 
 $query="SELECT * FROM domain a where domain_name LIKE '%$searchstring%' and $allowed_domains') ORDER BY domain_name";
-$query2="SELECT distinct a.username, a.domain_name FROM virtual as v, accountuser as a where ((v.username LIKE '%$searchstring%') or (v.alias LIKE '%$searchstring%')) and (v.username=a.username) and $allowed_domains') ORDER BY username";
+
+// Query Usernames
+if( $ENABLE_FQUN ) {
+	// If ENABLE_FQUN there is no email in the virtual table
+	// accountuser.username == email
+	$query2="SELECT distinct a.username, a.domain_name FROM accountuser as a where a.username LIKE '%$searchstring%' and $allowed_domains' ) ORDER BY username";
+} else {
+	$query2="SELECT distinct a.username, a.domain_name FROM virtual as v, accountuser as a where ((v.username LIKE '%$searchstring%') or (v.alias LIKE '%$searchstring%')) and (v.username=a.username) and $allowed_domains') ORDER BY username";
+}
 $query3="SELECT DISTINCT alias, username FROM virtual WHERE (((dest LIKE '%$searchstring%') OR (alias LIKE '%$searchstring%')) AND (dest <> username) AND (username<>'') ) AND $allowed_domains3') ORDER BY username";	
 $result=$handle->query($query);
 $result2=$handle->query($query2);
@@ -111,7 +119,15 @@
 if (!isset($row_pos)){
 	$row_pos=0;
 	}
-        $query="SELECT distinct a.username, a.domain_name FROM virtual as v, accountuser as a where ((v.username LIKE '%$searchstring%') or (v.alias LIKE '%$searchstring%')) and (v.username=a.username) and $allowed_domains') ORDER BY username";
+	
+	// Query Usernames
+	if( $ENABLE_FQUN ) {
+        	// If ENABLE_FQUN there is no email in the virtual table
+	        // accountuser.username == email
+        	$query="SELECT distinct a.username, a.domain_name FROM accountuser as a where a.username LIKE '%$searchstring%' and $allowed_domains' ) ORDER BY username";
+	} else {
+        	$query="SELECT distinct a.username, a.domain_name FROM virtual as v, accountuser as a where ((v.username LIKE '%$searchstring%') or (v.alias LIKE '%$searchstring%')) and (v.username=a.username) and $allowed_domains') ORDER BY username";
+	}
 	$result=$handle->limitQuery($query,$row_pos,10);
 	$cnt=$result->numRows($result);