diff options
author | root <root@plonk.spline.inf.fu-berlin.de> | 2011-02-01 18:04:52 +0100 |
---|---|---|
committer | root <root@plonk.spline.inf.fu-berlin.de> | 2011-02-01 18:04:52 +0100 |
commit | 77205d26ead19ab6f63c63f9b1875e30a6158805 (patch) | |
tree | 61ce1badadb23073be4a7a62d5a9113f87a3569b | |
parent | cdb59abdde1a303d1e962142b3955132d9839996 (diff) | |
download | usermanagement-77205d26ead19ab6f63c63f9b1875e30a6158805.tar.gz usermanagement-77205d26ead19ab6f63c63f9b1875e30a6158805.tar.xz usermanagement-77205d26ead19ab6f63c63f9b1875e30a6158805.zip |
added checklog script to check if user exists, that were not created with the lduseradd script
-rwxr-xr-x | checklog | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/checklog b/checklog new file mode 100755 index 0000000..22f84bc --- /dev/null +++ b/checklog @@ -0,0 +1,30 @@ +#!/bin/bash +# Copyright (c) 2011 Alexander Sulfrian +# This script should check if only that user exists, that are created +# by the lduseradd script. + +tmp=$(mktemp) +ldapsearch | grep "^dn: uid=[a-z]\+,ou=People,dc=spline" | sort > "${tmp}" + +grep -v "^[[:blank:]]*\(#\|$\)" /var/db/useradd/users.log | sort | \ + diff -u - "${tmp}" | \ + sed -n 's/^+dn: uid=\([a-z]\+\),.*$/\1/ p' | \ + while read user; do + sendmail -t <<EOM +Subject: WARNING: New user detected! +From: root@plonk.spline.inf.fu-berlin.de +To: spline@lists.spline.inf.fuf-berlin.de + +WARNING: The following user was not created by the lduseradd tool + +$(ldapsearch -LLL "uid=$user") +EOM + + echo "# new user detected at: $(date)" >> /var/db/useradd/users.log + echo "# WARNING: THIS USER WAS NOT CREATED BY THE LDUSERADD TOOL" >> /var/db/useradd/users.log + echo "dn: uid=$user,ou=People,dc=spline,dc=inf,dc=fu-berlin,dc=de" >> /var/db/useradd/users.log + echo >> /var/db/useradd/users.log + done + +# clean up +rm -f ${tmp} |