PDA

View Full Version : Hayes: Dream 4xx Error



tobias
06-22-2007, 09:43 AM
I installed the Hayes release after some difficulties on Ubuntu (the new mono packages were not available for feisty so we had to upgrade to gutsy...) and could only get the Option 2: mod_mono setup to work. The wiki is running now but unfortunately I get the following error on the top bar whenever I load te site:


Dream 4xx Error
Sorry, but there was a system error.
Viewing Details:
Request URI: http://wiki.i2stest.de/@api/deki/pages/33/security?dream.out.format=php&dream.in.host=wiki.i2stest.de
Server response:

Any ideas?

SteveB
06-23-2007, 09:31 PM
To find out if the host is accessible, try the following from your browser:
http://wiki.i2stest.de/@api/host/test

You should get back an XML document. If not, the host isn't reachable. This might be a mod_mono configuration issue.

However, I'm surprised that you got mod_mono to run and not mod_proxy. Form my experience, the latter is much easier to setup and is standard in Apache.

tobias
06-26-2007, 10:57 AM
I always got stuck with the folowing command while installing mod_proxy:


root@ubuntu:/var/www/deki-hayes/config# su www-data /var/www/deki-hayes/bin/mindtouch.host.sh start
/var/www/deki-hayes/bin/mindtouch.host.sh: 20: function: not found
stop: missing job name
Try `stop --help' for more information.
Starting MindTouch Deki API: mono /var/www/deki-hayes/bin/mindtouch.host.exe apikey 12345 script /etc/dekiwiki/mindtouch.deki.startup.xml root-uri http://deki-hayes/@api http-port 8081 ip localhost notty
/var/www/deki-hayes/bin/mindtouch.host.sh: 25: Syntax error: "}" unexpected

Any ideas?
thanks
Tobias

PeteE
06-26-2007, 02:08 PM
I always got stuck with the folowing command while installing mod_proxy:

Any ideas?


tobias - could you post the contents of your mindtouch.host.sh file?

Thanks!

tobias
06-26-2007, 02:12 PM
Here you go:


#!/bin/sh
BIN_DIR=`dirname $0`;

#### Modify HOSTNAME to suit your configuratoin ####
#HOSTNAME=`hostname`
HOSTNAME=wiki.i2stest.de

ROOT_URI="http://$HOSTNAME/@api"
HTTP_PORT="8081"
IP="localhost"
HOST_EXE="$BIN_DIR/mindtouch.host.exe"
APIKEY="12345"
SCRIPT="/etc/dekiwiki/mindtouch.deki.startup.xml"
#SCRIPT="$BIN_DIR/mindtouch.deki.startup.xml"
NOTTY="notty"
MONO="mono"
LOGFILE="/var/log/deki-api.log"
MONO_CMD="$MONO $HOST_EXE apikey $APIKEY script $SCRIPT root-uri $ROOT_URI http-port $HTTP_PORT ip $IP $NOTTY"

function start {
stop
#echo "Starting MindTouch Deki API: $MONO_CMD"
#nohup $MONO_CMD 2>&1 >> $LOGFILE &
#echo $! > /tmp/deki-api.pid
}

function stop {
PID=0
if [ -f /tmp/deki-api.pid ]; then
PID=`cat /tmp/deki-api.pid`
fi

echo "Stopping MindTouch Deki API"
rm -f /tmp/deki-api.pid
curl -m 10 -s -d "" "http://$IP:$HTTP_PORT/host/?apikey=$APIKEY&dream.in.verb=DELETE"
sleep 3

# just in case the POST didn't shut down deki-api, try to kill it
if [ $PID -ne 0 ]; then
kill -9 $PID > /dev/null 2>&1
fi
rm -f nohup.out
}

function restart {
start
}

function usage {
echo "Usage: `basename $0` [start|stop|restart]"
}

ACTION=$1
if [ ! $ACTION ]; then
ACTION="start"
fi

case "$ACTION" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
usage
;;
esac

PeteE
06-26-2007, 02:24 PM
tobias - Try moving the stop function above the start function (it's not recognizing the stop function since it's declared after). Also, you'll need to uncomment the commented lines in your start function. Give this a shot:



#!/bin/sh
BIN_DIR=`dirname $0`;

#### Modify HOSTNAME to suit your configuratoin ####
#HOSTNAME=`hostname`
HOSTNAME=wiki.i2stest.de

ROOT_URI="http://$HOSTNAME/@api"
HTTP_PORT="8081"
IP="localhost"
HOST_EXE="$BIN_DIR/mindtouch.host.exe"
APIKEY="12345"
SCRIPT="/etc/dekiwiki/mindtouch.deki.startup.xml"
#SCRIPT="$BIN_DIR/mindtouch.deki.startup.xml"
NOTTY="notty"
MONO="mono"
LOGFILE="/var/log/deki-api.log"
MONO_CMD="$MONO $HOST_EXE apikey $APIKEY script $SCRIPT root-uri $ROOT_URI http-port $HTTP_PORT ip $IP $NOTTY"


function stop {
PID=0
if [ -f /tmp/deki-api.pid ]; then
PID=`cat /tmp/deki-api.pid`
fi
echo "Stopping MindTouch Deki API"
rm -f /tmp/deki-api.pid
curl -m 10 -s -d "" "http://$IP:$HTTP_PORT/host/?apikey=$APIKEY&dream.in.verb=DELETE"
sleep 3

# just in case the POST didn't shut down deki-api, try to kill it
if [ $PID -ne 0 ]; then
kill -9 $PID > /dev/null 2>&1
fi
rm -f nohup.out
}

function start {
stop
echo "Starting MindTouch Deki API: $MONO_CMD"
nohup $MONO_CMD 2>&1 >> $LOGFILE &
echo $! > /tmp/deki-api.pid
}

function restart {
start
}

function usage {
echo "Usage: `basename $0` [start|stop|restart]"
}

ACTION=$1
if [ ! $ACTION ]; then
ACTION="start"
fi
case "$ACTION" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
usage
;;
esac

tobias
06-26-2007, 02:39 PM
Still the same error...


root@ubuntu:~# su www-data /var/www/i2stest/htdocs/wiki/bin/mindtouch.host.sh start
/var/www/i2stest/htdocs/wiki/bin/mindtouch.host.sh: 21: function: not found
Stopping MindTouch Deki API
/var/www/i2stest/htdocs/wiki/bin/mindtouch.host.sh: 36: Syntax error: "}" unexpected

PeteE
06-26-2007, 02:48 PM
Oh the problem is that you're using /bin/sh as an interpreter instead of /bin/bash. Either change the first statement to:

#!/bin/bash

or modify the script to look like this (note the different function syntax):



#!/bin/sh
BIN_DIR=`dirname $0`;

#### Modify HOSTNAME to suit your configuratoin ####
#HOSTNAME=`hostname`
HOSTNAME=wiki.i2stest.de

ROOT_URI="http://$HOSTNAME/@api"
HTTP_PORT="8081"
IP="localhost"
HOST_EXE="$BIN_DIR/mindtouch.host.exe"
APIKEY="12345"
SCRIPT="/etc/dekiwiki/mindtouch.deki.startup.xml"
#SCRIPT="$BIN_DIR/mindtouch.deki.startup.xml"
NOTTY="notty"
MONO="mono"
LOGFILE="/var/log/deki-api.log"
MONO_CMD="$MONO $HOST_EXE apikey $APIKEY script $SCRIPT root-uri $ROOT_URI http-port $HTTP_PORT ip $IP $NOTTY"


stop() {
PID=0
if [ -f /tmp/deki-api.pid ]; then
PID=`cat /tmp/deki-api.pid`
fi
echo "Stopping MindTouch Deki API"
rm -f /tmp/deki-api.pid
curl -m 10 -s -d "" "http://$IP:$HTTP_PORT/host/?apikey=$APIKEY&dream.in.verb=DELETE"
sleep 3

# just in case the POST didn't shut down deki-api, try to kill it
if [ $PID -ne 0 ]; then
kill -9 $PID > /dev/null 2>&1
fi
rm -f nohup.out
}

start() {
stop
echo "Starting MindTouch Deki API: $MONO_CMD"
nohup $MONO_CMD 2>&1 >> $LOGFILE &
echo $! > /tmp/deki-api.pid
}

restart() {
start
}

usage() {
echo "Usage: `basename $0` [start|stop|restart]"
}

ACTION=$1
if [ ! $ACTION ]; then
ACTION="start"
fi

case "$ACTION" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
*)
usage
;;
esac

PeteE
06-26-2007, 02:52 PM
just a followup - Debian has a symlink from /bin/sh to /bin/bash whereas Ubuntu has a symlink from /bin/sh to /bin/dash

I'll updated the mindtouch.host.sh script to explicitly use /bin/bash in the upcoming release of Hayes Beta2 (which will be up on SourceForge sometime today).

Thanks for bringing this up tobias!

tobias
06-26-2007, 02:58 PM
GREAT! It worked!

Unfortunately, I get now the Dream 4xx Error again but with different information when I try to log into the Sysop account:

Request URI: http://sysop:password@wiki.i2stest.de/@api/deki/users/authenticate?dream.out.format=php&dream.in.host=wiki.i2stest.de&authprovider=1


Server response: User has {READ,DELETE,CHANGEPERMISSIONS,CONTROLPANEL} permissions for the resource. User requires {LOGIN} permissions for the resource.

PeteE
06-26-2007, 03:06 PM
Hrmm...that's the same problem sjb ran into!

http://forums.opengarden.org/showthread.php?t=265&page=3&highlight=CHANGEPERMISSIONS

I'll ping MaxM about it and see if he ever found a resolution.

I'll try to recreate on my Ubuntu box.

Thanks,
pete

tobias
06-26-2007, 04:03 PM
Just as a note, I just reseted the VM i was testing beta 1 on and made a fresh install. I still can't log in as Sysop. I get the same error message again:


Request URI: http://sysop:password@deki-hayes/@api/deki/users/authenticate?dream.out.format=php&dream.in.host=deki-hayes&authprovider=1


Server response: User has {READ,DELETE,CHANGEPERMISSIONS,CONTROLPANEL} permissions for the resource. User requires {LOGIN} permissions for the resource.

One other thing I found out during the install.:
Apparently you require this directory also in the beta 1 release (the install guide mentioned it only on the beta 2 site):


Create the mono .wapi directory (Note: the mono .wapi directory needs to exist in the home directory for your apache user. In debian the www-data user's home dir is: /var/www/ but this location may be different for different linux distros.)

mkdir /var/www/.wapi
chown www-data /var/www/.wapi

i changed it on the beta 1 site accordingly! Please let me know if I am wrong with this, but for me it made the API work.
Cheers,
Tobias

PeteE
06-26-2007, 04:39 PM
tobias - I was able to recreate the issue. Apparently the permission mask is being truncated. When I attempt to login I get a permission mask of:

9223372036

but it should be:
9223372036854779903

The ifnull() function appears to be the problem. It produces different behavior on my Debian Etch machine versus my Ubuntu machine.

On Ubuntu (5.0.38-Ubuntu_0ubuntu1-log)


mysql> set @effective_rights_flags=0,@group_flags=0, @effective_rights_flags=0;
Query OK, 0 rows affected (0.00 sec)

mysql> call perm_get_UserRightsFlags('1', @user_flags, @group_flags, @effective_rights_flags);
Query OK, 0 rows affected, 1 warning (0.01 sec)

mysql> select @effective_rights_flags;
+-------------------------+
| @effective_rights_flags |
+-------------------------+
| 9223372036 |
+-------------------------+
1 row in set (0.00 sec)


But on Debian (5.0.32-Debian_7etch1-log):


mysql> set @effective_rights_flags=0,@group_flags=0, @effective_rights_flags=0;
Query OK, 0 rows affected (0.00 sec)

mysql> call perm_get_UserRightsFlags('1', @user_flags, @group_flags, @effective_rights_flags);
Query OK, 0 rows affected (0.00 sec)

mysql> select @effective_rights_flags;
+-------------------------+
| @effective_rights_flags |
+-------------------------+
| 9223372036854779903 |
+-------------------------+
1 row in set (0.00 sec)


Now that we can repro it consistently, it should be to difficult to resolve.

thanks,
pete

PeteE
06-26-2007, 05:17 PM
tobias - I was able to resolve the issue by changing the perm_get_UserRightsFlags stored procedure like this:



DELIMITER $$

DROP PROCEDURE IF EXISTS `perm_get_UserRightsFlags`$$

CREATE PROCEDURE `perm_get_UserRightsFlags`(
IN userid INT UNSIGNED,
OUT user_flags BIGINT(8) UNSIGNED,
OUT group_flags BIGINT(8) UNSIGNED,
OUT effective_rights_flags BIGINT(8) UNSIGNED
)
BEGIN
select bit_or(r.role_perm_flags) into group_flags from user_groups as ug
join groups as g on ug.group_id = g.group_id
join roles as r on g.group_role_id = r.role_id
where
ug.user_id = userid;
select r.role_perm_flags into user_flags from users as u
join roles as r on u.user_role_id = r.role_id
where
u.user_id = userid;
select CAST(ifnull(user_flags,0) as unsigned) | CAST(ifnull(group_flags,0) as unsigned) into effective_rights_flags;
END$$

DELIMITER ;


Could you try running that procedure against your hayes database and verify that it works for you? If it works, I'll make sure it gets into the Beta2 release.

Thanks,
pete

tobias
06-26-2007, 06:50 PM
It works like a charm :D

Thanks a lot! Keep up the awesome work, guys. Your Wiki is definately the best!
Tobias

AaronF
06-26-2007, 07:13 PM
Spread the word!

PeteE
06-26-2007, 07:15 PM
It works like a charm :D
Tobias

Excellent. I'll get the patch into beta2.

tobias
06-29-2007, 08:29 AM
I just tried to install beta 2 and ran into trouble again. Apparently you couldn't get the /bin/sh fix into beta 2 so I changed the mindtouch.host.sh according to your description from last time. After I start the dekiapi, I get the following error message:

root@ubuntu:/var/www/deki-hayes/config# /etc/init.d/dekihost restart
Stopping MindTouch Deki API
<?xml-stylesheet type='text/xsl' href='/@api/host/resources/error.xslt'?><error><status>403</status><title>Forbidden</title><message>insufficient access privileges</message><uri>http://localhost:8081/@api/host/?apikey=D4Yr0vxiCeMhE8wPMdxALkwmeb9RLJi0&amp;dream.in. verb=DELETE</uri></error>Starting MindTouch Deki API: mono /var/www/deki-hayes/bin/mindtouch.host.exe apikey D4Yr0vxiCeMhE8wPMdxALkwmeb9RLJi0 script /etc/dekiwiki/mindtouch.deki.startup.xml server-name http://deki-hayes path-prefix @api http-port 8081 ip localhost notty

I followed the guidelines for beta 2 closely, so I am not sure where those permission issues come from....
Tobias

PS: I get the following error when I try to access the site:

Fatal error: Call to a member function At() on a non-object in /var/www/deki-hayes/includes/WebServiceManagement.php on line 210

PeteE
06-29-2007, 02:59 PM
Apparently you couldn't get the /bin/sh fix into beta 2
Doh! I had that in at one point but must have got the old version in there somehow. Sorry about that :(




root@ubuntu:/var/www/deki-hayes/config# /etc/init.d/dekihost restart
Stopping MindTouch Deki API
<?xml-stylesheet type='text/xsl' href='/@api/host/resources/error.xslt'?><error><status>403</status><title>Forbidden</title><message>insufficient access privileges</message><uri>http://localhost:8081/@api/host/?apikey=D4Yr0vxiCeMhE8wPMdxALkwmeb9RLJi0&amp;dream.in. verb=DELETE</uri></error>Starting MindTouch Deki API: mono /var/www/deki-hayes/bin/mindtouch.host.exe apikey D4Yr0vxiCeMhE8wPMdxALkwmeb9RLJi0 script /etc/dekiwiki/mindtouch.deki.startup.xml server-name http://deki-hayes path-prefix @api http-port 8081 ip localhost notty

You can safely ignore that error. The dekihost script tries to shutdown an existing instance of the dekihost in 2 ways:

1) it sends a DELETE command to the host (using the APIKEY) to shut the service down gracefully
2) if that fails, it attempts to kill the process (using `kill`)

What happened here is that you have a mindtouch.host.sh process running from your previous install (using that install's apikey). When it tried to send the DELETE using the new apikey it failed since the apikey for your new install is different.



PS: I get the following error when I try to access the site:

Fatal error: Call to a member function At() on a non-object in /var/www/deki-hayes/includes/WebServiceManagement.php on line 210

If you clear your cookies and log in again this won't happen. We ran into this issue at like 3am the night of the release but didn't get it patched in time. It's trying to log you in with an existing authtoken from your cookies.

tobias
07-02-2007, 10:57 AM
Great, that worked!

Unfortunately, the navigation on the left side is screwed up, seems to me as if the images are not linked correctly...
See the attached screenshot:
http://i2solutions.de/share/links.png

tobias
07-10-2007, 03:05 PM
Nobody any ideas about the navigation??

SteveB
07-20-2007, 05:44 AM
I just noticed that the images that should be loading are appearing in your breadcrumbs above the navigation pages (see Parent-open.gif, Home.gif, etc.). So, I'm suspecting that this is an issue with your Apache rewrite rules. The requrest files are in the /skins folder, we should be excluded from the mod_rewrite set. If not, it will appear as if you were requesting a given page, which would make it appear in the breadcrumbs, as is the case in the your screenshot.