head	1.2;
access;
symbols;
locks; strict;
comment	@# @;


1.2
date	2000.05.13.17.06.37;	author jrobbins;	state dead;
branches;
next	1.1;

1.1
date	2000.03.24.20.33.58;	author jrobbins;	state Exp;
branches;
next	;


desc
@@


1.2
log
@removed files that have been replaced with newer files in helm/perl/scripts
@
text
@# ================================================================
# Copyright (c) 2000 Collab.Net.  All rights reserved.
# 
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
# 
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 
# 3. The end-user documentation included with the redistribution, if
# any, must include the following acknowlegement: "This product includes
# software developed by Collab.Net (http://www.Collab.Net/)."
# Alternately, this acknowlegement may appear in the software itself, if
# and wherever such third-party acknowlegements normally appear.
# 
# 4. The hosted project names must not be used to endorse or promote
# products derived from this software without prior written
# permission. For written permission, please contact info@@collab.net.
# 
# 5. Products derived from this software may not use the "Tigris" name
# nor may "Tigris" appear in their names without prior written
# permission of Collab.Net.
# 
# THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL COLLAB.NET OR ITS CONTRIBUTORS BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
# IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# ====================================================================
# 
# This software consists of voluntary contributions made by many
# individuals on behalf of Collab.Net.
#


# Helm/qmail.pm
# $Id: qmail.pm,v 1.1 2000/03/24 20:33:58 jrobbins Exp $
# --------------------

# Provides functions to update the qmail aliases to match the user list;
# forward all the email addrs to the proper place.  Also, update the config
# files used by qmail to do virtual hosting.



# Note that for this to work (and the qmail mailing lists - see
# Helm::QmailLists) several users must exist and be configured in
# qmail. The user configured in the $qmail_user config parameter
# (see Helm::Config) must exist and qmail be set to use it for
# mail to domain.org (in control/virtualdomains). For each project,
# qmail should map project.domain.org to ${qmail_user}-project.
#
# Note that we create these aliases for each domain, so that mail to
# user@@tigris.org works as well as user@@project.tigris.org.

package Helm::qmail;


use Helm::ToolHook;
@@ISA = qw(Helm::ToolHook);

use strict;

use Helm::QmailUtils;


sub projectAdd {
    my ($class, $project_name, $domain_name, $brand_name) = @@_;
    print "qmail: call add_host\n";
    add_host($class, $project_name, $domain_name, $brand_name);
}

sub add_host {
    my ($class, $project_name, $domain_name, $brand_name) = @@_;
    print "qmail: add virtualhost line for $project_name in $domain_name\n";
}

sub add_vhost_user_forwarding {
    my ($class, $project_name, $domain_name, $brand_name) = @@_;
    print "qmail: add files .qmail- $project_name - username for every user\n";

}

sub projectDelete {
    my ($class, $project_name, $domain_name, $brand_name) = @@_;
    print "qmail: install some kind of sorry script to bounce email\n";
}

sub userAdd {
    my ($class, $user_login_id, $domain_name, $brand_name, $user_email_address) = @@_;

    print "qmail: add a .qmail file for the domain $domain_name and \n";
    print "       forward $user_login_id to $user_email_address\n";
}

sub userDelete {
    my ($class, $user_login_id, $domain_name) = @@_;
    print "qmail: remove fowarding files for $user_login_id in $domain_name\n";

}

sub userEdit {
    my ($class, $user_login_id, $domain_name, $brand_name, $user_email_address) = @@_;
    print "qmail: change a the forwarding email for $user_login_id to $user_email_address\n";
}



################################################################

sub moduleAdd {
}

sub moduleDelete {
}

sub moduleEdit {
}


################################################################

sub projMailAdd {
}

sub projMailDelete {
}

sub projMailEdit {
}



################################################################

sub user {
    my ($class, $db) = @@_;
    return $db->config('qmail_user');
}

# update Helm::QmailAlias $db;
# perform the update - make all the files proper
sub update {
    my ($class, $db) = @@_;
    my ($ts, $home);

    # Find the home directory of the qmail user;
    $home = Helm::QmailUtils::home($db);

    $ts = new Helm::TableSync($db, 'domain_users', 'username',
				"$home/tigris-qmail", \&_qmail_map);
    $ts->check("$home/.qmail-", 'email', undef, 'email');

    # Now for each project
    my $proj;
    foreach $proj ($db->projects) {
	$ts = new Helm::TableSync($db, 'domain_users', 'username',
				    "$home/tigris-qmail-$proj", \&_qmail_map);
	$ts->check("$home/.qmail-$proj-", 'email', undef, 'email');
    }
}

# Map email addr into qmail file. The cookie is a string giving
# the prefix - $HOME_OF_QMAIL_USER/.qmail-project- - this just adds
# the username, really.
sub _qmail_map {
    my ($cookie, $db, $cols) = @@_;
    return "$cookie$cols->[0]";
}

sub add_project {
    my ($class, $db, $project) = @@_;

    # We don't need to do much, but remind the user...
    return("add $project." . $db->config('domain_dns')
	   . ':' . $db->config('qmail_user')
	   . "-$project to control/virtualdomains\n");
}

# If a project is deleted, we must remove all of its qmail-alias files
sub del_project {
    my ($class, $db, $project) = @@_;

    my $home = Helm::QmailUtils::home;
    my $ts = new Helm::TableSync($db, 'domain_users', 'username',
				   "$home/tigris-qmail-$project",
				   \&_qmail_map);
    $ts->delete;

    # Note to the user
    return("remove $project." . $db->config('domain_dns')
	   . " from control/virtualdomains\n");
}
@


1.1
log
@initial check in of new perl modules for more-direct config file updating
@
text
@d49 1
a49 1
# $Id$
@

