~ubuntu-branches/ubuntu/hoary/cvs/hoary-security

« back to all changes in this revision

Viewing changes to debian/config

  • Committer: Bazaar Package Importer
  • Author(s): Steve McIntyre
  • Date: 2004-06-09 20:42:37 UTC
  • Revision ID: james.westby@ubuntu.com-20040609204237-xdqypwnaqxd965tc
Tags: 1:1.12.9-1
* New upstream version.
  + Several security fixes: CAN-2004-0414, CAN-2004-0416,
    CAN-2004-0417 & CAN-2004-0418

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh -e
 
2
 
 
3
# Config script for CVS using debconf
 
4
. /usr/share/debconf/confmodule
 
5
db_version 2.0 || [ $? -lt 30 ]
 
6
 
 
7
# Guard, since it's possible that we can have illegal constructs like
 
8
# ROT__tmp_cvs-test=false
 
9
# in those files.
 
10
set +e
 
11
if [ -f /etc/cvs-pserver.conf ]; then
 
12
    . /etc/cvs-pserver.conf || true
 
13
fi
 
14
 
 
15
if [ -f /etc/cvs-cron.conf ]; then
 
16
    . /etc/cvs-cron.conf
 
17
fi
 
18
set -e
 
19
 
 
20
# This function reads the current configuration from the config file
 
21
# (or rather, the variables sourced above)
 
22
 
 
23
set_debconf() {
 
24
    if [ "$REPOS" ]; then
 
25
        db_set cvs/repositories "$REPOS" || true
 
26
    fi
 
27
    if [ "$ROT_HIST" ]; then
 
28
        db_set cvs/rotatehistory "$ROT_HIST" || true
 
29
        if [ "$ROT_HIST" = "individual" -a -f /etc/cvs-cron.conf ]; then
 
30
            for rep in `grep "^ROT__" /etc/cvs-cron.conf`; do
 
31
                key=`echo $rep| sed -e 's,^ROT_,,g' -e 's,=.*,,g'`
 
32
                value=`echo $rep| sed -e 's,.*=,,g'`
 
33
                db_set cvs/rotate/$key $value || true
 
34
            done
 
35
        fi
 
36
    fi
 
37
    if [ "$ROTKEEP" ]; then
 
38
        db_set cvs/rotatekeep_nondefault "$ROTKEEP" || true
 
39
        if [ "$ROTKEEP" = "individual" ]; then
 
40
            # Cycle through
 
41
            for rep in `grep "^ROTKEEP_" /etc/cvs-cron.conf`; do
 
42
                key=`echo $rep| sed -e 's,^ROTKEEP_,,g' -e 's,=.*,,g'`
 
43
                value=`echo $rep| sed -e 's,.*=,,g'`
 
44
                db_set cvs/rotatekeep/$key $value || true
 
45
            done
 
46
        fi
 
47
    fi
 
48
        
 
49
    if [ "$CVS_PSERV_RESPAWN" ]; then
 
50
        db_set cvs/pserver_spawnlimit "$CVS_PSERV_RESPAWN" || true
 
51
    fi
 
52
    if [ "$CVS_ENAB_PSERV" ]; then
 
53
        CVS_ENAB_PSERV=`echo "$ENAB_PSERV" | tr A-Z a-z`
 
54
        if [ "$CVS_ENAB_PSERV" = "yes" ]; then
 
55
            db_set cvs/pserver true || true
 
56
        else
 
57
            db_set cvs/pserver false || true
 
58
        fi
 
59
    fi
 
60
    if [ "$OTHER_ROTKEEP" ]; then
 
61
        db_set cvs/rotatekeep "$OTHER_ROTKEEP" || true
 
62
    fi
 
63
    if [ "$CVS_PSERV_REPOS" = "$REPOS" ]; then
 
64
        db_set cvs/pserver_repos all || true
 
65
    elif [ "$CVS_PSERV_REPOS" ]; then
 
66
        db_set cvs/pserver_repos some || true
 
67
        for rep in `echo $REPOS | sed 's,:, ,g'`; do
 
68
            found=0
 
69
            key=`echo $rep | sed 's,/,_,g'`
 
70
            for pservrep in `echo $CVS_PSERV_REPOS | sed 's,:, ,'g`; do
 
71
                if [ "$rep" = "$pservrep" ]; then
 
72
                    # export it and 
 
73
                    found=1
 
74
                    db_set cvs/pserver/$key true || true
 
75
                fi
 
76
            done
 
77
            if [ "$found" = "0" ]; then
 
78
                db_set  cvs/pserver/$key false || true
 
79
            fi
 
80
        done
 
81
    fi
 
82
}
 
83
 
 
84
# Get the repositories list.
 
85
get_repositories ()
 
86
{
 
87
OK=0
 
88
while [ $OK -eq 0 ]; do
 
89
        db_input medium cvs/repositories ||:
 
90
        db_go ||:
 
91
        db_get cvs/repositories
 
92
        REPOS="$RET"
 
93
        BAD=""
 
94
        IFS=':'
 
95
        for i in $RET; do
 
96
                if [ ! -d "$i" ]; then
 
97
                        if [ ! -z "$BAD" ]; then
 
98
                                BAD="$BAD:$i"
 
99
                                BADDESC="$BADDESC, $i"
 
100
                        else
 
101
                                BAD="$i"
 
102
                                BADDESC="$i"
 
103
                        fi
 
104
                fi
 
105
        done
 
106
        IFS='   \
 
107
'
 
108
        if [ ! -z "$BAD" ]; then
 
109
                IGNORE=0
 
110
                db_subst cvs/badrepositories badreps "$BADDESC"
 
111
                db_input medium cvs/badrepositories || if [ $? -eq 30 ]; then
 
112
                        IGNORE=1
 
113
                fi
 
114
                db_go ||:
 
115
                db_get cvs/badrepositories
 
116
                if [ "$RET" = "reenter" -a $IGNORE -eq 0 ]; then
 
117
                        db_fset cvs/repositories seen false
 
118
                        OK=0
 
119
                        continue
 
120
                else
 
121
                        OK=1
 
122
                fi
 
123
        else
 
124
                OK=1
 
125
        fi
 
126
done
 
127
        IFS='   \
 
128
'
 
129
}
 
130
 
 
131
# Get history rotation information.
 
132
get_history ()
 
133
{
 
134
        db_get cvs/repositories
 
135
        REPOS="$RET"
 
136
        if [ -z "$REPOS" ]; then
 
137
            return
 
138
        fi
 
139
        db_input low cvs/rotatehistory ||:
 
140
        db_go ||:
 
141
        db_get cvs/rotatehistory
 
142
        ROTHIST="$RET"
 
143
        if [ x"$ROTHIST" = x"yes" -o x"$ROTHIST" = x"individual" ]; then
 
144
                db_input low cvs/rotatekeep_nondefault ||:
 
145
                db_go ||:
 
146
        else
 
147
                db_set cvs/rotatekeep_nondefault no
 
148
                db_fset cvs/rotatekeep_nondefault seen false
 
149
        fi
 
150
        db_get cvs/rotatekeep_nondefault
 
151
        ROTKEEP="$RET"
 
152
        if [ x"$ROTHIST" = x"individual" -o x"$ROTHIST" = x"yes" -a x"$ROTKEEP" = x"individual" ]; then
 
153
                db_beginblock
 
154
                IFS=':'
 
155
                for i in $REPOS; do
 
156
                        IFS='   \
 
157
'
 
158
                        RNAME="`echo "$i" | sed -e 's:/:_:g'`"
 
159
                        DO_RK=1
 
160
                        if [ x"$ROTHIST" = x"individual" ]; then
 
161
                                db_register cvs/rotate_individual "cvs/rotate/$RNAME"
 
162
                                db_subst "cvs/rotate/$RNAME" repos "$i"
 
163
                                db_input medium "cvs/rotate/$RNAME" ||:
 
164
                        fi
 
165
                done
 
166
                db_endblock
 
167
                db_go ||:
 
168
                db_beginblock
 
169
                IFS=':'
 
170
                for i in $REPOS; do
 
171
                        IFS='   \
 
172
'
 
173
                        RNAME="`echo "$i" | sed -e 's:/:_:g'`"
 
174
                        DO_RK=1
 
175
                        if [ x"$ROTHIST" = x"individual" ]; then
 
176
                                db_get "cvs/rotate/$RNAME"
 
177
                                if [ x"$RET" = x"false" ]; then
 
178
                                        DO_RK=0
 
179
                                fi
 
180
                        fi
 
181
                        if [ "$ROTKEEP" = "individual" -a $DO_RK -eq 1 ]; then
 
182
                                db_register cvs/rotatekeep_individual "cvs/rotatekeep/$RNAME"
 
183
                                db_subst "cvs/rotatekeep/$RNAME" repos "$i"
 
184
                                db_input medium "cvs/rotatekeep/$RNAME" ||:
 
185
                        fi
 
186
                done
 
187
                db_endblock
 
188
                db_go ||:
 
189
        fi
 
190
}
 
191
 
 
192
# Set up the pserver.
 
193
setup_pserver ()
 
194
{
 
195
        db_get cvs/repositories
 
196
        REPOS="$RET"
 
197
        if [ -z "$REPOS" ]; then
 
198
            return
 
199
        fi
 
200
        db_input medium cvs/pserver ||:
 
201
        db_go ||:
 
202
        db_get cvs/pserver
 
203
        if [ "$RET" = "true" ]; then
 
204
                db_input low cvs/pserver_repos ||:
 
205
                db_go ||:
 
206
                db_get cvs/pserver_repos
 
207
                if [ "$RET" = "some" ]; then
 
208
                        db_beginblock
 
209
                        db_get cvs/repositories
 
210
                        REPOS="$RET"
 
211
                        IFS=':'
 
212
                        for i in $REPOS; do
 
213
                                IFS='   \
 
214
'
 
215
                                RNAME="`echo "$i" | sed -e 's:/:_:g'`"
 
216
                                db_register cvs/pserver_repos_individual "cvs/pserver/$RNAME"
 
217
                                db_subst "cvs/pserver/$RNAME" repos "$i"
 
218
                                db_input medium "cvs/pserver/$RNAME" ||:
 
219
                        done
 
220
                        db_endblock
 
221
                        db_go ||:
 
222
                fi
 
223
                db_input low cvs/pserver_setspawnlimit ||:
 
224
                db_go ||:
 
225
                db_get cvs/pserver_setspawnlimit
 
226
                if [ "$RET" = "true" ]; then
 
227
                        db_input low cvs/pserver_spawnlimit ||:
 
228
                        db_go ||:
 
229
                fi
 
230
        fi
 
231
}
 
232
 
 
233
# Import old settings from cvs.conf.
 
234
import_cvsconf ()
 
235
{
 
236
        if [ -f /etc/cvs.conf ]; then
 
237
          . /etc/cvs.conf
 
238
        fi
 
239
        if [ -f /etc/cvs.conf.import ]; then
 
240
          . /etc/cvs.conf.import
 
241
        fi
 
242
        db_set cvs/repositories "$CVS_REPOS"
 
243
        if [ x"$CVS_ROTATE" = x"no" ]; then
 
244
                db_set cvs/rotatehistory no
 
245
        else
 
246
                if [ x"$CVS_ROTDIRS" != x"$CVS_REPOS" ]; then
 
247
                        db_set cvs/rotatehistory individual
 
248
                        IFS=':'
 
249
                        for i in $CVS_REPOS; do
 
250
                                IFS='   \
 
251
'
 
252
                                RNAME="`echo "$i" | sed -e 's:/:_:g'`"
 
253
                                db_register cvs/rotate_individual "cvs/rotate/$RNAME"
 
254
                                db_subst "cvs/rotate/$RNAME" repos "$i"
 
255
                                db_set "cvs/rotate/$RNAME" false
 
256
                        done
 
257
                        IFS=':'
 
258
                        for i in $CVS_ROTDIRS; do
 
259
                                IFS='   \
 
260
'
 
261
                                RNAME="`echo "$i" | sed -e 's:/:_:g'`"
 
262
                                db_set "cvs/rotate/$RNAME" true
 
263
                        done
 
264
                else
 
265
                        db_set cvs/rotatehistory yes
 
266
                fi
 
267
                if [ x"$CVS_ROTATE" = x"yes" ]; then
 
268
                        db_set cvs/rotatekeep_nondefault no
 
269
                else
 
270
                        db_set cvs/rotatekeep_nondefault individual
 
271
                        # Advanced syntax
 
272
                        OLDIFS="$IFS"
 
273
                        IFS=":  "
 
274
                        SAME=1
 
275
                        set -- $CVS_ROTATE
 
276
                        LAST="$1"
 
277
                        DIRS="$CVS_ROTDIRS"
 
278
                        for i in $CVS_ROTATE; do
 
279
                                if [ x"$i" != x"$LAST" -a x"$i" != x"" ]; then
 
280
                                        SAME=0
 
281
                                fi
 
282
                        done
 
283
                        if [ $SAME -eq 1 ]; then
 
284
                                if [ x"$LAST" != x"n" ]; then
 
285
                                        db_set cvs/rotatekeep_nondefault yes
 
286
                                        db_set cvs/rotatekeep "$LAST"
 
287
                                else
 
288
                                        db_set cvs/rotatekeep_nondefault no
 
289
                                fi
 
290
                        else
 
291
                                for i in $CVS_ROTATE; do
 
292
                                        IFS="$OLDIFS"
 
293
                                        DIR="`echo $DIRS | sed 's/\([^:]*\):.*/\1/'`"
 
294
                                        DIRS="`echo $DIRS | sed 's/[^:]*:\(.*\)/\1/'`"
 
295
                                        RNAME="`echo "$DIR" | sed -e 's:/:_:g'`"
 
296
                                        db_register cvs/rotatekeep_individual "cvs/rotatekeep/$RNAME"
 
297
                                        db_subst "cvs/rotatekeep/$RNAME" repos "$DIR"
 
298
                                        case "$i" in
 
299
                                                n)
 
300
                                                db_set "cvs/rotate/$RNAME" false
 
301
                                                ;;
 
302
                                                
 
303
                                                [0-9]*)
 
304
                                                db_set "cvs/rotatekeep/$RNAME" $i
 
305
                                                ;;
 
306
                                        esac
 
307
                                done
 
308
                        fi
 
309
                fi
 
310
        fi
 
311
        if [ x"$CVS_ENAB_PSERV" = x"yes" ]; then
 
312
                db_set cvs/pserver true
 
313
                if [ x"$CVS_PSERV_REPOS" != x"$CVS_REPOS" ]; then
 
314
                        db_set cvs/pserver_repos some
 
315
                        IFS=':'
 
316
                        for i in $CVS_REPOS; do
 
317
                                IFS='   \
 
318
'
 
319
                                RNAME="`echo "$i" | sed -e 's:/:_:g'`"
 
320
                                db_register cvs/pserver_repos_individual "cvs/pserver/$RNAME"
 
321
                                db_subst "cvs/pserver/$RNAME" repos "$i"
 
322
                                db_set "cvs/pserver/$RNAME" false
 
323
                        done
 
324
                        IFS=':'
 
325
                        for i in $CVS_PSERV_REPOS; do
 
326
                                IFS='   \
 
327
'
 
328
                                RNAME="`echo "$i" | sed -e 's:/:_:g'`"
 
329
                                db_set "cvs/pserver/$RNAME" true
 
330
                        done
 
331
                else
 
332
                        db_set cvs/pserver_repos all
 
333
                fi
 
334
                if [ $CVSCONF_VERSION -ge 2 ]; then
 
335
                        if [ "$CVS_PSERV_RESPAWN" != "off" -a
 
336
                                "$CVS_PSERV_RESPAWN" != "off-def" ]; then
 
337
                                db_set cvs/pserver_setspawnlimit true
 
338
                                db_set cvs/pserver_spawnlimit "$CVS_PSERV_RESPAWN"
 
339
                        else
 
340
                                db_set cvs/pserver_setspawnlimit false
 
341
                        fi
 
342
                else
 
343
                        db_set cvs/pserver_setspawnlimit false
 
344
                fi
 
345
        else
 
346
                db_set cvs/pserver false
 
347
        fi
 
348
        if [ -f /etc/cvs.conf.import ]; then
 
349
                rm -f /etc/cvs.conf.import
 
350
        fi
 
351
}
 
352
 
 
353
## Main program
 
354
 
 
355
# Check if we need to import the old /etc/cvs.conf
 
356
if [ -f /etc/cvs.conf -o -f /etc/cvs.conf.import ]; then
 
357
    import_cvsconf
 
358
    if [ -f /etc/cvs.conf ]; then
 
359
        mv /etc/cvs.conf /etc/cvs.conf.dpkg-old
 
360
    fi
 
361
fi
 
362
 
 
363
set_debconf
 
364
get_repositories
 
365
get_history
 
366
setup_pserver
 
367
 
 
368
# End of file.