Re: create password in postinst
On Thu, Jan 26, 2006 at 01:28:47PM +0100, Daniel Knabl wrote:
> Hi folks,
> me once again. In my postinst I need to generate a MD5 crypted password
> hash out of a userdefined password. Both of them have to replace the
> defaults in a MySQL dump file, which I tend to do the following way,
> unless there is a better solution:
> depend on mkpasswd
> ask the user for a password via debconf (store in $CLEARPASS)
> and then do HASH=`mkpasswd -S 35348090 -H md5 $CLEARPASS` and
> afterwards the usual sed -e "s/default/"$HASH"/;" ...
> Is this OK in the postinst, especially the dependency on mkpasswd?
With the dependency, it is okay; without the dependency, you would
have to be prepared for mkpasswd to be not available. (Most probably
by disabling password authentication).
But why not use md5sum, instead, which is the "essential: yes" package
coreutils? Is it because you need a "salt"ed hash? It doesn't seem
that a constant salt does much good..