This file is indexed.

/usr/share/yasat/plugins/ldap.test is in yasat 526-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/bin/sh
################################################################################
#                                                                              #
#   Copyright (C) 2008-2012 LABBE Corentin <corentin.labbe@geomatys.fr>
#
#    YASAT is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    YASAT is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with YASAT.  If not, see <http://www.gnu.org/licenses/>.
#                                                                              #
################################################################################


POSSIBLE_OPENLDAP_CONF="/etc/openldap/ldap.conf /usr/local/etc/openldap/ldap.conf"
OPENLDAP_CONF="/etc/openldap/ldap.conf"

for LOCATION in ${POSSIBLE_OPENLDAP_CONF}
do
	if [ -e "${LOCATION}" ] ; then
		OPENLDAP_CONF="${LOCATION}"
	fi
done

OPENSLAPD_CONF="`dirname $OPENLDAP_CONF`/slapd.conf"

Title "Check OPENLDAP"

if [ ! -e "$OPENLDAP_CONF" ] ; then
	return 1;
fi

Display --indent 2 --text "$OPENLDAP_CONF" --result FOUND --color BLUE
#get_simple_right $OPENLDAP_CONF
#if [ "$RESULTAT" = '644' ] ; then
#	Display --indent 4 --text "Right of $OPENLDAP_CONF" --result OK --color GREEN
#else
#	Display --indent 4 --text "Right of $OPENLDAP_CONF" --result "$RESULTAT" --color RED
#fi
check_a_file "$OPENLDAP_CONF" 2 root root 644

if [ ! -e "$OPENSLAPD_CONF" ]
then
	return 1;
fi

Display --indent 2 --text "$OPENSLAPD_CONF" --result FOUND --color GREEN
#get_simple_right $OPENSLAPD_CONF
#if [ "$RESULTAT" = '640' ] ; then
#	Display --indent 4 --text "Right of $OPENSLAPD_CONF" --result OK --color GREEN
#else
#	Display --indent 4 --text "Right of $OPENSLAPD_CONF" --result "$RESULTAT" --color RED
#fi
check_a_file "$OPENSLAPD_CONF" 2 root ldap 640

#TLSCertificateFile
FindValueOfEqual $OPENSLAPD_CONF TLSCertificateFile JUSTTEST
if [ ! -z "$RESULTAT" ] ; then
	Display --indent 2 --text "TLS cert $RESULTAT" --result OK --color GREEN
	check_file $RESULTAT 4 CERT
else
	Display --indent 2 --text "No cert TLS" --result ADVICE --color ORANGE --advice LDAP_NO_TLS
fi

#TLSCACertificateFile
FindValueOfEqual $OPENSLAPD_CONF TLSCACertificateFile JUSTTEST
if [ ! -z "$RESULTAT" ] ; then
	Display --indent 2 --text "TLS ca $RESULTAT" --result OK --color GREEN
	check_file $RESULTAT 4 CERT
else
	Display --indent 2 --text "No ca TLS" --result ADVICE --color ORANGE --advice LDAP_NO_TLS
fi


#TLSCertificateKeyFile
FindValueOfEqual $OPENSLAPD_CONF TLSCertificateKeyFile JUSTTEST
if [ ! -z "$RESULTAT" ] ; then
	Display --indent 2 --text "TLS key $RESULTAT" --result OK --color GREEN
	check_file $RESULTAT 4 PRIVKEY
else
	Display --indent 2 --text "No TLS key" --result ADVICE --color ORANGE --advice LDAP_NO_TLS
fi

if [ ! -z "`grep '^[[:space:]]*allow[[:space:]]bind_v2' $OPENSLAPD_CONF`" ] ; then
	Display --indent 2 --text "allow bind_v2" --result FOUND --color ORANGE --advice LDAP_BINDV2
fi

if [ -z "`grep '^[[:space:]]*disallow[[:space:]]bind_anon' $OPENSLAPD_CONF`" ] ; then
	Display --indent 2 --text "disallow bind_anon" --result NOTFOUND --color ORANGE --advice LDAP_BIND_ANON
else
	Display --indent 2 --text "disallow bind_anon" --result FOUND --color GREEN
fi
if [ -z "`grep '^[[:space:]]*require[[:space:]]authc' $OPENSLAPD_CONF`" ] ; then
	Display --indent 2 --text "require authc" --result NOTFOUND --color ORANGE --advice LDAP_REQUIRE_AUTHC
else
	Display --indent 2 --text "require authc" --result FOUND --color GREEN
fi

#TODO hint for replication

#clear password
grep rootpw $OPENSLAPD_CONF |
while read line
do
	FOUND=0
	PASS=`echo $line | sed 's/^.*rootpw[[:space:]]*//g'`
	if [ `echo $PASS |grep '{SHA}'` ] ; then
		Display --indent 2 --text "rootpw $PASS" --result SHA --color GREEN
		FOUND=1
	fi
	if [ `echo $PASS |grep '{SSHA}'` ] ; then
		Display --indent 2 --text "rootpw $PASS" --result SSHA --color GREEN
		FOUND=1
	fi

	if [ `echo $PASS |grep '{MD5}'` ] ; then
		Display --indent 2 --text "rootpw $PASS" --result MD5 --color GREEN
		FOUND=1
	fi
	if [ `echo $PASS |grep '{SMD5}'` ] ; then
		Display --indent 2 --text "rootpw $PASS" --result SMD5 --color GREEN
		FOUND=1
	fi
	if [ `echo $PASS |grep '{CLEARTEXT}'` ] ; then
		Display --indent 2 --text "rootpw $PASS" --result CLEARTEXT --color RED --advice LDAP_PASSWD_CLEAR
		FOUND=1
	fi
	if [ `echo $PASS |grep '{CRYPT}'` ] ; then
		Display --indent 2 --text "rootpw $PASS" --result CRYPT --color GREEN
		FOUND=1
	fi
	if [ $FOUND -eq 0 ] ; then
		Display --indent 2 --text "rootpw " --result CLEARTEXT --color RED --advice LDAP_PASSWD_CLEAR
	fi

done

#try to find under which user openldap is running
LDAPUSER=''
LDAPUSER="`ps aux | grep slapd |grep -v grep | cut -d\  -f1`"

if [ -z "$LDAPUSER" ] ; then
	LDAPUSER='ldap'
fi

#ubuntu use /var/lib/slapd/
#gentoo use /var/lib/openldap-data/
#redhat use /var/lib/ldap

for ldapdata in /var/lib/slapd/ /var/lib/openldap-data/
do
	if [ -e "${ldapdata}" ] ; then
		Display --indent 2 --text "LDAP DATA $ldapdata" --result FOUND --color GREEN
		TMP_RESULT="${TEMPYASATDIR}/slapd.cdo"
		check_directory_owner $ldapdata "$LDAPUSER" $TMP_RESULT 4
		TMP_RESULT="${TEMPYASATDIR}/slapd.cdg"
		check_directory_group $ldapdata "$LDAPUSER" $TMP_RESULT 4
		TMP_RESULT="${TEMPYASATDIR}/slapd.cdother"
		#TODO better advice
		check_directory_others $ldapdata $TMP_RESULT 4 GLOBAL_FILE_OTHER_READABLE
	fi
done
return 0;