Gossamer Forum
Home : Products : Gossamer Mail : Discussion :

Case sensitive accounts?

Quote Reply
Case sensitive accounts?
If an account 'info' exists and a mail is sent to 'Info@my_domain' incoming.pl stop with error while trying to wite this mail to .../msgs/I/Info/...'. But this doesnt exist (only .../msg/i/info/... is available).
Is the any patch or update (join.cgi, login.cgi,...), that will accounts handle ONLY in LOWER- or UPPERcase?
This will help on unix, otherwise no mail are deliverd at all!

We have GossamerMail installed on unix.

Greetings
Andreas


Quote Reply
Re: Case sensitive accounts? In reply to
Because of getting trouble with this problem, I have cahnged a view cgi's (quick and dirty), but now they work fine:

../webmail/user/join.cgi (sub sign_up):

...
# Make sure it is all fielded out and build our query
my $uid = $dbh->quote ($in->param('userid') || '');
my $pass = $dbh->quote ($in->param('password') || '');

my $guser = $in->param('userid');
$guser =~ tr/A-Z/a-z/;

(length ($guser) <= 16) or $error .= "<li>$uid $Webmail::DGRAPH{JOIN_LONG} 16</li>";
(&Webmail::Authenticate::auth_valid_format ($in->param('userid'))) or $error .= "<li>$uid $Webmail::LANGUAGE{JOIN_FMT} $auth_error</li>";
...

The variable guser was created and transformed to only lower case.
The rest of the sub 'sign_up' is changed, that all uses of '$in->param('userid')' are changed to '$guser'.

So, regardless what ID the enteres while joining, only lowercase accounts are created therefor.

../webmail/batch/incoming.pl (sub get_pop)


...
# Attempt to insert the message
$user =~ tr/A-Z/a-z/;
my $ret = &Webmail::insert_message ($user, $outfile);
if ($ret > 0) {
&Webmail::debug ("Incoming ($$): Inserted message for user '$user'") if ($Webmail::DEBUG);
&Webmail::update_folder ($user);
}
elsif ($ret < 0) {
&Webmail::debug ("Incoming ($$): Not inserting '$user' for rest of session.") if ($Webmail::DEBUG);
$user{$user} = 1;
undef $user;
}
else {
&Webmail::debug ("Incoming ($$): '$user' reached maximum space.") if ($Webmail::DEBUG);
undef $user;
}
next TO;
...

Here, the line '$user =~ tr/A-Z/a-z/;' is inserted, you'll find the place.

---------------------------------------------------------

And, at least in

../webmail/admin/webmail.pm


(Sub make_user_dir)


sub make_user_dir {
# --------------------------------------------------------
# Makes a users directory.
#
my $user = shift;
my ($prefix) = ($user =~ /^(.)/);
my $umask;

$user =~ tr/A-Z/a-z/;
$prefix =~ tr/A-Z/a-z/;

eval { $umask = umask (oct $Webmail::CONFIG{'dir_umask'}); };
....

(sub format_message)
...
sub format_message {
# --------------------------------------------------------
# Formats a message body, removes intro html if html, line wraps if
# text.
#
my ($user, $msg) = @_;
my $i = 60;
(ref $user eq 'HASH') or &cgierr("Webmail: User Argument '$user' to format_message is invalid. Must be (user hash, msgdata hash).");
(ref $msg eq 'HASH') or &cgierr("Webmail: Messsage Argument '$msg' to format_message is invalid. Must be (user hash, msgdata hash).");

# Tags to take out
my $tags = '(embed|script|applet)';

# Figure out where we are storing messages.
my ($prefix) = $user->{'userid'} =~ /^(.)/;
my $msg_dir = $Webmail::CONFIG{path_data} . "/msgs/" . $prefix . "/" . $user->{'userid'};
$msg_dir =~ tr/A-Z/a-z/;
my $file = $msg_dir . "/" . $msg->{'msgdata_mid'} . ".1";
$file =~ tr/A-Z/a-z/;


####################################################
(sub get_user_dir)

sub get_user_dir {
# --------------------------------------------------------
# Returns the user message directory.
#
my $user = shift;
my ($prefix) = ($user =~ /^(.)/);
$user =~ tr/A-Z/a-z/;
$prefix =~ tr/A-Z/a-z/;
return "$Webmail::CONFIG{path_data}/msgs/$prefix/$user";
}


So far, so good.

(changes in webmail.pm are usefull, if you have already users. They wont reach there existing mails until you rename (FTP or what ever) all uppercase letters to lowercase and join directories like msgs/K and msgs/k to have at the end only lowercase stuff in ../webmail/data/msgs)

Andreas