On Tue, 19 Nov 2002, Mike Diehl wrote:

> On Tuesday 19 November 2002 10:19 am, Jason R. Mastaler wrote:
>      > "Marcin M. Jessa" <[EMAIL PROTECTED]> writes:
>      > > Any idea how to automagically add generation of the crypt_key file
>      > > for my new users so tmda could be copied to the new user's home
>      > > directory like all the other dot files?
>      >
>      > tmda-keygen has a ``--batch'' option that you can use
>      > programmatically.
>
> No, I think the original poster is hitting on a bigger issue.  I've found
> that there is a lot to do to setup a user to be "tmda protected."  I have to
> create the .tmdarc file, .tmda directory and all of it's conents.  Then I
> have to set ownership and permissions.  Then change the .forward, or
> .procmailrc files....  I have to do all of this by hand, then my users can
> make "policy" changes themselves.  But this is a lot of work on my part.
>
> Does anyone have a script wich does this?
>
>

Well, I do, but I don't know how portable it is.

I'm using OpenBSD.  I set up /etc/skel like this:

$ls -alR /etc/skel

total 18
drwxr-xr-x   4 root  wheel   512 Oct  1 08:59 .
drwxr-xr-x  28 root  wheel  3072 Nov 19 11:42 ..
-rw-r--r--   1 root  wheel   180 Oct  1 09:06 .profile
-rw-r--r--   1 root  wheel    47 May 12  2002 .qmail
lrwxr-xr-x   1 root  wheel     6 May 12  2002 .qmail-default -> .qmail
drwxr-xr-x   5 root  wheel   512 Oct  1 09:10 .tmda
-rw-------   1 root  wheel   320 May 13  2002 .tmdarc
drwx------   5 root  wheel   512 Jul 24  2001 Maildir

/etc/skel/.tmda:
total 10
drwxr-xr-x  5 root  wheel  512 Oct  1 09:10 .
drwxr-xr-x  4 root  wheel  512 Oct  1 08:59 ..
-rw-r--r--  1 root  wheel    0 Oct  1 09:10 crypt_key
drwxr-xr-x  2 root  wheel  512 May 12  2002 filters
drwxr-xr-x  2 root  wheel  512 May 12  2002 lists
drwx------  2 root  wheel  512 May 12  2002 pending

/etc/skel/.tmda/filters:
total 6
drwxr-xr-x  2 root  wheel  512 May 12  2002 .
drwxr-xr-x  5 root  wheel  512 Oct  1 09:10 ..
-rw-r--r--  1 root  wheel   37 Apr 22  2002 incoming

/etc/skel/.tmda/lists:
total 4
drwxr-xr-x  2 root  wheel  512 May 12  2002 .
drwxr-xr-x  5 root  wheel  512 Oct  1 09:10 ..
-rw-r--r--  1 root  wheel    0 May 12  2002 blacklist
-rw-r--r--  1 root  wheel    0 May 12  2002 whitelist

/etc/skel/.tmda/pending:
total 4
drwx------  2 root  wheel  512 May 12  2002 .
drwxr-xr-x  5 root  wheel  512 Oct  1 09:10 ..

/etc/skel/Maildir:
total 10
drwx------  5 root  wheel  512 Jul 24  2001 .
drwxr-xr-x  4 root  wheel  512 Oct  1 08:59 ..
drwx------  2 root  wheel  512 Jul 24  2001 cur
drwx------  2 root  wheel  512 Jul 24  2001 new
drwx------  2 root  wheel  512 Jul 24  2001 tmp

/etc/skel/Maildir/cur:
total 4
drwx------  2 root  wheel  512 Jul 24  2001 .
drwx------  5 root  wheel  512 Jul 24  2001 ..

/etc/skel/Maildir/new:
total 4
drwx------  2 root  wheel  512 Jul 24  2001 .
drwx------  5 root  wheel  512 Jul 24  2001 ..

/etc/skel/Maildir/tmp:
total 4
drwx------  2 root  wheel  512 Jul 24  2001 .
drwx------  5 root  wheel  512 Jul 24  2001 ..


The specific files in /etc/skel are

$ sudo grep -r ^ /etc/skel

/etc/skel/.profile:PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
/etc/skel/.profile:export PATH
/etc/skel/.profile:w=`whoami`
/etc/skel/.profile:HOME=/home/$w
/etc/skel/.profile:export HOME
/etc/skel/.profile:umask 022
/etc/skel/.profile:EDITOR=/usr/local/bin/pico
/etc/skel/.profile:export EDITOR
/etc/skel/.profile:h=`hostname`
/etc/skel/.profile:PS1="[$w@$h] $ "
/etc/skel/.tmda/filters/incoming:from-file ~/.tmda/lists/whitelist ok
/etc/skel/.qmail:|preline /usr/local/bin/tmda-filter
/etc/skel/.qmail:./Maildir/
/etc/skel/.qmail-default:|preline /usr/local/bin/tmda-filter
/etc/skel/.qmail-default:./Maildir/


That's all pretty standard stuff.

To add a new user, I run (as root, via sudo) my /usr/local/sbin/newuser
script.

NOTE!  I wrote the following for my own use.  I use qmail and OpenBSD and
this script works for me.  YMMV.


_______start script_______


#!/bin/sh
#newuser script
#       automates adding a new user,
#       changing ownership of home directory to new user
#       calling qmail programs qmail-pw2u and qmail-newu
#       to add the user to receive e-mail
#       Jeff Ross [EMAIL PROTECTED]
#       May 1, 2001
#added tmda specific stuff 6/2002-11/2002

#Make sure calling syntax is correct

        if [ $# != 1 ]; then
                echo
                echo newuser username
                echo
                exit 1
        fi
#passed parameter is the username
USER=$1
#use the tools at hand!
#it is the UNIX way!
useradd -m -v $USER
chmod 700 /home/$USER
#add the new user to the qmail stuff
# input from /etc/passwd, output to /var/qmail/users/assign
/var/qmail/bin/qmail-pw2u < /etc/passwd > /var/qmail/users/assign
# call qmail-newu to convert assign to cdb
/var/qmail/bin/qmail-newu
#tmda stuff
echo "import os" > /home/$USER/.tmdarc
/usr/local/bin/tmda-keygen -b > /home/$USER/.tmda/crypt_key

chmod 400 /home/$USER/.tmda/crypt_key

echo "CONFIRM_APPEND = os.path.expanduser(\"~/.tmda/lists/whitelist\")" >> \
        /home/$USER/.tmdarc

echo "CONFIRM_MAX_MESSAGE_SIZE = 50000" >> /home/$USER/.tmdarc

echo "DATADIR = os.path.expanduser(\"~/.tmda/\")" >> /home/$USER/.tmdarc

echo "FILTER_INCOMING = os.path.expanduser(\"~/.tmda/filters/incoming\")" \
        /home/$USER/.tmdarc


echo "LOGFILE_DEBUG = os.path.expanduser(\"~/tmda_debug.log\")" >> \
        /home/$USER/.tmdarc

echo "LOGFILE_INCOMING = os.path.expanduser(\"~/tmda_incoming.log\")" >> \
        /home/$USER/.tmdarc
chown $USER /home/$USER/.tmdarc
chown $USER /home/$USER/.tmda/crypt_key

#let root know everything went okay
echo $USER > /root/newuser
mail -s "User Added Successfully" root@<yourdomainhere> < /root/newuser
rm -f /root/newuser
exec passwd $USER

______end of script_______


Note!

This is for TMDA 0.61.  I haven't had the chance to upgrade to the newest
version yet.

But I will.

I have no objections to adding this script to the TMDA contributions if it
is portable enough.

Jeff

-- 
Jeff Ross
Open Vistas Networking, Inc.
http://www.openvistas.net



_____________________________________________
tmda-users mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-users

Reply via email to