Latest Entries »

Laptop

Oké mensjes, ik heb vanmiddag mijn nieuwe laptop van de universiteit opgehaald. Het is een HP EliteBook 8570w. Hij ziet er goed uit, en zo’n verlicht toetsenbord is best cool (en handig als je in het donker wil typen)IMG_1297

Natuurlijk staat hier de universiteitsimage op met allerlei meuk waar ik niet op zit te wachten. Het is trouwens een Windows 7 systeem. Thank God is not Windows 8, maar boeiend, het gaat er toch af. Op de vorige universiteitslaptop (HP EliteBook 8530w) werd ik gek van die “anti-rsi” software die zeurt dat ik te snel typ. Maar ff serieus, kijk eens hoeveel ikoontjes er langs de klok staan! En waar is het allemaal goed voor? Argh… ik haat voorgeïnstalleerde software.  IMG_1299

En kijk hoe ik “begroet” wordt? Muisgedrag? Opvolging interventies? Ja weer van die “anti-rsi” software (andere dan de vorige keer) die me constant lastig gaat vallen . Nee…. daar gaan we dus niet aan beginnen. We gaan die hele laptop leeg gooien en opnieuw installeren. En als we dat dan toch moeten doen, er natuurlijk gelijk Linux op zetten. Geen Microsoft meuk! Afin. Het plan was dus eerst een image te trekken van de huidige inhoud van die harde schijf, om er vervolgens ArchLinux op te zetten.

startup_screemHet eerste issue daarbij is dat er blijkbaar geen optische drive in deze laptop zit. Wegbezuinigd? Afin, er lijkt een blindklep op te zitten, dus waarschijnlijk is deze gewoon te bestellen. (zie hiero) Dusch…. dan maar externe DVD drive aangesloten… doet die drive het niet meer. Arrgghh…. Dat schiet dus niet op. Nou ja… eerst maar eens navragen of ik via de universiteit nog een optische drive kan aanschaffen, anders maar kijken waar ik die kan bestellen, want ik heb geen zin altijd een USB DVD drive te moeten meezeulen. (Trouwens ik betwijfel of ik een nieuwe USB DVD drive ga aanschaffen aangezien ik geen netbook meer heb)

Het zou in principe mogelijk zijn om vanaf een USB stick te booten en toch door te gaan met de image en installatieprocedure, maar ik heb daar vandaag mooi geen zin meer in.

Edit: It’s the power adaptor, it’s always the power adaptor. Ik had dus twee gelijke voedingen (precies zelfde type) voor de desbetreffende USB DVD drive. Het probleem lag dus aan de voeding. Met de andere voeding werkt hij wel. (alsof ik niet al genoeg ellende met voedingen heb… het in “Power for Pi” project is ook alweer gestrand in verband met een crappy chinese voeding)

Time to test my Raspberry Pi with my new “Power Board”. In order to do so, I’m writing a clean image to my SD card.

[root@hplaptop raspberry_pi]# dd of=/dev/mmcblk0 if=archlinux-hf-2013-07-22.img bs=1M
1870+0 records gelezen
1870+0 records geschreven
1960837120 bytes (2,0 GB) gekopieerd, 317,354 s, 6,2 MB/s
[root@hplaptop raspberry_pi]# sync

Now, something weird is going on. It appears nothing has been written, as when I boot it up, it boots my previous image. It is set to it’s hostname and accepting my username and password. But this is supposed to be a clean, unconfigured instance of ArchLinuxARM. Now, I have been experiencing problems with my laptop’s SD card slot when the laptop is running hot. Now my laptop has been running for hours, but it’s not that hot I think. Anyhow. I’ll remove the existing partitions before I am going to write the image:


[root@hplaptop raspberry_pi]# fdisk /dev/mmcblk0
Opdracht (m voor hulp): o
Aanmaken van een nieuw DOS-schijflabel met schijf-ID 0x67404a92.

Opdracht (m voor hulp): w
De partitietabel is gewijzigd!

Aanroepen van ioctl() om partitietabel opnieuw in te lezen…
Leegmaken van schijfbuffers…
[root@hplaptop raspberry_pi]# ls /dev/mmcblk0*
/dev/mmcblk0 /dev/mmcblk0p1 /dev/mmcblk0p2 /dev/mmcblk0p5

What is going on here? Looking at my dmesg output, there indeed appears to be a problem with my SD slot

[12272.101180] WARNING: at drivers/mmc/host/sdhci.c:838 sdhci_send_command+0xa35/0xd90 [sdhci]()
[12272.101184] Modules linked in: nfsv3 nfs_acl rpcsec_gss_krb5 auth_rpcgss oid_registry nfsv4 fuse cpufreq_powersave uvcvideo videobuf2_vmalloc videobuf2_memops vide
obuf2_core videodev media pata_pcmcia joydev iTCO_wdt coretemp iTCO_vendor_support kvm_intel hp_wmi ppdev sparse_keymap kvm arc4 r852 sm_common nand nand_ecc nand_ids
mtd iwldvm snd_hda_codec_analog mac80211 pcmcia microcode nouveau pcspkr r592 psmouse yenta_socket memstick pcmcia_rsrc serio_raw pcmcia_core evdev mxm_wmi lpc_ich t
tm drm_kms_helper iwlwifi cfg80211 drm i2c_algo_bit i2c_core snd_hda_intel snd_hda_codec snd_hwdep snd_pcm snd_page_alloc snd_timer snd rfkill soundcore parport_pc pa
rport hp_accel fan lis3lv02d e1000e ptp thermal wmi intel_agp acpi_cpufreq input_polldev mperf button pps_core intel_gtt processor ac battery video
[12272.101283] nfs lockd sunrpc fscache ext4 crc16 mbcache jbd2 sd_mod sr_mod cdrom mmc_block sdhci_pci ahci sdhci libahci mmc_core libata firewire_ohci scsi_mod fir
ewire_core crc_itu_t ehci_pci uhci_hcd ehci_hcd usbcore usb_common
[12272.101319] CPU: 1 PID: 7658 Comm: mmcqd/0 Tainted: G W 3.10.6-2-ARCH #1
[12272.101323] Hardware name: Hewlett-Packard HP EliteBook 8530w/30E7, BIOS 68PDV Ver. F.0E 07/31/2009
[12272.101327] 0000000000000009 ffff88013934bbc8 ffffffff814c239c ffff88013934bc00
[12272.101335] ffffffff81055881 ffff8800a26e78e8 ffff8800a26e7958 0000000000000001
[12272.101342] ffff880138b954c0 0000000000000001 ffff88013934bc10 ffffffff8105595a
[12272.101350] Call Trace:
[12272.101359] [] dump_stack+0x19/0x1b
[12272.101366] [] warn_slowpath_common+0x61/0x80
[12272.101373] [] warn_slowpath_null+0x1a/0x20
[12272.101389] [] sdhci_send_command+0xa35/0xd90 [sdhci]
[12272.101396] [] ? strlcpy+0x42/0x60
[12272.101402] [] ? elv_rb_del+0x2a/0x40
[12272.101417] [] sdhci_request+0x147/0x1d0 [sdhci]
[12272.101433] [] mmc_start_request+0x124/0x250 [mmc_core]
[12272.101440] [] ? sg_init_table+0x1a/0x40
[12272.101457] [] mmc_start_req+0x325/0x400 [mmc_core]
[12272.101471] [] mmc_blk_issue_rw_rq+0xe1/0xb50 [mmc_block]
[12272.101487] [] ? __mmc_claim_host+0x131/0x1c0 [mmc_core]
[12272.101501] [] mmc_blk_issue_rq+0x1d3/0x540 [mmc_block]
[12272.101509] [] ? blk_dequeue_request+0x88/0xd0
[12272.101522] [] mmc_queue_thread+0xc3/0x1c0 [mmc_block]
[12272.101535] [] ? mmc_blk_compat_ioctl+0x20/0x20 [mmc_block]
[12272.101543] [] kthread+0xc0/0xd0
[12272.101550] [] ? kthread_create_on_node+0x120/0x120
[12272.101558] [] ret_from_fork+0x7c/0xb0
[12272.101565] [] ? kthread_create_on_node+0x120/0x120
[12272.101570] ---[ end trace c0b8a10a2230b2df ]---
[12272.104585] DMA: Out of SW-IOMMU space for 4096 bytes at device 0000:86:09.1

It seems, nothing is being written to this SD card. Is it my laptop’s SD slot, or is there something wrong with the SD card? Well…. I’ll attempt to use an USB Card Reader in stead. But that thing also refuses with stange messages in smesg

[12585.412195] usb 6-2: new full-speed USB device number 13 using uhci_hcd
[12585.412716] DMA: Out of SW-IOMMU space for 8 bytes at device 0000:00:1d.2
[12585.615960] DMA: Out of SW-IOMMU space for 8 bytes at device 0000:00:1d.2
[12585.818833] usb 6-2: device not accepting address 13, error -11
[12585.818876] hub 6-0:1.0: unable to enumerate USB device on port 2

Rebooting the system doesn’t solve the problem. Even though no SD/MMC related error messages appear in the dmesg output, nothing is being written to the card. The USB card reader appears to be working after reboot. However, I am not sure if the image was written correctly this time. After writing the 2 GB image it appears to be hanging and dmesg shows


[ 1680.563508] INFO: task systemd-udevd:1853 blocked for more than 120 seconds.
[ 1680.563518] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[ 1680.563524] systemd-udevd D 0000000000000246 0 1853 127 0x00000004
[ 1680.563535] ffff88004bb8db10 0000000000000086 0000000000014340 ffff88004bb8dfd8
[ 1680.563545] ffff88004bb8dfd8 0000000000014340 ffff88012232b2a0 7fffffffffffffff
[ 1680.563552] ffff88004bb8db18 ffff88004bb8db10 ffff88012232b2a0 ffff88004bb8dad0
[ 1680.563559] Call Trace:
[ 1680.563578] [] ? wait_for_common+0x136/0x180
[ 1680.563588] [] ? wake_up_process+0x40/0x40
[ 1680.563595] [] ? wait_for_completion+0x1d/0x20
[ 1680.563603] [] schedule+0x29/0x70
[ 1680.563610] [] schedule_preempt_disabled+0x23/0x30
[ 1680.563617] [] __mutex_lock_slowpath+0x168/0x3b0
[ 1680.563656] [] mutex_lock+0x12/0x30
[ 1680.563664] [] __blkdev_get+0x6b/0x4e0
[ 1680.563671] [] blkdev_get+0x1c5/0x330
[ 1680.563677] [] blkdev_open+0x5b/0x80
[ 1680.563685] [] do_dentry_open+0x190/0x2b0
[ 1680.563693] [] ? __inode_permission+0x41/0xb0
[ 1680.563700] [] ? blkdev_get_by_dev+0x50/0x50
[ 1680.563707] [] finish_open+0x31/0x40
[ 1680.563714] [] do_last+0x2fa/0xf10
[ 1680.563721] [] path_openat+0xb0/0x4f0
[ 1680.563730] [] ? handle_mm_fault+0x2bd/0x650
[ 1680.563739] [] do_filp_open+0x38/0x80
[ 1680.563748] [] ? __alloc_fd+0xa7/0x130
[ 1680.563755] [] do_sys_open+0xe9/0x1c0
[ 1680.563762] [] SyS_open+0x1e/0x20
[ 1680.563771] [] system_call_fastpath+0x1a/0x1f

However, dd unfroze and appears to have completed normally.
[root@hplaptop raspberry_pi]# dd of=/dev/sdb if=archlinux-hf-2013-07-22.img bs=1M
1870+0 records gelezen
1870+0 records geschreven
1960837120 bytes (2,0 GB) gekopieerd, 367,65 s, 5,3 MB/s
1870+0 records gelezen
1870+0 records geschreven
1960837120 bytes (2,0 GB) gekopieerd, 612,42 s, 3,2 MB/s

Please note the multiple output due running

[root@hplaptop 1000]# while true; do kill -USR1 `pidof dd`; sleep 1; done

in another terminal window.

Anyways, I’m will obtain a new laptop soon. But that doesn’t mean this one has my permission to fall apart now. Well… it has some overheating issues, but I believe a little dusting will solve that. I just don’t feel like opening up this laptop before I have a working spare.

I mean… I have been writing about SD card problems in the past. I believe they’ve appeared especially when my laptop was running hot. But since I’m running it at 800 MHz, heat should not be an issue. However…. the problems with the USB card reader, I don’t know.

A known XSS attack is using echo $_SERVER[‘PHP_SELF’] in forms. More about this problem on stack overflow. Anyhow, recently I have been working on a project, where I was to extend existing PHP code, and I noticed this vulnerability to be present in the code. As this is a case of “replace string in all files”, this can be solved with a single command.

However, it sounded much simpler then it was. I must admit I have little experience with regular expressions, or the differences between the regular expressions in perl and sed, as the following expression worked in sed but not in perl. Another problem was escaping, especially in my previous failed attempt that was using -exec as find parameter.(As recommended here) That would need double escaping and such. Way too messy, therefore, xargs looks much cleaner. Anyhow, the following code is working:


$ find directory -name "*.php" -print | xargs sed -i  "s/<?php echo \$_SERVER\['PHP_SELF'\]; ?>/<?php echo htmlspecialchars\(\$_SERVER\['PHP_SELF'\], ENT_QUOTES, 'utf-8'); ?>/g;"

I have been complaining about file system corruption on the SD card of my Raspberry Pi’s before. A suggested cause for this problem was a faultly power supply, delivering a too low voltage. Thinking about it, a faulty power supply might also be at the root of the stability issues I’ve always experienced with my BeagleBoard.


Jul 20 00:20:42 rpi kernel: [45414.541554] EXT4-fs error (device mmcblk0p5): ext4_ext_check_inode:462: inode #36100: comm pacman: bad header/extent: invalid eh_entries - magic f30a, entries 513, max 4(4), depth 0(0)

IMG_1287Anyways, I’ve decided to try to power the Raspberry Pi with a fat power supply. A 5 Volt 6 Ampère power supply should not suffer from any voltage drops by the load of a Raspberry Pi, BeagleBoard or CubieBoard for that matter.

IMG_1289Apart from hooking up just an ARM board, there are more reasons for purchasing this power supply. Having a full extension socket with just power adapters that all output 5 Volts is just insane. It would be far more efficient to just have one supply to power all my devices, such as a network switch and USB hub. It could also be used to charge a phone. Think about it, a Raspberry Pi power supply is just a phone charger with Micro USB connector anyways.

Since this power supply just outputs it’s 5 Volts on a terminal block I will of course have to fix some connectivity:

IMG_1256IMG_1261IMG_1270IMG_1254IMG_1271IMG_1262

Since I am using regular female USB connectors, the part where I solder the connector itself to the PCB does not fit in my holes PCB, and I have to fold it away. The actual USB pins are soldered to the PCB. The middle pins are the data pins. I’ve short circuited the data pins to indicate being a charging port. (This is according to the USB specs.) I’ve connected some wires to the outer pins, being the plus and minus of the 5 Volt power pins. The idea was to solder some PCB terminal blocks, one to be connected to the power supply, and the others to provide power to devices, such as a network switch or my BeagleBoard, that require 5 Volt but come with some other power connected.

But then I discovered a problem. The distance between the pins of the connector blocks I’ve ordered is not an e-multiple. 1 e is 2,54 mm, a unit commonly used in electronics. It’s derived from American units (as 1 American inch is 2,54 cm) It is the distance between the holes on an PCB holes board. Components usually have a multiple of this. But not my connectors. So… a problem. Causing my little project to catch dust for several weeks.

IMG_1288But thanks to Dean I’ve got some connectors that do fit by holes PCB, and I’ve continued my project. I’ve only wired two positions from my connector block, just hooking up the power supply. I’ve connected my Raspberry Pi, and a voltage meter to it now. This is just a prototype, far from the ideal situation I am aiming for. I want to built in some protection. Thinking about some over-voltage protection. I am using some cheap-ass Chinese power supply after all. Better safe then sorry, right? Same goes for over-current protection. When hooking all kinds of devices up, it might be wise. (P.S. I also have a 5 Volts 20 Ampère version…. a current like that could easily start a fire)

Anyhow, I got some 1 Ampère polyfuses. I suppose I could just put two of them in parallel to obtain a 2A polyfuse, right?

What’s going on here? I cannot SSH to my raspberry pi. SSH claims it cannot resolve the hostname, however, when I use host, it resolves the hostname just fine.

[andre@hplaptop ~]$ ssh ehv.blaaschaap.be
ssh: Could not resolve hostname ehv.blaaschaap.be: Name or service not known
[andre@hplaptop ~]$ host ehv.blaatschaap.be
ehv.blaatschaap.be has address 83.160.145.152
ehv.blaatschaap.be has IPv6 address 2001:980:55e0:1:ba27:ebff:fe89:f248

I have mentioned I am going to do this, and here it is: My new blog

http://blog.blaatschaap.be

This blog will be about various, mostly philosophical, topics. I have been planning to do this for several years. I have announced this before but didn’t post anything but an announcement. Well… here it is, my long overdue blog. Now, keep kicking my ass so I write stuff in there, okay?

Cheers!

Hallo mensjes!

Dit keer schrijf ik weer eens in het Nederlands. Ik weet het, ik heb lang niks geschreven hier, en ik heb de klachten over dit feit in goede staat ontvangen, maar heb toch op me laten wachten. Want ja, waar had ik over moeten schrijven. Dus, hoe staan de zaken ervoor. Tsja, ik heb de laatste tijd alleen maar technische blaat geproduceerd op dit blog, en dan sta je voor de vraag, of je het een puur technisch blog moet houden of er ook andere dingen op kunt bespreken. Maar ja, als je terug gaat in de tijd vind je die zat in dit blog, dus vooruit, we gaan het gewoon doen. Met behulp van categorieën houden we Nederlands en Engels uit elkaar, en met tags de onderwerpen. Dus geen probleem.

Het academisch jaar is alweer twee weken oud, het weer is herfstachtig, en de zomer lijkt een lang vervlogen herinnering. Ondertussen is afgelopen dinsdag ook nog eens mijn verstandskies rechtsonder getrokken. Het laatste beetje verstand, rechtsonder, wordt a.s. dinsdag getrokken, en zodoende moet ik zonder verstand mijn studie afmaken. Nu is er nog één homologatievak dat ik gehaald móét hebben voordat ik mág afstuderen. Dit vak heet “Discrete Structuren”. Als je een indruk van dit vak wil hebben, kun je het dictaat op de website van de docent downloaden.

De manier waarop dit vak gegeven wordt is veranderd, en nu heb ik volgende week een tussentijdse toets over het eerste hoofdstuk en een deel van hoofdstuk twee. Dat is dus woensdagmiddag, het 7e uur. Nou als de dinsdag ervoor mijn laatste beetje verstand getrokken wordt…

En verder… ik roep al jaren dat ik eens wat meuk moet gaan schrijven en dan moet ik het ook een keer doen. Ik was van plan hier een aparte blog voor op te zetten. Maar…. keuzes….keuzes… Nederlands of Engels…. of beiden, zoals iemand suggereerde toen ik hem die vraag voorlegde. Ik had ooit als eens een blog aangemaakt, maar had er verder niks in geschreven. De ondertitel was “Over wetenschap, filosofie en spiritualiteit”. Tsja… als dat je onderwerp is, waar begin je dan met schrijven? Geef me een schop onder mijn kont als ik weer eens zit te niksen zodat ik eindelijk eens begin. Maar goed….

Designing a CMS

I have decided to start building my own CMS. This is due the fact a friend wishes a custom website for which the common CMS systems, such as WordPress, Joomla and Drupal are limitations. Limitations with respect to theming is the problem here. As my friend also wishes to be able to change the content in an easy way, a static page isn’t really an option. Therefore, I have decided to design something new.

My incidence, the computer magazine I’m subscribed to, PC-Active, is also doing articles on building your own CMS. I guess I can have a look at their articles for inspiration. But also at my previous websites. Well… at the moment I am considering some design decisions.

Oké, here are some thoughts:

The idea is to have one “background” image, with on certain locations in the image room for a menu item. So, this would lead to a system where I select the background image, and select locations for a clickable area.
The menu engine: The number of menu locations will have to be made available to a place where the menu can be configured. And finally, the content itself.

Also, some standard stuff as user authentication, etc.  But again, the idea is to make this modular…. seeing how clumsy my attempts are to integrate OAuth authentication with WordPress, which is nothing more then a dirty hack. So… the design should be modular… yet… how?

So far, I have been thinking about the following modules “localauth” for authentication with username and password,  “page” for content, and “freeform” as freeformed theming render engine. Yet, how should they interact? They should be designed in such a way I can, for example, switch the engine without having to change anything else.

As I have mentioned in my previous post, I am working on creating an “universal” OAuth plugin for WordPress.
So far, I have been trying with Facebook, Twitter and Google. I have made the following observations:

FaceBook doesn’t login when the scope is not set, but allows this to be an empty string. However, Google complains about a missing parameter when this is not set. When this is set to an incorrect parameter, such as “email” (which is correct for Facebook btw), the login dialog appears, asking me to grant permissions to my application. However, the application does not receive an access token. I do receive an access token when I use ‘https://www.googleapis.com/auth/userinfo.email’ as my scope.

Facebook has something like a default scope when I don’t request anything. Therefore, a scope is not required there. It seems, I must request some scope for Google. So, it seems, I should store a default scope to my plugin as well.

The PHP OAuth implementation I am using to generate my WordPress plugin has some services pre-defined. So, I can just tell it to connect to Facebook, Twitter, Google, Tumblr, etc. etc. So, if some scope is required, I might add it as default in the OAuth implementation, or add it as a predefined interface element.

Recently, I’ve been looking at OAuth again. When, in the past, I was checking our Drupal, I had this general OAuth plugin. Just enter the protocol version, urls, client id and secret, and you could use any OAuth provider.

I have been looking for something simular for WordPress, but it doesn’t appear to exist. There exist some plugins specific to a website,
There are plugins line Gigyas and Janrain, which require you to sign up at their site. I don’t trust those kind of services, introducing another party in the login process, which, if compromised, could harm both the user and the website. Depending on a third party to authenticate your users is one thing, but letting a fourth party nagotiate between you and the third party is just asking for trouble if you ask me.

Last time I looked at OAuth, it seemed to me Facebook was the only service using OAuth 2.0. Nowadays, a higher number of services is using the 2.0 version of the protocol. Even Microsoft has adapted to this protocol, depricating it’s proprietary protocols it used when it was still called a Passport account. I know it was a long time ago when it was called this, but still, since when does Microsoft actually use standards (without raping them)?

Anyways… since there doesn’t appear to exist an universal OAuth solution for WordPress, I intent to make such a plugin. I think I’ll base it upon the oauth php library by Manuel Lemos. This library implements OAuth 1.0, 1.0a and 2.0. (For 2.0 some sites might use earlier drafts, not sure if this becomes problematic.) The source code is released under the 3 clause BSD license, so it could be used without a problem. I intend to create WordPress bindings for this library. So, I’ve been looking at the WordPress plugin API as well.

Well… I’m just getting some ideas ;)

P.S. When you think about using OAuth with Twitter, back then, and right now, I’m noticing the problem with the callback URL. You have to specify the callback URL at the application settings at their site.