Skip to content

Commit 36d7303

Browse files
committed
security stuff
1 parent 314e6a7 commit 36d7303

File tree

15 files changed

+138
-84
lines changed

15 files changed

+138
-84
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
dn: olcDatabase={1}hdb,cn=config
2+
changetype: modify
3+
delete: olcAccess
4+
-
5+
add: olcAccess
6+
olcAccess: {0}to attrs=userPassword,shadowLastChange by self write by anonymous auth by dn="cn=admin,dc=example,dc=org" write by * none
7+
-
8+
add: olcAccess
9+
olcAccess: {1}to dn.base="" by * read
10+
-
11+
add: olcAccess
12+
olcAccess: {2}to * by self write by dn="cn=admin,dc=example,dc=org" write by * none
13+
-
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-----BEGIN DH PARAMETERS-----
2+
MIIBCAKCAQEA7adhygsX/CvbcQBlSEKBmm0D0+hVfIttcftyFTuDPNok4yDJUBUF
3+
zzc7X/i3PUMzANhShBrngBaXbOhVk3QcjMC623TPhFmILx0r236+aQEUGnlwN73M
4+
RUFM6EblYgH4+E4nv+JLwzHdO72+qMAd92rtzVMiaDlCWghH6wdAFoasTsT6Posc
5+
F5T8WCkzFAZeVhNGRKPP6k3l2BjvRJzkwYMMJrxaIYznMEK6H5CYIqZcpeAB3d2B
6+
NaZXLxFCemLrSS16UHrH1modEe8yjrOaE5+ZesGAA9onsNRZkAJp0x/pRaO/+rHn
7+
Q5QVCQCzxY16UsLzH0q/P80xPMU7BMoocwIBAg==
8+
-----END DH PARAMETERS-----

β€Žimage/service/slapd/container-start.shβ€Ž

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,26 @@ chown -R openldap:openldap /etc/ldap
99
# container first start
1010
if [ ! -e "$FIRST_START_DONE" ]; then
1111

12+
function get_base_dn(){
13+
BASE_DN=""
14+
IFS='.' read -ra BASE_DN_TABLE <<< "$LDAP_DOMAIN"
15+
for i in "${BASE_DN_TABLE[@]}"; do
16+
EXT="dc=$i,"
17+
BASE_DN=$BASE_DN$EXT
18+
done
19+
20+
BASE_DN=${BASE_DN::-1}
21+
}
22+
23+
function is_new_schema(){
24+
local COUNT=$(ldapsearch -Q -Y EXTERNAL -H ldapi:/// -b cn=schema,cn=config cn | grep -c $1)
25+
if [ "$COUNT" -eq 0 ]; then
26+
echo 1
27+
else
28+
echo 0
29+
fi
30+
}
31+
1232
# database is uninitialized
1333
if [ -z "$(ls -A /var/lib/ldap)" ]; then
1434

@@ -29,20 +49,21 @@ slapd slapd/dump_database select when needed
2949
EOF
3050

3151
dpkg-reconfigure -f noninteractive slapd
32-
fi
3352

53+
# start OpenLDAP
54+
slapd -h "ldapi:///" -u openldap -g openldap
3455

35-
function is_new_schema(){
36-
local COUNT=$(ldapsearch -Q -Y EXTERNAL -H ldapi:/// -b cn=schema,cn=config cn | grep -c $1)
37-
if [ "$COUNT" -eq 0 ]; then
38-
echo 1
39-
else
40-
echo 0
41-
fi
42-
}
56+
get_base_dn
57+
sed -i "s|dc=example,dc=org|$BASE_DN|g" /osixia/slapd/security.ldif
58+
59+
ldapmodify -Y EXTERNAL -Q -H ldapi:/// -f /osixia/slapd/security.ldif
60+
61+
else
4362

44-
# start OpenLDAP
45-
slapd -h "ldapi:///" -u openldap -g openldap
63+
# start OpenLDAP
64+
slapd -h "ldapi:///" -u openldap -g openldap
65+
66+
fi
4667

4768
# add ppolicy schema if not already exists
4869
ADD_PPOLICY=$(is_new_schema ppolicy)
@@ -64,7 +85,6 @@ function is_new_schema(){
6485
sed -i "s,/osixia/slapd/ssl/ldap.crt,/osixia/slapd/ssl/${SSL_CRT_FILENAME},g" /osixia/slapd/tls.ldif
6586
sed -i "s,/osixia/slapd/ssl/ldap.key,/osixia/slapd/ssl/${SSL_KEY_FILENAME},g" /osixia/slapd/tls.ldif
6687

67-
# set tls config
6888
ldapmodify -Y EXTERNAL -Q -H ldapi:/// -f /osixia/slapd/tls.ldif
6989

7090
# add localhost route to certificate cn (need docker 1.5.0)

β€Žtest/config/cn=config.ldifβ€Ž

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
2-
# CRC32 eb45b050
2+
# CRC32 46c15dd8
33
dn: cn=config
44
objectClass: olcGlobal
55
cn: config
@@ -11,6 +11,6 @@ entryUUID: db089696-51e1-1034-95ec-9d03bc6be361
1111
creatorsName: cn=config
1212
createTimestamp: 20150226090154Z
1313
olcLogLevel: stats
14-
entryCSN: 20150505124437.961383Z#000000#000#000000
14+
entryCSN: 20150511154546.689799Z#000000#000#000000
1515
modifiersName: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
16-
modifyTimestamp: 20150505124437Z
16+
modifyTimestamp: 20150511154546Z
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,11 @@
11
# AUTO-GENERATED FILE - DO NOT EDIT!! Use ldapmodify.
2-
# CRC32 8b1aead3
2+
# CRC32 4f6c59f2
33
dn: olcDatabase={1}hdb
44
objectClass: olcDatabaseConfig
55
objectClass: olcHdbConfig
66
olcDatabase: {1}hdb
77
olcDbDirectory: /var/lib/ldap
88
olcSuffix: dc=test,dc=osixia,dc=net
9-
olcAccess: {0}to attrs=userPassword,shadowLastChange by self write by anonymou
10-
s auth by dn="cn=admin,dc=test,dc=osixia,dc=net" write by * none
11-
olcAccess: {1}to dn.base="" by * read
12-
olcAccess: {2}to * by self write by dn="cn=admin,dc=test,dc=osixia,dc=net" wri
13-
te by * read
149
olcLastMod: TRUE
1510
olcRootDN: cn=admin,dc=test,dc=osixia,dc=net
1611
olcRootPW:: e1NTSEF9bU9FWlh4OUpPNmlhK1dkeFV4S0FKam43R3dmNVJrby8=
@@ -24,6 +19,11 @@ structuralObjectClass: olcHdbConfig
2419
entryUUID: db09539c-51e1-1034-95f6-9d03bc6be361
2520
creatorsName: cn=config
2621
createTimestamp: 20150226090154Z
27-
entryCSN: 20150226090154.826706Z#000000#000#000000
28-
modifiersName: cn=config
29-
modifyTimestamp: 20150226090154Z
22+
olcAccess: {0}to attrs=userPassword,shadowLastChange by self write by anonymou
23+
s auth by dn="cn=admin,dc=example,dc=org" write by * none
24+
olcAccess: {1}to dn.base="" by * read
25+
olcAccess: {2}to * by self write by dn="cn=admin,dc=example,dc=org" write by *
26+
none
27+
entryCSN: 20150511151550.910171Z#000000#000#000000
28+
modifiersName: gidNumber=0+uidNumber=0,cn=peercred,cn=external,cn=auth
29+
modifyTimestamp: 20150511151550Z

β€Žtest/database/__db.001β€Ž

0 Bytes
Binary file not shown.

β€Žtest/database/__db.002β€Ž

0 Bytes
Binary file not shown.

β€Žtest/database/__db.003β€Ž

0 Bytes
Binary file not shown.

β€Žtest/database/alockβ€Ž

0 Bytes
Binary file not shown.

β€Žtest/database/log.0000000001β€Ž

0 Bytes
Binary file not shown.

0 commit comments

Comments
Β (0)