Code:
#!/usr/bin/perl
# ispCP (OMEGA) a Virtual Hosting Control Panel
# Copyright (c) 2001-2006 by moleSoftware GmbH
# http://www.molesoftware.com
# Copyright (c) 2006-2007 by isp Control Panel
# http://isp-control.net
#
#
# License:
# This program is free software; you can redistribute it and/or
# modify it under the terms of the MPL Mozilla Public License
# as published by the Free Software Foundation; either version 1.1
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# MPL Mozilla Public License for more details.
#
# You may have received a copy of the MPL Mozilla Public License
# along with this program.
#
# An on-line copy of the MPL Mozilla Public License can be found
# http://www.mozilla.org/MPL/MPL-1.1.html
#
#
# The ispCP Home Page is at:
#
# http://isp-control.net
#
use FindBin;
use lib "$FindBin::Bin/..";
require 'ispcp_common_code.pl';
use strict;
use warnings;
use Socket;
%main::ua = ();
################################################################################
## SUBROUTINES ##
################################################################################
sub welcome_note {
my ($rs, $rdata) = (undef, undef);
push_el(\@main::el, 'welcome_note()', 'Starting...');
my $welcome_message = <<MSG;
Welcome to ispCP '$main::cfg{'Version'}' Password Gen.
This program will gen a password for ispCP OMEGA system.
MSG
print STDOUT $welcome_message;
push_el(\@main::el, 'welcome_note()', 'Ending...');
return 0;
}
sub ask_db_password {
my ($rs, $pass1, $pass2) = (undef, undef, undef);
push_el(\@main::el, 'ask_db_password()', 'Starting...');
my $db_password = 'none';
my $qmsg = "\n Please enter system SQL password. [$db_password]: ";
$pass1 = read_password($qmsg);
if (!defined($pass1) || $pass1 eq '') {
$main::ua{'db_password'} = '';
} else {
$qmsg = " Please repeat system SQL password: ";
$pass2 = read_password($qmsg);
if ($pass1 eq $pass2) {
$main::ua{'db_password'} = $pass1;
} else {
print STDOUT "\n Passwords do not match!";
return 1;
}
}
push_el(\@main::el, 'ask_db_password()', 'Ending...');
my $encryptedpass=encrypt_db_password($main::ua{'db_password'});
print STDOUT " Password:\n $pass1\n Encrypted:\n $encryptedpass\n\n";
return 0;
}
sub user_dialog {
my $rs = undef;
push_el(\@main::el, 'user_dialog()', 'Starting...');
$rs = welcome_note();
return $rs if ($rs != 0);
do {
$rs = ask_db_password();
} while ($rs == 1);
push_el(\@main::el, 'user_dialog()', "db_password: $main::ua{'db_password'}");
push_el(\@main::el, 'user_dialog()', 'Ending...');
return 0;
}
################################################################################
## MAIN ##
################################################################################
my $rs = undef;
$rs = user_dialog();
if ($rs != 0) {
my $el_data = pop_el(\@main::el);
my ($sub_name, $msg) = split(/$main::el_sep/, $el_data);
print STDERR "$msg\n";
exit 1;
}
if ($rs != 0) {
my $el_data = pop_el(\@main::el);
my ($sub_name, $msg) = split(/$main::el_sep/, $el_data);
print STDERR "$msg\n";
exit 1;
}