#! /bin/sh #---------------------------------------------------------------------------- # /var/install/bin/invalidate-password - invalidate password of a user # # Copyright (c) 2001-2005 The Eisfair Team, c/o Frank Meyer, frank(at)eisfair(dot)org # # Creation: 15.08.2003 fm # Last Update: $Id$ # # 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 #---------------------------------------------------------------------------- function is_valid_pw () { u_name="$1" ret=1 if [ "$1" != "" ] then pword=`grep "^$u_name:" /etc/shadow|cut -d: -f2` [ "$pword" != "*" ] && ! echo "$pword"|grep -q "^!" if [ $? -eq 0 ] then ret=0 fi fi return $ret } #============================================================================ # main #============================================================================ user=$1 if [ "$user" = "" ] then clrhome mecho -info "Invalidate password" mecho mecho interactive=true /var/install/bin/ask "User:" '' '*' > /tmp/ask.$$ rc=$? user=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ $rc = 255 ] then exit 1 fi mecho else interactive=false fi if [ "$user" != "" ] then if is_valid_pw "$user" then # lock password passwd -l "$user" fi else mecho -warn "Command aborted" fi if [ $interactive = true ] then mecho anykey fi