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


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

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

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

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

1.3
date	2001.01.13.02.04.52;	author kmaples;	state Exp;
branches
	1.3.6.1;
next	1.2;

1.2
date	2000.12.27.22.57.44;	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.06;	author dlr;	state Exp;
branches;
next	;

1.3.6.1
date	2001.08.13.23.06.41;	author kmaples;	state Exp;
branches;
next	;


desc
@@


1.7
log
@Made sure -D flag is set when calling mysql from the command line.
@
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-delete,v 1.6 2001/07/31 18:03:45 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 $project_name       = $ARGV[0] || '';
my $dbname             = $ARGV[1] || '';
my $module_name        = $ARGV[2] || '';
my $module_description = $ARGV[3] || 'none';
my $multiple_dbs       = $ARGV[4] || '';  

# 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/;

#---------------------------------------------------------------
# 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, $module_name, $module_description){
    $_ =~ s/'/\\'/g;
    $_ =~ s/"/\\"/g;
}

# Don't use double-quotes when building the command string:
my $command = qq[
	DELETE FROM subcomponents 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";

system($mysql_bin,"-u$dbuser","-p$dbpass","-D$dbname",
    '--port='.$ENV{DATABASE_PORT}, '--host='.$ENV{DATABASE_HOST}, 
    '-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.6
log
@Issue number: 4544
Removed unnecessary args; fixed the name of the default subcomponent owner
to simply 'issues@@{project}'
@
text
@d51 1
a51 1
# $Id: issuezilla-module-delete,v 1.5 2001/04/18 02:02:58 kmaples Exp $
d125 1
a125 1
system($mysql_bin,"-u$dbuser","-p$dbpass","$dbname",
@


1.5
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-delete,v 1.3 2001/01/13 02:04:52 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] || '';  
d99 1
a99 1
foreach($project_name, $domain_name, $module_name, $module_description){
@


1.4
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";

d92 1
a92 1
    print_log(1, "$script_name: envrionmentals for DB access not set\n");
d125 1
a125 1
print_log(1, "$script_name: doing mysql delete\n");
@


1.3
log
@First furtive attempts to support remote databases.
@
text
@d51 1
a51 1
# $Id: issuezilla-module-delete,v 1.2 2000/12/27 22:57:44 kmaples Exp $
d55 5
d97 1
a97 1
    print "$script_name: envrionmentals for DB access not set\n";
d130 1
a130 1
print "$script_name: doing mysql delete\n";
@


1.3.6.1
log
@Issue number: 5406
Reviewed by:  lucas@@collab.net
Added '-D' option when invoking mysql directly.  Fixes a bug on Solaris
using mysql 3.22.32
@
text
@d51 1
a51 1
# $Id: issuezilla-module-delete,v 1.3 2001/01/13 02:04:52 kmaples Exp $
d127 1
a127 1
system($mysql_bin,"-u$dbuser","-p$dbpass","-D$dbname",
@


1.2
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-delete,v 1.1.1.1 2000/11/12 21:17:35 dlr Exp $
a125 2
#print qq[executing system($mysql_bin,"-u$dbuser","-p$dbpass","$dbname",'-e',$command)/n] ;
#exit;
d127 3
a129 1
system($mysql_bin,"-u$dbuser","-p$dbpass","$dbname",'-e',$command) == 0
@


1.1
log
@Initial revision
@
text
@d51 1
a51 1
# $Id: issuezilla-module-delete,v 1.3 2000/11/07 03:02:07 kmaples Exp $
d72 1
@


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-delete,v 1.3 2001/01/13 02:04:52 kmaples Exp $
a71 1
my $multiple_dbs       = $ARGV[6] || '';  
d125 2
d128 1
a128 3
system($mysql_bin,"-u$dbuser","-p$dbpass","$dbname",
    '--port='.$ENV{DATABASE_PORT}, '--host='.$ENV{DATABASE_HOST}, 
    '-e',$command) == 0
@

