git.schokokeks.org
Repositories
Help
Report an Issue
keks-overlay.git
Code
Commits
Branches
Tags
Suche
Strukturansicht:
8c4e5b8
Branches
Tags
master
keks-overlay.git
net-mail
courierpasswd
files
mailpasswd
A keks * initial commit
Lars Strojny
commited
8c4e5b8
at 2006-12-17 11:28:02
mailpasswd
Blame
History
Raw
#!/bin/bash # # /usr/bin/mailpasswd # # Shell script wrapper for courierpasswd to change passwords # for courier-imapd via authdaemon. # # Originally written for the Gentoo Linux distribution # # Copyright (c) 1999-2005 Gentoo Technologies, Inc # Released under v2 of the GNU GPL # # Author(s) Christoph Probst <chris-sw-ccp@netzpunkt.org> # # Notes - to change passwords you need to emerge courierpasswd. # - If you don't want the password-change dialog then rather use # checkpasswd directly. # - there is a plugin courierchang_pass available for squirrelmail # that uses courierpasswd INSTEAD of courierpassd or poppassd. # # Todo - convert this script to python # # Version 0.1 # # ======================================================================== if [ "${1}x" == "x" ] ; then echo "mailpasswd - Interface to change the password for an e-mail user." echo "Syntax: mailpasswd e-mail-username" exit 2 fi username=${1} echo "Changing password for e-mail user ${username}" echo -n "(current) E-Mail password: " read -s oldpassword echo echo -n "New E-Mail password: " read -s newpassword echo if [ "${newpassword}x" == "x" ] ; then echo "New password is empty, that is not allowed! Password NOT changed." exit 3 fi echo -n "Retype new E-Mail password: " read -s newpassword2 echo if [ "${newpassword}x" == "${newpassword2}x" ] ; then # don't use echo (see courierpasswd manpage) python -c "print \"%s\0%s\0%s\0\" % (\"${username}\",\"${oldpassword}\",\"${newpassword}\")" \ | courierpasswd --changepwd --stdin errcode=$? if [ $errcode == 0 ] ; then echo "Password successfully changed for e-mail user ${username}." exit 0 else echo "Wrong username or password. Password NOT changed." exit ${errcode} fi else echo "New passwords don't match. Password NOT changed." exit 4 fi