From 8e8e305d1889640b81c92d92d4e1352997352b66 Mon Sep 17 00:00:00 2001 From: Dragan Dosen Date: Fri, 26 Mar 2010 14:21:22 +0100 Subject: [PATCH] Imported Upstream version 3.0 --- README | 1 + config_example.php | 9 ++ doc/.htaccess | 1 + doc/COPYING | 281 ++++++++++++++++++++++++++++++++++++++++++++++++++++ doc/ChangeLog | 144 +++++++++++++++++++++++++++ doc/FAQ | 26 +++++ doc/INSTALL | 59 +++++++++++ doc/README | 36 +++++++ doc/index.php | 13 +++ functions.php | 141 ++++++++++++++++++++++++++ index.php | 13 +++ options.php | 127 ++++++++++++++++++++++++ setup.php | 34 +++++++ version | 2 + 14 files changed, 887 insertions(+) create mode 100644 README create mode 100644 config_example.php create mode 100644 doc/.htaccess create mode 100644 doc/COPYING create mode 100644 doc/ChangeLog create mode 100644 doc/FAQ create mode 100644 doc/INSTALL create mode 100644 doc/README create mode 100644 doc/index.php create mode 100644 functions.php create mode 100644 index.php create mode 100644 options.php create mode 100644 setup.php create mode 100644 version diff --git a/README b/README new file mode 100644 index 0000000..dd0e567 --- /dev/null +++ b/README @@ -0,0 +1 @@ +See the documentation in the doc/ directory. diff --git a/config_example.php b/config_example.php new file mode 100644 index 0000000..ba9b67a --- /dev/null +++ b/config_example.php @@ -0,0 +1,9 @@ + +- Code cleanups and changes +- Updated version number to 3.0 + +* Sat Jan 17 2009 Seth Randall +- Considerable rewrite + +* Sat Jun 23 2007 Seth Randall +- Added Bahasa Melayu translation by zamri + +* Sat Jun 9 2007 Seth Randall +- Updated version to 2.7a-1.4.x + +* Mon Jun 4 2007 Seth Randall +- Added Korean translation by LEE CHANG MIN . +- Added Dutch translation by Sander Eerkes . + +* Sun Jun 3 2007 Seth Randall +- Added Swedish translation by Erik Lindgren . + +* Wed Oct 4 2006 Tomas Kuliavas +- Added Norwegian Bokmal translation by Svein Olav Bjerkeset + . SquirrelMail tracker #1525721. + +* Sat Nov 19 2005 Seth Randall + +- Added FAQ +- Updated INSTALL and README files +- Added Slovenian translation (sl_SI) from "Sasa Stupar +- Added Czech translation (cs_CZ) from "Martin Å louf" +- Updated Italian translation (it_IT) from "Salvatore Bocchetti" + +* Mon Jul 18 2005 Seth Randall + +- Added Finnish translation (fi_FI) from "Kari Mattsson" + +* Thu Sep 16 2004 Seth Randall + +- Added Italian translation (it_IT) from "magomarcelo" + +* Wed Jul 21 2004 Seth Randall + +- Added option to specify a poppass server if it's different than the imap server +- Changed version number to 2.7-1.4.x + +* Wed Jun 30 2004 Seth Randall + +- Added Brazilian Portuguese translation (pt_BR) from "Edinardo Potrich" + +* Thu Dec 18 2003 Seth Randall + +- Minor updates to some translations +- Changed version number to 2.6-1.4.x + +* Wed Dec 17 2003 Seth Randall + +- Added French translation (fr_FR) from "Ludovic Marcotte" + +* Sun Dec 7 2003 Seth Randall + +- Added German translation (de_DE) from "Steffen Beyer" +- Accept 3xx codes after pass command (arguably wrong, but the poppass daemon + in the ports collection does it that way) +- Changed version number to 2.5-1.4.x + +* Sat Nov 8 2003 Seth Randall + +- Added Bulgarian translation (bg_BG) from "Marian Popov" + +* Mon Oct 20 2003 Seth Randall + +- Changed version number to 2.4-1.4.x + +* Wed Oct 1 2003 Seth Randall + +- Added Polish translation (pl_PL) from "Sebastian Turzynski" + +* Thu Sep 25 2003 Seth Randall + +- Added Spanish (es_ES) translation from "grana canal10" +- Explicitly define SQ_SESSION as the source of onetimepad + +* Fri Sep 19 2003 Seth Randall + +- Added translation support (thanks to Ruben Leote Mendes) +- Added Portuguese (Portugal) (pt_PT) translation from "Ruben Leote Mendes" +- Added change_pass_version in setup.php +- Changed version number to 2.3-1.4.x + +* Thu Jul 10 2003 Seth Randall + +- Removed poppassd software +- Added proper handling of 2xx and 3xx responses +- Changed version number to 2.2-1.4.x + +* Fri Apr 25 2003 Seth Randall + +- Added support for 300 after "user" command (thanks to Richard Gee) +- Added version file +- Changed version number to 2.1-1.4.x + +* Mon Apr 7 2003 Seth Randall + +- Updated for SquirrelMail 1.4.x +- Changed version number to 2.0-1.4.x + +* Tue Jan 7 2003 Seth Randall + +- Added courierpassd +- Changed version number to 1.5 + +* Wed Dec 18 2002 Seth Randall + +- Removed debug code +- Added a poppassd for some BSDs +- Changed version number to 1.4a + +* Thu Sep 26 2002 Seth Randall + +- Updated for SquirrelMail 1.2.8 +- Changed version number to 1.4 + +* Mon Mar 26 2001 Tyler Akins + +- Now uses the mail server address instead of hardcoding "localhost" +- Now forwards to correct URL (removes errors if you want to change your + password twice in a row) +- Changed version number to 1.3 + +* Tue Feb 6 2001 Tyler Akins + +- Added debug mode +- Better error message +- Better error checking +- No need to log out and back in after password change +- Changed version number to 1.2 + +* Tue Jan 23 2001 Tyler Akins + +- Changed variable and function names using change_pass_ as a prefix to + avoid conflict with other plugins as has been mentioned in the plugins + mailing list +- Changed version number to 1.1 diff --git a/doc/FAQ b/doc/FAQ new file mode 100644 index 0000000..8c5ec52 --- /dev/null +++ b/doc/FAQ @@ -0,0 +1,26 @@ +Q. I get an error saying "ERROR: Connection refused (111)" + +A. You don't have a poppass daemon running on the server you've selected. + Make certain you have followed the installation steps in the INSTALL + document and tested it as shown below. + +Q. The plugin does not seem to work + +A. Make sure you can change the password manually. + To test, try telneting into the daemon and changing a password: + + $ telnet localhost 106 + Trying 127.0.0.1... + Connected to localhost. + Escape character is '^]'. + 200 poppassd v1.8.1 hello, who are you? + user + 200 Your password please. + pass + 200 Your new password please. + newpass + 200 Password changed, thank-you. + quit + 200 Bye. + Connection closed by foreign host. + diff --git a/doc/INSTALL b/doc/INSTALL new file mode 100644 index 0000000..53ef501 --- /dev/null +++ b/doc/INSTALL @@ -0,0 +1,59 @@ +Installing change_pass +====================== +0) NOTE: This plugin is not needed for SquirrelMail 1.5.0 or above. + The functionality it provides is already included in the + change_password plugin that is part of 1.5.x. + +1) Start with untaring the file into the plugins directory. + Here is an example for the 3.0 version of the change_pass plugin. + + $ cd plugins + $ tar -zxf change_pass-3.0-1.4.0.tar.gz + +2) By default, the plugin will connect to the IMAP server configured + for SquirrelMail on port 106 to change passwords. + If you need to change any of the following: + IP address of your poppass server + poppass server port number (if not 106) + minimum or maximum password length + you will need to create a configuration file. + + Decide if you want to store the plugin configuration file + in the plugin directory or in the main SquirrelMail config + directory. + + A) To store the configuration file in the plugin directory, + change into the change_pass directory, copy config_example.php + to config.php and edit config.php, making adjustments as + you deem necessary. + + $ cd change_pass + $ cp config_example.php config.php + $ vi config.php + + B) To store the configuration file in the main SquirrelMail + config directory, change into the change_pass directory, + copy config_example.php to ../../config/config_change_pass.php + and edit ../../config/config_change_pass.php, making + adjustments as you deem necessary. + + $ cd change_pass + $ cp config_example.php ../../config/config_change_pass.php + $ vi ../../config/config_change_pass.php + +3) Go to your config directory and run conf.pl. Choose + option 8 and move the plugin from the "Available Plugins" + category to the "Installed Plugins" category. Save and + exit. + + $ cd ../../../../config/ + $ ./conf.pl + +4) If not being used with SquirrelMail 1.4.16+, + please verify that you have the "Compatibility" plugin + installed (but not necessarily activated). + +5) Translations are not included in this package. To get a + translation, download the language pack needed from: + + http://www.squirrelmail.org/download.php diff --git a/doc/README b/doc/README new file mode 100644 index 0000000..92d644c --- /dev/null +++ b/doc/README @@ -0,0 +1,36 @@ +change_pass plugin for SquirrelMail +=================================== +Version 3.0, 2009/05/09 + +Ritchie Low +Tyler Akins +Seth Randall + +Description +=========== +This is a Squirrelmail plugin to change password using the Poppassd service + +You can get poppassd compliant services from the following places: +Pawel Krawczyk http://ipsec.pl/meta/pawel-krawczyk-projekty-open-source.html (Supports PAM) +Andrew Stevenson ftp://ftp.ugh.net.au/pub/unix/poppwd +NetWin http://netwinsite.com/poppassd/ (Changes /etc/passwd) +Kerberos http://kpoppassd.sourceforge.net (Thank to Michael G. Rozman this link) +HP-UX 11.x http://barney.gonzaga.edu/~awithers/poppassd/ (link from above site) +BSD users should try the one from the ports collection for their brand of BSD first. +Courier users should try courierpassd at http://www.arda.homeunix.net/store/ + +poppassd must be running on your whatever server handles the passwords for your +mail server for this plugin to work. Other than that, you just need to add +this plugin to SquirrelMail (using the perl script or by editing config.php +by hand), and all should be fine. For full installation instructions, +see the INSTALL file. + +To change the server or port poppassd listens on, see the INSTALL file. + +If you experience problems, please see the INSTALL file and FAQ + +License +======= + +This plugin is released under the GNU General Public +License (see COPYING for details). diff --git a/doc/index.php b/doc/index.php new file mode 100644 index 0000000..5fbde0d --- /dev/null +++ b/doc/index.php @@ -0,0 +1,13 @@ + _("Change Password"), + 'url' => sqm_baseuri() . 'plugins/change_pass/options.php', + 'desc' => _("Use this to change your email password."), + 'js' => FALSE + ); + sq_change_text_domain('squirrelmail'); +} + +function change_pass_dochange($change_pass_old, $change_pass_new, $debug = false) { + global $username, $imapServerAddress; + $poppass_server = $imapServerAddress; + $poppass_port = 106; + + if(!@include(SM_PATH . 'config/config_change_pass.php')) { + @include(SM_PATH . 'plugins/change_pass/config.php'); + } + + $error_messages = array(); + + $pop_socket = @fsockopen($poppass_server, $poppass_port, $errno, $errstr); + if (!$pop_socket) { + sq_change_text_domain('change_pass'); + $error_messages[] = sprintf(_("Connection error: %s"), "$errstr ($errno)"); + sq_change_text_domain('squirrelmail'); + return $error_messages; + } + + // Look for a 2xx result to continue + $result = change_pass_readfb($pop_socket, $debug); + if(preg_match('/^2\d\d/', $result)) { + // Send the username whose password to change + if(fwrite($pop_socket, "user $username\r\n")) { + $result = change_pass_readfb($pop_socket, $debug); + if(preg_match('/^[23]\d\d/', $result)) { + // Send the users current password + if(fwrite($pop_socket, "pass $change_pass_old\r\n")) { + $result = change_pass_readfb($pop_socket, $debug); + if(preg_match('/^[23]\d\d/', $result)) { + // Send the new password + if(fwrite($pop_socket, "newpass $change_pass_new\r\n")) { + $result = change_pass_readfb($pop_socket, $debug); + if(!preg_match('/^2\d\d/', $result)) { + sq_change_text_domain('change_pass'); + $error_messages[] = _("Password change was not successful!"); + sq_change_text_domain('squirrelmail'); + } else { + change_pass_closeport($pop_socket, $debug); + sqauth_save_password($change_pass_new); + session_write_close(); + header('Location: ' . sqm_baseuri() . 'src/options.php?optmode=submit&optpage=change_pass&plugin_change_pass=1'); + exit; + } + } + } + } + } + } + } + change_pass_closeport($pop_socket, $debug); + return $error_messages; +} + +function change_pass_closeport($pop_socket, $debug = false) { + if ($debug) { + $messages[] = "Closing Connection"; + } + fputs($pop_socket, "quit\r\n"); + fclose($pop_socket); +} + +function change_pass_readfb($pop_socket, $debug = false) { + $strResp = ''; + $result = ''; + + if (!feof($pop_socket)) { + $strResp = fgets($pop_socket, 1024); + $result = substr(trim($strResp), 0, 3); // 200, 300, 500 + if($debug) { + $messages[] = "--> $strResp"; + } + } + return $result; +} + +function change_pass_info_real() { + return array( + 'english_name' => 'Change Password', + 'authors' => array( + 'Richie Low' => array(), + 'Tyler Akins' => array(), + 'Seth Randall' => array( + 'email' => 'indiri69@users.sourceforge.net', + 'sm_site_username' => 'randall', + ), + ), + 'version' => '3.0', + 'required_sm_version' => '1.4.0', + 'requires_configuration' => 0, + 'requires_source_patch' => 0, + 'required_plugins' => array(), + 'per_version_requirements' => array( + '1.5.0' => SQ_INCOMPATIBLE, + '1.4.16' => array( + 'required_plugins' => array() + ), + '1.4.0' => array( + 'required_plugins' => array( + 'compatibility' => array( + 'version' => '2.0.13', + 'activate' => FALSE + ) + ) + ) + ), + 'summary' => 'Change passwords using a poppass daemon', + 'details' => 'Works with a compatible poppass daemon to allow users to change their passwords.' + ); +} + +function change_pass_loadinfo_real() { + global $optpage, $optpage_name; + + if ($optpage == 'change_pass') { + // i18n: is displayed after "Successfully Saved Options:" + sq_change_text_domain('change_pass'); + $optpage_name = _("User's Password"); + sq_change_text_domain('squirrelmail'); + } +} diff --git a/index.php b/index.php new file mode 100644 index 0000000..5fbde0d --- /dev/null +++ b/index.php @@ -0,0 +1,13 @@ + $max_pass_length) { + $error_messages[] = sprintf(_("Your new password should be %s to %s characters long."), + $min_pass_length, $max_pass_length); + } + } + } + + $old_pass = sqauth_read_password(); + if(!isset($error_messages['cp_no_old']) && $change_pass_old != $old_pass) { + $error_messages['cp_wrong_old'] = _("Your current password is not correct."); + } + + if(count($error_messages) == 0) { + $error_messages = change_pass_dochange($change_pass_old, $change_pass_new, $debug); + if(count($error_messages) == 0) { + $showform = false; + } + } + sq_change_text_domain('squirrelmail'); +} +displayPageHeader($color, ''); +sq_change_text_domain('change_pass'); + +echo + html_tag('table', "\n" . + html_tag('tr', "\n" . + html_tag('td', '' . _("Change Password") . '', 'center', $color[0]) + ), + 'center', $color[9], 'width="95%" border="0" cellpadding="1" cellspacing="0"') . "
\n"; + +if(count($error_messages) > 0) { + echo html_tag('table', '', 'center', '', 'width="100%" border="0" cellpadding="1" cellspacing="0"'); + echo html_tag('tr'); + echo html_tag('td', '', 'center'); + echo html_tag('ul'); + foreach($error_messages as $line) { + echo html_tag('li', htmlspecialchars($line), '', '', 'style="color: ' . $color[2] . '"'); + } + echo html_tag('/ul'); + echo html_tag('tr', html_tag('td', ' ')) . "\n"; + echo html_tag('/table'); +} + +if($showform) { + echo addForm($PHP_SELF); + echo + html_tag('table', "\n" . + html_tag('tr', "\n" . + html_tag('td', _("Current Password:"), 'right') . + html_tag('td', addPwField('change_pass_old', ''), 'left') + ) . + html_tag('tr', "\n" . + html_tag('td', _("New Password:"), 'right') . + html_tag('td', addPwField('change_pass_new', ''), 'left') + ) . + html_tag('tr', "\n" . + html_tag('td', _("Verify New Password:"), 'right') . + html_tag('td', addPwField('change_pass_verify', ''), 'left') + ) . + html_tag('tr', "\n" . + html_tag('td', addSubmit(_('Change Password'), 'change_pass_form'), 'center', '', 'colspan="2"') + ), + 'center', '', 'border="0" cellpadding="1" cellspacing="0"') . "\n"; + echo html_tag('/form'); + echo html_tag('/body'); + echo html_tag('/html'); +} +sq_change_text_domain('squirrelmail'); diff --git a/setup.php b/setup.php new file mode 100644 index 0000000..a9f58fc --- /dev/null +++ b/setup.php @@ -0,0 +1,34 @@ +