1 | #! /bin/sh
|
---|
2 | # Please have a TMP or TMPDIR environment variable if you don't trust /tmp,
|
---|
3 | # or don't run this as root.
|
---|
4 | #
|
---|
5 | # -- partly taken from PureFTPd
|
---|
6 | #
|
---|
7 |
|
---|
8 | VERSION=1.6.4
|
---|
9 |
|
---|
10 |
|
---|
11 | # exits with a custom error message
|
---|
12 | bail_error () {
|
---|
13 | echo
|
---|
14 | echo $1
|
---|
15 | echo
|
---|
16 | exit 1
|
---|
17 | }
|
---|
18 |
|
---|
19 | get_config() {
|
---|
20 | mfile=`cat $tmp`
|
---|
21 | for z in $mfile ; do
|
---|
22 | cfgline="$cfgline --$z"
|
---|
23 | done
|
---|
24 | }
|
---|
25 |
|
---|
26 | get_error() {
|
---|
27 | ge_rval=0
|
---|
28 | if cat $tmp 2>&1 | grep Error > /dev/null ; then
|
---|
29 | ge_rval=1
|
---|
30 | fi
|
---|
31 | return ${ge_rval}
|
---|
32 | }
|
---|
33 |
|
---|
34 |
|
---|
35 |
|
---|
36 | #------------------------------------------------------------
|
---|
37 | #
|
---|
38 | # Find a 'dialog' program
|
---|
39 | #
|
---|
40 | #------------------------------------------------------------
|
---|
41 | PATH=/usr/local/bin:/usr/local/sbin:$PATH; export PATH
|
---|
42 |
|
---|
43 | WELCOME=`cat <<EOF
|
---|
44 | Welcome to the SAMHAIN configuration tool
|
---|
45 |
|
---|
46 | This script is meant to make installing SAMHAIN as easy as
|
---|
47 | possible. Just read the text below, hit ENTER, and you are
|
---|
48 | on your way.
|
---|
49 |
|
---|
50 | SAMHAIN ships with NO WARRANTY whatsoever, without
|
---|
51 | even the implied warranty of merchantability or fitness
|
---|
52 | for a particular purpose. The author takes no responsibility
|
---|
53 | for the consequences of running this script.
|
---|
54 |
|
---|
55 | Please send any questions to support@la-samhna.com.
|
---|
56 | EOF`
|
---|
57 |
|
---|
58 | if [ -z "$dialog" ] ; then
|
---|
59 | if [ -n "$DISPLAY" ] ; then
|
---|
60 | Xdialog --msgbox "$WELCOME" 20 75 2> /dev/null && dialog='Xdialog'
|
---|
61 | gauge='--gauge'
|
---|
62 | fi
|
---|
63 | fi
|
---|
64 | if [ -z "$dialog" ] ; then
|
---|
65 | dialog --msgbox "$WELCOME" 20 75 2> /dev/null && dialog='dialog'
|
---|
66 |
|
---|
67 | # Workaround for old versions of 'dialog' (Slackware)
|
---|
68 |
|
---|
69 | if "$dialog" 2>&1 | grep gauge > /dev/null ; then
|
---|
70 | gauge='--gauge'
|
---|
71 | elif "$dialog" 2>&1 | grep guage > /dev/null ; then
|
---|
72 | gauge='--guage'
|
---|
73 | else
|
---|
74 | gauge=''
|
---|
75 | fi
|
---|
76 | fi
|
---|
77 | if [ -z "$dialog" ] ; then
|
---|
78 | lxdialog --msgbox "$WELCOME" 20 75 2> /dev/null && dialog='lxdialog'
|
---|
79 | fi
|
---|
80 | if [ -z "$dialog" ] ; then
|
---|
81 | /usr/src/linux/scripts/lxdialog/lxdialog --msgbox "$WELCOME" 20 75 2> /dev/null && dialog='/usr/src/linux/scripts/lxdialog/lxdialog'
|
---|
82 | fi
|
---|
83 |
|
---|
84 | if [ -z "$dialog" ] ; then
|
---|
85 | bail_error "No \"dialog\" found, GUI installation impossible"
|
---|
86 | fi
|
---|
87 |
|
---|
88 | #------------------------------------------------------------
|
---|
89 | #
|
---|
90 | # Find a writable temporary directory
|
---|
91 | #
|
---|
92 | #------------------------------------------------------------
|
---|
93 | tempdir=''
|
---|
94 | for tmpdir in "$TMP" "$TMPDIR" /tmp /var/tmp; do
|
---|
95 | if [ -z "$tempdir" ] && [ -d "$tmpdir" ] && [ -w "$tmpdir" ]; then
|
---|
96 | tempdir="$tmpdir"
|
---|
97 | fi
|
---|
98 | done
|
---|
99 | if [ -z "$tempdir" ]; then
|
---|
100 | bail_error "Unable to find a suitable temporary directory"
|
---|
101 | fi
|
---|
102 |
|
---|
103 | # Create a temporary file
|
---|
104 | tmp=`mktemp $tempdir/build.gui.XXXXXX`
|
---|
105 | if [ $? -ne 0 ]; then
|
---|
106 | bail_error "Cannot create temp file, exiting..."
|
---|
107 | fi
|
---|
108 |
|
---|
109 | trap "rm -f $tmp; exit 1" EXIT SIGHUP SIGINT SIGQUIT SIGSEGV SIGTERM
|
---|
110 |
|
---|
111 | #------------------------------------------------------------
|
---|
112 | #
|
---|
113 | # Build config line
|
---|
114 | #
|
---|
115 | #------------------------------------------------------------
|
---|
116 | cfgline='';
|
---|
117 |
|
---|
118 | $dialog \
|
---|
119 | --title "Compile-time options" \
|
---|
120 | --backtitle "Samhain $VERSION" \
|
---|
121 | --radiolist "Samhain can run as standalone application on a single dektop machine, or as a client/server application for centralized monitoring of many hosts" \
|
---|
122 | 10 75 3 \
|
---|
123 | "disable-network" "Single desktop machine" on \
|
---|
124 | "enable-network=client" "Network (client)" off \
|
---|
125 | "enable-network=server" "Network (server)" off \
|
---|
126 | 2> $tmp
|
---|
127 |
|
---|
128 | mtest=$?
|
---|
129 | if [ $mtest = -1 ]; then
|
---|
130 | exit 1
|
---|
131 | fi
|
---|
132 | if [ $mtest = 0 ]; then
|
---|
133 | get_config
|
---|
134 | else
|
---|
135 | get_error || bail_error "Your \"dialog\" does not support --radiolist, GUI installation impossible"
|
---|
136 | cfgline="--disable-network"
|
---|
137 | fi
|
---|
138 |
|
---|
139 | cfgtest=`echo $cfgline | grep disable`
|
---|
140 |
|
---|
141 |
|
---|
142 | #------------------------------------------------------------
|
---|
143 | #
|
---|
144 | # Server options
|
---|
145 | #
|
---|
146 | #------------------------------------------------------------
|
---|
147 | if [ -z $cfgtest ]; then
|
---|
148 |
|
---|
149 | INET=yes
|
---|
150 | HTML="\n /usr/local/var/samhain/samhain.html"
|
---|
151 |
|
---|
152 | $dialog \
|
---|
153 | --backtitle "Samhain $VERSION" \
|
---|
154 | --msgbox "You have chosen to build SAMHAIN as a client/server application.\n\nThis requires some additional configuration.\nPlease read the manual if you are not sure\nwhich options are useful or neccessary for you." 10 75
|
---|
155 |
|
---|
156 | if [ $? = -1 ]; then
|
---|
157 | exit 1
|
---|
158 | fi
|
---|
159 |
|
---|
160 |
|
---|
161 | $dialog \
|
---|
162 | --title 'Network options' \
|
---|
163 | --separate-output \
|
---|
164 | --backtitle "Samhain $VERSION" \
|
---|
165 | --checklist 'Use SPACE to set/unset. If in doubt, read the manual.' \
|
---|
166 | 20 75 10 \
|
---|
167 | 'enable-udp' "Server listens also on 514/udp" off \
|
---|
168 | 'disable-encrypt' "Disable client/server encryption" off \
|
---|
169 | 'disable-srp' "Disable SRP client/server authentication" off \
|
---|
170 | 2> $tmp
|
---|
171 |
|
---|
172 | mtest=$?
|
---|
173 | if [ $mtest = -1 ]; then
|
---|
174 | exit 1
|
---|
175 | fi
|
---|
176 | if [ $mtest = 0 ]; then
|
---|
177 | get_config
|
---|
178 | fi
|
---|
179 |
|
---|
180 | $dialog \
|
---|
181 | --title 'Network options' \
|
---|
182 | --backtitle "Samhain $VERSION" \
|
---|
183 | --inputbox "Server port" 10 75 "49777" \
|
---|
184 | 2> $tmp
|
---|
185 |
|
---|
186 | mtest=$?
|
---|
187 | if [ $mtest = -1 ]; then
|
---|
188 | exit 1
|
---|
189 | fi
|
---|
190 |
|
---|
191 | if [ $mtest = 0 ]; then
|
---|
192 | mfile=`cat $tmp`
|
---|
193 | for z in $mfile ; do
|
---|
194 | cfgline="$cfgline --with-port=$z"
|
---|
195 | done
|
---|
196 | fi
|
---|
197 |
|
---|
198 |
|
---|
199 | $dialog \
|
---|
200 | --title 'Network options' \
|
---|
201 | --backtitle "Samhain $VERSION" \
|
---|
202 | --inputbox "Server address" 10 75 "127.0.0.1" \
|
---|
203 | 2> $tmp
|
---|
204 |
|
---|
205 | mtest=$?
|
---|
206 | if [ $mtest = -1 ]; then
|
---|
207 | exit 1
|
---|
208 | fi
|
---|
209 | if [ $mtest = 0 ]; then
|
---|
210 | mfile=`cat $tmp`
|
---|
211 | for z in $mfile ; do
|
---|
212 | cfgline="$cfgline --with-logserver=$z"
|
---|
213 | done
|
---|
214 | fi
|
---|
215 |
|
---|
216 | $dialog \
|
---|
217 | --title "Network options" \
|
---|
218 | --backtitle 'Samhain $VERSION' \
|
---|
219 | --inputbox "Backup server address" 10 75 "none" \
|
---|
220 | 2> $tmp
|
---|
221 |
|
---|
222 | mtest=$?
|
---|
223 | if [ $mtest = -1 ]; then
|
---|
224 | exit 1
|
---|
225 | fi
|
---|
226 | if [ $mtest = 0 ]; then
|
---|
227 | mfile=`cat $tmp`
|
---|
228 | for z in $mfile ; do
|
---|
229 | if [ "x$z" != "xnone" ]; then
|
---|
230 | cfgline="$cfgline --with-altlogserver=$z"
|
---|
231 | fi
|
---|
232 | done
|
---|
233 | fi
|
---|
234 |
|
---|
235 | # if [ -z $cfgtest ]; then
|
---|
236 | fi
|
---|
237 |
|
---|
238 | os=`uname -s`
|
---|
239 | if [ x"$os" = xLinux ]
|
---|
240 | then
|
---|
241 | PROC=`uname -m`
|
---|
242 | if [ x"$PROC" = xi686 ] ; then
|
---|
243 | I386_LINUX=yes
|
---|
244 | fi
|
---|
245 | if [ x"$PROC" = xi586 ] ; then
|
---|
246 | I386_LINUX=yes
|
---|
247 | fi
|
---|
248 | if [ x"$PROC" = xi486 ] ; then
|
---|
249 | I386_LINUX=yes
|
---|
250 | fi
|
---|
251 | if [ x"$PROC" = xi386 ] ; then
|
---|
252 | I386_LINUX=yes
|
---|
253 | fi
|
---|
254 | fi
|
---|
255 |
|
---|
256 | $dialog \
|
---|
257 | --title 'General options' \
|
---|
258 | --separate-output \
|
---|
259 | --backtitle "Samhain $VERSION" \
|
---|
260 | --checklist 'Use SPACE to set/unset. If in doubt, read the MANUAL.' \
|
---|
261 | 20 75 10 \
|
---|
262 | 'enable-static' "Don't link with shared libraries" on \
|
---|
263 | 'enable-suidcheck' "Check for suid/sgid files" on \
|
---|
264 | 'enable-login-watch' "Watch for login/logout events" off \
|
---|
265 | 'enable-ptrace' "Enable anti-debugger code" off \
|
---|
266 | 'enable-db-reload' "Reload database on SIGHUP" off \
|
---|
267 | 'enable-xml-log' "Write log in XML format" off \
|
---|
268 | 'disable-mail' "Compile without built-in mailer" off \
|
---|
269 | 'disable-external-scripts' "Disable use of external scripts" off \
|
---|
270 | 'enable-debug' "Compile in debugging code" off \
|
---|
271 | 2> $tmp
|
---|
272 |
|
---|
273 | mtest=$?
|
---|
274 | if [ $mtest = -1 ]; then
|
---|
275 | exit 1
|
---|
276 | fi
|
---|
277 | if [ $mtest = 0 ]; then
|
---|
278 | get_config
|
---|
279 | fi
|
---|
280 |
|
---|
281 | #------------------------------------------------------------
|
---|
282 | #
|
---|
283 | # Kernel module
|
---|
284 | #
|
---|
285 | #------------------------------------------------------------
|
---|
286 |
|
---|
287 | KCHECK="no"
|
---|
288 |
|
---|
289 | if [ "x$I386_LINUX" = "xyes" ]; then
|
---|
290 |
|
---|
291 | $dialog \
|
---|
292 | --title "Kernel module rootkit detection" \
|
---|
293 | --separate-output \
|
---|
294 | --backtitle "Samhain $VERSION" \
|
---|
295 | --inputbox "SAMHAIN can detect kernel module rootkits if compiled with support\nfor this. If you want to enable this option, please give the path\nto your System.map file, else choose CANCEL.\n\nNOTE: this option will require root privileges for at least one\ncommand during compilation (to read from /dev/kmem)." \
|
---|
296 | 16 75 "/boot/System.map" \
|
---|
297 | 2> $tmp
|
---|
298 |
|
---|
299 | mtest=$?
|
---|
300 |
|
---|
301 | if [ $mtest = -1 ]; then
|
---|
302 | exit 1
|
---|
303 | fi
|
---|
304 | if [ $mtest = 0 ]; then
|
---|
305 | mfile=`cat $tmp`
|
---|
306 | for z in $mfile ; do
|
---|
307 | cfgline="$cfgline --with-kcheck=$z"
|
---|
308 | done
|
---|
309 | KCHECK="yes"
|
---|
310 | fi
|
---|
311 |
|
---|
312 | fi
|
---|
313 |
|
---|
314 | #------------------------------------------------------------
|
---|
315 | #
|
---|
316 | # Signature options
|
---|
317 | #
|
---|
318 | #------------------------------------------------------------
|
---|
319 | $dialog \
|
---|
320 | --title "Signed database and configuration" \
|
---|
321 | --separate-output \
|
---|
322 | --backtitle "Samhain $VERSION" \
|
---|
323 | --yesno "Samhain can be configured to support PGP signed database\nand configuration files. This requires a working installation\nof GnuPG.\n\nDo you want to use this option ?" \
|
---|
324 | 10 75 \
|
---|
325 | 2> $tmp
|
---|
326 |
|
---|
327 | mtest=$?
|
---|
328 |
|
---|
329 | if [ $mtest = -1 ]; then
|
---|
330 | exit 1
|
---|
331 | fi
|
---|
332 | if [ $mtest = 0 ]; then
|
---|
333 |
|
---|
334 |
|
---|
335 | $dialog \
|
---|
336 | --title "Signed database and configuration" \
|
---|
337 | --separate-output \
|
---|
338 | --backtitle "Samhain $VERSION" \
|
---|
339 | --inputbox "Please enter the full path to gpg (i.e. the GnuPG binary)" \
|
---|
340 | 10 75 "/usr/bin/gpg" \
|
---|
341 | 2> $tmp
|
---|
342 |
|
---|
343 | mtest=$?
|
---|
344 |
|
---|
345 | if [ $mtest = -1 ]
|
---|
346 | then
|
---|
347 | exit 1
|
---|
348 | fi
|
---|
349 | if [ $mtest = 0 ]
|
---|
350 | then
|
---|
351 |
|
---|
352 | mfile=`cat $tmp`
|
---|
353 | for z in $mfile ; do
|
---|
354 | cfgline="$cfgline --with-gpg=$z"
|
---|
355 | done
|
---|
356 |
|
---|
357 | $dialog \
|
---|
358 | --title "Signed database and configuration" \
|
---|
359 | --separate-output \
|
---|
360 | --backtitle "Samhain $VERSION" \
|
---|
361 | --inputbox "Please enter the fingerprint of the key to use (one string, no spaces)" \
|
---|
362 | 10 75 "6BD9050FD8FC941B43412DCC68B7AB8957548DCD" \
|
---|
363 | 2> $tmp
|
---|
364 |
|
---|
365 | mtest=$?
|
---|
366 |
|
---|
367 | if [ $mtest = -1 ]; then
|
---|
368 | exit 1
|
---|
369 | fi
|
---|
370 | if [ $mtest = 0 ]; then
|
---|
371 | z=`cat $tmp`
|
---|
372 | cfgline="$cfgline --with-fp=$z"
|
---|
373 | fi
|
---|
374 |
|
---|
375 |
|
---|
376 | fi
|
---|
377 | # want signed
|
---|
378 | fi
|
---|
379 |
|
---|
380 | #------------------------------------------------------------
|
---|
381 | #
|
---|
382 | # Stealth options
|
---|
383 | #
|
---|
384 | #------------------------------------------------------------
|
---|
385 | $dialog \
|
---|
386 | --title "Stealth options" \
|
---|
387 | --separate-output \
|
---|
388 | --backtitle "Samhain $VERSION" \
|
---|
389 | --yesno "Samhain has some stealth options to hide its presence.\nDo you want to take advantage of these ?" \
|
---|
390 | 10 75 \
|
---|
391 | 2> $tmp
|
---|
392 |
|
---|
393 | mtest=$?
|
---|
394 | if [ $mtest = -1 ]; then
|
---|
395 | exit 1
|
---|
396 | fi
|
---|
397 | if [ $mtest = 0 ]; then
|
---|
398 |
|
---|
399 | $dialog \
|
---|
400 | --title "Stealth options" \
|
---|
401 | --backtitle "Samhain $VERSION" \
|
---|
402 | --radiolist "Full stealth mode will hide ascii strings within the binary, and use a config file that is hidden by steganography within an image file. Micro stealth is just strings hiding, without the stego config file." \
|
---|
403 | 20 75 4 \
|
---|
404 | 'full' "Enable full stealth mode" off \
|
---|
405 | 'micro' "Enable micro stealth mode" on \
|
---|
406 | 'none' "None of both" off \
|
---|
407 | 2> $tmp
|
---|
408 |
|
---|
409 | mtest=$?
|
---|
410 | if [ $mtest = -1 ]; then
|
---|
411 | exit 1
|
---|
412 | fi
|
---|
413 | if [ $mtest = 0 ]; then
|
---|
414 | mfile=`cat $tmp`
|
---|
415 | for z in $mfile ; do
|
---|
416 | mtest=$z
|
---|
417 | done
|
---|
418 | else
|
---|
419 | mtest="none"
|
---|
420 | fi
|
---|
421 |
|
---|
422 | if [ "x$mtest" != "xnone" ]; then
|
---|
423 |
|
---|
424 | if [ "x$mtest" = "xfull" ]; then
|
---|
425 | FULL_STEALTH="yes"
|
---|
426 | fi
|
---|
427 |
|
---|
428 | $dialog \
|
---|
429 | --title 'Stealth options' \
|
---|
430 | --backtitle "Samhain $VERSION" \
|
---|
431 | --inputbox "Please select a number between 128 and 255. This number will be used to obfuscate strings within the binary by xoring them." 10 75 "137" \
|
---|
432 | 2> $tmp
|
---|
433 |
|
---|
434 | mtest=$?
|
---|
435 | if [ $mtest = -1 ]; then
|
---|
436 | exit 1
|
---|
437 | fi
|
---|
438 | if [ $mtest = 0 ]; then
|
---|
439 | mfile=`cat $tmp`
|
---|
440 | for z in $mfile ; do
|
---|
441 | mnum=$z
|
---|
442 | done
|
---|
443 | else
|
---|
444 | mnum="137"
|
---|
445 | fi
|
---|
446 |
|
---|
447 | if [ "x$FULL_STEALTH" = "xyes" ]; then
|
---|
448 | cfgline="$cfgline --enable-stealth=$mnum"
|
---|
449 | else
|
---|
450 | cfgline="$cfgline --enable-micro-stealth=$mnum"
|
---|
451 | fi
|
---|
452 |
|
---|
453 | # if [ "x$mtest" != "xnone" ]; then
|
---|
454 | fi
|
---|
455 |
|
---|
456 |
|
---|
457 | $dialog \
|
---|
458 | --title 'Stealth options' \
|
---|
459 | --backtitle "Samhain $VERSION" \
|
---|
460 | --inputbox "Please choose a new name to replace \"samhain\" upon installation" \
|
---|
461 | 10 75 "samhain" \
|
---|
462 | 2> $tmp
|
---|
463 |
|
---|
464 | mtest=$?
|
---|
465 | if [ $mtest = -1 ]; then
|
---|
466 | exit 1
|
---|
467 | fi
|
---|
468 | if [ $mtest = 0 ]; then
|
---|
469 | mfile=`cat $tmp`
|
---|
470 | for z in $mfile ; do
|
---|
471 | cfgline="$cfgline --enable-install-name=$z"
|
---|
472 | done
|
---|
473 | fi
|
---|
474 |
|
---|
475 | $dialog \
|
---|
476 | --title "Stealth options" \
|
---|
477 | --separate-output \
|
---|
478 | --backtitle "Samhain $VERSION" \
|
---|
479 | --inputbox "You can set a magic string such that command line arguments will be ignored unless the first argument is this magic string, and read from stdin otherwise. If you do not want this, select CANCEL, otherwise choose a string and select OK." \
|
---|
480 | 10 75 "foo" \
|
---|
481 | 2> $tmp
|
---|
482 |
|
---|
483 | mtest=$?
|
---|
484 | if [ $mtest = -1 ]; then
|
---|
485 | exit 1
|
---|
486 | fi
|
---|
487 | if [ $mtest = 0 ]; then
|
---|
488 | mfile=`cat $tmp`
|
---|
489 | for z in $mfile ; do
|
---|
490 | cfgline="$cfgline --enable-nocl=$z"
|
---|
491 | done
|
---|
492 | fi
|
---|
493 |
|
---|
494 | if [ "x$I386_LINUX" = "xyes" ]; then
|
---|
495 | $dialog \
|
---|
496 | --title "Stealth options" \
|
---|
497 | --separate-output \
|
---|
498 | --backtitle "Samhain $VERSION" \
|
---|
499 | --yesno "SAMHAIN can compile and install a kernel module to hide the SAMHAIN daemon process. Do you want that ?"\
|
---|
500 | 2> $tmp
|
---|
501 |
|
---|
502 | mtest=$?
|
---|
503 |
|
---|
504 | if [ $mtest = -1 ]; then
|
---|
505 | exit 1
|
---|
506 | fi
|
---|
507 | if [ $mtest = 0 ]; then
|
---|
508 | cfgline="$cfgline --enable-khide"
|
---|
509 | fi
|
---|
510 |
|
---|
511 | # f [ "x$I386_LINUX" = "xyes" ]; then
|
---|
512 | fi
|
---|
513 |
|
---|
514 | # want stealth
|
---|
515 | fi
|
---|
516 |
|
---|
517 | #------------------------------------------------------------
|
---|
518 | #
|
---|
519 | # Paths to configure
|
---|
520 | #
|
---|
521 | #------------------------------------------------------------
|
---|
522 | $dialog \
|
---|
523 | --title 'Paths' \
|
---|
524 | --backtitle "Samhain $VERSION" \
|
---|
525 | --radiolist "Do you wish to change the default paths ?\n\nThe default paths are:\n\n /usr/local/sbin all binaries\n /etc/samhainrc configuration file\n /var/lib/samhain/samhain_file data file\n /var/log/samhain_log log file\n /var/run/samhain.pid pid file $HTML" 20 76 5 \
|
---|
526 | 'usr' "Install binaries in /usr/sbin" off \
|
---|
527 | 'opt' "Use /opt/samhain, /etc/opt, /var/opt" off \
|
---|
528 | 'all' "Set paths individually" off \
|
---|
529 | 'cancel' "Don't change the paths" on \
|
---|
530 | 2> $tmp
|
---|
531 |
|
---|
532 | mtest=$?
|
---|
533 | if [ $mtest = -1 ]; then
|
---|
534 | exit 1
|
---|
535 | fi
|
---|
536 | if [ $mtest = 0 ]; then
|
---|
537 | #
|
---|
538 | # edit paths
|
---|
539 | #
|
---|
540 | mfile=`cat $tmp`
|
---|
541 | for z in $mfile ; do
|
---|
542 | if [ "x$z" = "xopt" ]; then
|
---|
543 | cfgline="$cfgline --prefix=OPT"
|
---|
544 | fi
|
---|
545 | if [ "x$z" = "xusr" ]; then
|
---|
546 | cfgline="$cfgline --prefix=USR"
|
---|
547 | fi
|
---|
548 | if [ "x$z" = "xall" ]; then
|
---|
549 | $dialog \
|
---|
550 | --title 'Paths' \
|
---|
551 | --backtitle "Samhain $VERSION" \
|
---|
552 | --inputbox "Exec prefix" 10 75 "/usr/local" \
|
---|
553 | 2> $tmp
|
---|
554 |
|
---|
555 | mtest=$?
|
---|
556 | if [ $mtest = -1 ]; then
|
---|
557 | exit 1
|
---|
558 | fi
|
---|
559 | if [ $mtest = 0 ]; then
|
---|
560 | mfile=`cat $tmp`
|
---|
561 | for z in $mfile ; do
|
---|
562 | cfgline="$cfgline --exec-prefix=$z"
|
---|
563 | done
|
---|
564 | fi
|
---|
565 |
|
---|
566 |
|
---|
567 | $dialog \
|
---|
568 | --title 'Paths' \
|
---|
569 | --backtitle "Samhain $VERSION" \
|
---|
570 | --inputbox "Configuration" 10 75 "/etc/samhainrc" \
|
---|
571 | 2> $tmp
|
---|
572 |
|
---|
573 | mtest=$?
|
---|
574 | if [ $mtest = -1 ]; then
|
---|
575 | exit 1
|
---|
576 | fi
|
---|
577 | if [ $mtest = 0 ]; then
|
---|
578 | mfile=`cat $tmp`
|
---|
579 | for z in $mfile ; do
|
---|
580 | cfgline="$cfgline --with-config-file=$z"
|
---|
581 | done
|
---|
582 | fi
|
---|
583 |
|
---|
584 | $dialog \
|
---|
585 | --title 'Paths' \
|
---|
586 | --backtitle "Samhain $VERSION" \
|
---|
587 | --inputbox "Man pages" 10 75 "/usr/local/share/man" \
|
---|
588 | 2> $tmp
|
---|
589 |
|
---|
590 | mtest=$?
|
---|
591 | if [ $mtest = -1 ]; then
|
---|
592 | exit 1
|
---|
593 | fi
|
---|
594 | if [ $mtest = 0 ]; then
|
---|
595 | mfile=`cat $tmp`
|
---|
596 | for z in $mfile ; do
|
---|
597 | cfgline="$cfgline --with-mandir=$z"
|
---|
598 | done
|
---|
599 | fi
|
---|
600 |
|
---|
601 | $dialog \
|
---|
602 | --title 'Paths' \
|
---|
603 | --backtitle "Samhain $VERSION" \
|
---|
604 | --inputbox "Database" 10 75 "/var/lib/samhain/samhain_data" \
|
---|
605 | 2> $tmp
|
---|
606 |
|
---|
607 | mtest=$?
|
---|
608 | if [ $mtest = -1 ]; then
|
---|
609 | exit 1
|
---|
610 | fi
|
---|
611 | if [ $mtest = 0 ]; then
|
---|
612 | mfile=`cat $tmp`
|
---|
613 | for z in $mfile ; do
|
---|
614 | cfgline="$cfgline --with-data-file=$z"
|
---|
615 | done
|
---|
616 | fi
|
---|
617 |
|
---|
618 | $dialog \
|
---|
619 | --title 'Paths' \
|
---|
620 | --backtitle "Samhain $VERSION" \
|
---|
621 | --inputbox "Log file" 10 75 "/var/log/samhain_log" \
|
---|
622 | 2> $tmp
|
---|
623 |
|
---|
624 | mtest=$?
|
---|
625 | if [ $mtest = -1 ]; then
|
---|
626 | exit 1
|
---|
627 | fi
|
---|
628 | if [ $mtest = 0 ]; then
|
---|
629 | mfile=`cat $tmp`
|
---|
630 | for z in $mfile ; do
|
---|
631 | cfgline="$cfgline --with-log-file=$z"
|
---|
632 | done
|
---|
633 | fi
|
---|
634 |
|
---|
635 | $dialog \
|
---|
636 | --title 'Paths' \
|
---|
637 | --backtitle "Samhain $VERSION" \
|
---|
638 | --inputbox "Lock file" 10 75 "/var/run/samhain.pid" \
|
---|
639 | 2> $tmp
|
---|
640 |
|
---|
641 | mtest=$?
|
---|
642 | if [ $mtest = -1 ]; then
|
---|
643 | exit 1
|
---|
644 | fi
|
---|
645 | if [ $mtest = 0 ]; then
|
---|
646 | mfile=`cat $tmp`
|
---|
647 | for z in $mfile ; do
|
---|
648 | cfgline="$cfgline --with-pid-file=$z"
|
---|
649 | done
|
---|
650 | fi
|
---|
651 |
|
---|
652 | if [ "x$INET" = "xyes" ]; then
|
---|
653 | $dialog \
|
---|
654 | --title 'Paths' \
|
---|
655 | --backtitle "Samhain $VERSION" \
|
---|
656 | --inputbox "Server status" 10 75 "/var/lib/samhain/samhain.html" \
|
---|
657 | 2> $tmp
|
---|
658 |
|
---|
659 | mtest=$?
|
---|
660 | if [ $mtest = -1 ]; then
|
---|
661 | exit 1
|
---|
662 | fi
|
---|
663 | if [ $mtest = 0 ]; then
|
---|
664 | mfile=`cat $tmp`
|
---|
665 | for z in $mfile ; do
|
---|
666 | cfgline="$cfgline --with-html-file=$z"
|
---|
667 | done
|
---|
668 | fi
|
---|
669 | # if [ "x$INET" = "xyes" ]; then
|
---|
670 | fi
|
---|
671 |
|
---|
672 | fi
|
---|
673 |
|
---|
674 | done
|
---|
675 | # edit paths
|
---|
676 | fi
|
---|
677 |
|
---|
678 |
|
---|
679 | if [ ! -f "configure" ] ; then
|
---|
680 | bail_error "Setup problem... try to install manually"
|
---|
681 | fi
|
---|
682 |
|
---|
683 | echo "./configure $cfgline" > Install.log 2>/dev/null
|
---|
684 |
|
---|
685 | if [ $? != 0 ]; then
|
---|
686 | $dialog --infobox "ERROR writing to \"Install.log\".\n\nAborting." 10 55
|
---|
687 | exit 1
|
---|
688 | fi
|
---|
689 |
|
---|
690 |
|
---|
691 |
|
---|
692 | if [ "x$KCHECK" = "xyes" ]; then
|
---|
693 | if [ `id -u` != 0 ]; then
|
---|
694 | $dialog --msgbox "Compiling with --with-kcheck option (kernel rootkit detection). This\nrequires root privileges for at least one command during compilation,\nbut you are not running this as root. Please expect compilation to fail.\n\nYou need to run \"make\" manually after failure, and\nfollow the instructions to execute the one required\ncommand as root." 20 75
|
---|
695 | fi
|
---|
696 | fi
|
---|
697 |
|
---|
698 |
|
---|
699 | if [ -n "$gauge" ] ; then
|
---|
700 | (
|
---|
701 | sfail=0
|
---|
702 | echo 20
|
---|
703 | rm -f config.cache 2> /dev/null
|
---|
704 | echo 30
|
---|
705 | if [ -z "$cfgline2" ]; then
|
---|
706 | ./configure $cfgline >> Install.log 2>&1
|
---|
707 | else
|
---|
708 | ./configure $cfgline --with-checksum="$cfgline2" >> Install.log 2>&1
|
---|
709 | fi
|
---|
710 | cfail=$?
|
---|
711 | echo 50
|
---|
712 | if [ $cfail = 0 ]; then
|
---|
713 | make clean >> Install.log 2>&1
|
---|
714 | cfail=$?
|
---|
715 | else
|
---|
716 | sfail=1
|
---|
717 | fi
|
---|
718 | echo 60
|
---|
719 | if [ $cfail = 0 ]; then
|
---|
720 | make >> Install.log 2>&1
|
---|
721 | cfail=$?
|
---|
722 | else
|
---|
723 | sfail=1
|
---|
724 | fi
|
---|
725 | echo 80
|
---|
726 | if [ $cfail = 0 ]; then
|
---|
727 | make install >> Install.log 2>&1
|
---|
728 | cfail=$?
|
---|
729 | else
|
---|
730 | sfail=1
|
---|
731 | fi
|
---|
732 | echo 100
|
---|
733 | echo cfail=$cfail > $tmp
|
---|
734 | echo sfail=$sfail >> $tmp
|
---|
735 | ) | $dialog \
|
---|
736 | --title 'Compilation and installation' \
|
---|
737 | --backtitle "Samhain $VERSION" \
|
---|
738 | "$gauge" 'Please wait...' 10 75 10
|
---|
739 | else
|
---|
740 | sfail=0
|
---|
741 | rm -f config.cache 2> /dev/null
|
---|
742 | $dialog --infobox "Running configure ..." 4 44
|
---|
743 | if [ -z "$cfgline2" ]; then
|
---|
744 | ./configure $cfgline >> Install.log 2>&1
|
---|
745 | else
|
---|
746 | ./configure $cfgline --with-checksum="$cfgline2" >> Install.log 2>&1
|
---|
747 | fi
|
---|
748 | cfail=$?
|
---|
749 | if [ $cfail = 0 ]; then
|
---|
750 | $dialog --infobox "Running make clean ..." 4 44
|
---|
751 | make clean >> Install.log 2>&1
|
---|
752 | cfail=$?
|
---|
753 | else
|
---|
754 | sfail=1
|
---|
755 | fi
|
---|
756 | if [ $cfail = 0 ]; then
|
---|
757 | $dialog --infobox "Running make ..." 4 44
|
---|
758 | make >> Install.log 2>&1
|
---|
759 | cfail=$?
|
---|
760 | else
|
---|
761 | sfail=1
|
---|
762 | fi
|
---|
763 | if [ $cfail = 0 ]; then
|
---|
764 | $dialog --infobox "Running make install ..." 4 44
|
---|
765 | make install >> Install.log 2>&1
|
---|
766 | cfail=$?
|
---|
767 | else
|
---|
768 | sfail=1
|
---|
769 | fi
|
---|
770 | echo cfail=$cfail > $tmp
|
---|
771 | echo sfail=$sfail >> $tmp
|
---|
772 | fi
|
---|
773 |
|
---|
774 | . $tmp
|
---|
775 |
|
---|
776 |
|
---|
777 | echo "SAMHAIN is now installed on your system." > $tmp
|
---|
778 | echo "Please read the documentation to know how to run it." >> $tmp
|
---|
779 |
|
---|
780 |
|
---|
781 | if [ "x$sfail" = "x0" ] ; then
|
---|
782 |
|
---|
783 | if [ "x$cfail" = "x0" ] ; then
|
---|
784 | if [ "x${FULL_STEALTH}" = "xyes" ]; then
|
---|
785 | tail -21 Install.log >> $tmp
|
---|
786 | else
|
---|
787 | tail -11 Install.log >> $tmp
|
---|
788 | fi
|
---|
789 | $dialog --title "Build report (use arrow keys to scroll the text box)" \
|
---|
790 | --backtitle "Samhain $VERSION installed. PLEASE READ THE MANUAL." \
|
---|
791 | --textbox \
|
---|
792 | $tmp \
|
---|
793 | 20 75
|
---|
794 | else
|
---|
795 | $dialog --title "Problem report" \
|
---|
796 | --backtitle "Samhain $VERSION: Build failed (see Install.log):" \
|
---|
797 | --msgbox \
|
---|
798 | "Compilation was successful, but you need to be root in\norder to install the files to the selected prefix.\nPlease run 'make install' as root." \
|
---|
799 | 10 75
|
---|
800 | fi
|
---|
801 |
|
---|
802 | else
|
---|
803 |
|
---|
804 | MSG=`tail -10 Install.log`
|
---|
805 | $dialog --title "Problem report" \
|
---|
806 | --backtitle "Samhain $VERSION: Build failed (see Install.log):" \
|
---|
807 | --msgbox "$MSG" 20 75
|
---|
808 |
|
---|
809 | fi
|
---|
810 |
|
---|
811 | rm -f $tmp
|
---|
812 |
|
---|
813 | exit 0
|
---|
814 |
|
---|
815 |
|
---|
816 |
|
---|
817 |
|
---|
818 |
|
---|
819 |
|
---|