Page Index Toggle Pages: 1
There are no actions to perform.
Normal Topic Case conversion not happening with Username (Read 578 times)
Irata
YaBB Newcomer
*
Offline



Posts: 1

YaBB 2.5.2
Case conversion not happening with Username
Feb 6th, 2014 at 10:02am
There are no actions to perform.
Hi,

I have a problem with a YaBB 2.2.1 installation that works fine on one server but when copied to two other servers if the username you use to login with has an Uppercase character then it is not recognised or found. The following message is returned.


Code
Select All
Error: Username / Password mismatch.
The Username you specified does not exist or you entered a wrong password.
Script: ......removed....../forum/Sources/LogInOut.pl
Line: 63
Subroutine: Login2 



I am not Perl program by any stretch but I think I have managed to locate the code where the problem lies and and i think it might be because there is some missing extension required that is not on the two servers I am testing on, a WAMP and a Hosted Linux

In sources/LogInOut.pl - Lines 37 to 64
Code (Perl)
Select All
sub Login2 {
	&fatal_error("no_username") if ($FORM{'username'} eq "");
	&fatal_error("no_password") if ($FORM{'passwrd'} áeq "");
	$username = $FORM{'username'};
	$username =~ s/\s/_/g;
	&fatal_error("invalid_character","$loginout_txt{'35'} $loginout_txt{'241r'}")	if ($username =~ /[^\w\+\-\.\@]/);
	&fatal_error("only_numbers_allowed")						if ($FORM{'cookielength'} !~ /^[0-9]+$/);
	## Check if login ID is not and email address or screenname ##
	if (!-e "$memberdir/$username.vars"){
		$test_id = &MemberIndex("who_is", "$FORM{'username'}");
		if ($test_id ne ""){ $username = $test_id} else {&fatal_error("bad_credentials"); }
	}
	if (-e "$memberdir/$username.pre" && -e "$memberdir/$username.vars") { unlink "$memberdir/$username.pre"; }
	if (-e "$memberdir/$username.pre" && ($regtype == 1 || $regtype == 2)) { &fatal_error('not_activated'); }


	# Need to do this to get correct case of username,
	# for case insensitive systems. Can cause weird issues otherwise
	$caseright = 0;
	&ManageMemberlist("load");
	while (($curmemb, $value) = each(%memberlist)) {
		if ($username =~ m/\A\Q$curmemb\E\Z/) { $caseright = 1; last; }
	}
		undef %memberlist;
	if(!$caseright) {
		$username = "Guest";
		&fatal_error("bad_credentials");
	} 


If i change $caseright to 1 then it will avoid falling into the last few lines of being a Guest with bad_credentials. á

I tested logging in with an all lowercase user and it worked so I am assuming the load of %memberlist is happening but I cannot be 100% it is doing it properly, however this is the code from Subs.pl - lines 1617 to 1625
Code (Perl)
Select All
sub ManageMemberlist {
	my $todo á á= $_[0];
	my $user á á= $_[1];
	my $userreg = $_[2];
	if ($todo eq "load" || $todo eq "update" || $todo eq "delete" || $todo eq "add") {
		fopen(MEMBLIST, "$memberdir/memberlist.txt");
		%memberlist = map /(.*)\t(.*)/, <MEMBLIST>;
		fclose(MEMBLIST);
	} 



The two things I haven't been able to understand properly is the 'map' function and the pattern matching going on in Login2.

The userid I am testing with is 'Gryphon' in the memberlist.txt and I am typing in 'gryphon' which is what works on the production system at the moment, regardless of case.

I have managed to get a list of Perl modules between the working and non working servers and on the non working server the list is a lot shorter so i am thinking there is something missing that YaBB needs to translate the case of the Userids.

I could be wrong about it being a missing module, but I had already moved the site years ago for this group with a dump and restore and change the paths.pl and that is what i have done this time but with less success.

Terry
  
Back to top
 
IP Logged
 
Dandello
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Offline



Posts: 2,952
Location: Earth

YaBB 2.6.1
Re: Case conversion not happening with Username
Reply #1 - Feb 23rd, 2014 at 3:27pm
There are no actions to perform.
The question is not why it isn't working on 2 servers but why it's working on the one server.

Perl is by it's nature case sensitive. 'Roger' is not 'roger'. The case insensitivity referred to in the code refers to the var files name, not the login.

In most Windows/IIS installs 'Roger.vars' is functionally the same as 'roger.vars' and in that case you don't want someone trying to register with 'rOger' as a user name if 'Roger' is already a member.

YaBB tries to prevent the above situation is it has no way to fix things like that if you happen to move your forum from a Case Sensitive platform to a Case Insensitive one.

Linux is Case Sensitive. To open 'Roger.vars' you absolutely have to use 'Roger' as the login.
  

If you only have one solution to a problem you're not trying hard enough!
Back to top
WWW  
IP Logged
 
JonB
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Offline



Posts: 4,228
Location: Land of the Blazing Sun!

YaBB 2.6.1
Re: Case conversion not happening with Username
Reply #2 - Mar 2nd, 2014 at 5:40pm
There are no actions to perform.
Its likely on a Mac (mamp) running Mac OSX in 'ci' mode.  Then it works by CIFS (roughly FAT32) rules, rather than Unic rules on filenames.

Mac's support two versions of the Unix filesystem, CaseSensitive and CaseInsenstive. áYou have to reformat and re-install to switch.

Yep, I support Hackintoshes tooo Tongue

Smiley
« Last Edit: Mar 2nd, 2014 at 5:42pm by JonB »  

I find your lack of faith disturbing.
Back to top
IP Logged
 
Dandello
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Offline



Posts: 2,952
Location: Earth

YaBB 2.6.1
Re: Case conversion not happening with Username
Reply #3 - Mar 3rd, 2014 at 2:45am
There are no actions to perform.
Code (Perl)
Select All
$caseright = 0;
	&ManageMemberlist("load");
	while (($curmemb, $value) = each(%memberlist)) {
		if ($username =~ m/\A\Q$curmemb\E\Z/) { $caseright = 1; last; }
	}
		undef %memberlist;
	if(!$caseright) {
		$username = "Guest";
		&fatal_error("bad_credentials");
	}  



What the above piece of code does is make sure the name used in the login exactly matches the name in the memberlist before doing anything else. It actually has nothing to do (at that point) with opening the member's vars file. áOn Login Yabb has loaded the Memberlist 'table' and compares the name that was used against the names it has. If it matches it stops and goes to the next step. If it reaches the end of the list without a match it throws a 'bad credentials' error.

What I'm trying to say is that even running in Windows (which has a non-case sensitive file system) YaBB doesn't (and shouldn't) mistake Roger for roger on a login.
  

If you only have one solution to a problem you're not trying hard enough!
Back to top
WWW  
IP Logged
 
Page Index Toggle Pages: 1
There are no actions to perform.