set -u
set -e
-BASE_NAME="$( basename ${0} )"
-MY_REAL_NAME=$( readlink -f $0 )
+BASE_NAME=$( basename "${0}" )
+MY_REAL_NAME=$( readlink -f "$0" )
BIN_DIR=$( dirname "${MY_REAL_NAME}" )
-BASE_DIR=$( dirname "${BIN_DIR}" )
-LIB_DIR="${BASE_DIR}/lib"
-CONF_DIR="${BASE_DIR}/etc"
if [[ -f "${BIN_DIR}/functions.rc" ]] ; then
+ # shellcheck source=functions.rc
. "${BIN_DIR}/functions.rc"
else
echo "Bash resource file '${BIN_DIR}/functions.rc' not found" >&2
get_options() {
local tmp=
- local base_dir=
set +e
- tmp=$( getopt -o ${LDAP_STD_OPTS_SHORT}${STD_SHORT_OPTIONS} \
- --long ${LDAP_STD_OPTS_LONG},${STD_LONG_OPTIONS} \
+ tmp=$( getopt -o "${LDAP_STD_OPTS_SHORT}${STD_SHORT_OPTIONS}" \
+ --long "${LDAP_STD_OPTS_LONG},${STD_LONG_OPTIONS}" \
-n "${BASE_NAME}" -- "$@" )
+ # shellcheck disable=SC2181
if [[ $? != 0 ]] ; then
echo "" >&2
usage >&2
local cmd="${cmd_base} \"${filter}\" userPassword 2>&1 | "
cmd+=" grep -i '^userPassword:' | sed -e 's/^userPassword::[ ][ ]*//'"
debug "Executing: ${cmd}"
+ # shellcheck disable=SC2086
result=$( eval ${cmd} )
debug "ldap_passwd_coded: '${CYAN}${result}${NORMAL}'."
exit 1
fi
- local ldap_passwd_value=$( echo "${result}" | base64 -d )
+ local ldap_passwd_value
+ ldap_passwd_value=$( echo "${result}" | base64 -d )
debug "ldap_passwd_value: '${CYAN}${ldap_passwd_value}${NORMAL}'."
- local ldap_hash_method=$( echo "${ldap_passwd_value}" | \
+ local ldap_hash_method
+ ldap_hash_method=$( echo "${ldap_passwd_value}" | \
sed -e 's/^{//' -e 's/}.*//' | \
tr '[:upper:]' '[:lower:]' )
debug "ldap_hash_method: '${CYAN}${ldap_hash_method}${NORMAL}'."
if [[ "${ldap_hash_method}" != 'crypt' ]] ; then
+ IFS="${oifs}"
echo
error "Unbekannte Hash-Methode '${RED}${ldap_hash_method}${NORMAL}'" >&2
echo
exit 5
fi
- local ldap_passwd_hash=$( echo "${ldap_passwd_value}" | sed -e 's/^{[^}]*}//' )
+ local ldap_passwd_hash
+ # shellcheck disable=SC2001
+ ldap_passwd_hash=$( echo "${ldap_passwd_value}" | sed -e 's/^{[^}]*}//' )
debug "ldap_passwd_hash: '${CYAN}${ldap_passwd_hash}${NORMAL}'."
- local salt=$( echo "${ldap_passwd_hash}" | sed -e 's/^\(..\).*/\1/' )
+ local salt
+ # shellcheck disable=SC2001
+ salt=$( echo "${ldap_passwd_hash}" | sed -e 's/^\(..\).*/\1/' )
debug "salt: '${CYAN}${salt}${NORMAL}'."
- local encr_passwd=$( mkpasswd -m des "${GIVEN_PASSWD}" "${salt}" )
+ local encr_passwd
+ encr_passwd=$( mkpasswd -m des "${GIVEN_PASSWD}" "${salt}" )
debug "encr_passwd: '${CYAN}${encr_passwd}${NORMAL}'."
+ IFS="${oifs}"
+
echo
if [[ "${ldap_passwd_hash}" == "${encr_passwd}" ]] ; then
echo -e "Passwort ist ${GREEN}OKAY${NORMAL}."