From 985f7c8865cf42ed89eac49147e7be23c742c726 Mon Sep 17 00:00:00 2001 From: fidian Date: Tue, 17 Oct 2000 18:15:35 +0000 Subject: [PATCH] Bug 116811 - login usernames are not case sensitive but prefs files are Added option to convert usernames transparently to lowercase, defaulted it to off. Username is converted before preferences are loaded/set and before hooks are called. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@802 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- config/conf.pl | 50 +++++++++++++++++++++++++++++---------- config/config_default.php | 10 +++++++- src/webmail.php | 4 +++- 3 files changed, 49 insertions(+), 15 deletions(-) diff --git a/config/conf.pl b/config/conf.pl index 805a4976..b118f71e 100755 --- a/config/conf.pl +++ b/config/conf.pl @@ -4,7 +4,7 @@ # # A simple configure script to configure squirrelmail ############################################################ -$conf_pl_version = "x61"; +$conf_pl_version = "x62"; ############################################################ # First, lets read in the data already in there... @@ -304,10 +304,11 @@ while (($command ne "q") && ($command ne "Q")) { print "R Return to Main Menu\n"; } elsif ($menu == 4) { print $WHT."General Options\n".$NRM; - print "1. Default Charset : $WHT$default_charset$NRM\n"; - print "2. Data Directory : $WHT$data_dir$NRM\n"; - print "3. Attachment Directory : $WHT$attachment_dir$NRM\n"; - print "4. Default Left Size : $WHT$default_left_size$NRM\n"; + print "1. Default Charset : $WHT$default_charset$NRM\n"; + print "2. Data Directory : $WHT$data_dir$NRM\n"; + print "3. Attachment Directory : $WHT$attachment_dir$NRM\n"; + print "4. Default Left Size : $WHT$default_left_size$NRM\n"; + print "5. Usernames in Lowercase : $WHT$force_username_lowercase$NRM\n"; print "\n"; print "R Return to Main Menu\n"; } elsif ($menu == 5) { @@ -451,10 +452,11 @@ while (($command ne "q") && ($command ne "Q")) { elsif ($command == 12){ $default_unseen_notify = command212(); } elsif ($command == 13){ $default_unseen_type = command213(); } } elsif ($menu == 4) { - if ($command == 1) { $default_charset = command31 (); } - elsif ($command == 2) { $data_dir = command33 (); } - elsif ($command == 3) { $attachment_dir = command34 (); } - elsif ($command == 4) { $default_left_size = command35 (); } + if ($command == 1) { $default_charset = command31 (); } + elsif ($command == 2) { $data_dir = command33 (); } + elsif ($command == 3) { $attachment_dir = command34 (); } + elsif ($command == 4) { $default_left_size = command35 (); } + elsif ($command == 5) { $force_username_lowercase = command36 (); } } elsif ($menu == 5) { if ($command == 1) { command41 (); } elsif ($command == 2) { $theme_css = command42 (); } @@ -1136,6 +1138,27 @@ sub command35 { } +sub command36 { + print "Some IMAP servers only have lowercase letters in the usernames\n"; + print "but they still allow people with uppercase to log in. This\n"; + print "causes a problem with the user's preference files. This option\n"; + print "transparently changes all usernames to lowercase."; + print "\n"; + + if ($force_username_lowercase eq "true") { + $default_value = "y"; + } else { + $default_value = "n"; + } + print "Convert usernames to lowercase (y/n) [$WHT$default_value$NRM]: $WHT"; + $new_show = ; + if (($new_show =~ /^y\n/i) || (($new_show =~ /^\n/) && ($default_value eq "y"))) { + return "true"; + } + return "false"; +} + + sub command41 { print "\nNow we will define the themes that you wish to use. If you have added\n"; print "a theme of your own, just follow the instructions (?) about how to add\n"; @@ -1500,10 +1523,11 @@ sub save_data { print FILE "\t\$default_unseen_type = $default_unseen_type;\n"; print FILE "\n"; - print FILE "\t\$default_charset = \"$default_charset\";\n"; - print FILE "\t\$data_dir = \"$data_dir\";\n"; - print FILE "\t\$attachment_dir = \"$attachment_dir\";\n"; - print FILE "\t\$default_left_size = $default_left_size;\n"; + print FILE "\t\$default_charset = \"$default_charset\";\n"; + print FILE "\t\$data_dir = \"$data_dir\";\n"; + print FILE "\t\$attachment_dir = \"$attachment_dir\";\n"; + print FILE "\t\$default_left_size = $default_left_size;\n"; + print FILE "\t\$force_username_lowercase = $force_username_lowercase;\n"; print FILE "\n"; diff --git a/config/config_default.php b/config/config_default.php index 116742c8..cce85fb3 100644 --- a/config/config_default.php +++ b/config/config_default.php @@ -9,7 +9,7 @@ // // don't change - $config_version = "x61"; + $config_version = "x62"; // Organization's logo picture (blank if none) $org_logo = "../images/sm_logo.jpg"; @@ -168,6 +168,14 @@ $default_left_size = 200; +// Some IMAP servers allow a username (like "bob") to log in if they use +// uppercase in their name (like "Bob" or "BOB"). This creates extra +// preference files. Toggling this option to true will transparently +// change all usernames to lowercase. + + $force_username_lowercase = false; + + // Themes // You can define your own theme and put it in this directory. You must // call it as the example below. You can name the theme whatever you diff --git a/src/webmail.php b/src/webmail.php index d0ad62b1..66eb3af3 100644 --- a/src/webmail.php +++ b/src/webmail.php @@ -33,7 +33,6 @@ setcookie("squirrelmail_language", $squirrelmail_language, time()+2592000); } - include ("../config/config.php"); include ("../functions/prefs.php"); include ("../functions/imap.php"); @@ -44,6 +43,9 @@ if (!isset($strings_php)) include ("../functions/strings.php"); + if ($force_username_lowercase) + $username = strtolower($username); + if (!session_is_registered("user_is_logged_in") || $logged_in != 1) { do_hook ("login_before"); -- 2.25.1