Skip to content

Cloning VirtualBox machines, II

I've covered this before, but this time we're not using VBoxManage import/export but will clone the disk, then create a new VM:
$ mkdir vm1
$ VBoxManage clonehd vm0/disk0.vdi vm1/disk0.vdi

$ VBoxManage createvm --ostype Debian_64 --name vm1 --basefolder `pwd` --register
Virtual machine 'vm1' is created and registered.
UUID: f9f52566-40df-48cd-bb5f-c52e6d050260
Settings file: 'vm1/vm1.vbox'
Now the VM and its disk is already in place, we're going to tune our VM a bit and attach the disk to the VM:
$ VBoxManage modifyvm vm1 --memory 256 --rtcuseutc on --pae off \
                      --boot1 disk --boot2 dvd --boot3 none --boot4 none \
                      --nic1 bridged --nictype1 virtio --bridgeadapter1 "en1"

$ VBoxManage storagectl vm1 --name "SATA Controller" --add sata \
                      --controller IntelAHCI --sataportcount 1

$ VBoxManage storageattach vm1 --storagectl "SATA Controller" \
                      --port 0 --device 0 --type hdd --medium `pwd`/vm1/disk0.vdi
:-)

open_basedir & phpMyAdmin

When open_basedir was in effect, phpMyAdmin would not work. But it would not give these helpful error messages away:
   open_basedir restriction in effect. File(/tmp/foo) is not within the allowed path(s)
The webserver would just terminate the script with an error 500 and be done with it. As soon as open_basedir is disabled, phpMyAdmin works. So what's bothering phpMyAdmin or: which files can phpMyAdmin not access?

Since we're using PHP via FastCGI, we have one webserver process and 10 php-cgi processes. But let's strace them anyway:
 $ strace -p `pgrep php-cgi | xargs echo | sed 's/ / -p /g'` -p `pgrep lighttpd`
Now disable open_basedir, restart the webserver and run strace(1) again. Thanks to GNU/diff, we can use:
  $ diff -y with-openbasedir.log without-openbasedir.log
  [...]
                                 > open("/var/lib/phpmyadmin/blowfish_secret.inc.php",
                                 > open("/var/lib/phpmyadmin/config.inc.php",
...and there it was. Adding /var/lib/phpmyadmin/ to open_basedir did the trick. In retrospect, pretty trivial - but without a proper error message in the logs, strace(1) was the only solution I could think of.

Hook ReCaptcha::confirmEdit failed to return a value

Today, editing (and saving) a MediaWiki article barfed with:
Detected bug in an extension! Hook ReCaptcha::confirmEdit failed to return a value;
should return true to continue hook processing or false to abort.

Backtrace:

#0 ../includes/EditPage.php(802): wfRunHooks('EditFilter', Array)
#1 ../includes/EditPage.php(2552): EditPage->internalAttemptSave(false, false)
#2 ../includes/EditPage.php(389): EditPage->attemptSave()
#3 ../includes/EditPage.php(271): EditPage->edit()
#4 ../includes/Wiki.php(553): EditPage->submit()
#5 ../includes/Wiki.php(70): MediaWiki->performAction(Object(OutputPage),
     Object(Article), Object(Title), Object(User), Object(WebRequest))
#6 ../index.php(117): MediaWiki->performRequestForTitle(Object(Title), 
     Object(Article), Object(OutputPage), Object(User), Object(WebRequest))
#7 {main}
Apparently, this has been caused by the recent upgrade to Debian/Squeeze, which comes with php-5.3.3. The fix is to apply the following patch to the reCAPTCHA extension:
--- mediawiki/ConfirmEdit.php.orig      2011-02-13 07:55:38.366172048 +0100
+++ mediawiki/ConfirmEdit.php   2011-02-13 07:59:47.115119111 +0100
@@ -483,7 +483,7 @@ class SimpleCaptcha {
         * @param string $section
         * @param bool true to continue saving, false to abort and show a captcha form
         */
-       function confirmEdit( &$editPage, $newtext, $section ) {
+       function confirmEdit( $editPage, $newtext, $section ) {
                if( $this->shouldCheck( $editPage, $newtext, $section ) ) {
                        if( $this->passCaptcha() ) {
                                return true;
--- mediawiki/ReCaptcha.php.orig        2011-02-13 07:57:27.700624763 +0100
+++ mediawiki/ReCaptcha.php     2011-02-13 08:05:47.903120256 +0100
@@ -97,7 +97,7 @@ class ReCaptcha extends SimpleCaptcha {
          * Called on all edit page saves. (EditFilter events)
          * @return boolean - true if page save should continue, false if should display Captcha widget.
          */
-        function confirmEdit( &$editPage, $newtext, $section ) {
+       function confirmEdit( $editPage, $newtext, $section ) {
                 if( $this->shouldCheck( $editPage, $newtext, $section ) ) {
 
                         if (!isset($_POST['recaptcha_response_field'])) {