initial commit of file from CVS for smeserver-mediawiki on Sat Sep 7 20:40:03 AEST 2024

This commit is contained in:
Trevor Batley
2024-09-07 20:40:03 +10:00
parent 6206aa2519
commit 259c480052
23 changed files with 16844 additions and 2 deletions

View File

@@ -0,0 +1,35 @@
#!/bin/sh
# Use this file to finish MediaWiki removal ONLY if you don't want to keep it on your system.
clear
echo "WARNING!!!"
echo "This script will delete:"
echo " - MediaWiki MySQL database"
echo " - MediaWiki MySQL User"
echo " - MediaWiki DB entries..."
echo " - MediaWiki SME groups..."
echo " - All Install files"
echo -n "ARE YOU SURE YOU WANT TO DELETE PERMANENTLY MEDIAWIKI? (y/n) [n] "
read del
if [ "$del" = "y" -o "$del" = "Y" ]; then
echo "Deleting MySQL database..."
mysql -u root -e "DROP DATABASE mediawiki"
echo "Deleting MySQL User..."
mysql -u root -e "REVOKE ALL PRIVILEGES ON mediawiki.* FROM 'mediawikiuser'@'localhost';"
mysql -u root -e "DROP USER mediawikiuser@localhost;"
echo "Removing SME DB entries..."
/sbin/e-smith/config delete mediawiki
echo "Removing SME group entries..."
# /sbin/e-smith/db accounts set mw_read deleted
# /sbin/e-smith/db accounts set mw_edit deleted
# /sbin/e-smith/db accounts set mw_createpage deleted
# /sbin/e-smith/db accounts set mw_createtalk deleted
# /sbin/e-smith/signal-event group-delete mw_read
# /sbin/e-smith/signal-event group-delete mw_edit
# /sbin/e-smith/signal-event group-delete mw_createpage
# /sbin/e-smith/signal-event group-delete mw_createtalk
echo "Removing Install files..."
rm -rf /opt/mediawiki
echo "Done!"
rm -f /root/MW-Full-Uninstall.sh
fi

View File

@@ -0,0 +1,140 @@
<?php
# This file was automatically generated by the MediaWiki 1.38.1
# installer. If you make manual changes, please keep track in case you
# need to recreate them later.
#
# See docs/Configuration.md for all configurable settings
# and their default values, but don't forget to make changes in _this_
# file, not there.
#
# Further documentation for configuration settings may be found at:
# https://www.mediawiki.org/wiki/Manual:Configuration_settings
# Protect against web entry
if ( !defined( 'MEDIAWIKI' ) ) {
exit;
}
## Uncomment this to disable output compression
# $wgDisableOutputCompression = true;
$wgSitename = "SMEmediawiki";
## The URL base path to the directory containing the wiki;
## defaults for all runtime URL paths are based off of this.
## For more information on customizing the URLs
## (like /w/index.php/Page_title to /wiki/Page_title) please see:
## https://www.mediawiki.org/wiki/Manual:Short_URL
$wgScriptPath = "/mediawiki";
## The protocol and server name to use in fully-qualified URLs
$wgServer = "https://myhost.mydomain";
## The URL path to static resources (images, scripts, etc.)
$wgResourceBasePath = $wgScriptPath;
## The URL paths to the logo. Make sure you change this from the default,
## or else you'll overwrite your logo when you upgrade!
$wgLogos = [
'1x' => "$wgResourceBasePath/resources/assets/change-your-logo.svg",
'icon' => "$wgResourceBasePath/resources/assets/change-your-logo-icon.svg",
];
## UPO means: this is also a user preference option
$wgEnableEmail = true;
$wgEnableUserEmail = true; # UPO
$wgEmergencyContact = "admin@mydomain";
$wgPasswordSender = "admin@mydomain";
$wgEnotifUserTalk = false; # UPO
$wgEnotifWatchlist = false; # UPO
$wgEmailAuthentication = true;
## Database settings
$wgDBtype = "mysql";
$wgDBserver = "localhost";
$wgDBname = "mediawiki";
$wgDBuser = "mediawikiuser";
$wgDBpassword = "mediawikipassword";
# MySQL specific settings
$wgDBprefix = "";
# MySQL table options to use during installation or update
$wgDBTableOptions = "ENGINE=InnoDB, DEFAULT CHARSET=binary";
# Shared database table
# This has no effect unless $wgSharedDB is also set.
$wgSharedTables[] = "actor";
## Shared memory settings
$wgMainCacheType = CACHE_NONE;
$wgMemCachedServers = [];
## To enable image uploads, make sure the 'images' directory
## is writable, then set this to true:
$wgEnableUploads = false;
$wgUseImageMagick = true;
$wgImageMagickConvertCommand = "/usr/bin/convert";
# InstantCommons allows wiki to use images from https://commons.wikimedia.org
$wgUseInstantCommons = false;
# Periodically send a pingback to https://www.mediawiki.org/ with basic data
# about this MediaWiki instance. The Wikimedia Foundation shares this data
# with MediaWiki developers to help guide future development efforts.
$wgPingback = true;
# Site language code, should be one of the list in ./languages/data/Names.php
$wgLanguageCode = "en-gb";
# Time zone
$wgLocaltimezone = "Europe/London";
## Set $wgCacheDirectory to a writable directory on the web server
## to make your wiki go slightly faster. The directory should not
## be publicly accessible from the web.
#$wgCacheDirectory = "$IP/cache";
$wgSecretKey = "99d03bd9d6070e2d2ba6f96443e5b0c65de1cebc75b6b059287a864285799397";
# Changing this will log out all existing sessions.
$wgAuthenticationTokenVersion = "1";
# Site upgrade key. Must be set to a string (default provided) to turn on the
# web installer while LocalSettings.php is in place
$wgUpgradeKey = "f00fc216bf2414ef";
## For attaching licensing metadata to pages, and displaying an
## appropriate copyright notice / icon. GNU Free Documentation
## License and Creative Commons licenses are supported so far.
$wgRightsPage = ""; # Set to the title of a wiki page that describes your license/copyright
$wgRightsUrl = "";
$wgRightsText = "";
$wgRightsIcon = "";
# Path to the GNU diff3 utility. Used for conflict resolution.
$wgDiff3 = "/usr/bin/diff3";
## Default skin: you can change the default skin. Use the internal symbolic
## names, e.g. 'vector' or 'monobook':
$wgDefaultSkin = "vector";
# Enabled skins.
# The following skins were automatically enabled:
wfLoadSkin( 'MinervaNeue' );
wfLoadSkin( 'MonoBook' );
wfLoadSkin( 'Timeless' );
wfLoadSkin( 'Vector' );
# End of automatically generated settings.
# Add more configuration options below.
# Uncomment to get full error messages on failures.
#$wgShowExceptionDetails = true;

View File

@@ -0,0 +1,309 @@
<?php
/**
* Version 1.0
*
* Authentication Plugin for pwauth
* Derived from AuthPlugin.php
*
* Much of the commenting comes straight from AuthPlugin.php
*
* Copyright 2006 Nicholas J. Humfrey
* Released under the GNU General Public License
*
* pwauth is available from http://www.unixpapa.com/pwauth/
*
* LocalSettings configuration:
* require_once("./extensions/PwAuthPlugin.php");
* $wgAuth = new PwAuthPlugin();
*
*
*/
require_once('AuthPlugin.php');
$pwauth_email_domain = "";
$pwauth_bin_path = "/usr/lib/httpd/modules/pwauth";
error_reporting(E_ALL); // Debug
// First check if class has already been defined.
if (!class_exists('AuthPlugin')) {
/**
* Auth Plugin
*
*/
require_once './includes/AuthPlugin.php';
} // End: if (!class_exists('AuthPlugin')) {
class PwAuthPlugin extends AuthPlugin {
/**
* Check whether there exists a user account with the given name.
* The name will be normalized to MediaWiki's requirements, so
* you might need to munge it (for instance, for lowercase initial
* letters).
*
* @param string $username
* @return bool
* @access public
*/
function userExists( $username ) {
$user = posix_getpwnam( strtolower($username) );
return is_array($user);
}
/**
* Check if a username+password pair is a valid login.
* The name will be normalized to MediaWiki's requirements, so
* you might need to munge it (for instance, for lowercase initial
* letters).
*
* @param string $username
* @param string $password
* @return bool
* @access public
*/
function authenticate( $username, $password ) {
global $pwauth_bin_path;
$username = strtolower( $username );
$handle = popen($pwauth_bin_path, 'w');
if ($handle === FALSE) {
error_log("Error opening pipe to pwauth");
return false;
}
if (fwrite($handle, "$username\n$password\n") === FALSE) {
error_log("Error writing to pwauth pipe");
return false;
}
# Is the password valid?
$result = pclose( $handle );
if ($result==0) return TRUE;
#0 - Login OK.
#1 - Nonexistant login or (for some configurations) incorrect password.
#2 - Incorrect password (for some configurations).
#3 - Uid number is below MIN_UNIX_UID value configured in config.h.
#4 - Login ID has expired.
#5 - Login's password has expired.
#6 - Logins to system have been turned off (usually by /etc/nologin file).
#7 - Limit on number of bad logins exceeded.
#50 - pwauth was not run with real uid SERVER_UID. If you get this
# this error code, you probably have SERVER_UID set incorrectly
# in pwauth's config.h file.
#51 - pwauth was not given a login & password to check. The means
# the passing of data from mod_auth_external to pwauth is messed
# up. Most likely one is trying to pass data via environment
# variables, while the other is trying to pass data via a pipe.
#52 - one of several possible internal errors occured.
error_log("pwauth returned $result for username $username");
return false;
}
/**
* Modify options in the login template.
*
* @param UserLoginTemplate $template
* @access public
*/
function modifyUITemplate( &$template ) {
$template->set('usedomain', false );
$template->set('useemail', false); // Disable the mail new password box.
$template->set('create', false); // Remove option to create new accounts from the wiki.
}
/**
* Check to see if the specific domain is a valid domain.
*
* @param string $domain
* @return bool
* @access public
*/
function validDomain( $domain ) {
# We ignore domains, so erm, yes?
return true;
}
/**
* When a user logs in, optionally fill in preferences and such.
* For instance, you might pull the email address or real name from the
* external user database.
*
* The User object is passed by reference so it can be modified; don't
* forget the & on your function declaration.
*
* @param User $user
* @access public
*/
function updateUser( &$user ) {
global $pwauth_email_domain;
// Lookup information about user
$username = strtolower( $user->getName() );
$account = posix_getpwnam( $username );
$gecos = split( ',', $account['gecos'] );
// Set users real name
$user->setRealName( $gecos[0] );
// Set email if domain is configured
if (!empty( $pwauth_email_domain ) ) {
// Set the email address
$user->setEmail( $username.'@'.$pwauth_email_domain );
// We set the email address, therefore it is valid
$user->confirmEmail();
}
// For security, scramble the password to ensure the user can
// only login using system password.
// This set the password to a 15 byte random string.
$pass = '';
for($i=0; $i<15;++$i) $pass .= chr(mt_rand(0,255));
$user->setPassword($pass);
return true;
}
/**
* Return true if the wiki should create a new local account automatically
* when asked to login a user who doesn't exist locally but does in the
* external auth database.
*
* If you don't automatically create accounts, you must still create
* accounts in some way. It's not possible to authenticate without
* a local account.
*
* This is just a question, and shouldn't perform any actions.
*
* @return bool
* @access public
*/
function autoCreate() {
return true;
}
/**
* Can users change their passwords?
*
* @return bool
*/
function allowPasswordChange() {
# We can't change users system passwords
return false;
}
/**
* Set the given password in the authentication database.
* Return true if successful.
*
* @param string $password
* @return bool
* @access public
*/
function setPassword( $password ) {
# We can't change users system passwords
return false;
}
/**
* Update user information in the external authentication database.
* Return true if successful.
*
* @param User $user
* @return bool
* @access public
*/
function updateExternalDB( $user ) {
# We can't change users details
return false;
}
/**
* Check to see if external accounts can be created.
* Return true if external accounts can be created.
* @return bool
* @access public
*/
function canCreateAccounts() {
# We can't create accounts
return false;
}
/**
* Add a user to the external authentication database.
* Return true if successful.
*
* @param User $user
* @param string $password
* @return bool
* @access public
*/
function addUser( $user, $password ) {
# We can't create accounts
return false;
}
/**
* Return true to prevent logins that don't authenticate here from being
* checked against the local database's password fields.
*
* This is just a question, and shouldn't perform any actions.
*
* @return bool
* @access public
*/
function strict() {
# Only allow authentication from system database
return true;
}
/**
* When creating a user account, optionally fill in preferences and such.
* For instance, you might pull the email address or real name from the
* external user database.
*
* The User object is passed by reference so it can be modified; don't
* forget the & on your function declaration.
*
* @param User $user
* @access public
*/
function initUser(&$user) {
# We do everything in updateUser
}
}
/**
* Some extension information init
*/
$wgExtensionCredits['other'][] = array(
'name' => 'PWAuthPlugin',
'version' => '1.0',
'author' => 'Nicholas Humfrey',
'description' => 'Automagic login with system accounts, using pwauth',
'url' => 'http://www.mediawiki.org/wiki/Extension:PwAuthPlugin'
);
?>

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 894 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.9 KiB