head	1.9;
access;
symbols
	TIGRIS_1_1_0RC2:1.5
	TIGRIS_1_1_0RC1:1.5
	TIGRIS_1_1:1.5.0.6
	TIGRIS_1_0_8:1.5
	TIGRIS_1_0_8RC3:1.5
	TIGRIS_1_0_8RC2:1.5
	TIGRIS_1_0_8RC1:1.5
	TIGRIS_1_0_7:1.5
	TIGRIS_1_0_7RC3:1.5
	TIGRIS_1_0_7RC2:1.5
	TIGRIS_1_0_7RC1:1.5
	TIGRIS_1_0_6:1.5
	TIGRIS_1_0_6RC5:1.5
	TIGRIS_1_0_6RC4:1.5
	TIGRIS_1_0_6RC3:1.5
	TIGRIS_1_0_6RC2:1.5
	TIGRIS_1_0_6RC1:1.5
	TIGRIS_1_0_5:1.5
	TIGRIS_1_0_5RC6:1.5
	TIGRIS_1_0_5RC5:1.5
	TIGRIS_1_0_5RC4:1.5
	TIGRIS_1_0_5RC3:1.5
	TIGRIS_1_0_5RC2:1.5
	TIGRIS_1_0_5RC1:1.5
	TIGRIS_1_0_4:1.5
	TIGRIS_1_0_3:1.5
	TIGRIS_1_0_2:1.5
	TIGRIS_1_0_1:1.5
	TIGRIS_1_0:1.5.0.8
	TIGRIS_1_0_0:1.5
	TIGRIS_1_0_0_RC1:1.5.0.4
	dlr:1.1.1
	TIGRIS_0_9_2_4:1.5
	TIGRIS_0_9_2_3:1.5
	HELM_PEER_PORT_BRANCH:1.1.1.2
	TURBINE_PEER:1.5
	TIGRIS_0_9_2_1:1.5
	TIGRIS_0_9_2:1.5.0.2
	TIGRIS_0_9_0:1.3.0.4
	TIGRIS_0_8_4:1.3.0.2
	NEWHELM:1.1.1.1
	TIGRIS_NOV_12_2000:1.1.1;
locks; strict;
comment	@# @;


1.9
date	2001.07.31.18.03.45;	author kmaples;	state Exp;
branches;
next	1.8;

1.8
date	2001.04.20.00.02.50;	author kmaples;	state Exp;
branches;
next	1.7;

1.7
date	2001.04.18.02.02.58;	author kmaples;	state Exp;
branches;
next	1.6;

1.6
date	2001.04.17.04.44.54;	author kmaples;	state Exp;
branches;
next	1.5;

1.5
date	2001.01.13.02.04.52;	author kmaples;	state Exp;
branches;
next	1.4;

1.4
date	2000.12.27.22.57.44;	author kmaples;	state Exp;
branches;
next	1.3;

1.3
date	2000.11.16.21.58.53;	author kmaples;	state Exp;
branches;
next	1.2;

1.2
date	2000.11.16.00.38.49;	author kmaples;	state Exp;
branches;
next	1.1;

1.1
date	2000.11.12.21.17.35;	author dlr;	state Exp;
branches
	1.1.1.1;
next	;

1.1.1.1
date	2000.11.12.21.17.35;	author dlr;	state Exp;
branches;
next	1.1.1.2;

1.1.1.2
date	2001.02.21.00.36.00;	author dlr;	state Exp;
branches;
next	;


desc
@@


1.9
log
@Issue number: 4544
Removed unnecessary args; fixed the name of the default subcomponent owner
to simply 'issues@@{project}'
@
text
@#!/usr/bin/perl

# ================================================================
# 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.
#


# 
# $Id: issuezilla-module-add,v 1.8 2001/04/20 00:02:50 kmaples Exp $
# --------------------
# 

# Flush buffer, just in case:
$| = 1;

use strict;
use DBI;
# For the sake of -T:
$ENV{'PATH'} = "/bin:/usr/bin:/usr/local/bin";
# Detaint the args by brute force:
@@ARGV = detaint_array(@@ARGV);

# Process arguments
my $project_name       = $ARGV[0] || '';
my $dbname             = $ARGV[1] || '';
my $module_name        = $ARGV[2] || '';
my $module_description = $ARGV[3] || 'none';
my $multiple_dbs       = $ARGV[4] || '';  

# Some email address for issuezilla:
my $init_owner = "issues\@@$project_name";
my $init_qa    = $init_owner;

# NOTE - this script requires the info necessary to connect
# to the correct DB, e.g., username/password, DB name, etc.

my $dbuser         = $ENV{DATABASE_USER}     || '';
my $dbpass         = $ENV{DATABASE_PASSWORD} || '';

# Grab just the filename portion of this script to use as a 
# log identifier:
my $script_name = $0;
$script_name =~ s/^.*\/([^\/]+)$/  $1/;

# String for current sql statement
my $command;

# Placeholder vars for db work:
my ($select, $ret);

#---------------------------------------------------------------
# MAIN
#---------------------------------------------------------------

# Fail if we don't have what we need to talk to the database:
unless($dbname && $dbuser && $dbpass){
    print "$script_name: envrionmentals for DB access not set\n";
    exit(1);
}

my $dbc = join(':',"DBI:mysql:$dbname",$ENV{DATABASE_HOST},$ENV{DATABASE_PORT});
my $CONN = DBI->connect($dbc, $dbuser, $dbpass);

# Check for a good connection:
unless( $CONN =~ m/HASH/){
    print "$script_name: no connection to database: $!\n";
    exit(1);
}

# Do the sql quoting for the values we're gonna play with:
foreach($project_name, $module_name, $module_description, $init_owner, $init_qa){
    $_ = $CONN->quote( $_ );
}

# Check to see if there's already a record, and if so, return
# successful:

print "$script_name: checking for previous record\n";

$command = qq[
    SELECT * FROM subcomponents WHERE 
    value   = $module_name AND
    program = $project_name
    LIMIT 1
];

$select = $CONN->prepare($command);
$ret    = $select->execute;

if($ret && $ret ne '0E0'){
    print "$script_name: record found\n";
    $select->finish();
    $CONN->disconnect;
    exit(0);
}

# Now prepare the actual insert:
print "$script_name: doing mysql insert\n";
$command = qq[
    INSERT INTO subcomponents SET
        value        =  $module_name, 
	    program      =  $project_name,
	    initialowner =  $init_owner, 
	    initialqacontact = $init_qa,
    	description  =  $module_description
];

$select = $CONN->prepare($command);
$ret    = $select->execute;

$CONN->disconnect;

unless($ret){
    print "$script_name: unable to perform insert: $!\n";
    exit(1);
}
#---------------------------------------------------------------
# END MAIN
#---------------------------------------------------------------


# A crude attempt to overcome data tainting in perl:
#-------------------
sub detaint_array {
#-------------------
    my @@unclean = @@_;
    my @@clean = ();

    foreach(@@unclean){
        # We don't really have rules for this, so at the moment
        # this acts as a passthrough:
        $_ =~ m/^(.*)$/;
        push(@@clean,$1);
    }

    return(@@clean);
}

@


1.8
log
@Cleaned up some potential problems with the tigris user; modified how the
bridge redirects stdout and stderr to the logfile in advance of setting up
some proper debugging.
@
text
@d51 1
a51 1
# $Id: issuezilla-module-add,v 1.7 2001/04/18 02:02:58 kmaples Exp $
d66 5
a70 7
my $sandbox            = $ARGV[0] || '';
my $project_name       = $ARGV[1] || '';
my $dbname             = $ARGV[2] || '';
my $domain_name        = $ARGV[3] || '';
my $module_name        = $ARGV[4] || '';
my $module_description = $ARGV[5] || 'none';
my $multiple_dbs       = $ARGV[6] || '';  
d73 1
a73 2
my $mail_pfx   = $ENV{MAIL_PREFIX} || '';
my $init_owner = $mail_pfx . "issues\@@$project_name". '.' . "$domain_name";
@


1.7
log
@Undoing yesterday's commit - my hastiness to implement some sort of logging
level notion into these scripts caused me great pain.
@
text
@d51 1
a51 1
# $Id: issuezilla-module-add,v 1.5 2001/01/13 02:04:52 kmaples Exp $
d147 3
a149 3
	program      =  $project_name,
	initialowner =  $init_owner, 
	initialqacontact = $init_qa,
@


1.6
log
@Scripts now use IN_PRODUCTION to determine logging level
@
text
@a54 5
my $scripts_dir = $ENV{'SANDBOX'} . '/helm/perl/scripts';

require "$scripts_dir/ParentChildArgumentBridge.pl"
    or die "Require failed: $!\n";

d102 1
a102 1
    print_log(1, "$script_name: envrionmentals for DB access not set\n");
d111 1
a111 1
    print_log(1, "$script_name: no connection to database: $!\n");
d123 1
a123 1
print_log(1, "$script_name: checking for previous record\n");
d136 1
a136 1
    print_log(1, "$script_name: record found\n");
d143 1
a143 1
print_log(1, "$script_name: doing mysql insert\n");
d159 1
a159 1
    print_log(1, "$script_name: unable to perform insert: $!\n");
@


1.5
log
@First furtive attempts to support remote databases.
@
text
@d51 1
a51 1
# $Id: issuezilla-module-add,v 1.4 2000/12/27 22:57:44 kmaples Exp $
d55 5
d107 1
a107 1
    print "$script_name: envrionmentals for DB access not set\n";
d116 1
a116 1
    print "$script_name: no connection to database: $!\n";
d128 1
a128 1
print "$script_name: checking for previous record\n";
d141 1
a141 1
    print "$script_name: record found\n";
d148 1
a148 1
print "$script_name: doing mysql insert\n";
d164 1
a164 1
    print "$script_name: unable to perform insert: $!\n";
@


1.4
log
@Framework changes to recognize whether database type is set to single or
multiple.  This implements no changes in the behavior of the scripts, only
changes in the framework.
@
text
@d51 1
a51 1
# $Id: issuezilla-module-add,v 1.3 2000/11/16 21:58:53 kmaples Exp $
d106 1
a106 1
my $dbc = "DBI:mysql:$dbname";
@


1.3
log
@Tweaking emailing when MAIL_PREFIX is set.
@
text
@d51 1
a51 1
# $Id: issuezilla-module-add,v 1.2 2000/11/16 00:38:49 kmaples Exp $
d72 1
@


1.2
log
@Changed presumptive mailing addresses to be <user>@@<project>.<domain>
@
text
@d51 1
a51 1
# $Id: issuezilla-module-add,v 1.1.1.1 2000/11/12 21:17:35 dlr Exp $
d74 2
a75 1
my $init_owner = "issues\@@$project_name". '.' . "$domain_name";
@


1.1
log
@Initial revision
@
text
@d51 1
a51 1
# $Id: issuezilla-module-add,v 1.5 2000/11/07 20:58:04 kmaples Exp $
d74 1
a74 1
my $init_owner = "$project_name-issues\@@$domain_name";
@


1.1.1.1
log
@Merging newhelm tree into helm, as per IZ issue #557.  Previous major version of helm is tagged TIGRIS_NOV_11_2000.
@
text
@@


1.1.1.2
log
@Replacing the HEAD with the HELM_PEER_PORT_BRANCH.
@
text
@d51 1
a51 1
# $Id: issuezilla-module-add,v 1.5 2001/01/13 02:04:52 kmaples Exp $
a71 1
my $multiple_dbs       = $ARGV[6] || '';  
d74 1
a74 2
my $mail_pfx   = $ENV{MAIL_PREFIX} || '';
my $init_owner = $mail_pfx . "issues\@@$project_name". '.' . "$domain_name";
d104 1
a104 1
my $dbc = join(':',"DBI:mysql:$dbname",$ENV{DATABASE_HOST},$ENV{DATABASE_PORT});
@

