initial commit of file from CVS for smeserver-phppgadmin on Sat Sep 7 20:53:08 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 20:53:08 +10:00
parent 9692a5d986
commit 968f65d84e
20 changed files with 1131 additions and 2 deletions

View File

@@ -0,0 +1 @@
reserved

View File

@@ -0,0 +1 @@
private

View File

@@ -0,0 +1 @@
enabled

View File

@@ -0,0 +1 @@
configuration

View File

@@ -0,0 +1,11 @@
{
my $rec = $DB->get('phppgadmin')
|| $DB->new_record('phppgadmin', {type => 'configuration'});
my $pw = $rec->prop('Password');
if (not $pw or length($pw) < 20){
my $pw = `/usr/bin/openssl rand -base64 28 | tr -c -d '[:alnum:]'`;
$rec->set_prop('Password', $pw);
}
}

View File

@@ -0,0 +1,12 @@
#!/usr/bin/bash
psql='/usr/pgsql-13/bin/psql'
password=`/sbin/e-smith/db configuration getprop phppgadmin Password || echo "changeme"`
admin=`sudo -Hiu postgres $psql -tAc "SELECT 1 FROM pg_roles WHERE rolname='admin'"`
if [[ $admin -ne '1' ]];then
# sudo -Hiu postgres $psql -c "CREATE USER admin CREATEDB CREATEUSER CREATEROLE ENCRYPTED PASSWORD '$password';"
sudo -Hiu postgres $psql -c "CREATE USER admin CREATEDB CREATEROLE ENCRYPTED PASSWORD '$password';"
else
sudo -Hiu postgres $psql -c "ALTER USER admin WITH PASSWORD '$password';"
exit 0
fi

View File

@@ -0,0 +1,31 @@
{
my $status = $phppgadmin{'status'} || 'disabled';
return "# phpPgAdmin configuration is disabled by its status property" unless ($status eq 'enabled');
$OUT .="#-------------------------------------------------\n";
$OUT .="# phpPgAdmin settings from smeserver-phppgadmin\n";
$OUT .="#-------------------------------------------------\n";
$OUT .="\n";
$OUT .= "Alias /phpPgAdmin /usr/share/phpPgAdmin\n";
$OUT .= "Alias /phppgadmin /usr/share/phpPgAdmin\n";
my $access = ($phppgadmin{access} eq "public" ) ? "all granted" : "ip $localAccess" ;
$OUT .= qq(
<Directory /usr/share/phpPgAdmin/>
SSLRequireSSL
Options -Indexes
AllowOverride None
AddType application/x-httpd-php .php
<FilesMatch \.(php|phar)\$>
SetHandler "proxy:unix:/var/run/php-fpm/php74-phppgadmin.sock|fcgi://localhost"
</FilesMatch>
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=\$1
<RequireAny>
Require $access
</RequireAny>
</Directory>);
}

View File

@@ -0,0 +1,13 @@
{
if (($port eq "80") && ($haveSSL eq 'yes')){
$OUT=qq(#
# 50phpPgAdmin
#
RewriteEngine On
RewriteCond %\{HTTPS\} !=on
RewriteRule ^/phppgadmin(/.*)?$ https://%\{HTTP_HOST\}/phppgadmin$1 [L,R=301]
RewriteRule ^/phpPgAdmin(/.*)?$ https://%\{HTTP_HOST\}/phpPgAdmin$1 [L,R=301]);
} else {
$OUT="";
}
}

View File

@@ -0,0 +1,72 @@
{
if ($PHP_VERSION eq '74'){
if (($phppgadmin{'status'} || 'disabled') eq 'enabled'){
my $max_upload_size = ($phppgadmin{MaxUploadSize} || '100M');# 104857600 bytes
$max_upload_size .= 'M' if ($max_upload_size =~ m/^\d+$/);
my $memory_limit = ($phppgadmin{MemoryLimit} || '512M');
$memory_limit .= 'M' if ($memory_limit =~ m/^\d+$/);
my $open_basedir= $phppgadmin{PHPBaseDir} || '';
$open_basedir = "/usr/share/phpPgAdmin/:/etc/phpPgAdmin/:".
"/usr/share/php/:".
"/var/log/php/phppgadmin:/dev/urandom:/proc/meminfo:$open_basedir";
my $max_children = $phppgadmin{'PHPmaxChildren'} || 20;
my $min_spare_servers = $phppgadmin{'PHPminServers'} || 4;
my $start_servers = $phppgadmin{'PHPstartServers'} || 6;
my $max_spare_servers = $phppgadmin{'PHPmaxServers'} || 8;
my $max_requests = $phppgadmin{'PHPmaxRequests'} || 1000;
$min_spare_servers = ( $min_spare_servers > $max_spare_servers ) ? printf("%.0f",$max_spare_servers/2) : $min_spare_servers;
$start_servers = ( $start_servers > $max_spare_servers ) ? printf("%.0f", $max_spare_servers /2 + $min_spare_servers/2 ) : $start_servers;
my $id = 'phppgadmin';
$OUT .=<<"_EOF";
[php$PHP_VERSION-$id]
user = www
group = www
listen.owner = root
listen.group = www
listen.mode = 0660
listen = /var/run/php-fpm/php$PHP_VERSION-$id.sock
pm = dynamic
pm.max_children = $max_children
pm.start_servers = $start_servers
pm.min_spare_servers = $min_spare_servers
pm.max_spare_servers = $max_spare_servers
pm.max_requests = $max_requests
; Used in nextcloud
php_admin_value[session.save_path] = /var/lib/php/$id/session
php_admin_value[session.gc_maxlifetime] = 86400
php_admin_value[opcache.file_cache] = /var/lib/php/$id/opcache
php_admin_value[upload_tmp_dir] = /var/lib/php/$id/tmp
php_admin_value[sys_temp_dir] = /var/lib/php/$id/tmp
php_admin_value[error_log] = /var/log/php/$id/error.log
slowlog = /var/log/php/$id/slow.log
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f php@{ $DomainName }
php_admin_flag[display_errors] = off
php_admin_flag[log_errors] = on
php_admin_value[memory_limit] = $memory_limit
php_admin_value[max_execution_time] = 3600
php_admin_value[post_max_size] = $max_upload_size
php_admin_value[upload_max_filesize] = $max_upload_size
php_admin_value[disable_functions] = system, show_source, symlink, exec, dl, shell_exec, passthru, phpinfo, escapeshellarg, escapeshellcmd
php_admin_value[open_basedir] = $open_basedir
php_admin_flag[allow_url_fopen] = on
php_admin_flag[file_upload] = on
php_admin_flag[session.cookie_httponly] = on
php_admin_flag[allow_url_include] = off
php_admin_value[session.save_handler] = files
php_admin_flag[output_buffering] = off
php_admin_value[auto_prepend_file] = /usr/share/php/auth_translation.php
php_flag[session.use_trans_sid] = off
php_flag[track_vars] = on
php_flag[magic_quotes_gpc] = off
_EOF
}
else{
$OUT .= '; phppgadmin is disabled';
}
}
}

View File

@@ -0,0 +1,151 @@
/**
* Central phpPgAdmin configuration. As a user you may modify the
* settings here for your particular configuration.
*
* $Id: config.inc.php-dist,v 1.55 2008/02/18 21:10:31 xzilla Exp $
*/
// An example server. Create as many of these as you wish,
// indexed from zero upwards.
// Display name for the server on the login screen
$conf['servers'][0]['desc'] = 'PostgreSQL';
// Hostname or IP address for server. Use '' for UNIX domain socket.
// use 'localhost' for TCP/IP connection on this computer
$conf['servers'][0]['host'] = 'localhost';
// Database port on server (5432 is the PostgreSQL default)
$conf['servers'][0]['port'] = {${postgresql}{'TCPPort'}|| '5432'};
// Database SSL mode
// Possible options: disable, allow, prefer, require
// To require SSL on older servers use option: legacy
// To ignore the SSL mode, use option: unspecified
$conf['servers'][0]['sslmode'] = 'require';
// Change the default database only if you cannot connect to template1.
// For a PostgreSQL 8.1+ server, you can set this to 'postgres'.
$conf['servers'][0]['defaultdb'] = 'template1';
// Specify the path to the database dump utilities for this server.
// You can set these to '' if no dumper is available.
$conf['servers'][0]['pg_dump_path'] = '/usr/bin/pg_dump';
$conf['servers'][0]['pg_dumpall_path'] = '/usr/bin/pg_dumpall';
// Example for a second server (PostgreSQL for Windows)
//$conf['servers'][1]['desc'] = 'Test Server';
//$conf['servers'][1]['host'] = '127.0.0.1';
//$conf['servers'][1]['port'] = 5432;
//$conf['servers'][1]['sslmode'] = 'allow';
//$conf['servers'][1]['defaultdb'] = 'template1';
//$conf['servers'][1]['pg_dump_path'] = 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dump.exe';
//$conf['servers'][1]['pg_dumpall_path'] = 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dumpall.exe';
/* Groups definition */
/* Groups allow administrators to logicaly group servers together under
* group nodes in the left browser tree
*
* The group '0' description
*/
//$conf['srv_groups'][0]['desc'] = 'group one';
/* Add here servers indexes belonging to the group '0' seperated by comma */
//$conf['srv_groups'][0]['servers'] = '0,1,2';
/* A server can belong to multi groups. Here server 1 is referenced in both
* 'group one' and 'group two'*/
//$conf['srv_groups'][1]['desc'] = 'group two';
//$conf['srv_groups'][1]['servers'] = '3,1';
/* A group can be nested in one or more existing groups using the 'parents'
* parameter. Here the group 'group three' contains only one server and will
* appear as a subgroup in both 'group one' and 'group two':
*/
//$conf['srv_groups'][2]['desc'] = 'group three';
//$conf['srv_groups'][2]['servers'] = '4';
//$conf['srv_groups'][2]['parents'] = '0,1';
/* Warning: Only groups with no parents appears at the root of the tree. */
// Default language. E.g.: 'english', 'polish', etc. See lang/ directory
// for all possibilities. If you specify 'auto' (the default) it will use
// your browser preference.
$conf['default_lang'] = 'auto';
// AutoComplete uses AJAX interaction to list foreign key values
// on insert fields. It currently only works on single column
// foreign keys. You can choose one of the following values:
// 'default on' enables AutoComplete and turns it on by default.
// 'default off' enables AutoComplete but turns it off by default.
// 'disable' disables AutoComplete.
$conf['autocomplete'] = 'default on';
// If extra login security is true, then logins via phpPgAdmin with no
// password or certain usernames (pgsql, postgres, root, administrator)
// will be denied. Only set this false once you have read the FAQ and
// understand how to change PostgreSQL's pg_hba.conf to enable
// passworded local connections.
$conf['extra_login_security'] = true;
// Only show owned databases?
// Note: This will simply hide other databases in the list - this does
// not in any way prevent your users from seeing other database by
// other means. (e.g. Run 'SELECT * FROM pg_database' in the SQL area.)
$conf['owned_only'] = true;
// Display comments on objects? Comments are a good way of documenting
// a database, but they do take up space in the interface.
$conf['show_comments'] = true;
// Display "advanced" objects? Setting this to true will show
// aggregates, types, operators, operator classes, conversions,
// languages and casts in phpPgAdmin. These objects are rarely
// administered and can clutter the interface.
$conf['show_advanced'] = true;
// Display "system" objects?
$conf['show_system'] = false;
// Minimum length users can set their password to.
$conf['min_password_length'] = 8;
// Width of the left frame in pixels (object browser)
$conf['left_width'] = 300;
// Which look & feel theme to use
$conf['theme'] = 'default';
// Show OIDs when browsing tables?
$conf['show_oids'] = false;
// Max rows to show on a page when browsing record sets
$conf['max_rows'] = 30;
// Max chars of each field to display by default in browse mode
$conf['max_chars'] = 50;
// Send XHTML strict headers?
$conf['use_xhtml_strict'] = false;
// Base URL for PostgreSQL documentation.
// '%s', if present, will be replaced with the PostgreSQL version
// (e.g. 8.4 )
$conf['help_base'] = 'http://www.postgresql.org/docs/%s/interactive/';
// Configuration for ajax scripts
// Time in seconds. If set to 0, refreshing data using ajax will be disabled (locks and activity pages)
$conf['ajax_refresh'] = 3;
/** Plugins management
* Add plugin names to the following array to activate them
* Example:
* $conf['plugins'] = array(
* 'Example',
* 'Slony'
* );
*/
$conf['plugins'] = array();

View File

@@ -0,0 +1,6 @@
/*****************************************
* Don't modify anything below this line *
*****************************************/
$conf['version'] = 19;

View File

@@ -0,0 +1,14 @@
{
$OUT = <<HERE;
<?php
/*
HERE
$OUT .=
Text::Template::_load_text("/etc/e-smith/templates-default/template-begin");
$OUT .= <<HERE;
*/
HERE
}