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



Relevant Pages

  • Re: sed or awk: decode base64 string in passwd-like file
    ... I need to decode the second field (password field), ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx ...
    (Debian-User)
  • Re: sed or awk: decode base64 string in passwd-like file
    ... I need to decode the second field, ... you'll find tons of base64 decoders that you can easily translate into awk ... To UNSUBSCRIBE, email to debian-user-REQUEST@xxxxxxxxxxxxxxxx with a subject of "unsubscribe". ...
    (Debian-User)
  • Re: Unicode/UTF-8 decoding
    ... I don't really know how this work, but IE or Firefox browser can decode easily. ... This text looks as it has been decoded with a different encoding than was used to encode it. ... If you want to store unicode strings in the MySQL database, it has to be set up to use unicode as character set. ... While this gives the correct result for some strings, some byte codes used in UTF-8 doesn't represent a single character by themselves, so if you contine to store mis-decoded strings as unicode, you will sooner or later experience corrupted strings. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: how to decode different charset in subject line ???
    ... >> Actually i know the formatof such encoded strings... ... > able to write methods to decode and encode rfc2047 headers in a little over ... > probably deal with rfc2047 headers for you. ...
    (comp.mail.mime)
  • Re: How to decode this unicode-hex string
    ... > I'm wondering how I can decode such strings and return the 8-bit character. ... > So far I've been looking into the following Perl modules man pages an ... for Java to use unicode. ...
    (comp.lang.perl.misc)