Fix for #2100 - the scheduler user is not created in the development environment. Added a script called campcaster-user.php which allows you to add users, change user passwords, and delete users. The changeSchedulerPassword.php script is no longer needed because of this.
This commit is contained in:
parent
00762f95c6
commit
2ff948f2ed
|
@ -435,8 +435,8 @@ if [ "$storage_is_local" = "yes" ]; then
|
|||
grep -q 'ls_scheduler_storage_pass' $install_etc/campcaster-scheduler.xml
|
||||
if [ $? = 0 ]; then
|
||||
SCHEDULER_STORAGE_PASS=`pwgen -N1 -c -n -s`
|
||||
php -q $install_var_ls/storageServer/var/changeSchedulerPassword.php \
|
||||
${SCHEDULER_STORAGE_PASS}
|
||||
php -q $install_var_ls/storageServer/var/install/campcaster-user.php \
|
||||
--addupdate scheduler ${SCHEDULER_STORAGE_PASS}
|
||||
sed -i -e "s/ls_scheduler_storage_pass/${SCHEDULER_STORAGE_PASS}/" \
|
||||
$install_etc/campcaster-scheduler.xml
|
||||
fi
|
||||
|
|
|
@ -334,6 +334,14 @@ echo "Setting up database tables for the scheduler..."
|
|||
make -C $products_dir/scheduler init || exit 1
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Add "scheduler" user
|
||||
#-------------------------------------------------------------------------------
|
||||
echo "Adding the 'scheduler' user..."
|
||||
|
||||
php $modules_dir/storageServer/var/install/campcaster-user.php --addupdate scheduler $scheduler_storage_pass
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Setup directory permissions
|
||||
#-------------------------------------------------------------------------------
|
||||
|
@ -349,15 +357,17 @@ chmod g+sw $modules_dir/archiveServer/var/access
|
|||
chmod g+sw $modules_dir/archiveServer/var/trans
|
||||
chmod g+sw $modules_dir/archiveServer/var/stor/buffer
|
||||
|
||||
chgrp $apache_group $modules_dir/storageServer/var/stor
|
||||
chgrp $apache_group $modules_dir/storageServer/var/access
|
||||
chgrp $apache_group $modules_dir/storageServer/var/trans
|
||||
chgrp $apache_group $modules_dir/storageServer/var/stor/buffer
|
||||
|
||||
chmod g+sw $modules_dir/storageServer/var/stor
|
||||
chmod g+sw $modules_dir/storageServer/var/access
|
||||
chmod g+sw $modules_dir/storageServer/var/trans
|
||||
chmod g+sw $modules_dir/storageServer/var/stor/buffer
|
||||
# Commenting these out because it should already be
|
||||
# done by the storageserver install script. -Paul
|
||||
#
|
||||
#chgrp $apache_group $modules_dir/storageServer/var/stor
|
||||
#chgrp $apache_group $modules_dir/storageServer/var/access
|
||||
#chgrp $apache_group $modules_dir/storageServer/var/trans
|
||||
#chgrp $apache_group $modules_dir/storageServer/var/stor/buffer
|
||||
#chmod g+sw $modules_dir/storageServer/var/stor
|
||||
#chmod g+sw $modules_dir/storageServer/var/access
|
||||
#chmod g+sw $modules_dir/storageServer/var/trans
|
||||
#chmod g+sw $modules_dir/storageServer/var/stor/buffer
|
||||
|
||||
chgrp $apache_group $modules_dir/htmlUI/var/templates_c
|
||||
chgrp $apache_group $modules_dir/htmlUI/var/html/img
|
||||
|
|
|
@ -297,6 +297,27 @@ class Subjects {
|
|||
} // fn getSubjName
|
||||
|
||||
|
||||
/**
|
||||
* Get one subject from the table.
|
||||
*
|
||||
* @param string $p_fieldValue
|
||||
* @param string $p_fieldName
|
||||
* @return array
|
||||
*/
|
||||
public static function GetSubject($p_fieldValue, $p_fieldName='login')
|
||||
{
|
||||
global $CC_CONFIG, $CC_DBC;
|
||||
if (!in_array($p_fieldName, array("login", "id"))) {
|
||||
return null;
|
||||
}
|
||||
$escapedValue = pg_escape_string($p_fieldValue);
|
||||
$sql = "SELECT * FROM ".$CC_CONFIG['subjTable']
|
||||
." WHERE $p_fieldName='$escapedValue'";
|
||||
$row = $CC_DBC->GetRow($sql);
|
||||
return $row;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get all subjects
|
||||
*
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
#!/usr/bin/php
|
||||
|
||||
<?php
|
||||
/**
|
||||
* Change password for the scheduler account in storageServer
|
||||
*
|
||||
* required command line parameters:
|
||||
* @param 1. scheduler password
|
||||
*
|
||||
*/
|
||||
|
||||
require_once(dirname(__FILE__).'/../var/conf.php');
|
||||
require_once(dirname(__FILE__).'/../../alib/var/Subjects.php');
|
||||
include_once('DB.php');
|
||||
|
||||
if(trim(`whoami`) != 'root') {
|
||||
die("Please run this script as root.\n");
|
||||
}
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
die($CC_DBC->getMessage());
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
$pass = $argv[1];
|
||||
$r = Subjects::Passwd('scheduler', NULL, $pass);
|
||||
if (PEAR::isError($r)) {
|
||||
die($r->getMessage());
|
||||
}
|
||||
exit(0);
|
||||
?>
|
|
@ -0,0 +1,102 @@
|
|||
#!/usr/bin/php
|
||||
<?php
|
||||
require_once(dirname(__FILE__).'/../conf.php');
|
||||
require_once(dirname(__FILE__).'/../../../alib/var/Subjects.php');
|
||||
require_once('DB.php');
|
||||
require_once('Console/Getopt.php');
|
||||
|
||||
// Do not allow remote execution
|
||||
$arr = array_diff_assoc($_SERVER, $_ENV);
|
||||
if (isset($arr["DOCUMENT_ROOT"]) && ($arr["DOCUMENT_ROOT"] != "") ) {
|
||||
header("HTTP/1.1 400");
|
||||
header("Content-type: text/plain; charset=UTF-8");
|
||||
echo "400 Not executable\r\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
function printUsage()
|
||||
{
|
||||
echo "\n";
|
||||
echo "campcaster-user\n";
|
||||
echo "===============\n";
|
||||
echo " This program allows you to manage Campcaster users.\n";
|
||||
echo "\n";
|
||||
echo "OPTIONS:\n";
|
||||
echo " --addupdate <username> <password>\n";
|
||||
echo " Add the user or update the password for the user.\n";
|
||||
echo " --delete <username>\n";
|
||||
echo " Remove the user.\n";
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
$parsedCommandLine = Console_Getopt::getopt($argv, null, array("addupdate", "delete"));
|
||||
|
||||
if (PEAR::isError($parsedCommandLine)) {
|
||||
printUsage();
|
||||
exit(1);
|
||||
}
|
||||
$cmdLineOptions = $parsedCommandLine[0];
|
||||
if (count($parsedCommandLine[1]) == 0) {
|
||||
printUsage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$action = null;
|
||||
foreach ($cmdLineOptions as $tmpValue) {
|
||||
$optionName = $tmpValue[0];
|
||||
$optionValue = $tmpValue[1];
|
||||
switch ($optionName) {
|
||||
case '--addupdate':
|
||||
$action = "addupdate";
|
||||
break 2;
|
||||
case "--delete":
|
||||
$action = "delete";
|
||||
break 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_null($action)) {
|
||||
printUsage();
|
||||
exit;
|
||||
}
|
||||
|
||||
if (count($parsedCommandLine) < 1) {
|
||||
printUsage();
|
||||
exit;
|
||||
}
|
||||
|
||||
$username = $parsedCommandLine[1][0];
|
||||
$password = $parsedCommandLine[1][1];
|
||||
|
||||
PEAR::setErrorHandling(PEAR_ERROR_RETURN);
|
||||
$CC_DBC = DB::connect($CC_CONFIG['dsn'], TRUE);
|
||||
if (PEAR::isError($CC_DBC)) {
|
||||
die($CC_DBC->getMessage());
|
||||
}
|
||||
$CC_DBC->setFetchMode(DB_FETCHMODE_ASSOC);
|
||||
|
||||
// Check if the user exists
|
||||
$user = Subjects::GetSubject($username);
|
||||
|
||||
if ($action == "addupdate") {
|
||||
if (empty($password)) {
|
||||
printUsage();
|
||||
exit;
|
||||
}
|
||||
if (empty($user)) {
|
||||
// Add the user.
|
||||
$r = Subjects::AddSubj($username, $password);
|
||||
} else {
|
||||
// Update the password
|
||||
$r = Subjects::Passwd($username, NULL, $password);
|
||||
}
|
||||
} elseif (($action == "delete") && (is_array($user))) {
|
||||
// Delete the user
|
||||
$r = Subjects::RemoveSubj($username);
|
||||
}
|
||||
|
||||
if (PEAR::isError($r)) {
|
||||
die($r->getMessage());
|
||||
}
|
||||
exit(0);
|
||||
?>
|
|
@ -130,11 +130,6 @@ echo ""
|
|||
#-------------------------------------------------------------------------------
|
||||
# The details of installation
|
||||
#-------------------------------------------------------------------------------
|
||||
ls_dbserver=$dbserver
|
||||
ls_dbuser=$dbuser
|
||||
ls_dbpassword=$dbpassword
|
||||
ls_database=$database
|
||||
|
||||
|
||||
postgres_user=postgres
|
||||
|
||||
|
@ -180,31 +175,31 @@ echo "Creating database and database user...";
|
|||
|
||||
# FIXME: the below might not work for remote databases
|
||||
|
||||
if [ "x$ls_dbserver" == "xlocalhost" ]; then
|
||||
su - $postgres_user -c "echo \"CREATE USER $ls_dbuser \
|
||||
ENCRYPTED PASSWORD '$ls_dbpassword' \
|
||||
if [ "x$dbserver" == "xlocalhost" ]; then
|
||||
su - $postgres_user -c "echo \"CREATE USER $dbuser \
|
||||
ENCRYPTED PASSWORD '$dbpassword' \
|
||||
CREATEDB NOCREATEUSER;\" \
|
||||
| psql template1" \
|
||||
|| echo "Couldn't create database user $ls_dbuser.";
|
||||
|| echo "Couldn't create database user $dbuser.";
|
||||
|
||||
su - $postgres_user -c "echo \"CREATE DATABASE \\\"$ls_database\\\" \
|
||||
OWNER $ls_dbuser ENCODING 'utf-8';\" \
|
||||
su - $postgres_user -c "echo \"CREATE DATABASE \\\"$database\\\" \
|
||||
OWNER $dbuser ENCODING 'utf-8';\" \
|
||||
| psql template1" \
|
||||
|| echo "Couldn't create database $ls_database.";
|
||||
|| echo "Couldn't create database $database.";
|
||||
else
|
||||
echo "Unable to automatically create database user and table for";
|
||||
echo "remote database $ls_dbserver.";
|
||||
echo "Make sure to create database user $ls_dbuser with password";
|
||||
echo "$ls_dbpassword on database server at $ls_dbserver.";
|
||||
echo "remote database $dbserver.";
|
||||
echo "Make sure to create database user $dbuser with password";
|
||||
echo "$dbpassword on database server at $dbserver.";
|
||||
echo "Also create a database called $ld_database, owned by this user.";
|
||||
echo "";
|
||||
echo "The easiest way to achieve this is by issuing the following SQL";
|
||||
echo "commands to PostgreSQL:";
|
||||
echo "CREATE USER $ls_dbuser";
|
||||
echo " ENCRYPTED PASSWORD '$ls_dbpassword'";
|
||||
echo "CREATE USER $dbuser";
|
||||
echo " ENCRYPTED PASSWORD '$dbpassword'";
|
||||
echo " CREATEDB NOCREATEUSER;";
|
||||
echo "CREATE DATABASE \"$ls_database\"";
|
||||
echo " OWNER $ls_dbuser ENCODING 'utf-8';";
|
||||
echo "CREATE DATABASE \"$database\"";
|
||||
echo " OWNER $dbuser ENCODING 'utf-8';";
|
||||
fi
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue