#Copyright (C) Joe Maimon 2002- All rights released except for attribution/# # # versions of this and related can be found on www.jmaimon.com/sendmail /# ######################################################################################################### # Migrate Sendmail for NT users,passwords,mailbox spools to a unix-like sendmail setup # use at your own risk, Proof-Of-Concept code. # # This is written in Aestiva HTML/OS code. Really all it does is parse the sendmail for nt users file, # which is a passwd style file, and generate a bash shell script or two. # # To rewrite it in bash shell script entirely should be fairly simple. ######################################################################################################### # REQUIRES: #On winnt Machine: Sendmail for NT 3.02, Aestiva HTML/OS 1.8+ runtime.(start.exe), FTP server for spool #files setup. ( See below to configure ncftpget statement #On Unix Machine: Redhat style useradd, userdel, passwd, ncftpget. Unix style chown, chgrp, mkdir ######################################################################################################### # Run this script in the sendmail for nt installation directory root. You need to handle these # files manualy. virtusertable,access,relay-domains,sendmail.cw,aliases,access and so on # # Some things you may miss from Sendmail for NT (besides the web interface) are: buildcf and makevirt # Check out www.jmaimon.com/sendmail/scripts for stuff I use. # # Copy the resulting shell scripts to the unix machine and run the migrateion script. The undo # script is provided for convenience if it screws up. Might I suggest eyeballing the results before # running them? ######################################################################################################### # CONFIGURABLES: Noted in comments through the script # Include: New users home dir, New users GID, base UID to increment for new users # file to be created, user creation statement, ncftpget download spool file statement ######################################################################################################### # Security implications: If cleartext password is unavailable (no APOP configured for user) the # password is migrated as is which is not MD5, just DES, you may change this lower down at the cost of # having to reset the users password # ALL USERNAMES ARE CONVERTED TO LOWERCASE. This is probaly what you want # ALL users share the same GID.You may wish to change that lower down ######################################################################################################### # Side effects: Log files in /tmp/success.log and /tmp/failure.log # Creation of local users with home directories. No skeleton files ######################################################################################################### # Testimonial: # I migrated my 600-800 userbase to RHL 7.1 Sendmail 8.12/Qpopper 4/Uw-Imap with this in one night # Actual execution time is under an hour with fast network for spool file transfer ( Bulk of work) # # Lost a couple passwords and had to deal with some {Lower|Upper}case issues. Thats it. #######################################################################################################/# #The passwd style file that sendmail for NT uses/# passwd.file="smusers.txt" copy file=passwd.file ts=":" to passwd.contents /copy counter.pwd=0 ################################################################################## #Some configurables here. Change the resulting users home dir to suit your setup # ################################################################################/# scriptmove= "#!/bin/bash USERS_MAIL_HOME=/home/mail/ PATH=${PATH}:/usr/sbin:/sbin:. rm -f /tmp/success.log rm -f /tmp/failure.log " scriptdelete= "#!/bin/bash PATH=${PATH}:/usr/sbin:/sbin:. " for name=passwd.contents rownum=passwd.row do User.Name=lower(passwd.contents[1,passwd.row]) #Put all users to skip here/# If User.Name = "root" or User.Name = "Administrator" or User.Name = "Mailer-Daemon" or User.Name = "josephsc" or User.Name = "test1" or User.Name = "cilka" or User.Name = "wwwmailer" or User.Name = "mcordaro" or User.Name = "mdangelo" or User.Name = "pglikas" or User.Name = "" or User.Name = "Postmaster" Then continue /If counter.pwd=counter.pwd+1 display counter.pwd+':'+ascii(09)+User.Name+cr+lf /display #debug if counter.pwd=3 then break /if end debug/# ######################################################################## #Deal with passwords not stored in cleartext. Port them as is(Not MD5) # ######################################################################/# if passwd.contents[7,passwd.row]="*" or passwd.contents[7,passwd.row]="" then Temp.Crypt.Password='-p "'+passwd.contents[2,passwd.row]+'"' else Temp.Crypt.Password='' /if #################################################### #Starting UID. Configure to match your environment # ##################################################/# User.UID = counter.pwd+2500 scriptdelete=scriptdelete+lf+ "userdel -r "+User.Name #################################################### # Users gid. Update here to match your environment # ################################################################## # Update the below statement to reflect you user creation policy # ################################################################/# scriptmove=scriptmove+lf+ 'echo User: '+User.Name+lf+ 'useradd '+User.Name+' -c "MAIL User - '+passwd.contents[5,passwd.row]+'" -d "${USERS_MAIL_HOME}'+User.Name+'" -g "mailusers" -n -M -u '+User.UID+' -s "/bin/false" '+Temp.Crypt.Password+' &&\'+lf+ 'mkdir "${USERS_MAIL_HOME}'+User.Name+'"'+' &&\'+lf+ 'chown '+User.Name+':mailusers "${USERS_MAIL_HOME}'+User.Name+'"'+' &&\'+lf If Temp.Crypt.Password='' then scriptmove= scriptmove + 'echo '+passwd.contents[7,passwd.row]+' | passwd --stdin '+User.Name+' &&\'+lf /if scriptmove=scriptmove+ 'echo '+User.Name+' >> /tmp/success.log || echo '+User.Name+' >> /tmp/failure.log'+lf+lf /for ################################################################## # NCFTP GET: Put the authentication information in the file -f # ################################################################/# scriptmove=scriptmove+ ' [ -f /tmp/undomigratepop3.sh ] || ( echo "#!/bin/bash" > /tmp/undomigratepop3.sh ; echo "PATH=${PATH}" >>/tmp/undomigratepop3.sh ; chmod +x /tmp/undomigratepop3.sh ) [ -f /tmp/success.log ] && ( for FILENAME in $(cat /tmp/success.log); do echo "userdel -r ${FILENAME}" >>/tmp/undomigratepop3.sh ; done ) echo '+"'rm $0 '"+'>>/tmp/undomigratepop3.sh [ -f /tmp/success.log ] && ( for FILENAME in $(cat /tmp/success.log); do ncftpget -f /ncftp-pop3-auth -a /var/spool/mail /spool/${FILENAME} && chown ${FILENAME}:mail /var/spool/mail/${FILENAME} ; done ) ' copy scriptmove to file="migratepop3.sh" /copy copy scriptdelete to file="migratepop3del.sh" /copy