~ubuntu-branches/ubuntu/edgy/bugzilla/edgy

« back to all changes in this revision

Viewing changes to patch-250638-2.diff

  • Committer: Bazaar Package Importer
  • Author(s): Alexis Sukrieh
  • Date: 2005-10-03 16:51:01 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20051003165101-38n0y5qofd68vole
Tags: 2.18.4-1
* New upstream minor release
  + Fixed a security issue: It was possible to bypass the "user
    visibility groups" restrictions if user-matching was turned on
    in "substring" mode.
  + Fixed a security issue: config.cgi exposed information to users who
    weren't logged in, even when "requirelogin" was turned on in Bugzilla.
  (closes: #331206)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
--- debian/bugzilla.templates   2004-11-29 15:44:23.000000000 +0100
2
 
+++ debian/bugzilla.templates   2004-11-30 17:49:37.000000000 +0100
3
 
@@ -20,13 +20,16 @@
4
 
 Template: bugzilla/mysql_available
5
 
 Type: boolean
6
 
 Default: true
7
 
-_Description: Do you have a MySQL server somewhere on your network?
8
 
+_Description: Do you want to continue?
9
 
+ You need a mysql server installed on your local machine, or
10
 
+ accessable on your network.
11
 
+ .
12
 
  The Bugzilla package does not declare a mandatory package dependency on
13
 
  the MySQL server package, since Bugzilla can use a remote MySQL database.
14
 
  To complete Bugzilla configuration, access to a MySQL server is required.
15
 
  .
16
 
- Answering no to this question will make Bugzilla configuration fail and
17
 
- let you install a MySQL server.
18
 
+ Answering no to this question will stop the Bugzilla configuration.
19
 
+ .
20
 
 
21
 
 Template: bugzilla/mysql_need_root
22
 
 Type: boolean
23
 
@@ -110,3 +113,31 @@
24
 
 Template: bugzilla/bugzilla_admin_pwd
25
 
 Type: password
26
 
 _Description: Enter the password for the Bugzilla administrator account.
27
 
+
28
 
+Template: bugzilla/bugzilla_installation_way_single
29
 
+Type: select
30
 
+Choices: Manual, Later
31
 
+Default: Automatic
32
 
+_Description: Choose the way you want to configure bugzilla:
33
 
+ As you don't have a MySQL server installed locally, I can just provide
34
 
+ the automatic installation.
35
 
+ .
36
 
+ Manual installation will let you enter all the preferences for the MySQL
37
 
+ server you want to use (either present locally or on the network).
38
 
+ .
39
 
+ Later means that you don't have yet a MySQL server up for bugzilla, 
40
 
+ choosing this will stop the installation.
41
 
+
42
 
+Template: bugzilla/bugzilla_installation_way
43
 
+Type: select
44
 
+Choices: Automatic, Manual, Later
45
 
+Default: Automatic
46
 
+_Description: Choose the way you want to configure bugzilla:
47
 
+ Automatic installation will assume you have a locally installed MySQL 
48
 
+ server and will try to use as many default values as possible.
49
 
+ .
50
 
+ Manual installation will let you enter all the preferences for the MySQL
51
 
+ server you want to use (either present locally or on the network).
52
 
+ .
53
 
+ Later means that you don't have yet a MySQL server up for bugzilla, 
54
 
+ choosing this will stop the installation.
55
 
--- debian/bugzilla.config      2004-11-29 15:44:23.000000000 +0100
56
 
+++ debian/bugzilla.config      2004-11-30 18:09:57.000000000 +0100
57
 
@@ -13,19 +13,39 @@
58
 
 while [ "$STATE" != 0 -a "$STATE" != 90 ]; do
59
 
        case "$STATE" in
60
 
        10)
61
 
-               #give chance to make install fail if there no
62
 
-               #mysql server available
63
 
-               db_input high bugzilla/mysql_available || true
64
 
-               if db_go; then 
65
 
-                       db_get bugzilla/mysql_available || true
66
 
-                       if [ "$RET" = "true" ]; then
67
 
+               # First ask user which installation way he wants
68
 
+               # if the mysql default file doesn't exists, only Manual install is available.
69
 
+               if [ ! -f /etc/mysql/debian.cnf ]; then
70
 
+                       db_input high bugzilla/bugzilla_installation_way_single || true
71
 
+                       db_go || true
72
 
+                       db_get bugzilla/bugzilla_installation_way_single || true
73
 
+               else 
74
 
+                       db_input high bugzilla/bugzilla_installation_way || true
75
 
+                       db_go || true
76
 
+                       db_get bugzilla/bugzilla_installation_way || true
77
 
+               fi
78
 
+               case "$RET" in
79
 
+                       "Automatic")
80
 
+                               # as bugzilla/bugzilla_installation_way  
81
 
+                               # is set to Automatic, postinst will try 
82
 
+                               # to do the stuff, but first we have to ask
83
 
+                               # for bugziall admin name and so on :
84
 
+                               STATE=65
85
 
+                               
86
 
+                       ;;
87
 
+                       
88
 
+                       "Manual")
89
 
+                               # Let's do all what we did before.
90
 
                                STATE=20
91
 
-                       else
92
 
-                               exit 1
93
 
-                       fi
94
 
-               else
95
 
-                       STATE=10
96
 
-               fi
97
 
+                       ;;
98
 
+                       
99
 
+                       "Later")
100
 
+                               # Here we just stop the process and postinst won't do 
101
 
+                               # anything. User will have to run dpkg-reconfigure
102
 
+                               # when he is ready.
103
 
+                               exit 0
104
 
+                       ;;
105
 
+               esac
106
 
        ;;
107
 
 
108
 
        20)
109
 
@@ -154,6 +174,11 @@
110
 
                else
111
 
                        db_set bugzilla/pwd_check ""
112
 
                fi
113
 
+               STATE=65
114
 
+       ;;
115
 
+       # this is a split of the STATE #60.
116
 
+       # In this way, Automatic jump to here directly.
117
 
+       65)
118
 
                db_beginblock
119
 
                db_input high bugzilla/bugzilla_admin_name || true
120
 
                db_input high bugzilla/bugzilla_admin_real_name || true
121
 
--- debian/changelog    2004-11-30 18:23:22.000000000 +0100
122
 
+++ debian/changelog    2004-11-30 18:23:13.000000000 +0100
123
 
@@ -1,3 +1,13 @@
124
 
+bugzilla (2.16.7-0.1.1) unstable; urgency=low
125
 
+
126
 
+  * Non-maintainer upload:
127
 
+    - post-inst won't fail anymore when no MySQL server is
128
 
+      available. Added an automatic way of setting up the MySQL server if 
129
 
+      /etc/mysql/debian.cnf exists, will read values from it then.
130
 
+      (closes: #250638)
131
 
+
132
 
+ -- Alexis Sukrieh  <sukria@sukria.net>  Tue, 30 Nov 2004 17:14:24 +0100
133
 
+
134
 
 bugzilla (2.16.7-0.1) unstable; urgency=low
135
 
 
136
 
   * NMU 0-days due to major security issues, solved upstream.
137
 
--- debian/bugzilla.postinst    2004-11-29 15:44:23.000000000 +0100
138
 
+++ debian/bugzilla.postinst    2004-11-30 18:25:58.000000000 +0100
139
 
@@ -4,34 +4,106 @@
140
 
 use vars qw( $dsn $dbh 
141
 
             $mysql_host $mysql_port
142
 
             $mysql_name $mysql_user $mysql_user_pwd
143
 
-            $mysql_root_name $mysql_root_pwd );
144
 
+            $mysql_root_name $mysql_root_pwd $mysql_need_root);
145
 
 
146
 
 use Debconf::Client::ConfModule ':all';
147
 
-
148
 
 use DBI;
149
 
 
150
 
-if ( get('bugzilla/mysql_available') ne 'true' ) {
151
 
-       print STDERR "You answer that there is no MySQL server "
152
 
-                   ."suitable to support the bugzilla database. "
153
 
-                   ."This makes bugzilla installation to failed\n";
154
 
+# according to installation way user choosed, 
155
 
+# we'll do different things.
156
 
+my $install_way;
157
 
+my $default_file = '/etc/mysql/debian.cnf';    
158
 
+if (-f $default_file) {
159
 
+       $install_way = get('bugzilla/bugzilla_installation_way');
160
 
+}
161
 
+else {
162
 
+       $install_way = get('bugzilla/bugzilla_installation_way_single');
163
 
+}
164
 
+
165
 
+# The Automatic way will read /etc/mysql/default.cnf
166
 
+# and will use the values found there.
167
 
+if ($install_way eq 'Automatic') {
168
 
+       $mysql_name = 'bugzilla';
169
 
+       $mysql_need_root = 'true';
170
 
+       $mysql_port = '3306';
171
 
+       
172
 
+       # parsing default.cnf file to get host, user and password.
173
 
+       if (-f $default_file) {
174
 
+               if (open(MYSQL_DEFAULT_FILE, $default_file)) {
175
 
+                       while (<MYSQL_DEFAULT_FILE>) {
176
 
+                               chomp;
177
 
+                               next if /^#/ or /^\[\w*\]$/;
178
 
+                               if (/(\S+)\s*=\s*(\S+)/) {
179
 
+                                       my ($key, $val) = ($1, $2);
180
 
+                                       if ($key eq 'host') {
181
 
+                                               $mysql_host = $val;
182
 
+                                       }
183
 
+                                       elsif($key eq 'user') {
184
 
+                                               $mysql_user = $val;
185
 
+                                               $mysql_root_name = $val;
186
 
+                                       }
187
 
+                                       elsif($key eq 'password') {
188
 
+                                               $mysql_user_pwd = $val;
189
 
+                                               $mysql_root_pwd = $val;
190
 
+                                       }
191
 
+                               }
192
 
+                       }
193
 
+                       close MYSQL_DEFAULT_FILE;
194
 
+               }
195
 
+               else {
196
 
+                       print STDERR "Cannot read $default_file\n";
197
 
+                       exit 1;
198
 
+               }
199
 
+       }
200
 
+       else {
201
 
+               print STDERR "The file $default_file has disapeared.\n";
202
 
        exit 1;
203
 
+       }
204
 
+}
205
 
+
206
 
+# The Manual way is the same as before, everything 
207
 
+# was asked with debconf and is used here.
208
 
+elsif ($install_way eq 'Manual') {
209
 
+       $mysql_host = get('bugzilla/mysql_host');
210
 
+       $mysql_port = get('bugzilla/mysql_port');
211
 
+       $mysql_name = get('bugzilla/mysql_name');
212
 
+       $mysql_user = get('bugzilla/mysql_user');
213
 
+       $mysql_user_pwd  = get('bugzilla/mysql_user_pwd');
214
 
+       $mysql_need_root = get('bugzilla/mysql_need_root');
215
 
+       if ($mysql_need_root) {
216
 
+               $mysql_root_name =  get('bugzilla/mysql_root_name');
217
 
+               $mysql_root_pwd =  get('bugzilla/mysql_root_pwd');
218
 
+       }
219
 
 }
220
 
 
221
 
-$mysql_host = get('bugzilla/mysql_host');
222
 
-$mysql_port = get('bugzilla/mysql_port');
223
 
-$mysql_name = get('bugzilla/mysql_name');
224
 
-$mysql_user = get('bugzilla/mysql_user');
225
 
-$mysql_user_pwd  = get('bugzilla/mysql_user_pwd');
226
 
+# Later maeans that there is no MySQL server ready for
227
 
+# bugzilla now, user will come back later.
228
 
+elsif ($install_way eq 'Later') {
229
 
+       print STDERR "You answer that there is no MySQL server "
230
 
+                   ."suitable to support the bugzilla database. "
231
 
+                   ."Use 'dpkg-reconfigure bugzilla' when you have"
232
 
+                   ." a MySQL server.\n";
233
 
+       exit 0;
234
 
+}
235
 
        
236
 
-my $mysql_need_root = get('bugzilla/mysql_need_root');
237
 
+# Well, that should never happend...
238
 
+else {
239
 
+       print STDERR "Postinst error, unknown installation way : $install_way";
240
 
+       exit 1;
241
 
+}
242
 
 
243
 
+# If we have to create the databse, let's do it (that will be
244
 
+# in automatic mode).
245
 
 if ($mysql_need_root eq 'true') {
246
 
-       $mysql_root_name =  get('bugzilla/mysql_root_name');
247
 
-       $mysql_root_pwd =  get('bugzilla/mysql_root_pwd');
248
 
        $dsn = "DBI:mysql:;$mysql_host;$mysql_port";
249
 
        $dbh = DBI->connect($dsn, $mysql_root_name, $mysql_root_pwd)
250
 
                or die "Can't connect as admin to the database";
251
 
 
252
 
+       if ($install_way eq 'Automatic' and exists_database()) {
253
 
+               print STDERR "The database $mysql_name already exists in your MySQL server, I cannot follow the automatic installation.\n";
254
 
+               exit 1;
255
 
+       }
256
 
+
257
 
        create_database();
258
 
        
259
 
        $dbh = DBI->connect($dsn, $mysql_root_name, $mysql_root_pwd)
260
 
@@ -60,7 +132,7 @@
261
 
        or die "checksetup.pl failed";
262
 
 
263
 
 my $temp="set -e\nset -- @ARGV\n" . << 'EOF';
264
 
-#DEBHELPER#
265
 
+
266
 
 EOF
267
 
 
268
 
 system ($temp) / 256 == 0
269
 
@@ -108,6 +180,11 @@
270
 
                or die "Can't fix $path/* dirs perm : $!";
271
 
 }
272
 
 
273
 
+sub exists_database
274
 
+{
275
 
+       return grep /^$mysql_name$/, $dbh->func('_ListDBs');
276
 
+}
277
 
+
278
 
 sub create_database {
279
 
        my @databases = $dbh->func('_ListDBs');
280
 
        unless (grep /^$mysql_name$/, @databases) {
281
 
@@ -125,7 +202,8 @@
282
 
        } else {
283
 
                $fqdn=`hostname -f`;
284
 
        }
285
 
-       $dbh->do("grant all on $mysql_name.* to $mysql_user\@$fqdn identified by '$mysql_user_pwd'")
286
 
+       my $sql = "grant all on $mysql_name.* to '$mysql_user'\@$fqdn identified by '$mysql_user_pwd'";
287
 
+       $dbh->do($sql)
288
 
                or die "Can't grant or create $mysql_user user";
289
 
 }
290