스탑 갭 (Stop-gap) shadowLastChange
으로 암호 변경을 업데이트하는 Samba 용 스크립트를 만들었습니다 .
#!/bin/sh
# script to update shadowLastChange when samba updates passwords
# it's not needed when using 'passwd', it does update the field,
# even if pam_ldap is using LDAP Extented Operation to change password
LDAP_MODIFY="/usr/bin/ldapmodify"
LDAP_SEARCH="/usr/bin/ldapsearch"
LDAP_USER="uid=shadow-update,ou=Services,dc=example,dc=com"
LDAP_PASSWORD="change-me"
LDAP_HOST="localhost"
# get date
SLC=$((`date '+%s'` / 24 / 3600))
# get user login name
user=$1
# find user's DN
dn=$($LDAP_SEARCH -x -h $LDAP_HOST -LLL -b dc=example,dc=com "(uid=$user)" dn)
dn=${dn#dn:}
# check if DN is not base64 encoded
if [ "${dn:0:1}" = ":" ]; then
# update password change date
echo "dn:$dn
changetype: modify
replace: shadowLastChange
shadowLastChange: $SLC" | cat | $LDAP_MODIFY -x -h "$LDAP_HOST" \
-D "$LDAP_USER" -w "$LDAP_PASSWORD" > /dev/null 2>&1
else
# update password change date
echo "dn: $dn
changetype: modify
replace: shadowLastChange
shadowLastChange: $SLC" | cat | $LDAP_MODIFY -x -h "$LDAP_HOST" \
-D "$LDAP_USER" -w "$LDAP_PASSWORD" > /dev/null 2>&1
fi
err=$?
if [ ! $err -eq 0 ]; then
echo "error: can't update shadowLastChange: $err"
echo "`date`: shadow.sh: can't update shadowLastChange: $err"\
>> /var/log/shadow-update.log
exit;
fi
echo OK
삼바에서 IT 요구 config (설정) unix password sync
으로 설정 yes
, passwd chat
설정 *OK*
과 passwd program
와 위의 스크립트에 "%u"
PARAM있다.
에 지정된 계정 LDAP_USER
은 LDAP에서 작성해야하며 uid
모든 Samba 사용자 가 읽을 수있는 권한과 쓰기 권한이 부여되어야 shadowLastChange
합니다.