From 916cfa191e1e5fac30766c9404a56d2f0d31a708 Mon Sep 17 00:00:00 2001 From: Michael Weiser Date: Fri, 1 Feb 2019 11:03:53 +0000 Subject: Handle empty password change timestamp LDAP attribute If the password change timestamp LDAP attribute is unset, e.g. because the host has been freshly added, the search will return an empty value which will cause an error message from datetime.py: Traceback (most recent call last): File "src/usr/share/laps/dependencies/datetime.py", line 47, in print action(float(timestamp)) ValueError: could not convert string to float: With this change we initialise ts_epoch to zero and leave it at that if the attribute is not set to avoid the error and cause an immediate password change. --- src/usr/share/laps/laps.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/usr/share/laps/laps.sh b/src/usr/share/laps/laps.sh index 15280d3..efdf76d 100755 --- a/src/usr/share/laps/laps.sh +++ b/src/usr/share/laps/laps.sh @@ -215,8 +215,11 @@ wrapper_get_timestamp_from_ldap() { ___wgtfl_krb5cc_tmpfile="${7}" ts_filetime="$( get_attrib_from_ldap "${___wgtfl_ldapsearch_bin}" "${___wgtfl_ldapsearch_flags}" "${___wgtfl_ldapsearch_filter}" "${___wgtfl_attrib}" "${___wgtfl_ldapconf}" "${___wgtfl_krb5cc_tmpfile}" )" - debuglev 3 && ferror "timestamp(FILETIME): ${ts_filetime}" - ts_epoch="$( "${___wgtfl_datetime_py}" -e "${ts_filetime}" )" + ts_epoch=0 + if test -n "$ts_filetime" ; then + debuglev 3 && ferror "timestamp(FILETIME): ${ts_filetime}" + ts_epoch="$( "${___wgtfl_datetime_py}" -e "${ts_filetime}" )" + fi debuglev 2 && ferror "timestamp(epoch): ${ts_epoch}" debuglev 1 && ferror "timestamp(UTC): $( date -u -d "@${ts_epoch}" "+%FT%TZ" )" -- cgit