#! /bin/sh #---------------------------------------------------------------------------- # /var/install/bin/invalidate-password - invalidate password of a user # # Creation: 2003-08-15 fm # Last Update: $Id$ # # Copyright (c) 2001-@@YEAR@@ the eisfair team, team(at)eisfair(dot)org # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib # --------------------------------------------------------------------------- # check if password is valid # input : $1 - user name # return: 0 - valid password # 1 - invalid password # --------------------------------------------------------------------------- is_valid_pw () { u_name="${1}" ret=1 if [ -n "${u_name}" ] then pword=$( awk -F: '/^'${u_name}':/ {print $2}' /etc/shadow ) [ "${pword}" != "*" ] && ! echo "${pword}" | grep -q "^!" if [ ${?} -eq 0 ] then ret=0 fi fi return ${ret} } # --------------------------------------------------------------------------- # main # --------------------------------------------------------------------------- user=${1} if [ -z "${user}" ] then clrhome mecho --info "Invalidate password" mecho mecho interactive=true _ask_tmpfile=$( mktemp -t XXXXXXXXXXXXX ) /var/install/bin/ask "User:" '' '*' > ${_ask_tmpfile} rc=$? read user < ${_ask_tmpfile} rm -f ${_ask_tmpfile} if [ ${rc} = 255 ] then exit 1 fi mecho fi if [ -n "${user}" ] then if is_valid_pw "${user}" then # lock password passwd -l "${user}" fi else mecho --warn "Command aborted" fi if "${interactive:-false}" then mecho anykey fi # --------------------------------------------------------------------------- # end # ---------------------------------------------------------------------------