~ubuntu-branches/ubuntu/jaunty/memcached/jaunty-security

« back to all changes in this revision

Viewing changes to install-sh

  • Committer: Bazaar Package Importer
  • Author(s): Jay Bonci
  • Date: 2007-05-02 11:35:42 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502113542-qpoxsq28fjb7s9wc
Tags: 1.2.1-1
* New upstream release (Closes: #405054)
* Fix to logfile output so logrotate will work (Closes: #417941)
* Listen in on localhost by default (Closes: #383660)
* Default configuration suggests nobody by default (Closes: #391351)
* Bumped policy version to 3.7.2.2 (No other changes)

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
 
75
75
while [ x"$1" != x ]; do
76
76
    case $1 in
77
 
        -c) instcmd="$cpprog"
 
77
        -c) instcmd=$cpprog
78
78
            shift
79
79
            continue;;
80
80
 
97
97
            shift
98
98
            continue;;
99
99
 
100
 
        -s) stripcmd="$stripprog"
 
100
        -s) stripcmd=$stripprog
101
101
            shift
102
102
            continue;;
103
103
 
124
124
 
125
125
if [ x"$src" = x ]
126
126
then
127
 
        echo "install:  no input file specified"
 
127
        echo "$0: no input file specified" >&2
128
128
        exit 1
129
129
else
130
 
        true
 
130
        :
131
131
fi
132
132
 
133
133
if [ x"$dir_arg" != x ]; then
134
134
        dst=$src
135
135
        src=""
136
 
        
137
 
        if [ -d $dst ]; then
 
136
 
 
137
        if [ -d "$dst" ]; then
138
138
                instcmd=:
139
139
                chmodcmd=""
140
140
        else
141
 
                instcmd=mkdir
 
141
                instcmd=$mkdirprog
142
142
        fi
143
143
else
144
144
 
145
145
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
146
 
# might cause directories to be created, which would be especially bad 
 
146
# might cause directories to be created, which would be especially bad
147
147
# if $src (and thus $dsttmp) contains '*'.
148
148
 
149
 
        if [ -f $src -o -d $src ]
 
149
        if [ -f "$src" ] || [ -d "$src" ]
150
150
        then
151
 
                true
 
151
                :
152
152
        else
153
 
                echo "install:  $src does not exist"
 
153
                echo "$0: $src does not exist" >&2
154
154
                exit 1
155
155
        fi
156
 
        
 
156
 
157
157
        if [ x"$dst" = x ]
158
158
        then
159
 
                echo "install:  no destination specified"
 
159
                echo "$0: no destination specified" >&2
160
160
                exit 1
161
161
        else
162
 
                true
 
162
                :
163
163
        fi
164
164
 
165
165
# If destination is a directory, append the input filename; if your system
166
166
# does not like double slashes in filenames, you may need to add some logic
167
167
 
168
 
        if [ -d $dst ]
 
168
        if [ -d "$dst" ]
169
169
        then
170
 
                dst="$dst"/`basename $src`
 
170
                dst=$dst/`basename "$src"`
171
171
        else
172
 
                true
 
172
                :
173
173
        fi
174
174
fi
175
175
 
176
176
## this sed command emulates the dirname command
177
 
dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
 
177
dstdir=`echo "$dst" | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
178
178
 
179
179
# Make sure that the destination directory exists.
180
180
#  this part is taken from Noah Friedman's mkinstalldirs script
181
181
 
182
182
# Skip lots of stat calls in the usual case.
183
183
if [ ! -d "$dstdir" ]; then
184
 
defaultIFS='    
185
 
'
186
 
IFS="${IFS-${defaultIFS}}"
 
184
defaultIFS='
 
185
        '
 
186
IFS="${IFS-$defaultIFS}"
187
187
 
188
 
oIFS="${IFS}"
 
188
oIFS=$IFS
189
189
# Some sh's can't handle IFS=/ for some reason.
190
190
IFS='%'
191
 
set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'`
192
 
IFS="${oIFS}"
 
191
set - `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
 
192
IFS=$oIFS
193
193
 
194
194
pathcomp=''
195
195
 
196
196
while [ $# -ne 0 ] ; do
197
 
        pathcomp="${pathcomp}${1}"
 
197
        pathcomp=$pathcomp$1
198
198
        shift
199
199
 
200
 
        if [ ! -d "${pathcomp}" ] ;
 
200
        if [ ! -d "$pathcomp" ] ;
201
201
        then
202
 
                $mkdirprog "${pathcomp}"
 
202
                $mkdirprog "$pathcomp"
203
203
        else
204
 
                true
 
204
                :
205
205
        fi
206
206
 
207
 
        pathcomp="${pathcomp}/"
 
207
        pathcomp=$pathcomp/
208
208
done
209
209
fi
210
210
 
211
211
if [ x"$dir_arg" != x ]
212
212
then
213
 
        $doit $instcmd $dst &&
 
213
        $doit $instcmd "$dst" &&
214
214
 
215
 
        if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi &&
216
 
        if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi &&
217
 
        if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi &&
218
 
        if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi
 
215
        if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dst"; else : ; fi &&
 
216
        if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dst"; else : ; fi &&
 
217
        if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dst"; else : ; fi &&
 
218
        if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dst"; else : ; fi
219
219
else
220
220
 
221
221
# If we're going to rename the final executable, determine the name now.
222
222
 
223
 
        if [ x"$transformarg" = x ] 
 
223
        if [ x"$transformarg" = x ]
224
224
        then
225
 
                dstfile=`basename $dst`
 
225
                dstfile=`basename "$dst"`
226
226
        else
227
 
                dstfile=`basename $dst $transformbasename | 
 
227
                dstfile=`basename "$dst" $transformbasename |
228
228
                        sed $transformarg`$transformbasename
229
229
        fi
230
230
 
231
231
# don't allow the sed command to completely eliminate the filename
232
232
 
233
 
        if [ x"$dstfile" = x ] 
 
233
        if [ x"$dstfile" = x ]
234
234
        then
235
 
                dstfile=`basename $dst`
 
235
                dstfile=`basename "$dst"`
236
236
        else
237
 
                true
 
237
                :
238
238
        fi
239
239
 
240
 
# Make a temp file name in the proper directory.
241
 
 
242
 
        dsttmp=$dstdir/#inst.$$#
 
240
# Make a couple of temp file names in the proper directory.
 
241
 
 
242
        dsttmp=$dstdir/_inst.$$_
 
243
        rmtmp=$dstdir/_rm.$$_
 
244
 
 
245
# Trap to clean up temp files at exit.
 
246
 
 
247
        trap 'status=$?; rm -f "$dsttmp" "$rmtmp" && exit $status' 0
 
248
        trap '(exit $?); exit' 1 2 13 15
243
249
 
244
250
# Move or copy the file name to the temp name
245
251
 
246
 
        $doit $instcmd $src $dsttmp &&
247
 
 
248
 
        trap "rm -f ${dsttmp}" 0 &&
 
252
        $doit $instcmd "$src" "$dsttmp" &&
249
253
 
250
254
# and set any options; do chmod last to preserve setuid bits
251
255
 
253
257
# ignore errors from any of these, just make sure not to ignore
254
258
# errors from the above "$doit $instcmd $src $dsttmp" command.
255
259
 
256
 
        if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi &&
257
 
        if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi &&
258
 
        if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi &&
259
 
        if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi &&
 
260
        if [ x"$chowncmd" != x ]; then $doit $chowncmd "$dsttmp"; else :;fi &&
 
261
        if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd "$dsttmp"; else :;fi &&
 
262
        if [ x"$stripcmd" != x ]; then $doit $stripcmd "$dsttmp"; else :;fi &&
 
263
        if [ x"$chmodcmd" != x ]; then $doit $chmodcmd "$dsttmp"; else :;fi &&
 
264
 
 
265
# Now remove or move aside any old file at destination location.  We try this
 
266
# two ways since rm can't unlink itself on some systems and the destination
 
267
# file might be busy for other reasons.  In this case, the final cleanup
 
268
# might fail but the new file should still install successfully.
 
269
 
 
270
{
 
271
        if [ -f "$dstdir/$dstfile" ]
 
272
        then
 
273
                $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null ||
 
274
                $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null ||
 
275
                {
 
276
                  echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
 
277
                  (exit 1); exit
 
278
                }
 
279
        else
 
280
                :
 
281
        fi
 
282
} &&
260
283
 
261
284
# Now rename the file to the real destination.
262
285
 
263
 
        $doit $rmcmd -f $dstdir/$dstfile &&
264
 
        $doit $mvcmd $dsttmp $dstdir/$dstfile 
 
286
        $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
265
287
 
266
288
fi &&
267
289
 
 
290
# The final little trick to "correctly" pass the exit status to the exit trap.
268
291
 
269
 
exit 0
 
292
{
 
293
        (exit 0); exit
 
294
}