Friday, September 28, 2007

Apache 2.2 PAM troubles

This time i had to configure an apache to use pam to connect through winbind to an Active Directory.

Basically i was trying to port an Apache 2.0 vhost to Apache 2.2 since we are switching servers.

It took me some time until we found a bugreport indicating why it is not working anymore..

AuthBasicAuthorative Off


http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=394097

Monday, September 24, 2007

SATA Problems Part II

Last weekend i got the replacement disk for my broken sata disk and reinstalled it. I found a manual quite quick but had some serious problems since i either got one of the two following errors while trying to rebuild the raid 1 array:
ata1: Timeout
ata1: DMA Timeout

Although i had some ideas what could be wrong my last solution was to change the SATA Cable and that was all it needed...


Rebuild Array

To rebuild an array with a clean disk i found this guide useful:
http://www200.pair.com/mecham/raid/raid1-degraded-etch.html

Although it was written for IDE Disks you can use it also for SATA..

Here the needed parts extracted:
We start by copying the partition structure from /dev/hda to /dev/hdc. We do this for what should now be an obvious reason: the secondary drive is empty, but it needs to have the same structure as the primary drive. If the disk was first cleaned, and is large enough, you should have no errors (but you may still have to --force it):

sfdisk -d /dev/hda | sfdisk /dev/hdc

We make sure the superblocks are zeroed out on the new drive (as always, be careful you do this to the correct drive). Edit as needed:

mdadm --zero-superblock /dev/hdc1
mdadm --zero-superblock /dev/hdc5
mdadm --zero-superblock /dev/hdc6


Now we add our three hdc partitions to the corresponding md's.
Understand what you are doing here before you do it, edit as needed:


mdadm --add /dev/md0 /dev/hdc1
mdadm --add /dev/md1 /dev/hdc5
mdadm --add /dev/md2 /dev/hdc6


Watch them sync:
watch -n 6 cat /proc/mdstat

Once the recovery is complete (and not until then), create a new boot records on both drives:
grub

From the grub> prompt (edit partition number if needed):
root (hd0,0)
setup (hd0)
root (hd1,0)
setup (hd1)
quit

PHP5 DomDocument schemaValidation problems

First i have to tell about a SOAP Connection to a webservice. I don't know if the developers ever thought about SOAP more than just a quick thought how can we transfer data, since from my end it looks as if they have absolute no idea what they were doing.

We have a Service that holds a bunch of personal data which we have to transfer to the webservice of an higher instance. Now you would think they provide a SOAP Connection where there are a lot of functions to send them the data for every person.. but no.. there are only two functions:
  • One which wants a XML String where all personal data has been collected together and
  • a second one which wants the same string as zip
So you see the whole point of the SOAP connection is just to send them the already prepared XML Files and then they work with the collected data somehow internal.

Fortunately they provided a xsd file so i was able to add additional validation to ensure the data is valid.

Now i created the XML Files using php5 DomDocument. The library makes it really easy to create Elements and it also holds a schemaValidation functionality.

I don't want to get into to much detail but when i said that they want all personal data of all people collected in one file you will notice that it would not be a good idea creating first all users in one file and then check if that file is ok... or perhaps i am just the only paranoid here, but i wanted to know exactly which person is making troubles.

So my code first creates the xml data for each person separately (although cached) and then i add the xml data to an prepared xml so i can validate against the schema.

The Problem
Now we get to the point. My Function first creates a Validation XML which helds all the markup and then adds the XML Data of the person using DomDocument->importNode and then appendChild at the correct position.

Unfortunately the schemaValidation finds errors where there are not really one, or so i thought. I got Error Messages which i was unable to see anything wrong. But i found a workaround.
Using DomDocument->loadXML(DomDocument->saveXML()) just before the validation i was able to sort of "normalize" the DomDocument and the schemaValidation worked.

I am not sure if the schemaValidation was just not designed for such a work or i did misjudge and used it completely wrong. But since there is not much documentation at php.net i had no other way.