head	1.4;
access;
symbols
	TIGRIS_NOV_12_2000:1.3
	OLDHELM:1.3.0.4
	TIGRIS_NOV_11_2000:1.3
	TIGRIS_SEP_13_2000:1.3.0.2;
locks; strict;
comment	@# @;


1.4
date	2000.11.14.02.25.03;	author kmaples;	state dead;
branches;
next	1.3;

1.3
date	2000.09.27.21.04.57;	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.4
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-user-delete,v 1.3 2000/09/27 21:04:57 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 $bugs_password      = $ARGV[3] || '';

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

# Build the sql statment - do NOT use double-quotes here:
my $command = qq[
    DELETE FROM profiles WHERE
    login_name='$project_name-bugs\@@$domain_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)];
#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.3
log
@First checkin; they're not much more than stubs with a lot of code swiped
from related scripts.  None currently function.
@
text
@d51 1
a51 1
# $Id: bugzilla-project-delete,v 1.10 2000/09/26 05:51:17 kmaples Exp $
@


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-user-delete
# $Id: bugzilla-user-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
d60 6
d67 54
a120 3
my $sandbox      = $ARGV[0];
my $user_email_address = $ARGV[1];
my $domain_name        = $ARGV[2];
d122 25
a146 1
print "bugzilla: Delete profile for: " . $user_email_address . "\n";
d148 2
@


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

