Fork me on GitHub

#1 2012-01-22 01:38:38

s0600204
Member
From: UK
Registered: 2012-01-22
Posts: 118
Website

[FIXED] ACL Bug

I came across a nasty bug earlier, severe enough to prevent logins:

If you delete all the ACLs from your system, then logout and back in again, you'll probably find that oneye crashes. The error message given in the Error Console is:

INVALID ARGUMENT FOR FOREACH() IN .../system/kernal/kernal.eyecode on line 398

On closer inspection, it appears that oneye can't cope if the file .../system/conf/ACL/acl.xml exists but has no ACL rules inside it. Deleting the file solves the problem - until you create and then delete new ACL rules in the future.

Hope you don't mind, but I took the liberty of working out a solution in code. Changing Lines 489-492 (or thereabouts) in the function loadACLTables() in kernal.eyecode from this...

	if ($file{0} != '.') {
		$found = 1;
		$myArray = eyeXML('xml2array', array(file_get_contents($aclpath . $file)));
		$ACL = array_merge($ACL,$myArray);
	}

...to this...

	if ($file{0} != '.') {
		$myArray = eyeXML('xml2array', array(file_get_contents($aclpath . $file)));
		if (is_array($myArray[GACL][0])) {
			$found = 1;
			$ACL = array_merge($ACL,$myArray);
		}
	}

...solves the issue. Essentially, it checks to see if any ACL rules are actually written and preventing $found from becoming '1' if not.

Offline

#2 2012-01-22 17:49:53

lars-sh
Administrator
From: near Hamburg, Germany
Registered: 2011-07-14
Posts: 731
Website

Re: [FIXED] ACL Bug

You're absolutely right. That's a problem in our XML implementation, that converts empty arrays into an empty string...

Just comitted your fix, thanks.


Best regards,
Lars Knickrehm

The oneye project.

Offline

#3 2012-01-22 23:32:28

s0600204
Member
From: UK
Registered: 2012-01-22
Posts: 118
Website

Re: [FIXED] ACL Bug

Thanks, and I'm really sorry, but I'm going to have to disagree with line 491

if (is_array($myArray) === true) {

as this checks to see if $myArray is an array. Which it is whether there are ACL rules or not. I'm afraid line 491 really does need to be

if (is_array($myArray[GACL][0]) === true) {

If it helps, take a look at this print_r output of $myArray with no ACL rules:

Array
(
    [GACL] => Array
        (
            [0] => 
        )
)

The first Array is equivalent to $myArray, the second Array is equivalent to $myArray[GACL], it's $myArray[GACL][0] that isn't an array in this case.

My apologies for disagreeing, but as you refer to it as 'my' fix, I'd like to make sure it works wink

Edit: Ah, just noticed your change on line 384. I didn't think anything else but loadACLTables() wrote to the $ACL global? So checking if $myArray[GACL][0] is an array on line 384 is a little bit after the fact. And as that particular line will be run every time a call to a service is made...

Last edited by s0600204 (2012-01-24 02:33:59)

Offline

Board footer

Powered by FluxBB