Page Index Toggle Pages: [1] 2 
Topic Tools
Hot Topic (More than 10 Replies) Advanced Settings will not save some some Windows Machines (Read 4,502 times)
JonB
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Offline



Posts: 3,913
Location: Land of the Blazing Sun!

YaBB 2.6.1
Advanced Settings will not save some some Windows Machines
Sep 21st, 2012 at 8:33pm
Post Tools
Earlier today, I had a problem I had only heard about with YaBB.  On some Windows Systems, it does not seem to possible to save Advanced Settings.

I had mostly heard about it with regards Windows Server 2003, and I had never been able to replicate it. Today it happened to me while testing the 9/17 zip of the 2.5.2 Beta. It didn't happen on a Windows Server, but rather on an XP Media Center machine with SP3.

I didn't realize quite what was happening at first, nor did I know I had a problem. I was trying to fix the SMTP/Mail Settings so I could test notification. Each time I would select either Advanced Settings, or one of its Tabs, Windows would open a Command Window (actually 4 or 5).  They would open and close so fast there was no telling what was happening.  Advanced Settings returns to the Default Tab after you save, so you don't actually see what you have just saved.
I had configured the 'sendmail' with known good settings, so I was surprised when I got an SMTP error when I tried to post to a Board with notifications enabled (and discovered that if that gets broken, you can't post to Boards with notifications set).  I was very puzzled. I went back to the Admin Center and found my settings had not been saved. Some testing showed my I couldn't save any of the settings there, not just e-mail.

I talked to Dandello and she assured me we had not tinkered with Settings_Advanced.pl. I tested on another similar XP machine - no issue. So I opened the code - Got it!, and I remembered the old fix - rip out the DiskQuota.

THEN - it hit me and why it is so rare.  This machine dual boots as a Linux server. I'm guessing that if YaBB can see a *nix filesystem, its going to perform those Linux checks.  Since there isn't a 'mounted' Linux system, what is returned is likely 'garbage'. Fast forward to the Save routine for Advanced Settings:

Code (Perl)
Select All
# Routine to save them
sub SaveSettings {
	my %settings = @_;
	$settings{'extensions'} =~ s~[^\ A-Za-z0-9_]~~g;
	@ext = split(/\s+/, $settings{'extensions'});

	if ($settings{'enable_quota'} && $settings{'enable_quota_value'} > 1 && $settings{'hostusername'}) {
		$settings{'enable_quota'} = $settings{'enable_quota_value'};
		$settings{'findfile_maxsize'} = 0;
		$settings{'enable_freespace_check'} = 0;
	} elsif (-d "$settings{'findfile_root'}" && $settings{'findfile_maxsize'} > 0 && !$settings{'enable_freespace_check'}) {
		$findfile_space = '1<>0';
		$settings{'enable_quota'} = 0;
	} elsif ($settings{'enable_freespace_check'}) {
		$settings{'findfile_maxsize'} = 0;
		$settings{'enable_quota'} = 0;
	} elsif (!-d "$settings{'findfile_root'}" || !$settings{'findfile_maxsize'}) {
		$settings{'findfile_time'} = 0;
		$settings{'findfile_maxsize'} = 0;
	}

	# Settings.pl stuff
	&SaveSettingsTo('Settings.pl', %settings);
}

1;
 



I have found that ripping out the code from Lines 34-56 cures the issue, and I know/recall that was the fix way back when.  But I don't think we knew why.  

My 'guess' is that code won't execute on a Windows machine with no Linux filesystem - so its not an issue often. However on dual-boot or test servers with a ext3 drive installed, it runs the code and gets a nonsense answer, thus fails a test (I don't see an else to fall through onto); thus no save.

My thought is that the diskquota code needs a test against the Windows OS being what runs YaBB. Mac's may be OK with the code (Applescript is extended bash), but I don't know enough to be 100% sure.

Code (Perl)
Select All
# Free Disk Space Checking
my @disk_space = qx{df -k .};
map { $_ =~ s/ +/  /g } @disk_space;

my @find = qx(find . -noleaf -type f -printf "%s-");

$hostusername = $hostusername || (split(/ +/, qx{ls -l YaBB.$yyext}))[2];
my @quota = qx{quota -u $hostusername -v};
$quota[0] =~ s/^ +//;
$quota[0] =~ s/ /&nbsp;/g;
$quota[1] =~ s/^ +//;
$quota[1] =~ s/ /&nbsp;/g;
my $quota_select = qq~$quota[0]<br />$quota[1]~;
if ($quota[2]) {
	my $ds = (split(/ +/, $disk_space[1], 2))[0] if !$enable_quota;
	$quota_select .= qq~<br /><select name="enable_quota_value">~;
	for (my $i = 2; $i < @quota; $i++) {
		$quota[$i] =~ s/^ +//;
		$quota[$i] =~ s/ +/&nbsp;&nbsp;/g;
		$quota_select .= qq~<option value="$i" ~ . ${isselected($i == $enable_quota || ($ds && $quota[$i] =~ /^$ds/))} . qq~>$quota[$i]</option>~;
	}
	$quota_select .= '</select>';
}

 



The qx() executes a (Linux typically) system command -
That was where my Command Windows were being generated from.
And since Windows was returning WTF? each time - things got screwed.

As a temporary fix - removing lines 34-56 from Settings_Advanced.pl does the trick to getting this working again on Windows.

I think this bug exists in 2.3.1, 2.4.x and 2.5 AE

~tada~
Wink
  

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,380
Location: Earth

YaBB 2.6.1
Re: Advanced Settings will not save some some Windows Machines
Reply #1 - Sep 21st, 2012 at 9:06pm
Post Tools
I suspect the problem is a little spookier than just having an ext3 partition on an XP/2003 machine - since I have one on my test server (XP, WAMP and Activestate Perl 5.12) and can't duplicate the problem. I'm guessing though, that an OS detector and a warning for admin that there might maybe be issues would be in order?

On my XP testbed version, I don't even get the option of doing anything but enabling or disabling Free Space Check - none of the other options is available.  So, I'm also wondering if these options are enabled (though not functional or saveable) when this problem shows up?

Edited:
And I don't see anything in 2.3.1 regarding Space Checking, so that one may be okay.
 
« Last Edit: Sep 21st, 2012 at 9:27pm by Dandello »  

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: 3,913
Location: Land of the Blazing Sun!

YaBB 2.6.1
Re: Advanced Settings will not save some some Windows Machines
Reply #2 - Sep 21st, 2012 at 9:34pm
Post Tools
Do you have a 'grub' boot on that machine?  Maybe Linux has to be the default boot??? (that is the case on this box).

Quote:
I'm guessing though, that an OS detector and a warning for admin that there might maybe be issues would be in order?


I think that is the right approach. When we grok what the code is really doing maybe we can have a better solution.

I have to say it was/is surely bizarre.  This is the first time I have seen it.  

Well, at least we know how to fix for now...

Edited:
The 2.3.1 board on here seems OK, My impression earlier was it would not save - but I was a tad rattled...


Wink
« Last Edit: Sep 21st, 2012 at 9:39pm 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,380
Location: Earth

YaBB 2.6.1
Re: Advanced Settings will not save some some Windows Machines
Reply #3 - Sep 21st, 2012 at 9:44pm
Post Tools
I've got grub but XP is my default OS.

How about a version of the fix with the 'bad' code clearly commented out - that way it can go into the codex and help files (Of course, that does assume that people actually read the help files.)  Roll Eyes

I have to look through the code and see if it would be safe to just run an OS check to disable that feature for Windows users.
  

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



Posts: 1,591
Location: UK:Scotland/livingston

None
Re: Advanced Settings will not save some some Windows Machines
Reply #4 - Sep 21st, 2012 at 10:06pm
Post Tools
JonB wrote on Sep 21st, 2012 at 8:33pm:
THEN - it hit me and why it is so rare.  This machine dual boots as a Linux server. I'm guessing that if YaBB can see a *nix filesystem, its going to perform those Linux checks.  Since there isn't a 'mounted' Linux system, what is returned is likely 'garbage'. Fast forward to the Save routine for Advanced Settings:

ok i'm just grabbing at thin air here but can part of this be down to the (Use File-Locking) so yabb can see *nix and win NT
so when Advanced Settings are loaded it's cool but when it has to save it's like ooooooo Huh *nix and win NT file system emmmmmm emmmm  Cheesy Cheesy Cheesy Cheesy Cheesy Cheesy Cheesy and has a data dump and flushes all new settings and dont save them due to the Free Disk Space Checking settings on the same page ?
  

YaBB install help video
1. what yabb forum are you running and the url
2. describe in as much detail as you can what happens and also post screenshots if you can
3. please be patient we live in different time zones and have other commitments but we will help you
as bill and ted say (Be excellent to each other)
Back to top
IP Logged
 
Dandello
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Offline



Posts: 2,380
Location: Earth

YaBB 2.6.1
Re: Advanced Settings will not save some some Windows Machines
Reply #5 - Sep 21st, 2012 at 10:23pm
Post Tools
Well, the code the space checking is using uses some *nix specific stuff. (Looked it up  Roll Eyes) So I suspect some Windows systems could choke on it if there's some shell process that uses the same code for something else.

As I indicated, I can't duplicate it. And there's probably a better, more generic, way to write it as well.

However, in theory, putting the offending code inside a
Code
Select All
if ($^O ne 'MSWin32') {

} 


should take care of it.
« Last Edit: Sep 21st, 2012 at 10:27pm by Dandello »  

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



Posts: 2,380
Location: Earth

YaBB 2.6.1
Re: Advanced Settings will not save some some Windows Machines
Reply #6 - Sep 22nd, 2012 at 4:33pm
Post Tools
Just posted the problematic code section to PerlMonks - with any luck someone will take pity on me and actually respond - they like runnable code snippets and this one doesn't qualify in any way.
  

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



Posts: 1,591
Location: UK:Scotland/livingston

None
Re: Advanced Settings will not save some some Windows Machines
Reply #7 - Sep 22nd, 2012 at 6:29pm
Post Tools
Dandello wrote on Sep 22nd, 2012 at 4:33pm:
Just posted the problematic code section to PerlMonks - with any luck someone will take pity on me and actually respond - they like runnable code snippets and this one doesn't qualify in any way.

lol funny you should say that it was looking at File Locking here http://www.perlmonks.org/?node_id=7058 that had given me this thought xnoddyx wrote on Sep 21st, 2012 at 10:06pm:
ok i'm just grabbing at thin air here but can part of this be down to the (Use File-Locking) so yabb can see *nix and win NT so when Advanced Settings are loaded it's cool but when it has to save it's like ooooooo  *nix and win NT file system emmmmmm emmmm         and has a data dump and flushes all new settings and dont save them due to the Free Disk Space Checking settings on the same page ?
           

Grin
« Last Edit: Sep 22nd, 2012 at 6:29pm by xnoddyx »  

YaBB install help video
1. what yabb forum are you running and the url
2. describe in as much detail as you can what happens and also post screenshots if you can
3. please be patient we live in different time zones and have other commitments but we will help you
as bill and ted say (Be excellent to each other)
Back to top
IP Logged
 
JonB
YaBB Administrator
YaBB Next Team
Operations Team
Beta Testers
Support Team
*****
Offline



Posts: 3,913
Location: Land of the Blazing Sun!

YaBB 2.6.1
Re: Advanced Settings will not save some some Windows Machines
Reply #8 - Sep 23rd, 2012 at 2:28pm
Post Tools
I have been thinking about this.

I still think it has to do with fact there's an ext3 partition, but I can't see anywhere in Settings_Advanced.pl where the code itself would know how to make the decision to run the OS commands.

It clearly does make that decision on this one machine, as I can actually see the command windows opening + I can't save Advanced Settings. Yet on another XP machine, the code does not execute those command calls and everything is AOK.

Well, my thought is that YaBB.pl and AdminIndex.pl had to have run first, and the clue to the trigger is somewhere in that code.

Just my thoughts as usual.
Wink
  

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,380
Location: Earth

YaBB 2.6.1
Re: Advanced Settings will not save some some Windows Machines
Reply #9 - Sep 23rd, 2012 at 4:30pm
Post Tools
In Subs there's some freespace checking to determine if low-space maintenance mode should be turned on - but it's not the same code as Settings_Advanced uses for pretty much the same function and it looks like it's checking drive C - which may not be correct for some systems (like mine, my server directory is on D).

The quick and dirty solution would be putting an OS checker in Settings_Advanced as that looks like how that section of code is supposed to act anyway - ignoring the *nix only command. And this should work as apparently commenting out two lines works to correct this problem when it does occur.

A proper solution is to figure out how to get that section of code to properly return the data it needs, even on a Windows machine.

The code I got from PerlMonks kinda works - but doesn't bring back the actual freespace on my Windows machine - so I'm missing something in translation.
  

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: 3,913
Location: Land of the Blazing Sun!

YaBB 2.6.1
Re: Advanced Settings will not save some some Windows Machines
Reply #10 - Sep 23rd, 2012 at 7:18pm
Post Tools
I don't think there is a Windows OS command equivalent to 'df' - in part because Windows views the filesystem as something very different than *nix does. The present code would ONLY work on a Linux server that is set up correctly. Windows only supports quotas on certain versions of Windows and certain Filesystems (specifically NTFS) and often only with the use of a true Windows Domain.

Its probably only really relevant on hosted Linux systems, and a subset of those.

It's like the periodic debate I have to have over why Unix file permissions cannot be applied to virtual shares on non-Linux systems - the guest OS for the share (which is mounted as CIFS) just doesn't have that mechanism (ditto Samba integration).  The permissions are 'forced' in the mount statement, and are the *nix equivalent of RWE but there is no support for the concept of ownership, users or group in CIFS - thus the permissions are transient to that session.  I tell people who want to argue about it that they could probably get a nice job with VMware or Oracle if they could engineer that.   Cheesy

I had one guy tell me he has written a hack for that (with VirtualBox), but he didn't have time to post the solution. (I was not holding my breath  Roll Eyes )

For now; we know the nature of the issue, and how to fix it. I remain interested in its root cause, but I don't think it is worth spending more time on at this juncture.

Thanks for all the input - this is the kind of thing that goes with the Admin Center and Installer rethinking we need to do for Next Edition.  At that time, we should revisit the ideas of automated system checking and configuration/environment data gathering.

Wink




  

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,380
Location: Earth

YaBB 2.6.1
Re: Advanced Settings will not save some some Windows Machines
Reply #11 - Sep 23rd, 2012 at 9:18pm
Post Tools
In theory there's
Code
Select All
`fsutil volume diskfree 

that according to somebody at PerlMonks should do the trick (maybe). Then in Subs.pl there's
Code
Select All
			my @x = qx{DIR /-C}; # Do an ordinary DOS dir command and grab the output
			my $lastline = pop(@x); # should look like: 17 Directory(s), 21305790464 Bytes free
			return -1 if $lastline !~ m/byte/i; # error trapping if output fails. The word byte should be in the line
			$lastline =~ /^\s+(\d+)\s+(.+?)\s+(\d+)\s+(.+?)\n$/;
			$FreeBytes = $3 - 100000; # 100000 bytes reserve
 


which, in theory, is equivalent to
Code
Select All
my @x = qx{df -k .}; # Do an ordinary *nix df -k . command and grab the output
			my $lastline = pop(@x); # should look like: /dev/path 151694892 5495660 134063644 4% /
			return -1 if $lastline !~ m/\%/; # error trapping if output fails. The % sign should be in the line
			$FreeBytes = ((split(/ +/, $lastline, 5))[3] * 1024) - 100000; # 100000 bytes reserve
 



Haven't had time to play around with this.
Edited:
I keep saying 'in theory' since I can't actually confirm that the Window's freespace check works at all on my XP test machine.
« Last Edit: Sep 23rd, 2012 at 9:27pm by Dandello »  

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: 3,913
Location: Land of the Blazing Sun!

YaBB 2.6.1
Re: Advanced Settings will not save some some Windows Machines
Reply #12 - Sep 23rd, 2012 at 10:07pm
Post Tools
The patch you suggested works correctly at least for now, for 32 bit Windows XP and likely Vista & Win 7.

here is the properly indented fixed code - just tested.

Code (Perl)
Select All
if ($^O ne 'MSWin32') {
	# Free Disk Space Checking for Linux/Unix OS
	my @disk_space = qx{df -k .};
	map { $_ =~ s/ +/  /g } @disk_space;

	my @find = qx(find . -noleaf -type f -printf "%s-");

	$hostusername = $hostusername || (split(/ +/, qx{ls -l YaBB.$yyext}))[2];
	my @quota = qx{quota -u $hostusername -v};
	$quota[0] =~ s/^ +//;
	$quota[0] =~ s/ /&nbsp;/g;
	$quota[1] =~ s/^ +//;
	$quota[1] =~ s/ /&nbsp;/g;
	my $quota_select = qq~$quota[0]<br />$quota[1]~;
	if ($quota[2]) {
		my $ds = (split(/ +/, $disk_space[1], 2))[0] if !$enable_quota;
		$quota_select .= qq~<br /><select name="enable_quota_value">~;
			for (my $i = 2; $i < @quota; $i++) {
			$quota[$i] =~ s/^ +//;
			$quota[$i] =~ s/ +/&nbsp;&nbsp;/g;
			$quota_select .= qq~<option value="$i" ~ . ${isselected($i == $enable_quota || ($ds && $quota[$i] =~ /^$ds/))} . qq~>$quota[$i]</option>~;
		}
		$quota_select .= '</select>';
	}
}  



That code suppresses the diskchecking, and no command windows are launched + you are able to save settings now.

Let us leave it at that fix please.

Smiley
  

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,380
Location: Earth

YaBB 2.6.1
Re: Advanced Settings will not save some some Windows Machines
Reply #13 - Sep 23rd, 2012 at 10:27pm
Post Tools
I did get a version that actually checks space on Windows.  Wink

Edited:
Still working on getting to behave for both Win and *nix.
« Last Edit: Sep 23rd, 2012 at 10:53pm by Dandello »  

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



Posts: 2,380
Location: Earth

YaBB 2.6.1
Re: Advanced Settings will not save some some Windows Machines
Reply #14 - Sep 23rd, 2012 at 10:57pm
Post Tools
Code
Select All
if ($^O ne 'MSWin32') {
	# Free Disk Space Checking for Linux/Unix OS
	my @disk_space = qx{df -k .};
	map { $_ =~ s/ +/  /g } @disk_space;
} 



Otherwise it stops the *nix quota check from working. (Another one of those spooky WTF things.)
« Last Edit: Sep 23rd, 2012 at 10:58pm by Dandello »  

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] 2 
Topic Tools
 
  « Board Index ‹ Board  ^Top