Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   Debian User (http://www.linux-archive.org/debian-user/)
-   -   sed or awk: decode base64 string in passwd-like file (http://www.linux-archive.org/debian-user/546064-sed-awk-decode-base64-string-passwd-like-file.html)

Denny Schierz 06-29-2011 02:42 PM

sed or awk: decode base64 string in passwd-like file
 
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

",uid,maildomain,userpassword,maildomain,u,uid,mai lquota)}
END {printf("%s@%s:%s:500:12002::/imap/spool/%s/%s/%s:storage=%s

",uid,maildomain,userpassword,maildomain,u,uid,mai lquota)}
================

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

any suggestions?


All times are GMT. The time now is 06:35 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.