FreeNAS Code
This project has moved to github - see https://github.com/freenas
Brought to you by:
cochard,
mattolander
#!/bin/sh # Copyright (C) 2005-2010 FreeNAS Project. All rights reserved. # PROVIDE: passdb # BEFORE: smbd # KEYWORD: nostart . /etc/rc.subr . /etc/configxml.subr name="passdb" command="/usr/local/bin/pdbedit" load_rc_config "$name" # Defaults passdb_file=${passdb_file:-"/var/etc/private/passdb"} passdb_minuid=${passdb_minuid:-"1001"} # Display message echo "Updating passdb." # Clear password database rm -rf ${passdb_file} # Generate Samba password database. # Iterate over all configured users. _usernum=`configxml_get_count "//access/user"` while [ ${_usernum} -gt 0 ] do _username=`configxml_get "//access/user[position()=${_usernum}]/login"` _password=`configxml_get "//access/user[position()=${_usernum}]/password"` _uid=`configxml_get "//access/user[position()=${_usernum}]/id"` if [ ${_uid} -ge ${passdb_minuid} ]; then (/bin/echo "${_password}"; /bin/echo "${_password}") | ${command} -t -a -u "${_username}" > /dev/null fi _usernum=$(( ${_usernum} - 1 )) done