Ticket #1899 (assigned good practice)

Opened 3 years ago

Last modified 2 years ago

No Reusable ispcp_common_code.php

Reported by: nuxwin Owned by: nuxwin
Priority: blocker Milestone: ispCP ω Debian Package
Component: Backend (Engine) Version: ispCP ω nightly build
Severity: Medium Keywords:
Cc:

Description (last modified by nuxwin) (diff)

In several subsystem (scripts) who are handling by the main debian maintainer scripts ( postinst, prem... ), I want use the existent ispcp_common_code.php .

The problem is the processing of the database keys generation in main.

Example of subsystem script in which I want use the ispc_common.code.php :

#! /bin/sh
# 
# $Id$
#
# Configure Bind 9 for ispCP Omega
# Laurent Declercq (ispCP Omega for Debian)


set -e

if [ $(id -u) != 0 ] ; then
    echo "You must be root to run this, please enter passwd"
    exec su -c "$0 $1"
fi

case "$1" in
    configure-files)
	cp -a /etc/bind/named.conf /etc/bind/named.conf.ispcp-new
	hostname=$(perl -e'require "/var/www/ispcp/engine/ispcp_common_code.pl"; print "$main::cfg{'SERVER_HOSTNAME'}\n";')
	ip_address=$(perl -e'require "/var/www/ispcp/engine/ispcp_common_code.pl"; print "$main::cfg{'BASE_SERVER_IP'}\n";')

....

I suggest replace the following code ( in ispcp_common_code.p ) :

if ($main::db_pass_key eq '{KEY}' || $main::db_pass_iv eq '{IV}') {

	print STDOUT "\tGenerating database keys, it may take some time, please wait...\n";
	print STDOUT "\tIf it takes to long, please check http://www.isp-control.net/documentation/frequently_asked_questions/what_does_generating_database_keys_it_may_take_some_time_please_wait..._on_setup_mean\n";

	$rs = sys_command("perl $main::cfg{'ROOT_DIR'}/keys/rpl.pl $main::cfg{'GUI_ROOT_DIR'}/include/ispcp-db-keys.php $main::cfg{'ROOT_DIR'}/engine/ispcp-db-keys.pl $main::cfg{'ROOT_DIR'}/engine/messager/ispcp-db-keys.pl");

	return $rs if ($rs != 0);

	do 'ispcp-db-keys.pl';
	get_conf();
}

by:

# $main::skip_db_pass is ugly hack to permit the reusability of
# commons subroutines in another specific subsystem scripting.
# With this, the $skip_db_pass variable can be defined in
# another script to disable the db pass generation process.
if (!defined($main::skip_db_pass) && ($main::db_pass_key eq '{KEY}' || $main::db_pass_iv eq '{IV}')) {

	print STDOUT "\tGenerating database keys, it may take some time, please wait...\n";
	print STDOUT "\tIf it takes to long, please check http://www.isp-control.net/documentation/frequently_asked_questions/what_does_generating_database_keys_it_may_take_some_time_please_wait..._on_setup_mean\n";

	$rs = sys_command("perl $main::cfg{'ROOT_DIR'}/keys/rpl.pl $main::cfg{'GUI_ROOT_DIR'}/include/ispcp-db-keys.php $main::cfg{'ROOT_DIR'}/engine/ispcp-db-keys.pl $main::cfg{'ROOT_DIR'}/engine/messager/ispcp-db-keys.pl");

	return $rs if ($rs != 0);

	do 'ispcp-db-keys.pl';
	get_conf();
}

After, I can make :

domain_name=$(perl -e' $main::skip_db_pass='_on_'; require "ispcp_common_code.pl"; print "$main::cfg{'SERVER_HOSTNAME'}\n";')

Change History

comment:1 Changed 3 years ago by nuxwin

  • Description modified (diff)

comment:2 Changed 3 years ago by nuxwin

  • Description modified (diff)

comment:3 Changed 3 years ago by nuxwin

  • Description modified (diff)

comment:4 Changed 3 years ago by nuxwin

  • Description modified (diff)

comment:5 Changed 3 years ago by nuxwin

  • Description modified (diff)

comment:6 Changed 3 years ago by nuxwin

  • Description modified (diff)

comment:7 Changed 3 years ago by nuxwin

  • Description modified (diff)

comment:8 Changed 3 years ago by nuxwin

  • Description modified (diff)

comment:9 Changed 3 years ago by nuxwin

  • Description modified (diff)

comment:10 Changed 3 years ago by nuxwin

  • Description modified (diff)

comment:11 Changed 3 years ago by benedikt

Actually, the idea is not bad and I don't see any point not to do it like this.

Haven't found any ideas how to use it with an exploit. We can try it for sure.

comment:12 Changed 3 years ago by nuxwin

  • Owner set to nuxwin
  • Status changed from new to assigned
  • Severity changed from Don't know to Medium

comment:13 Changed 2 years ago by kilburn

Well, I don't think it's needed for this example. Why don't you just SOURCE the /etc/ispcp.conf file, and you'll automaticaly have all the variables (IP/HOST among them)?

Note: See TracTickets for help on using tickets.