blob: a31b8d6f91002bed21047547e4f1a1eed3cbaa86 (
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
|
#!/bin/sh
#################################################################################
#
# Lynis
# ------------------
#
# Copyright 2007-2013, Michael Boelen
# Copyright 2013-2016, CISOfy
#
# Website : https://cisofy.com
# Blog : http://linux-audit.com
# GitHub : https://github.com/CISOfy/lynis
#
# Lynis comes with ABSOLUTELY NO WARRANTY. This is free software, and you are
# welcome to redistribute it under the terms of the GNU General Public License.
# See LICENSE file for usage of this software.
#
######################################################################
#
# Helper program to configure Lynis
#
######################################################################
#
# How to use:
# ------------
#
# Run:
# lynis configure settings quick
# lynis configure settings quick=yes:debug=yes
#
######################################################################
CONFIGURE_CRONJOB=0
CONFIGURE_SETTINGS=0
# Check configure mode
if [ "${HELPER_PARAMS}" = "" ]; then
${ECHOCMD} "${YELLOW}Provide one or more configuration settings${NORMAL}"
${ECHOCMD} ""
${ECHOCMD} "Examples:"
${ECHOCMD} " $0 configure cronjob"
${ECHOCMD} ""
${ECHOCMD} " $0 configure settings quick"
${ECHOCMD} " $0 configure settings debug:developer-mode:quick"
${ECHOCMD} " $0 configure settings debug=yes:developer-mode=no:quick=yes"
${ECHOCMD} ""
ExitClean
elif [ "$1" = "cronjob" ]; then
CONFIGURE_CRONJOB=1
elif [ "$1" = "settings" ]; then
CONFIGURE_SETTINGS=1
fi
# Perform activities depending on requested task
if [ ${CONFIGURE_CRONJOB} -eq 1 ]; then
${ECHOCMD} "Automatic configuration for cronjobs is not implemented yet."
ExitClean
elif [ ${CONFIGURE_SETTINGS} -eq 1 ]; then
# Determine where profiles are stored
if [ -z "${PROFILEDIR}" ]; then
${ECHOCMD} "Can not configure Lynis, as profile directory is unknown"
ExitFatal
fi
if [ -z "${CUSTOM_PROFILE}" ]; then
${ECHOCMD} "No custom profile found yet."
${ECHOCMD} "Suggestion: create one with 'touch custom.prf' or 'touch /etc/lynis/custom.prf'"
ExitFatal
fi
FIND=$(echo ${HELPER_PARAMERS} | grep " ")
if [ ! "${FIND}" = "" ]; then ${ECHOCMD} "Found invalid character (space) in configuration string"; ExitFatal; fi
CONFIGURE_SETTINGS=$(echo $2 | sed 's/:/ /g')
for I in ${CONFIGURE_SETTINGS}; do
SETTING=$(echo ${I} | awk -F= '{print $1}')
VALUE=$(echo ${I} | awk -F= '{print $2}')
if [ "${VALUE}" = "" ]; then
${ECHOCMD} "Profile: ${CUSTOM_PROFILE}"
Debug "Did not find a value configured on the command line for setting ${SETTING}"
#read VALUE
else
Debug "Setting '${SETTING}' should be configured with value '${VALUE}'"
FIND=$(grep "^${SETTING}" ${CUSTOM_PROFILE})
if [ "${FIND}" = "" ]; then
${ECHOCMD} "Configuring setting '${CYAN}${SETTING}${NORMAL}'"
echo "${SETTING}=${VALUE}" >> ${CUSTOM_PROFILE}
if [ $? -eq 0 ]; then ${ECHOCMD} "${GREEN}Setting changed${NORMAL}"; fi
else
${ECHOCMD} "${YELLOW}Notice${NORMAL}: Setting '${CYAN}${SETTING}${NORMAL}' was already configured (not changed)${NORMAL}"
${ECHOCMD} " Current value: ${WHITE}${FIND}${NORMAL}"
${ECHOCMD} ""
fi
fi
# Now check if value is in line with expected type (boolean, integer, string)
# =To be implemented=
done
${ECHOCMD} ""
${ECHOCMD} ""
ExitClean
fi
ExitClean
# The End
|