head	1.11;
access;
symbols
	TIGRIS_NOV_12_2000:1.10
	OLDHELM:1.10.0.2
	TIGRIS_NOV_11_2000:1.10
	TIGRIS_SEP_13_2000:1.3.0.2
	TIGRIS_BASELINE:1.10;
locks; strict;
comment	@# @;


1.11
date	2000.11.14.02.25.03;	author kmaples;	state dead;
branches;
next	1.10;

1.10
date	2000.09.27.00.27.19;	author kmaples;	state Exp;
branches;
next	1.9;

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

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

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

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

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

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

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

1.2
date	2000.05.17.00.02.17;	author manoj;	state dead;
branches;
next	1.1;

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


desc
@@


1.11
log
@Changed the way that child scripts are called in order to return the number
or the (child) script which failed (if any).  Currently returns 0 or the
number of the first script in the sequence to fail.  Removed leftovers from
merge.
@
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: bugzilla-module-delete,v 1.10 2000/09/27 00:27:19 kmaples Exp $
# --------------------
# 

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

use strict;

# 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 $sandbox            = $ARGV[0] || '';
my $project_name       = $ARGV[1] || '';
my $domain_name        = $ARGV[2] || '';
my $module_name        = $ARGV[3] || '';
my $module_description = $ARGV[4] || 'none';

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

my $dbname         = $ENV{DATABASE_NAME}     || '';
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/;

#---------------------------------------------------------------
# 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);
}

# Ultimately, this command is going to be wrapped in double-quotes 
# as it's passed on the command line, so we need to escape both
# types of quotes - the first to appease mysql, the second to 
# prevent premature termination of the command:

foreach($project_name, $domain_name, $module_name, $module_description){
    $_ =~ s/'/\\'/g;
    $_ =~ s/"/\\"/g;
}

# Don't use double-quotes when building the command string:
my $command = qq[
	DELETE FROM components WHERE
        value='$module_name' AND  
        program='$project_name';
];

# compress whitespace:
$command =~ s/\s+/ /g;

# This approach is abandoned in favor of the safer use of 'system':
#
# my $string = qq[mysql -u$dbuser -p$dbpass $dbname -e "$command"];
#
# system($string) == 0 
#	or die "$script_name: Unable to execute mysql command: $!\n";

my $mysql_bin = `which mysql`; chomp $mysql_bin;

print "$script_name: doing mysql delete\n";
#print qq[executing system($mysql_bin,"-u$dbuser","-p$dbpass","$dbname",'-e',$command)/n] ;
#exit;

system($mysql_bin,"-u$dbuser","-p$dbpass","$dbname",'-e',$command) == 0
    or die "$script_name: Unable to execute mysql command: $!\n";

#---------------------------------------------------------------
# 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.10
log
@Added tests for number of columns before performing inserts, and padding out
the insert to match that number.  This is to avoid a potential problem in
upgrading to newer versions of bugzilla where the schema has been changed,
which meant that inserts of fixed-length would have choked.  Fixed a bug in
bugzilla-module-delete which was preventing some deletes from occuring.
@
text
@d51 1
a51 1
# $Id: bugzilla-module-delete,v 1.9 2000/09/22 23:42:20 kmaples Exp $
@


1.9
log
@Many changes and fixes; specified arguments to pass to bugzilla-*-delete
scripts; fixed some omissions preventing project dirs from being properly
deleted, etc.
@
text
@d51 1
a51 1
# $Id: bugzilla-module-delete,v 1.8 2000/09/22 22:12:18 kmaples Exp $
d109 1
a109 1
        program='$module_name';
d125 1
a125 1
#print qq[executing system($mysql_bin,"-u$dbuser","-p$dbpass","$dbname",'-e',$command)] ;
@


1.8
log
@Troubleshooting sql statements.
@
text
@d51 1
a51 1
# $Id: bugzilla-module-delete,v 1.7 2000/09/22 21:08:58 kmaples Exp $
d125 2
@


1.7
log
@Fixed typo.
@
text
@d51 1
a51 1
# $Id: bugzilla-module-delete,v 1.6 2000/09/22 21:05:41 kmaples Exp $
d109 1
a109 4
        program='$module_name' AND 
	initialowner='$project_name-bugs\@@$domain_name' AND
 	initialqacontact='$project_name-bugs\@@$domain_name' AND 
	description='$module_description';
d124 1
a124 1
print "$script_name: doing mysql insert\n";
@


1.6
log
@Changed scripts to mirror actions performed in related '-add' scripts.
@
text
@d51 1
a51 1
# $Id: bugzilla-module-delete,v 1.11 2000/09/21 19:29:10 kmaples Exp $
d112 1
a112 1
	description='$module_description');
@


1.5
log
@Fixed regex to display script name in logfiles.
@
text
@d51 1
a51 1
# $Id: bugzilla-module-delete,v 1.4 2000/09/13 22:33:46 kmaples Exp $
d65 13
a78 1
# Process arguments
d89 39
d129 2
@


1.4
log
@Added crude subroutine to all child scripts to detaint @@ARGV.  At the moment,
this isn't doing any real detainting - just spitting the args back out to get
around warnings setuid generates.  Complications with the scripts' knowledge
of it's own working dir when it's called prevent the effective use of 'require'
in the child scripts, thus the redundancy of code in the children (for the time
being)
@
text
@d51 1
a51 1
# $Id: bugzilla-module-delete,v 1.3 2000/09/12 16:28:06 kmaples Exp $
d71 1
a71 1
$script_name =~ s/^.*\/([\w]+)$/$1/;
@


1.3
log
@Stubs for bugzilla-related functions
@
text
@d51 1
a51 1
# $Id: $
d60 6
d84 16
@


1.2
log
@These functions will be performed by the servlets.
@
text
@d1 1
a1 1
#!/usr/bin/perl -w
d50 2
a51 2
# bugzilla-module-delete
# $Id: bugzilla-module-delete,v 1.1 2000/04/29 00:04:10 jrobbins Exp $
d53 4
a56 1
# Provide functions related to configuring the bugzilla bug tracking tool
d61 15
a75 5
my $sandbox      = $ARGV[0];
my $project_name = $ARGV[1];
my $domain_name  = $ARGV[2];
my $brand_name   = $ARGV[3];
my $module_name  = $ARGV[4];
a77 2
print "bugzilla: Remove component named: " . $module_name . "\n";
print "          from product: " . $project_name . "\n";
@


1.1
log
@initial checkin
@
text
@d51 1
a51 1
# $Id: bugzilla.pm,v 1.1 2000/03/24 20:33:58 jrobbins Exp $
@

