From f9d12a2d1e56a34f0f7dbe547ca0f7e0615fb291 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 13 Jul 2017 15:27:51 +0800 Subject: [PATCH] MDL-50925 auth_pam: Remove from core and into plugins DB --- auth/pam/auth.php | 123 --------------------------------- auth/pam/db/install.php | 6 -- auth/pam/db/upgrade.php | 49 ------------- auth/pam/lang/en/auth_pam.php | 28 -------- auth/pam/settings.php | 37 ---------- auth/pam/upgrade.txt | 7 -- auth/pam/version.php | 29 -------- lib/classes/plugin_manager.php | 4 +- 8 files changed, 2 insertions(+), 281 deletions(-) delete mode 100644 auth/pam/auth.php delete mode 100644 auth/pam/db/install.php delete mode 100644 auth/pam/db/upgrade.php delete mode 100644 auth/pam/lang/en/auth_pam.php delete mode 100644 auth/pam/settings.php delete mode 100644 auth/pam/upgrade.txt delete mode 100644 auth/pam/version.php diff --git a/auth/pam/auth.php b/auth/pam/auth.php deleted file mode 100644 index 35e0abf9df8..00000000000 --- a/auth/pam/auth.php +++ /dev/null @@ -1,123 +0,0 @@ -. - -/** - * Authentication Plugin: PAM Authentication - * - * PAM (Pluggable Authentication Modules) for Moodle - * - * Description: - * Authentication by using the PHP4 PAM module: - * http://www.math.ohio-state.edu/~ccunning/pam_auth/ - * - * Version 0.3 2006/09/07 by Jonathan Harker (plugin class) - * Version 0.2: 2004/09/01 by Martin V�geli (stable version) - * Version 0.1: 2004/08/30 by Martin V�geli (first draft) - * - * Contact: martinvoegeli@gmx.ch - * Website 1: http://elearning.zhwin.ch/ - * Website 2: http://birdy1976.com/ - * - * @package auth_pam - * @author Martin Dougiamas - * @license http://www.gnu.org/copyleft/gpl.html GNU Public License - */ - -defined('MOODLE_INTERNAL') || die(); - -require_once($CFG->libdir.'/authlib.php'); - -/** - * PAM authentication plugin. - */ -class auth_plugin_pam extends auth_plugin_base { - - /** - * Store error messages from pam authentication attempts. - */ - var $lasterror; - - /** - * Constructor. - */ - public function __construct() { - $this->authtype = 'pam'; - $this->config = get_config('auth_pam'); - $this->errormessage = ''; - } - - /** - * Old syntax of class constructor. Deprecated in PHP7. - * - * @deprecated since Moodle 3.1 - */ - public function auth_plugin_pam() { - debugging('Use of class name as constructor is deprecated', DEBUG_DEVELOPER); - self::__construct(); - } - - /** - * Returns true if the username and password work and false if they are - * wrong or don't exist. - * - * @param string $username The username - * @param string $password The password - * @return bool Authentication success or failure. - */ - function user_login ($username, $password) { - // variable to store possible errors during authentication - $errormessage = str_repeat(' ', 2048); - - // just for testing and debugging - // error_reporting(E_ALL); - - // call_time_pass_reference of errormessage is deprecated - throws warnings in multiauth - //if (pam_auth($username, $password, &$errormessage)) { - if (pam_auth($username, $password)) { - return true; - } - else { - $this->lasterror = $errormessage; - return false; - } - } - - function prevent_local_passwords() { - return true; - } - - /** - * Returns true if this authentication plugin is 'internal'. - * - * @return bool - */ - function is_internal() { - return false; - } - - /** - * Returns true if this authentication plugin can change the user's - * password. - * - * @return bool - */ - function can_change_password() { - return false; - } - -} - - diff --git a/auth/pam/db/install.php b/auth/pam/db/install.php deleted file mode 100644 index c519486c2a4..00000000000 --- a/auth/pam/db/install.php +++ /dev/null @@ -1,6 +0,0 @@ -. - -/** - * PAM authentication plugin upgrade code - * - * @package auth_pam - * @copyright 2017 Stephen Bourget - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -/** - * Function to upgrade auth_pam. - * @param int $oldversion the version we are upgrading from - * @return bool result - */ -function xmldb_auth_pam_upgrade($oldversion) { - global $CFG, $DB; - - // Automatically generated Moodle v3.2.0 release upgrade line. - // Put any upgrade step following this. - - if ($oldversion < 2017020700) { - // Convert info in config plugins from auth/pam to auth_pam. - upgrade_fix_config_auth_plugin_names('pam'); - upgrade_fix_config_auth_plugin_defaults('pam'); - upgrade_plugin_savepoint(true, 2017020700, 'auth', 'pam'); - } - - // Automatically generated Moodle v3.3.0 release upgrade line. - // Put any upgrade step following this. - - return true; -} diff --git a/auth/pam/lang/en/auth_pam.php b/auth/pam/lang/en/auth_pam.php deleted file mode 100644 index e4159be8329..00000000000 --- a/auth/pam/lang/en/auth_pam.php +++ /dev/null @@ -1,28 +0,0 @@ -. - -/** - * Strings for component 'auth_pam', language 'en'. - * - * @package auth_pam - * @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -$string['auth_pamdescription'] = 'This method uses PAM to access the native usernames on this server. You have to install PHP4 PAM Authentication in order to use this module.'; -$string['auth_passwordisexpired'] = 'Your password has expired. Do you want to change your password now?'; -$string['auth_passwordwillexpire'] = 'Your password will expire in {$a} days. Do you want to change your password now?'; -$string['pluginname'] = 'PAM (Pluggable Authentication Modules)'; diff --git a/auth/pam/settings.php b/auth/pam/settings.php deleted file mode 100644 index 7a053a3f10e..00000000000 --- a/auth/pam/settings.php +++ /dev/null @@ -1,37 +0,0 @@ -. - -/** - * Admin settings and defaults. - * - * @package auth_pam - * @copyright 2017 Stephen Bourget - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die; - -if ($ADMIN->fulltree) { - - // Introductory explanation. - $settings->add(new admin_setting_heading('auth_pam/pluginname', '', - new lang_string('auth_pamdescription', 'auth_pam'))); - - // Display locking / mapping of profile fields. - $authplugin = get_auth_plugin('pam'); - display_auth_lock_options($settings, $authplugin->authtype, $authplugin->userfields, - get_string('auth_fieldlocks_help', 'auth'), false, false); -} diff --git a/auth/pam/upgrade.txt b/auth/pam/upgrade.txt deleted file mode 100644 index 19972b60b9e..00000000000 --- a/auth/pam/upgrade.txt +++ /dev/null @@ -1,7 +0,0 @@ -This files describes API changes in /auth/pam/*, -information provided here is intended especially for developers. - -=== 3.3 === - -* The config.html file was migrated to use the admin settings API. - The identifier for configuration data stored in config_plugins table was converted from 'auth/pam' to 'auth_pam'. diff --git a/auth/pam/version.php b/auth/pam/version.php deleted file mode 100644 index 35896816a5d..00000000000 --- a/auth/pam/version.php +++ /dev/null @@ -1,29 +0,0 @@ -. - -/** - * Version information - * - * @package auth_pam - * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -defined('MOODLE_INTERNAL') || die(); - -$plugin->version = 2017051500; // The current plugin version (Date: YYYYMMDDXX) -$plugin->requires = 2017050500; // Requires this Moodle version -$plugin->component = 'auth_pam'; // Full name of the plugin (used for diagnostics) diff --git a/lib/classes/plugin_manager.php b/lib/classes/plugin_manager.php index 89c9525855c..5a255be33ea 100644 --- a/lib/classes/plugin_manager.php +++ b/lib/classes/plugin_manager.php @@ -1646,7 +1646,7 @@ class core_plugin_manager { // Moodle 2.3 supports upgrades from 2.2.x only. $plugins = array( 'qformat' => array('blackboard', 'learnwise'), - 'auth' => array('radius', 'fc', 'nntp'), + 'auth' => array('radius', 'fc', 'nntp', 'pam'), 'block' => array('course_overview'), 'enrol' => array('authorize'), 'report' => array('search'), @@ -1702,7 +1702,7 @@ class core_plugin_manager { 'auth' => array( 'cas', 'db', 'email', 'imap', 'ldap', 'lti', 'manual', 'mnet', - 'nologin', 'none', 'oauth2', 'pam', 'pop3', 'shibboleth', 'webservice' + 'nologin', 'none', 'oauth2', 'pop3', 'shibboleth', 'webservice' ), 'availability' => array(