#!/bin/sh # ############################################## # /usr/local/bin/check-for-pw-reset4.sh by Axel Werner (mail@awerner.myhome-server.de) # # FREE for Use/modify/copy as long you include my Name and eMail Adress as original Source. # SELLING of this Script or even Parts of this Script is not allowed! # # This Script is to be sourced by /etc/profile or similar login script to # check a users homedir for a "Flare"-File dropped by the Administrator after # he reset the Users password. If that Flare-File is found the user is been # forced to change his password for security reasons. # ############################################### # # Version: 2009-07-20 # # # Version History: # # 2008-01-22 first Release by Axel Werner # 2009-02-26 change: removed that "flare file" check. only check if pwdReset flag is set in LDAP. # Else dont force user to reset pw as its been already set by samba or something else. # 2009-03-05 add: since debian 5.0 the "grace login" feature of openldaps ppolicy overlay got fixed. # therefor its nesesary to handly with it so users with expired passwords are not # getting locked out permanently. i added a check for grace logins so the user gets # a warning and an information about how many grace logins he got left. # 2009-03-16 add: notice added that the user needs to change samba pw separatly # change: re-added the "flare file" check. because there are problems with the pwdreset attribut # which locks out the user for some reason. # 2009-07-20 change: Enabled TLS by adding -ZZ to any LDAP Command # # ############################################## # # #set -x # set the default ppolicy for normal users here so i can lookup their grace logins ppolicydn='cn=default,ou=policies,dc=someou,dc=higherou,dc=de' flare='.password-reset-required' flag=false # check for ldap attribut 'pwdReset' if users pw has been reseted by admin flag=`ldapsearch -ZZ -x -LLL '(uid='"${USER}"')' 'pwdReset' | grep pwdReset | cut -s -f2 -d':'` # check for flare-file if users pw has been reseted by admin if test -f ~/${flare}; then { #echo "Flare-File found in Homedirectory..." flag=' TRUE' } fi if [ "${flag}" = ' TRUE' ] ; then cat < /dev/null 2>&1 cat <