[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

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



Il 29/06/2011 16:50, Denny Schierz ha scritto:
hi,

I have a file with strings like:

testds@domain.foo: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?

try google's codesearch, you'll find tons of base64 decoders that you can easily translate into awk


Reply to: