sed or awk: decode base64 string in passwd-like file



hi,

I have a file with strings like:

testds@xxxxxxxxxx:e0NSWVBUfVUx=:500:12002::/imap/spool/domain.foo/%1n/%
n:storage=50

I need to decode the second field (password field), with something like:

echo e0NSWVBUfVUx= | openssl base64 -d

How can I do this with all other lines?

I have already a small awk script, that converts my ldapsearch output to
a Dovecot readable passwd file.

===============
/^uid: / {uid=$2}
/^uid: / {uid=$2; u=tolower(substr(uid,1,1));}
/^postalAddress:/ {maildomain=$2}
/^myMailQuota/ {mailquota=$2}
/^userPassword/ {userpassword=$2}
/^dn/ {printf("%s@%s:%s:500:12002::/imap/spool/%s/%s/%s:storage=%s
\n",uid,maildomain,userpassword,maildomain,u,uid,mailquota)}
END {printf("%s@%s:%s:500:12002::/imap/spool/%s/%s/%s:storage=%s
\n",uid,maildomain,userpassword,maildomain,u,uid,mailquota)}
================

the third %s must be changed, means decoded from base64.

any suggestions?

Attachment: signature.asc
Description: This is a digitally signed message part