-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathe-smith-ldap-5.2.0-unix-cleanup.patch
35 lines (32 loc) · 1.58 KB
/
e-smith-ldap-5.2.0-unix-cleanup.patch
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
diff -up e-smith-ldap-5.2.0/createlinks.unix-cleanup e-smith-ldap-5.2.0/createlinks
--- e-smith-ldap-5.2.0/createlinks.unix-cleanup 2010-11-02 09:15:20.000000000 -0600
+++ e-smith-ldap-5.2.0/createlinks 2010-11-02 09:14:30.000000000 -0600
@@ -30,6 +30,7 @@ event_link("ldap-update", "ibay-modify",
event_link("ldap-delete", "ibay-delete", "55");
event_link("ldap-update", "bootstrap-ldap-save", "25");
+event_link("cleanup-unix-user-group", "bootstrap-ldap-save", "98");
event_link("ldap-update", "machine-account-create", "95");
diff -up e-smith-ldap-5.2.0/root/etc/e-smith/events/actions/cleanup-unix-user-group.unix-cleanup e-smith-ldap-5.2.0/root/etc/e-smith/events/actions/cleanup-unix-user-group
--- e-smith-ldap-5.2.0/root/etc/e-smith/events/actions/cleanup-unix-user-group.unix-cleanup 2010-11-02 09:13:34.000000000 -0600
+++ e-smith-ldap-5.2.0/root/etc/e-smith/events/actions/cleanup-unix-user-group 2010-11-02 09:13:20.000000000 -0600
@@ -0,0 +1,20 @@
+#!/bin/bash -e
+
+ldapauth=$(/sbin/e-smith/config getprop ldap Authentication || echo disabled)
+
+# Exit unless ldap auth is enabled
+[ "$ldapauth" == "enabled" ] || exit 0
+
+# Users and group accounts are now stored in LDAP, so we need to delete them
+# from the old passwd / group / shadow database
+
+for USER in $(/usr/bin/getent passwd | sort | cut -d':' -f1 | uniq -d); do
+ /usr/sbin/luserdel -G $USER
+done
+
+for GROUP in $(/usr/bin/getent group | sort | cut -d':' -f1 | uniq -d); do
+ /usr/sbin/lgroupdel $GROUP
+done
+
+# And add the admin back in the root group, which is not in the LDAP database
+/usr/bin/gpasswd -a admin root