<?xml version="1.0"?>
<rss version="2.0">

<channel>
	<title>Planet Redpill Linpro</title>
	<link>http://planet.redpill-linpro.com/</link>
	<language>en</language>
	<description>Planet Redpill Linpro - http://planet.redpill-linpro.com/</description>

<item>
	<title>Kacper Wysocki: pixie dust</title>
	<guid>http://kacper.blog.redpill-linpro.com/archives/420</guid>
	<link>http://kacper.blog.redpill-linpro.com/archives/420</link>
	<description>&lt;p&gt;we&amp;#8217;ve booted backtrack off usb before, now that&amp;#8217;s kinda&lt;br /&gt;
boring and installing backtrack onto the usb with unetbootin&lt;br /&gt;
is painfully slow and not the same as bootin strait off the&lt;br /&gt;
usb which is what we want in this case; not an install&lt;br /&gt;
but a fresh copy every boot&lt;/p&gt;
&lt;p&gt;there is someone disagreeing in the back of the room, now&lt;br /&gt;
wouldn&amp;#8217;t this be a lot more complicated? No sir. on the contrary&lt;br /&gt;
booting fresh every time makes work a lot simpler; you gain a&lt;br /&gt;
direct relationship to what you store where, and where you&lt;br /&gt;
access your data from&lt;/p&gt;
&lt;p&gt;but there is another one in the front;you sir, you feel that&lt;br /&gt;
one would have to sacrifice many of the comforts such as all&lt;br /&gt;
any tools of the trade at hand and permanent local storage -&lt;br /&gt;
but at best this is a lazy roadblock to salvation; by booting&lt;br /&gt;
off of local storage we have local storage at hand in a more&lt;br /&gt;
practical format, be that even a microscopic carrier can be&lt;br /&gt;
removed and replaced with sufficient storage for everything&lt;br /&gt;
and then some&lt;/p&gt;
&lt;p&gt;the medium can be embedded, destroyed or ingested, so&lt;br /&gt;
the impermiableness of accidentally recorded data and the&lt;br /&gt;
robustness, accessability and portability of removable storage&lt;br /&gt;
comes very much in hand upon situations that either require&lt;br /&gt;
inconspiciousness, anonymity, covertness, plausible deniability&lt;br /&gt;
or a high degree of reliability in day-to-day computing&lt;/p&gt;
&lt;p&gt;the totalality of the system given to remaining only in memory&lt;br /&gt;
causes it to be independent of other storage for operations, and when&lt;br /&gt;
operations cease from loss of any exterior preconditions, the&lt;br /&gt;
system simply ceases. when preconditions reoccur &amp;#8211; by powering on&lt;br /&gt;
and executing the first block &amp;#8211; the system can be relied upon to&lt;br /&gt;
simply starts afresh, completely unperturbed by any previous history&lt;/p&gt;
&lt;p&gt;should the need arise to patch the system; say some new app or&lt;br /&gt;
capability is called for where there is no time to rebuild,&lt;br /&gt;
a patch should be scripted always when there is certanity that&lt;br /&gt;
the capability will require a repeat performance. It is advised&lt;br /&gt;
to devise a patch which includes all dependencies.&lt;/p&gt;
&lt;p&gt;thus the fresh system becomes more capable and more accessible&lt;br /&gt;
over time, just like an install. patches can then easily be&lt;br /&gt;
rolled into the system should they proove useful to others.&lt;/p&gt;
&lt;p&gt;But how does one do it? Well, it&amp;#8217;s easy but unfortunately&lt;br /&gt;
not as easy as overwriting the boot device; it&amp;#8217;s just not&lt;br /&gt;
practical because partitioning is always an individual consideration&lt;/p&gt;
&lt;li&gt; . there are often other files on the block device&lt;/li&gt;
&lt;li&gt; . choice of filesystem and memory technology has much bearing&lt;/li&gt;
&lt;li&gt; . the block device is larger or smaller than expected&lt;/li&gt;
&lt;p&gt;instead, we allow any bootable partition scheme and any&lt;br /&gt;
filesystem and memory technology, as long as the storage&lt;br /&gt;
requirements of the system are met;&lt;/p&gt;
&lt;p&gt;here&amp;#8217;s to clone how:&lt;/p&gt;
&lt;pre&gt;cp -a boot/ apt/ casper/ gone/ preseed/ syslinux/
syslinux /dev/partition
mbr /dev/device
&lt;/pre&gt;
&lt;p&gt;but that&amp;#8217;s fine, it&amp;#8217;s been done and all, but even the ability to&lt;br /&gt;
boot the system with precisely zilch local storage comes in&lt;br /&gt;
handy, and for that we have pixie dust.&lt;/p&gt;
&lt;p&gt;pixie daemon and tiny ftp should be pointing a path&lt;br /&gt;
exactly matching the dhcp-provided patch.. otherwise&lt;br /&gt;
you will have worries!&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/etc/pxe.conf:&lt;br /&gt;
&lt;/code&gt;
&lt;pre&gt;
interface=eth1
service=X86PC,0,0,local,Local boot
service=X86PC,0,0,pxelinux,PXELinux
tftpdbase=/var/lib/tftpboot
domain=truly.yours
&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;/etc/default/tftpd-hpa:&lt;br /&gt;
&lt;/code&gt;TFTP_DIRECTORY=&amp;#8221;/var/lib/tftpboot/&amp;#8221;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/etc/dnsmasq.conf:&lt;br /&gt;
&lt;/code&gt;
&lt;pre&gt;
dhcp-boot=/var/lib/tftpboot/pxelinux,vulcano,10.10.10.86
&lt;/pre&gt;
&lt;p&gt;&amp;#8220;high speed&amp;#8221; tftp daemons and multicast can be found but it is&lt;br /&gt;
advised to stick to tftpd-hpa and dnsmasq with no esoterics due&lt;br /&gt;
to the sheer amount of variables introduced.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/var/lib/tftpboot/pxelinux.cfg/default:&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;
# not strictly necessary but makes the menu pretty
menu hshift 13
menu width 49
menu margin 8

menu title BackTrackBoot
default vesamenu.c32
display f.txt
timeout 600

label local
menu label Local Harddisk
localboot 0

menu begin bt
menu title BackTrack 5
# ok here comes the real shit
label backtrack5
menu label BackTrack R1
kernel bt5/vmlinuz
append boot=casper netboot=nfs nfsroot=vulcano:/mnt/bt5 initrd=bt5/initrd.gz text splash vga=791 file=/cdrom/preseed/custom.seed --
menu end
&lt;/pre&gt;
&lt;p&gt;you&amp;#8217;ll need to copy to tftpboot/bt5 the &lt;code&gt;initrd.gz&lt;/code&gt; and &lt;code&gt;vmlinuz&lt;/code&gt; from the backtrack ISO &lt;code&gt;/casper&lt;/code&gt; folder (which you can &lt;code&gt;mount -o loop -t iso9660 bt5.iso /mnt/bt5&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;the rest of the files you provide to the bootee over NFS&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/etc/exports:&lt;br /&gt;
&lt;/code&gt;
&lt;pre&gt;
/mnt/bt5 10.10.3.0/24(rw,sync,no_subtree_check) 10.10.10.0/24(rw,sync,no_subtree_check)
mount -t iso9660 -o loop BT5R1-GNOME-32.iso /mnt/bt5
&lt;/pre&gt;
&lt;p&gt;add a http server with kickstart / preseed files for an ever more powerful setup,&lt;br /&gt;
in which case you replace the &lt;code&gt;file=&lt;/code&gt; stanza in the append line with&lt;br /&gt;
&lt;code&gt;url=http://host/path/to/preseed&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
more on preseeds&amp;#8230; maybe later.&lt;/p&gt;
&lt;p&gt;Now restart all dependent services:&lt;/p&gt;
&lt;pre&gt;
/etc/init.d/nfs-kernel-server restart
/etc/init.d/tftpd-hpa restart
/etc/init.d/apache2 restart
/etc/init.d/pxe restart
&lt;/pre&gt;
&lt;p&gt;debugging this setup usually requires tracing the process that is failing, so:&lt;br /&gt;
- dhcp options tracing (dnsmasq verbose and &lt;code&gt;tcpdump&lt;/code&gt; / wireshark)&lt;br /&gt;
- verbose pxe&lt;br /&gt;
- verbose foreground tftpd-hpa : &lt;code&gt;in.tftpd -v -v -L /var/lib/tftpboot&lt;/code&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;&lt;/p&gt;</description>
	<pubDate>Thu, 02 Feb 2012 00:20:13 +0000</pubDate>
</item>
<item>
	<title>Trygve Vea: Presentation: Writing modules for nginx</title>
	<guid>http://trygvevea.com/?p=514</guid>
	<link>http://trygvevea.com/2012/02/01/presentation-writing-modules-for-nginx/</link>
	<description>&lt;p&gt;I held a presentation at Redpill Linpros &amp;#8220;C / C++ / Embedded&amp;#8221; Competence Group-meeting yesterday.&lt;/p&gt;
&lt;p&gt;It was about writing modules for nginx.  It contains a lot of source code.  I believe it&amp;#8217;s an OK primer.&lt;/p&gt;
&lt;div id=&quot;__ss_11363830&quot;&gt; &lt;strong&gt;&lt;a href=&quot;http://www.slideshare.net/trygvevea/extending-functionality-in-nginx-with-modules&quot; title=&quot;Extending functionality in nginx, with modules!&quot; target=&quot;_blank&quot;&gt;Extending functionality in nginx, with modules!&lt;/a&gt;&lt;/strong&gt; 
&lt;div&gt; View more &lt;a href=&quot;http://www.slideshare.net/&quot; target=&quot;_blank&quot;&gt;presentations&lt;/a&gt; from &lt;a href=&quot;http://www.slideshare.net/trygvevea&quot; target=&quot;_blank&quot;&gt;Trygve Vea&lt;/a&gt; &lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The example code can be found on github.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/kvisle/nginx_module_samples&quot;&gt;https://github.com/kvisle/nginx_module_samples&lt;/a&gt;&lt;/p&gt;</description>
	<pubDate>Wed, 01 Feb 2012 08:55:09 +0000</pubDate>
</item>
<item>
	<title>Magnus Hagander: Finding gaps in partitioned sequences</title>
	<guid>http://blog.hagander.net/archives/203-guid.html</guid>
	<link>http://blog.hagander.net/archives/203-Finding-gaps-in-partitioned-sequences.html</link>
	<description>&lt;div&gt;
                &lt;p&gt;There are an almost unlimited number of articles on the web about how to find gaps in sequences in SQL. And it doesn't have to be very hard. Doing it in a &quot;partitioned sequence&quot; makes it a bit harder, but still not very hard. But when I turned to a window aggregate to do that, I was immediately told &quot;hey, that's a good example of a window aggregate to solve your daily chores, you should blog about that&quot;. So here we go - yet another example of finding a gap in a sequence using SQL.&lt;/p&gt;

&lt;p&gt;I have a database that is very simply structured - it's got a primary key made out of &lt;i&gt;(groupid, year, month, seq)&lt;/i&gt;, all integers. On top of that it has a couple of largish text fields and an fti field for full text search. (Initiated people will know right away which database this is). The sequence in the seq column resets to zero for each combination of &lt;i&gt;(groupid, year, month)&lt;/i&gt;. And I wanted to find out where there were gaps in it, and how big they were, to debug the tool that wrote the data into the database. This is really easy with a window aggregate:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;div class=&quot;geshi&quot;&gt;&lt;br /&gt;&lt;span&gt;SELECT&lt;/span&gt; * &lt;span&gt;FROM&lt;/span&gt; &lt;span&gt;(&lt;/span&gt;&lt;br /&gt;   &lt;span&gt;SELECT&lt;/span&gt;&lt;br /&gt;      gropid,&lt;br /&gt;      year,&lt;br /&gt;      month,&lt;br /&gt;      seq, &lt;br /&gt;      seq-lag&lt;span&gt;(&lt;/span&gt;seq,&lt;span&gt;1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt; OVER &lt;span&gt;(&lt;/span&gt;PARTITION &lt;span&gt;BY&lt;/span&gt; groupid, year, month &lt;span&gt;ORDER&lt;/span&gt; &lt;span&gt;BY&lt;/span&gt; seq&lt;span&gt;)&lt;/span&gt; &lt;span&gt;AS&lt;/span&gt; gap &lt;span&gt;FROM&lt;/span&gt; mytable&lt;br /&gt;&lt;span&gt;)&lt;/span&gt; &lt;span&gt;AS&lt;/span&gt; t&lt;br /&gt;&lt;span&gt;WHERE&lt;/span&gt; &lt;span&gt;NOT&lt;/span&gt; &lt;span&gt;(&lt;/span&gt;t.gap=&lt;span&gt;1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt;&lt;br /&gt;&lt;span&gt;ORDER&lt;/span&gt; &lt;span&gt;BY&lt;/span&gt; groupid, year, month, seq&lt;br /&gt; &lt;/div&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;One advantage to using a window aggregate for this is that we actually get the whole row back, and not just the primary key - so it's easy enough to include all the data you need to figure something out.&lt;/p&gt;

&lt;p&gt;What about performance? I don't really have a big database to test this on, so I can't say for sure. It's going to be a sequential scan, since I look at the &lt;i&gt;whole&lt;/i&gt; table,and not just parts of it. It takes about 4 seconds to run over a table of about a million rows, 2.7Gb, on a modest VM with no actual I/O capacity to speak of and a very limited amount of memory, returning about 100 rows. It's certainly by far fast enough for me in this case.&lt;/p&gt;

&lt;p&gt;And as a bonus, it found me two bugs in the loading script and at least one bug in somebody elses code that I'm now waiting on to get fixed...&lt;/p&gt;

 
            &lt;/div&gt;</description>
	<pubDate>Fri, 27 Jan 2012 16:53:52 +0000</pubDate>
</item>
<item>
	<title>Trygve Vea: New Munin-plugin for HAProxy</title>
	<guid>http://trygvevea.com/?p=499</guid>
	<link>http://trygvevea.com/2012/01/23/new-munin-plugin-for-haproxy/</link>
	<description>&lt;p&gt;&lt;a href=&quot;http://munin-monitoring.org/browser/trunk/plugins/node.d/haproxy_ng.in&quot;&gt;I committed a new Munin-plugin for HAProxy&lt;/a&gt;.  It&amp;#8217;s a multigraph plugin, it discovers all the configured frontends and backends automatically &amp;#8211; all you need to provide is the username/password for the haproxy status page.&lt;/p&gt;
&lt;p&gt;It produces 8 graphs, + subgraphs for some of the backends, where it presents the same graphs, but with server-specific metrics.&lt;/p&gt;
&lt;p&gt;Some of the root-graphs:&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPActive-day.png&quot;&gt;&lt;img src=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPActive-day.png&quot; alt=&quot;&quot; title=&quot;HAPActive-day&quot; width=&quot;497&quot; height=&quot;311&quot; class=&quot;alignleft size-full wp-image-507&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPUptime-day.png&quot;&gt;&lt;img src=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPUptime-day.png&quot; alt=&quot;&quot; title=&quot;HAPUptime-day&quot; width=&quot;497&quot; height=&quot;311&quot; class=&quot;alignleft size-full wp-image-506&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPSessionsBack-day.png&quot;&gt;&lt;img src=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPSessionsBack-day.png&quot; alt=&quot;&quot; title=&quot;HAPSessionsBack-day&quot; width=&quot;497&quot; height=&quot;311&quot; class=&quot;alignleft size-full wp-image-505&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPErrorsBack-day.png&quot;&gt;&lt;img src=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPErrorsBack-day.png&quot; alt=&quot;&quot; title=&quot;HAPErrorsBack-day&quot; width=&quot;497&quot; height=&quot;311&quot; class=&quot;alignleft size-full wp-image-504&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPErrorsFront-day.png&quot;&gt;&lt;img src=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPErrorsFront-day.png&quot; alt=&quot;&quot; title=&quot;HAPErrorsFront-day&quot; width=&quot;497&quot; height=&quot;275&quot; class=&quot;alignleft size-full wp-image-503&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPBandwidthBack-day.png&quot;&gt;&lt;img src=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPBandwidthBack-day.png&quot; alt=&quot;&quot; title=&quot;HAPBandwidthBack-day&quot; width=&quot;497&quot; height=&quot;359&quot; class=&quot;alignleft size-full wp-image-502&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPBandwidthFront-day.png&quot;&gt;&lt;img src=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPBandwidthFront-day.png&quot; alt=&quot;&quot; title=&quot;HAPBandwidthFront-day&quot; width=&quot;497&quot; height=&quot;287&quot; class=&quot;alignleft size-full wp-image-501&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPSessionsFront-day.png&quot;&gt;&lt;img src=&quot;http://trygvevea.com/wp-content/uploads/2012/01/HAPSessionsFront-day.png&quot; alt=&quot;&quot; title=&quot;HAPSessionsFront-day&quot; width=&quot;497&quot; height=&quot;275&quot; class=&quot;alignleft size-full wp-image-500&quot; /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p&gt;Do you use HAProxy and Munin? &lt;a href=&quot;http://munin-monitoring.org/browser/trunk/plugins/node.d/haproxy_ng.in&quot;&gt;Check it out&lt;/a&gt;! &lt;/p&gt;</description>
	<pubDate>Mon, 23 Jan 2012 06:00:44 +0000</pubDate>
</item>
<item>
	<title>Ingvar Hagelund: Finding what binaries to restart</title>
	<guid>http://ingvar.blog.redpill-linpro.com/2012/01/19/</guid>
	<link>http://ingvar.blog.redpill-linpro.com/2012/01/19/finding-what-binaries-to-restart/</link>
	<description>&lt;p&gt;When I started working with Linux system administration a few years ago, restarting services after a package upgrade was fairly easy. If the package didn&amp;#8217;t restart itself, one could always ask lsof for help:&lt;/p&gt;
&lt;pre&gt;
lsof +L1 | egrep 'bin/|lib/'
&lt;/pre&gt;
&lt;p&gt;Now, on later Linux distributions, the usage of &lt;a href=&quot;http://en.wikipedia.org/wiki/Prelink&quot;&gt;prelink&lt;/a&gt; has changed this, so one usually gets a lot of false positives, and could never trust the result of that good old lsof output.&lt;/p&gt;
&lt;p&gt;Finding running executables is possible using some perl magic (Yes, I&amp;#8217;m pretty sure you perl guys can write this more compressed) along the lines of this, at least on RHEL5:&lt;/p&gt;
&lt;pre&gt;
perl -e ' for $i (glob &quot;/proc/[1-9]*/exe&quot;) { $f=readlink $i; if ( $f=~ /([^&amp;#092;0]+)&amp;#092;0.*deleted/ ) { print &quot;$1\n&quot; }} ' | sort | uniq
&lt;/pre&gt;
&lt;p&gt;But this won&amp;#8217;t help us finding what service to restart after a dependency library was updated. So I finally wrote this script to help me. My boxes are mostly Fedora and RHEL, so it uses the fact that installed binaries on Red Hat based systems have installation time stored in the rpm database (rpm tag %{INSTALLTIME} ). This script abuses rpm heavily, and may use some time to finish on a busy system.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://users.linpro.no/ingvar/check_newlibs&quot;&gt;http://users.linpro.no/ingvar/check_newlibs&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Test run:&lt;/p&gt;
&lt;pre&gt;
[root]# /home/ingvar/check_newlibs
Warning: Needs restart: /sbin/agetty, pids 6067
Warning: Needs restart: /usr/bin/tail, pids 7315
Warning: Needs restart: /usr/bin/vim, pids 19759
Warning: Needs restart: /usr/sbin/sendmail.sendmail, pids 10645 10637
Warning: Needs restart: /usr/sbin/acpid, pids 5259
Warning: Needs restart: /usr/sbin/crond, pids 5567
Warning: Needs restart: /bin/bash, pids 26074 17731 16848 15718 30753 6120 32704
Warning: Needs restart: /sbin/mingetty, pids 6071 6069 6076 6068 6072 6070
Warning: Needs restart: /sbin/portmap, pids 5082
Warning: Needs restart: /usr/sbin/smartd, pids 20948
Warning: Needs restart: /sbin/multipathd, pids 20170
Warning: Needs restart: /usr/sbin/atd, pids 5969
Warning: Needs restart: /usr/sbin/sshd, pids 19863
Warning: Needs restart: /usr/libexec/mysqld, pids 17775
&lt;/pre&gt;</description>
	<pubDate>Thu, 19 Jan 2012 21:39:06 +0000</pubDate>
</item>
<item>
	<title>Edward Bjarte Fjellskål: PassiveDNS 0.2.9</title>
	<guid>http://www.gamelinux.org/?p=519</guid>
	<link>http://www.gamelinux.org/?p=519</link>
	<description>&lt;p&gt;I added some features and changes to PassiveDNS. The most important change is that the output now contains the &lt;strong&gt;TTL&lt;/strong&gt; value, so you &lt;strong&gt;need&lt;/strong&gt; to use the current tools/* (if you use them) as they are also changed to work with this new output format (or update your own tools).&lt;/p&gt;
&lt;p&gt;I also added the ability to specify the DNS record types that you want to log from the command line and I added support for more record types. PassiveDNS now should be able to track:  &lt;strong&gt;A, AAAA, CNAME, DNAME, NAPTR, SOA, PTR, RP, SRV, TXT, MX and NS.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Support for &lt;strong&gt;chroot&lt;/strong&gt; and &lt;strong&gt;dropping privileges&lt;/strong&gt; are also added.&lt;/p&gt;
&lt;p&gt;I also added some features to &lt;strong&gt;tools/pdns2db.pl&lt;/strong&gt; while I was at it:&lt;br /&gt;
&lt;strong&gt;1)&lt;/strong&gt; You can now process a passivedns.log file in &amp;#8220;batch&amp;#8221; mode, exiting when finished.&lt;br /&gt;
&lt;strong&gt;2)&lt;/strong&gt; You can now specify a file with a list of domains or IPs to skip insertion to the DB.&lt;br /&gt;
&lt;strong&gt;3)&lt;/strong&gt; You can now specify a file with a list of PCRE (Perl Compatible Regular Expressions) of &amp;#8220;domains/IPs&amp;#8221; to skip insertion to the DB.&lt;br /&gt;
&lt;strong&gt;4)&lt;/strong&gt; You can now specify a file with a list of domains or IPs to alert on!&lt;br /&gt;
&lt;strong&gt;5)&lt;/strong&gt; You can now specify a file with a list of PCRE of &amp;#8220;domains/IPs&amp;#8221; to alert on!&lt;br /&gt;
&lt;strong&gt;6)&lt;/strong&gt; You can now specify a file with a list of domains to whitelist and not alert on.&lt;br /&gt;
&lt;strong&gt;7)&lt;/strong&gt; You can now specify a file with a list of PCRE of &amp;#8220;domains/IPs&amp;#8221; to whitelist and not alert on.&lt;/p&gt;
&lt;p&gt;The &lt;strong&gt;skiplists&lt;/strong&gt; will be checked first, and if the domain/IP is found/matched there, whitelist and blacklist will be ignored and insertion to DB will be ignored.&lt;/p&gt;
&lt;p&gt;Next the &lt;strong&gt;whitelists&lt;/strong&gt; will be checked, and if a domain/IP is found there or match a PCRE that you have defined it will not be checked by the blacklist.&lt;/p&gt;
&lt;p&gt;Last the &lt;strong&gt;blacklists&lt;/strong&gt; is checked, and if a domain/IP is found there or match a PCRE that you have defined, it will write the PassiveDNS record to the alert file that you specify (Default: /var/log/passivedns-alert.log).&lt;/p&gt;
&lt;p&gt;There are different sources for getting lists of known bad domains. Here is one if you want to test the blacklist functionality: &lt;a href=&quot;http://isc.sans.edu/feeds/suspiciousdomains_High.txt&quot;&gt;http://isc.sans.edu/feeds/suspiciousdomains_High.txt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Im pretty far as what it comes to planed features at this stage. Please try out PassiveDNS and beat the crap out of it &lt;img src=&quot;http://www.gamelinux.org/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:)&quot; class=&quot;wp-smiley&quot; /&gt;  I will probably &amp;#8220;up&amp;#8221; the version to &lt;strong&gt;0.5.0&lt;/strong&gt; soon and from there on, it is just testing and testing and more testing before it will be a &amp;#8220;&lt;strong&gt;one dot O&lt;/strong&gt;&amp;#8221; release.&lt;/p&gt;
&lt;p&gt;If you have any issues with PassiveDNS, please submit them &lt;a href=&quot;https://github.com/gamelinux/passivedns/issues&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;</description>
	<pubDate>Tue, 17 Jan 2012 15:17:07 +0000</pubDate>
</item>
<item>
	<title>Edward Bjarte Fjellskål: PRADS, and how it compares to pads and p0fv2 and p0fv3</title>
	<guid>http://www.gamelinux.org/?p=485</guid>
	<link>http://www.gamelinux.org/?p=485</link>
	<description>&lt;p&gt;The question was brought up to me late last night on IRC, as &lt;a href=&quot;http://lcamtuf.coredump.cx/p0f3/&quot;&gt;p0fv3&lt;/a&gt; RC was recently &lt;a href=&quot;http://www.securityfocus.com/archive/1/521169&quot;&gt;announced&lt;/a&gt;.  This is a short answer to that question:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;&amp;#8220;People that find the PRADS page and already know p0f or pads may be interested in a comparison or essentially arguments why you would use one over the other.&amp;#8221;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;First off, its exiting to see Michal Zalewski back with p0fv3 &lt;img src=&quot;http://www.gamelinux.org/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:)&quot; class=&quot;wp-smiley&quot; /&gt;  I quickly read through his code yesterday and tested it out, and its rather interesting how he solves things. The fingerprint database at the moment is limited, but expect that to grow in the near future. I also love his non formal output in his applications &lt;img src=&quot;http://www.gamelinux.org/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:)&quot; class=&quot;wp-smiley&quot; /&gt; &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;[PRADS vs PADS]&lt;/strong&gt;&lt;br /&gt;
So, back to the questions. First off, pads &amp;#8220;Passive Asset Detection System&amp;#8221; uses regexp syntax to look for common bytes in payload to identify server application. So if the server says &amp;#8221; Server: Apache/2.2.3 (Linux/SUSE)&amp;#8221; that is collected as what service is running on the server port where this was detected. The &amp;#8220;rules&amp;#8221; can be written more specifically for each server software, but are rather general and small today. Some pads &amp;#8220;rules&amp;#8221; look for ASCII strings, and some for different bytes in hex etc. to identify stuff like SSL/TLS. Pads is no longer actively developed by the original author, but I do maintain a &lt;a href=&quot;https://github.com/gamelinux/pads&quot;&gt;fork of the last version&lt;/a&gt; with enhancements added.&lt;/p&gt;
&lt;p&gt;PRADS extended the way pads does asset detection. We have build in IPv6 support in PRADS, so it also detects asset listening on IPv6 addresses. We also have build in connection tracking, so that we can cut off detection in a stream after an amount of packets or bytes seen from the client or server. This to drop trying to look for server/client assets in connections that transfers big files or are encrypted etc. Most &amp;#8220;banners/identifiers&amp;#8221; are in the first  packet etc. so limiting for how many packets in a stream to do detection on helps on performance etc.&lt;/p&gt;
&lt;p&gt;To extend pads a bit, we also added detection for client applications using the same method as for detecting server applications.&lt;/p&gt;
&lt;p&gt;My future thoughts on enhancing the pads/PRADS asset rules are to make them more like the Snort/Suricata rule language and use fast pattern matching before invoking the pcre method etc. Pads does no OS fingerprinting per say btw.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;[PRADS vs p0f]&lt;/strong&gt;&lt;br /&gt;
PRADS tcp fingerprinting was based on the p0fv2 way as p0f had the fingerprint DB and we thought that reusing the fingerprints would make it easier for people to migrate if they wanted, instead of recollecting and adding fingerprints. PRADS also added some touches of its own (for IPv6 etc) and the way we match the fingerprints (and fuzzing). We have thought about extending the fingerprints and re-write them, but thats in the future. Right now they are doing a good job. We also added all the p0fv2 ways of fingerprinting to the whole tcp session, from the syn to the rst/fin. p0fv2 could just use one method at a time, depending on how you started p0fv2. PRADS outputs all the info it gathers, and leaves the final correlation to the end user/program etc. A good example on that is &lt;strong&gt;prads-asset-report&lt;/strong&gt; and &lt;strong&gt;prads2snort&lt;/strong&gt;, which ads wight to each type of fingerprints, ranging the syn and syn+ack higher than stray-ack, rst and fin etc. You can also base the final guess on client or server applications to, say if the User-Agent contains: &amp;#8220;Linux&amp;#8221; or &amp;#8220;Windows NT 6.1&amp;#8243; or &amp;#8220;Macintosh; Intel Mac OS X 10.7&amp;#8243; etc.&lt;br /&gt;
or if the Server string of the web server is: &amp;#8220;Microsoft-IIS 6.0&amp;#8243; or &amp;#8220;Apache 2.2.15 (FreeBSD)&amp;#8221; or &amp;#8220;Apache 2.2.3 (Red Hat)&amp;#8221; etc.&lt;/p&gt;
&lt;p&gt;The p0fv3 tcp fingerprints are new in the way they are written. A new fingerprint file format, that makes it easy to add different types of fingerprints into one and same file (TCP/HTTP/SMTP etc). The most significant enhancement in the TCP fingerprints that I see is the MSS and MTU multiplier field. p0fv3 also detects new quirks not measured in p0fv2. The rules are now also more human readable, Example:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
# RULE&lt;br /&gt;
label = s:unix:Linux:2.6.x&lt;br /&gt;
sig   = *:64:0:*:mss*4,6:mss,sok,ts,nop,ws:df,id+:0&lt;/p&gt;
&lt;p&gt;# Will match:&lt;br /&gt;
.-[ X.X.X.X/58435 -&gt; Y.Y.Y.Y/22 (syn) ]-&lt;br /&gt;
|&lt;br /&gt;
| client   = X.X.X.X/58435&lt;br /&gt;
| os       = Linux 2.6.x&lt;br /&gt;
| dist     = 9&lt;br /&gt;
| params   = none&lt;br /&gt;
| raw_sig  = 4:55+9:0:1460:mss*4,6:mss,sok,ts,nop,ws:df,id+:0&lt;br /&gt;
|&lt;br /&gt;
`&amp;#8212;-
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The way the tcp fingerprints are matched are also changed a bit, and I believe Michal Zalewski has done this for good reasons and that it will enhance the detection.&lt;/p&gt;
&lt;p&gt;Beside the new tcp fingerprint changes, p0fv3 also has application layer detection added. I looked at the HTTP stuff, and p0fv3 matches also on the HTTP header order and dont blindly trust the User-Agent, as we do in PRADS. We have thought about extending the &amp;#8220;rule/signature&amp;#8221; in PRADS to be more Snort/Suricata like, so you can have more content matches etc, but more accuracy can be achieved today using the pcre language, to verify header order etc, before blindly trusting the UA, but pcre is way too expensive used alone I think, so organizing the signatures/rules better internally and having something like a fast_pattern matcher would help alot. Quick pcre example for a User-Agent with specific HTTP header order:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
# Detects Firefox/3.6.X with HTTP header order to add confidence in the match.&lt;br /&gt;
# PRADS rule:&lt;br /&gt;
http,v/MFF 3.6.X/$1//,\r\nHost: .*\r\nUser-Agent: Mozilla\/5\.0 (.*Firefox\/3\.6\..*)\r\nAccept: .*\r\nAccept-Language: .*\r\nAccept-Encoding: .*\r\nAccept-Charset:
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Running it in PRADS on an old pcap gives me:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
# Client IPs deducted just to be kind&lt;br /&gt;
[client:MFF 3.6.X (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.04 (lucid) Firefox/3.:80:6],[distance:8]&lt;br /&gt;
[client:MFF 3.6.X (X11; U; Linux x86_64; en-GB; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.10 (maverick) Firefox:80:6],[distance:11]&lt;br /&gt;
[client:MFF 3.6.X (Windows; U; Windows NT 5.1; de; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.:80:6],[distance:10]&lt;br /&gt;
[client:MFF 3.6.X (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 (.NET CLR :80:6],[distance:14]&lt;br /&gt;
[client:MFF 3.6.X (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Linux Mint/10 (Julia) Firefox/3:80:6],[distance:15]&lt;br /&gt;
[client:MFF 3.6.X (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.10 (maverick) Firefox:80:6],[distance:9]&lt;br /&gt;
[client:MFF 3.6.X (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12:80:6],[distance:6]&lt;br /&gt;
[client:MFF 3.6.X (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.6) Gecko/20100625 Firefox/3.6.6:80:6],[distance:12]&lt;br /&gt;
[client:MFF 3.6.X (Windows; U; Windows NT 6.1; es-ES; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12:80:6],[distance:14]&lt;br /&gt;
[client:MFF 3.6.X (X11; U; Linux x86_64; en-US; rv:1.9.2.10) Gecko/20101005 Fedora/3.6.10-1.fc14 Firefox/3.:80:6],[distance:8]&lt;br /&gt;
[client:MFF 3.6.X (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101027 Ubuntu/10.04 (lucid) Firefox/3.:80:6],[distance:12]
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Not the whole User-Agent is grabbed, and we need to extend that in the future. But the pcre language makes it possible to match on as much content as you want, to have the confidence you need in your signatures/rules for detecting assets. PRADS looks for client and server applications on all ports and both UDP and TCP and for IPv4 and IPv6.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;[PRADS vs The World]&lt;/strong&gt;&lt;br /&gt;
Right now we are working on adding the DHCP OS fingerprinting and ICMP OS fingerprinting. DHCP is pushed to the git master on github but is not fully integrated into the PRADS core yet, but printing and matching is working, so you can help add fingerprints if you want &lt;img src=&quot;http://www.gamelinux.org/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:)&quot; class=&quot;wp-smiley&quot; /&gt; . The ICMP part is tricky as I want to fingerprint on the protocol layer, and also the payload, so I kind of have to combine the p0f way with the pads way of detecting and matching.&lt;/p&gt;
&lt;p&gt;PRADS has also lots of other stuff, like connection tracking/Flow gathering with output compatible with cxtracker and sancp. I have also been working on my &lt;a href=&quot;https://github.com/gamelinux/passivedns&quot;&gt;passivedns&lt;/a&gt; project, and I tend to port the relevant function over to PRADS, so we can have domain names mapped with assets to.&lt;/p&gt;
&lt;p&gt;p0fv3 has an API so you can talk to it, to fetch relevant info about the IPs it knows about. I see p0fv3 with this functionality aimed at mail and web servers etc, to determine if this is spam or ham stuff coming its way, but you can use it in lots of cool ways.&lt;br /&gt;
I know PRADS is used in much the same way from people I have talked too. An example that Kacper put up can be found on &lt;a href=&quot;http://prads.delta9.pl/&quot;&gt;http://prads.delta9.pl/&lt;/a&gt;. On the road map for upcoming PRADS releases, we have access to assets via shared memory. That will make it easier for extracting info from the running PRADS process that is current. PRADS also ships with &lt;strong&gt;prads2db.pl&lt;/strong&gt; which parses a prads asset log-file and inserts the info to a DB so you can query it for info.&lt;/p&gt;
&lt;p&gt;PRADS philosophy is something like: &amp;#8220;If it can be detect passively, PRADS should probably do it.&amp;#8221;&lt;/p&gt;
&lt;p&gt;So if you are comparing for deciding which application to go for, I would say use them all, and correlate the the knowledge that each tool gives you. You can even add the output from the active fingerprinting tool &lt;a href=&quot;http://nmap.org/&quot;&gt;nmap&lt;/a&gt; into the mix.&lt;/p&gt;
&lt;p&gt;That said, much of my view on PRADS comes from that I use it in my Network Security Monitoring setup and from my wish to &amp;#8220;know as much as possible about my assets&amp;#8221;. If you have any wishes or suggestions, god or bad etc, feel free to contact us.&lt;/p&gt;
&lt;p&gt;E&lt;/p&gt;</description>
	<pubDate>Thu, 12 Jan 2012 10:49:01 +0000</pubDate>
</item>
<item>
	<title>Edward Bjarte Fjellskål: Suricata and some phun with flowints</title>
	<guid>http://www.gamelinux.org/?p=403</guid>
	<link>http://www.gamelinux.org/?p=403</link>
	<description>&lt;p&gt;I have been looking into malware traffic that is hard to make signatures for in a &amp;#8220;regular&amp;#8221; way. I&amp;#8217;m not a malware reverser, so I don&amp;#8217;t dig into a malware to determine byte-testes and jumps etc. in binary protocols. This lead me to use a lot of flowbits at first, for making my sigs, but the performance in &lt;a href=&quot;http://www.snort.org/&quot;&gt;Snort&lt;/a&gt; and &lt;a href=&quot;http://www.openinfosecfoundation.org/index.php/download-suricata&quot;&gt;Suricata&lt;/a&gt; was &amp;#8220;crap&amp;#8221; to say it nice. So I talked to &lt;em&gt;Victor Julien&lt;/em&gt;, lead programmer of Suricata, discussing implementing packet and byte counting in Suricata. I want to count each packet sent by a client and server and the total amount of bytes sent by client and server. Talking back and forth, Victor convinced me that I might be best to go for byte count  for reassembled streams. So I added a &lt;a href=&quot;https://redmine.openinfosecfoundation.org/issues/294&quot;&gt;feature request&lt;/a&gt; to Suricata. I since then updated the feature request to add the packet and byte counters, as I think they will do great use.&lt;/p&gt;
&lt;p&gt;Talking to &lt;em&gt;Matt Jonkman&lt;/em&gt; (&lt;a href=&quot;http://www.emergingthreatspro.com/&quot;&gt;Emerging Threats Pro&lt;/a&gt;), he pointed me to &lt;strong&gt;&lt;em&gt;&lt;a href=&quot;https://redmine.openinfosecfoundation.org/projects/suricata/wiki/Flowint&quot;&gt;flowint&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt; in Suricata to try to solve my packet counting. So in &lt;strong&gt;Suricata 1.1.1&lt;/strong&gt;, you can do something like this to initialize the packet counters:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
# Initialize the packet counter (Suricata 1.1.1 and some older versions)&lt;br /&gt;
#alert ip $HOME_NET any -&gt; $EXTERNAL_NET any (msg:&amp;#8221;Generic Client Established Flow IP Packet Counter set&amp;#8221;; flow:established,from_client; &lt;strong&gt;flowint:client_packet,notset; flowint:client_packet,=,0; &lt;/strong&gt;flowbits:noalert; classtype:not-suspicious; sid:1; rev:1;)&lt;/p&gt;
&lt;p&gt;#alert ip $EXTERNAL_NET any -&gt; $HOME_NET any (msg:&amp;#8221;Generic Server Established Flow IP Packet Counter set&amp;#8221;; flow:established,from_server; &lt;strong&gt;flowint:server_packet,notset; flowint:server_packet,=,0;&lt;/strong&gt; flowbits:noalert; classtype:not-suspicious; sid:2; rev:1;)
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;In &lt;strong&gt;Suricata 1.2dev&lt;/strong&gt; (rev 4c1e417) (I did my test for the blog on this version) and newer, you dont need to initialize the counter, as it will &lt;em&gt;automagical&lt;/em&gt; be initialized to zero, so you don&amp;#8217;t need sid:1 and sid:2:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
## Generic packet counter: (This could be better done internally in Suricata/Snort? and not with rules?)&lt;br /&gt;
alert ip $HOME_NET any -&gt; $EXTERNAL_NET any (msg:&amp;#8221;Generic Client Established Flow IP Packet Counter&amp;#8221;; flow:established,from_client; &lt;strong&gt;flowint:client_packet,+,1;&lt;/strong&gt; flowbits:noalert; classtype:not-suspicious; sid:3; rev:1;)&lt;/p&gt;
&lt;p&gt;alert ip $EXTERNAL_NET any -&gt; $HOME_NET any (msg:&amp;#8221;Generic Server Established Flow IP Packet Counter&amp;#8221;; flow:established,from_server; &lt;strong&gt;flowint:server_packet,+,1;&lt;/strong&gt; flowbits:noalert; classtype:not-suspicious; sid:4; rev:1;)
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;So, what can you do with packet counters?&lt;/p&gt;
&lt;p&gt;First off, lets look at some generic rules I made up to test with, which basically should limit the detections in streams to the first 29 packets from the client:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
# GENERiC GET&lt;br /&gt;
alert http $HOME_NET any -&gt; $EXTERNAL_NET any (msg:&amp;#8221;GENERIC GET (classic)&amp;#8221;; flow:from_client,established; content:&amp;#8221;GET &amp;#8220;; depth:4; content:!&amp;#8221;connection: keep-alive&amp;#8221;; nocase; http_header; classtype:not-suspicious; sid:5; rev:1;)&lt;/p&gt;
&lt;p&gt;alert http $HOME_NET any -&gt; $EXTERNAL_NET any (msg:&amp;#8221;GENERIC GET (&lt;strong&gt;flowint&lt;/strong&gt;)&amp;#8221;; flow:from_client,established; &lt;strong&gt;flowint:client_packet,,30;&lt;/strong&gt; content:&amp;#8221;GET &amp;#8220;; depth:4; content:!&amp;#8221;connection: keep-alive&amp;#8221;; nocase; http_header; classtype:not-suspicious; sid:6; rev:1;)&lt;/p&gt;
&lt;p&gt;# GENERiC UA&lt;br /&gt;
alert http $HOME_NET any -&gt; $EXTERNAL_NET any (msg:&amp;#8221;GENERIC User-Agent (classic)&amp;#8221;; flow:from_client,established; content:&amp;#8221;User-Agent: &amp;#8220;; http_header; content:!&amp;#8221;connection: keep-alive&amp;#8221;; nocase; http_header; classtype:not-suspicious; sid:7; rev:1;)&lt;/p&gt;
&lt;p&gt;alert http $HOME_NET any -&gt; $EXTERNAL_NET any (msg:&amp;#8221;GENERIC User-Agent (&lt;strong&gt;flowint&lt;/strong&gt;)&amp;#8221;; flow:from_client,established; &lt;strong&gt;flowint:client_packet,,30;&lt;/strong&gt; content:&amp;#8221;User-Agent: &amp;#8220;; http_header; content:!&amp;#8221;connection: keep-alive&amp;#8221;; nocase; http_header; classtype:not-suspicious; sid:8; rev:1;)
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Sid 5 and 6 looks for a HTTP GET request that is not a HTTP keep-alive. Sid 7 and 8 is looking for User-Agent in non HTTP keep-alive request. Common for the flowint versions of the rules, are that they are just limited to the first 29 packets in an established flow. So running Suricata against &lt;a href=&quot;http://www.itoc.usma.edu/research/dataset/data/2009-04-20-09-05-46.dmp&quot;&gt;2009-04-20-09-05-46.dmp&lt;/a&gt; etc. shows some interesting results:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
   Num      Rule         Gid      Rev      &lt;strong&gt;Ticks&lt;/strong&gt;        %      &lt;strong&gt;Checks   Matches&lt;/strong&gt;  Max Ticks   &lt;strong&gt;Avg Ticks&lt;/strong&gt;   Avg Match   Avg No Match&lt;br /&gt;
  &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212; &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212; &amp;#8212;&amp;#8212; &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211;&lt;br /&gt;
  1        4            1        1        1695335708   67.74  510720   510720   6412616     3319.50     3319.50     0.00&lt;br /&gt;
  2        3            1        1        581354624    23.23  508970   82175    3602972     1142.22     3061.99     772.59&lt;br /&gt;
  3        7            1        1        135943292    5.43   7900     2352     499972      17208.01    16156.62    17653.74&lt;br /&gt;
  4        &lt;strong&gt;5&lt;/strong&gt;            1        1        &lt;strong&gt;43040648&lt;/strong&gt;     1.72    &lt;strong&gt;3313    2517&lt;/strong&gt;     199052      &lt;strong&gt;12991.44&lt;/strong&gt;    16247.74    2694.82&lt;br /&gt;
  5        8            1        1        29172972     1.17   7900     2352     434592      3692.78     6588.51     2465.18&lt;br /&gt;
  6        &lt;strong&gt;6&lt;/strong&gt;            1        1        &lt;strong&gt;17917112&lt;/strong&gt;     0.72   &lt;strong&gt;3313     2517&lt;/strong&gt;     353684      &lt;strong&gt;5408.12&lt;/strong&gt;     6528.93     1864.06
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Sorry for the formating &lt;img src=&quot;http://www.gamelinux.org/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:)&quot; class=&quot;wp-smiley&quot; /&gt;&lt;br /&gt;
First, if we look at sid 5 and 6, we see that they both where checked 3313 times, and matched 2517 times. If we look at total ticks, sid 5 uses 43040648 ticks and sid 6 (flowint) uses 17917112 ticks. Average ticks for sid 5 is 12991.44 ticks and 5408.12 ticks for sid 6 (flowint).&lt;/p&gt;
&lt;p&gt;Looking at sid 7 and 8, we see that they both where checked 7900 times, and matched 2352 times. If we look at total ticks, sid 7 uses 135943292 ticks and sid 8 (flowint) uses 29172972 ticks. Average ticks for sid 7 is 17208.01 ticks and 3692.78 ticks for sid 8 (flowint).&lt;/p&gt;
&lt;p&gt;A basic conclusion for &lt;em&gt;this&lt;/em&gt; test, is that the rules with the flowint check are faster and will give you the same alerts.&lt;br /&gt;
But if we look at the ticks sid 3 and 4 uses to count the all the packets, they are high in total, but low on average ticks. So they are not expensive for each check, but since they are checked (and possibly incremented) for each packet, the total ticks are relative high. Having this in the core of Suricata and Snort, would probably make them less expensive (hint hint).&lt;/p&gt;
&lt;p&gt;So what more c00l stuff can we do with packet counters?&lt;/p&gt;
&lt;p&gt;Some malware I stumbled upon will give you an example (Mostly used in the &lt;a href=&quot;http://www.techrepublic.com/blog/10things/the-top-10-spam-botnets-new-and-improved/1373&quot;&gt;Gheg Spam bot&lt;/a&gt;, aka Tofsee/Mondera)&lt;br /&gt;
&lt;a href=&quot;http://www.xandora.net/xangui/malware/view/b31e4624cdc45655b468921823e1b72b&quot;&gt;b31e4624cdc45655b468921823e1b72b&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.virustotal.com/file-scan/report.html?id=42bf415e9c76e36efad53fdda4b1fca704d6d0972a0f4800a0a6518f0f8bb52e-1295099162&quot;&gt;3c453e40ff63da3c2a914c29b6c62ee0&lt;/a&gt;&lt;br /&gt;
&lt;a href=&quot;http://www.threatexpert.com/report.aspx?md5=e8034335afb724d8fe043166ba57cd23&quot;&gt;e8034335afb724d8fe043166ba57cd23&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It seems to communicate in a binary way (encrypted), but looking at 5 different pcaps I got, I saw a pattern and my flowint counters came to good use. It seems like the client and server sends packets with a specific payload size in different parts of the communication. I did not see any obvious content to match on, so content matches didn&amp;#8217;t seem trivial, and this is a great way to demonstrate my point: Flowint+packet counters to the rescue! Here is a tcpdump output of traffic on port 443 (not including the port 22050 traffic, which is much longer, but the start is the same), so you can see the packets sizes and in which order they do come in this short sessions:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
reading from file b31e4624cdc45655b468921823e1b72b.pcap, link-type EN10MB (Ethernet)&lt;br /&gt;
03:47:02.571111 IP 192.168.1.10.1031 &gt; 216.246.8.230.443: Flags [S], seq 910650996, win 65535, options [mss 1460,nop,nop,sackOK], length 0&lt;br /&gt;
03:47:02.608784 IP 216.246.8.230.443 &gt; 192.168.1.10.1031: Flags [S.], seq 442582883, ack 910650997, win 5840, options [mss 1380,nop,nop,sackOK], length 0&lt;br /&gt;
03:47:02.608977 IP 192.168.1.10.1031 &gt; 216.246.8.230.443: Flags [.], ack 1, win 65535, length 0&lt;br /&gt;
03:47:02.646959 IP 216.246.8.230.443 &gt; 192.168.1.10.1031: Flags [P.], seq 1:201, ack 1, win 5840, &lt;strong&gt;length 200&lt;/strong&gt;&lt;br /&gt;
03:47:02.647342 IP 192.168.1.10.1031 &gt; 216.246.8.230.443: Flags [P.], seq 1:142, ack 201, win 65335, &lt;strong&gt;length 141&lt;/strong&gt;&lt;br /&gt;
03:47:02.685098 IP 216.246.8.230.443 &gt; 192.168.1.10.1031: Flags [.], ack 142, win 6432, length 0&lt;br /&gt;
03:47:02.718986 IP 216.246.8.230.443 &gt; 192.168.1.10.1031: Flags [P.], seq 201:676, ack 142, win 6432, &lt;strong&gt;length 475&lt;/strong&gt;&lt;br /&gt;
03:47:02.718999 IP 216.246.8.230.443 &gt; 192.168.1.10.1031: Flags [F.], seq 676, ack 142, win 6432, length 0&lt;br /&gt;
03:47:02.719268 IP 192.168.1.10.1031 &gt; 216.246.8.230.443: Flags [.], ack 677, win 64860, length 0&lt;br /&gt;
03:47:02.719584 IP 192.168.1.10.1031 &gt; 216.246.8.230.443: Flags [F.], seq 142, ack 677, win 64860, length 0&lt;br /&gt;
03:47:02.757350 IP 216.246.8.230.443 &gt; 192.168.1.10.1031: Flags [.], ack 143, win 6432, length 0
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;And here is how I sigged it:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
# Backdoor:Win32/Tofsee (aka: Gheg / Mondera)&lt;br /&gt;
alert tcp $EXTERNAL_NET any -&gt; $HOME_NET any (msg:&amp;#8221;Possible Tofsee server Packet 2 (200 Bytes)&amp;#8221;; flow:established,from_server; &lt;strong&gt;flowint:server_packet,=,2; dsize:200; &lt;/strong&gt;flowbits:set,Tofsee_SERVER_200; flowbits:noalert; classtype:trojan-activity; sid:9; rev:1;)&lt;/p&gt;
&lt;p&gt;alert tcp $HOME_NET any -&gt; $EXTERNAL_NET any (msg:&amp;#8221;Possible Tofsee client Packet 3 (141 Bytes)&amp;#8221;; flow:established,from_client; &lt;strong&gt;flowint:client_packet,=,3; dsize:141;&lt;/strong&gt; flowbits:isset,Tofsee_SERVER_200; flowbits:set,Tofsee_CLIENT_141; flowbits:noalert; classtype:trojan-activity; sid:10; rev:1;)&lt;/p&gt;
&lt;p&gt;alert tcp $EXTERNAL_NET any -&gt; $HOME_NET any (msg:&amp;#8221;Possible Tofsee server Packet 4(475 Bytes)&amp;#8221;; flow:established,from_server; &lt;strong&gt;flowint:server_packet,=,4; dsize:475; &lt;/strong&gt;flowbits:isset,Tofsee_CLIENT_141; classtype:trojan-activity; sid:11; rev:1;)
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Sid 9 looks only for the 2. packet in an established flow from the Server (C&amp;#038;C) and the packet has to have payload size/dsize 200. It then sets the flowbit Tofsee_SERVER_200 if this hits and the rule has noalert, because this could easily trigger a false positive just this check. So we got to do some more checks. Sid 10 checks only Client packet 3, it has to have a payload size/dsize of 141 and flowbit Tofsee_SERVER_200 has to be set for this too match. Sid 10 is also no alert, as we still can check some more, to not be spammed by falses. So sid 11 checks if server packet 4 has payload size/dsize 475, and that flowbit Tofsee_CLIENT_141 is set. No we can give an alert, as this would probably be an unique set of conditions. So testing again with out 2009-04-20-09-05-46.dmp test pcap, we get:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
   Num      Rule         Gid      Rev      &lt;strong&gt;Ticks&lt;/strong&gt;        %      Checks   &lt;strong&gt;Matches&lt;/strong&gt;  Max Ticks   &lt;strong&gt;Avg Ticks&lt;/strong&gt;   Avg Match   Avg No Match&lt;br /&gt;
  &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212; &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212; &amp;#8212;&amp;#8212; &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211;&lt;br /&gt;
  1        4            1        1        1727862376   63.39  510720   510720   14059784    3383.19     3383.19     0.00&lt;br /&gt;
  2        3            1        1        508719672    18.66  508970   82176    3689732     999.51      2830.58     646.95&lt;br /&gt;
  3        7            1        1        140271824    5.15   7900     2352     1013800     17755.93    18570.93    17410.42&lt;br /&gt;
  4        &lt;strong&gt;9&lt;/strong&gt;            1        1        &lt;strong&gt;101662288&lt;/strong&gt;    3.73   28419    &lt;strong&gt;0&lt;/strong&gt;        6625384     &lt;strong&gt;3577.26&lt;/strong&gt;     0.00        3577.26&lt;br /&gt;
  5        &lt;strong&gt;11&lt;/strong&gt;           1        1        &lt;strong&gt;84264720&lt;/strong&gt;     3.09   32938    &lt;strong&gt;0&lt;/strong&gt;        612848      &lt;strong&gt;2558.28&lt;/strong&gt;     0.00        2558.28&lt;br /&gt;
  6        &lt;strong&gt;10&lt;/strong&gt;           1        1        &lt;strong&gt;71553560&lt;/strong&gt;     2.62   32938    &lt;strong&gt;0&lt;/strong&gt;        576132      &lt;strong&gt;2172.37&lt;/strong&gt;     0.00        2172.37&lt;br /&gt;
  7        5            1        1        42053248     1.54   3313     2517     805736      12693.40    15831.10    2771.81&lt;br /&gt;
  8        8            1        1        31547660     1.16   7900     2352     153972      3993.37     7039.04     2702.21&lt;br /&gt;
  9        6            1        1        17944504     0.66   3313     2517     292508      5416.39     6476.95     2062.83
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Overall, sid 9, 10 and 11 did not do that bad here. And the best thing is, they all have 0 matches. I ran this on many of my test pcaps, and I&amp;#8217;ve not been close to false positives. Sid 10 seems to fire some times, but not the others, so rather unique combo of packets in a stream I guess and a way to sig malware like this. Also, we could add check for the TCP &amp;#8220;PUSH&amp;#8221; flag in sid 9, 10 and 11 etc to be more accurate if we need.&lt;/p&gt;
&lt;p&gt;So the proof of the pudding, running it against a pcap of the malware:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
   Num      Rule         Gid      Rev      Ticks        %      Checks   &lt;strong&gt;Matches&lt;/strong&gt;  Max Ticks   Avg Ticks   Avg Match   Avg No Match&lt;br /&gt;
  &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212; &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212; &amp;#8212;&amp;#8212; &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211; &amp;#8212;&amp;#8212;&amp;#8212;&amp;#8212;&amp;#8211;&lt;br /&gt;
  1        3            1        1        443120       33.03  165      158      102108      2685.58     2731.72     1644.00&lt;br /&gt;
  2        &lt;strong&gt;11&lt;/strong&gt;           1        1        310420       23.14  259      &lt;strong&gt;2&lt;/strong&gt;        2860        1198.53     2478.00     1188.58&lt;br /&gt;
  3        4            1        1        302944       22.58  269      269      15376       1126.19     1126.19     0.00&lt;br /&gt;
  4        &lt;strong&gt;10&lt;/strong&gt;           1        1        257896       19.22  259      &lt;strong&gt;3&lt;/strong&gt;        16484       995.74      7446.67     920.14&lt;br /&gt;
  5        &lt;strong&gt;9&lt;/strong&gt;            1        1        27088        2.02   10       &lt;strong&gt;3&lt;/strong&gt;        7448        2708.80     5080.00     1692.57
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Events:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;
[**] [1:&lt;strong&gt;11&lt;/strong&gt;:1] Possible Tofsee server Packet 4(475 Bytes) [**] {TCP} 216.246.8.230:443 -&gt; 192.168.1.10:1031&lt;br /&gt;
[**] [1:&lt;strong&gt;11&lt;/strong&gt;:1] Possible Tofsee server Packet 4(475 Bytes) [**] {TCP} 84.16.252.136:22050 -&gt; 192.168.1.10:1032
&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;My Tofsee rules fire on all 5 pcaps I looked at initially (and lots more pcaps I tested after that), so hopefully it will fire on all current Tofsee traffic.&lt;/p&gt;
&lt;p&gt;I also &lt;a href=&quot;http://seclists.org/snort/2011/q4/250&quot;&gt;replied&lt;/a&gt; on an e-mail to the snort-user list 3. of November, making the same feature request as I did for Suricata. No one followed up :/ The email should probably be directed to the snort-devel list some time in the future&amp;#8230;&lt;/p&gt;
&lt;p&gt;I hope this post has been useful, and hopefully we can get some more flowint rules out there, and maybe even get native packet and byte counting in Snort and Suricata one day &lt;img src=&quot;http://www.gamelinux.org/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:)&quot; class=&quot;wp-smiley&quot; /&gt; &lt;/p&gt;</description>
	<pubDate>Mon, 09 Jan 2012 07:09:06 +0000</pubDate>
</item>
<item>
	<title>Edward Bjarte Fjellskål: Security thoughts for 2012+</title>
	<guid>http://www.gamelinux.org/?p=384</guid>
	<link>http://www.gamelinux.org/?p=384</link>
	<description>&lt;p&gt;Quoting Richard Bejtlich: &amp;#8220;Prevention will eventually fail!&amp;#8221;&lt;/p&gt;
&lt;p&gt;And I have always agreed. Accidents do happen, the world is not perfect. So when companies that really spend time and money on security get breached (RSA, Lockheed, Google, [place your company here?]) then you could work out from the theory that you eventually will get breached too.&lt;/p&gt;
&lt;p&gt;When you realize and accept that, you may need to redefine the way you think of IT security. You should prepare for the worst, so identifying what would be &amp;#8220;the worst&amp;#8221; for you (your company) and then identifying you most critical assets should be on the top of your list, and you should start focusing your effort on securing them the most.&lt;/p&gt;
&lt;p&gt;Limit the users that have access to the most critical assets (and work on sensitive projects etc). The users also need special attention when it comes to awareness training and follow up. They should also have a good communication with the security staff making it easy to report anything that seems suspicious and get positive feedback no matter what. They are an important part of picking up security issues where your technology fails! So you need them.&lt;/p&gt;
&lt;p&gt;The most critical assets needs to be monitored as close to real-time as it gets. The time it takes for an incident detection and till your response should be a minimum, even outside working hours and weekends.&lt;/p&gt;
&lt;p&gt;Then the users who has access to theses critical systems should also have special attention/hardening on their OS&amp;#8217;s etc. Use a modern operating system and enabling the security functionality all ready there and making sure that executables cant be executed from temporary directory etc. When you got basic security features in place (Including Anti-Virus), you should start looking at centralized logging and alerting on suspicious activities from the logs.&lt;br /&gt;
You should also look into implementing different ways of monitoring anomalies for the users usage. When do they normally log on? From where do they normally log on? Are they fetching lots of documents from the file servers? etc. And did they access the &lt;strong&gt;fake&lt;/strong&gt;&lt;em&gt; &amp;#8220;secret document&amp;#8221;&lt;/em&gt; that is there just for catching any suspicious activity? (You need to define your own anomalies).&lt;/p&gt;
&lt;p&gt;When the inner core (most valued assets + its users) are &amp;#8220;secured&amp;#8221;, you should strive to maintain an acceptable level of security on the rest of the corporate office network and also importantly the public facing part. Compromises here can be used to escalate into the &amp;#8220;inner core&amp;#8221; or to damage your reputation and business affairs, so keeping an acceptable level of security here &amp;#8220;as always&amp;#8221; is good.&lt;/p&gt;
&lt;p&gt;As &amp;#8220;Prevention will eventually fail!&amp;#8221;, you need to have sufficient logging up and running. So when you do have an incident, the analyst has sufficient data to work with and this will also keep the cost down, as the time it takes to handle an incident will be lower. I&amp;#8217;m mostly into Network Security Monitoring, so for me, NetFlow type data, IDS events, full packet capture, proxy logs, and DNS queries logs are some key logs from network that will help me. On the more host side of logging, the more logging, the better&amp;#8230; web, email, proxy, spam, anti-virus, file-access, local client logs, syslogs/eventlogs, and so on&amp;#8230;.. &lt;/p&gt;
&lt;p&gt;And remember &amp;#8211; if you cant spot any badness, you are not looking hard enough &lt;img src=&quot;http://www.gamelinux.org/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:)&quot; class=&quot;wp-smiley&quot; /&gt;&lt;br /&gt;
I always work on the theory that something in my networks are p0wned. That keeps me on my toes and keeps me actively finding new ways to spot badness. &lt;/p&gt;
&lt;p&gt;With that &amp;#8211; I wish you all a hacky new year!&lt;/p&gt;</description>
	<pubDate>Fri, 30 Dec 2011 14:15:21 +0000</pubDate>
</item>
<item>
	<title>Lars Strand: Terminal tip: Pipe Viewer</title>
	<guid>tag:blogger.com,1999:blog-5601918809570247446.post-561359115602142684</guid>
	<link>http://blog.larsstrand.org/2011/12/tip-pipe-viewer.html</link>
	<description>A couple of weeks ago, I held a Linux/Unix elementary course. One of the toughest concepts in that course are the concept of pipes and redirect.&lt;br /&gt;&lt;br /&gt;I usually begin explaining pipe as &quot;the output of one command becomes input to the next&quot;, and show by an example:&lt;br /&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp;$ &lt;b&gt;zcat pureftpd.log.gz | cut -f1 -d' ' | sort | uniq | wc -l&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp;1259073&lt;/div&gt;&lt;br /&gt;This command reads a ~550MB large compressed pureftpd logfile (from ftp.uio.no), and finds the number of unique visitors. Several commands are linked together by pipe, so the output of one command is input to the next.&lt;br /&gt;&lt;br /&gt;However, I received and interesting question: &lt;i&gt;&quot;Which command use the longest time?&quot;&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;There is no easy way to tell, we can just take an educated guess. However, we can use a handy little unix utility called &lt;a href=&quot;http://www.ivarch.com/programs/pv.shtml&quot;&gt;&quot;Pipe Viewer&quot;&lt;/a&gt; to monitor and measure the data going through a pipe. Install from apt:&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; $ &lt;b&gt;sudo apt-get install pv&lt;/b&gt;&lt;/div&gt;&lt;br /&gt;Next, we craft our command above using pv. Since pv behave like cat with respect to input/output, we measure the throughput between each command: &lt;br /&gt;&lt;br /&gt;&lt;div&gt;&amp;nbsp; $ &lt;b&gt;zcat pureftpd.log.gz | pv -cN zcat | cut -f1 -d' ' | \&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;gt; &lt;b&gt;pv -cN cut | sort | pv -cN sort | uniq | pv -cN uniq | \&lt;/b&gt;&lt;/div&gt;&lt;div&gt;&amp;nbsp; &amp;gt; &lt;b&gt;wc -l &lt;/b&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;div class=&quot;separator&quot;&gt;&lt;/div&gt;&lt;div class=&quot;separator&quot;&gt;&lt;a href=&quot;http://4.bp.blogspot.com/-LaSl167BPws/TvxC4MqmvfI/AAAAAAAABN8/ovw244PJkI0/s1600/PipeViewer.jpg&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;http://4.bp.blogspot.com/-LaSl167BPws/TvxC4MqmvfI/AAAAAAAABN8/ovw244PJkI0/s1600/PipeViewer.jpg&quot; /&gt;&lt;/a&gt;&lt;/div&gt;As we see from the command, the command that had the slowest throughput was &quot;uniq&quot;. Both cut and sort had an impressive 6-7MB/s throughput.&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/5601918809570247446-561359115602142684?l=blog.larsstrand.org&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</description>
	<pubDate>Thu, 29 Dec 2011 13:10:00 +0000</pubDate>
	<author>noreply@blogger.com (Lars Strand)</author>
</item>
<item>
	<title>Magnus Hagander: www.postgresql.org - brand new, yet old and familiar</title>
	<guid>http://blog.hagander.net/archives/202-guid.html</guid>
	<link>http://blog.hagander.net/archives/202-www.postgresql.org-brand-new,-yet-old-and-familiar.html</link>
	<description>&lt;div&gt;
                &lt;p&gt;Most of the visitors to &lt;a href=&quot;http://www.postgresql.org/&quot;&gt;www.postgresql.org&lt;/a&gt; probably never noticed that a couple of weeks back, the entire site was replaced with a new one. In fact, we didn't just change the website - just days before, we made large changes to our ftp network as well (more about that in another post, from me or others). So in fact, we &lt;strong&gt;hope&lt;/strong&gt; that most people didn't notice. The changes were mainly a technical refresh, and there hasn't been much change to the contents at all yet. We did sneak in a few content changes as well, that have been requested for a while, so I'm going to start with listing those:&lt;/p&gt;


&lt;ul&gt;
    &lt;li&gt;The &lt;a href=&quot;http://www.postgresql.org/docs/devel/&quot;&gt;developer version of the documentation&lt;/a&gt; (updated serveral times per day from the tip of the HEAD branch that will eventually become the next version of PostgreSQL) now live on the main website, and will use the same stylesheets to look a lot nicer than before.&lt;/li&gt;
    &lt;li&gt;Anybody who submits content to our site (news, events, professional services, products, etc) will notice there is now a new concept of an &lt;i&gt;Organisation&lt;/i&gt;. This means that it will finally be possible to have more than one person manage the submissions from a single company or group.&lt;/li&gt;
    &lt;li&gt;Again for those that submit content, it is now possible to view which of your submissions are still in the moderation queue, and it's also possible to edit something after it's been submitted. In fact, you can edit your items even after they've been approved. Any such editing will be &lt;i&gt;post-moderated&lt;/i&gt;, and if this is abused that organization will be banned from post-moderation - but we don't expect that to ever be necessary.&lt;/li&gt;
    &lt;li&gt;And finally, for those that submit content again, we've switched to markdown to format your submissions, instead of a very random subset of allowed HTML tags.&lt;/li&gt;
&lt;/ul&gt;

The rest of the changes are under the hood, and it's mostly done for two reasons:
&lt;ul&gt;
    &lt;li&gt;The technology powering the site was simply very old&lt;/li&gt;
    &lt;li&gt;The frameworks used were quite obscure, which severely limited the number of people who could (or wanted to) work with them&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hopefully these two changes will make it easier to contribute to the website, so if you're potentially interested in doing that, please read on!&lt;/p&gt;

 &lt;br /&gt;&lt;a href=&quot;http://blog.hagander.net/archives/202-www.postgresql.org-brand-new,-yet-old-and-familiar.html#extended&quot;&gt;Continue reading &quot;www.postgresql.org - brand new, yet old and familiar&quot;&lt;/a&gt;
            &lt;/div&gt;</description>
	<pubDate>Wed, 21 Dec 2011 13:33:00 +0000</pubDate>
</item>
<item>
	<title>Faggruppe PHP: Fake php time on your ubuntu server</title>
	<guid>http://elephpants.blog.redpill-linpro.com/2011/12/18/</guid>
	<link>http://elephpants.blog.redpill-linpro.com/2011/12/18/fake-php-time-on-your-ubuntu-server/</link>
	<description>&lt;p&gt;Some time it is necessary to fool your PHP application to test functionality related to a &amp;#8220;current date&amp;#8221;.&lt;/p&gt;
&lt;p&gt;Fooling php cli is simple using &lt;a href=&quot;http://packages.ubuntu.com/search?keywords=faketime&quot;&gt;faketime&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;Say you have this PHP script:&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ;&quot;&gt;
#!/usr/bin/env php
&amp;lt;?php
print date( 'F j. Y [H:i]' ).&amp;quot;\n&amp;quot;;
&lt;/pre&gt;
&lt;p&gt;Rendering this script with php through faketime will give you results like this:&lt;/p&gt;
&lt;pre class=&quot;brush: bash; title: ;&quot;&gt;
$ faketime 'last Friday 5 pm' ./time.php
December 9. 2011 [17:00]
&lt;/pre&gt;
&lt;p&gt;The same can be achieved using the &lt;a href=&quot;http://packages.ubuntu.com/lucid/datefudge&quot;&gt;datefudge&lt;/a&gt; command:&lt;/p&gt;
&lt;pre class=&quot;brush: bash; title: ;&quot;&gt;
$ datefudge &amp;quot;2007-04-01 10:23&amp;quot; ./time.php
April 1. 2007 [10:23]
&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Faking time for a webapplication&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Faking time for a web application is not that simple since apache will fork a process for each request and thus create a new php processes.&lt;br /&gt;
In this post I will show you how to use &lt;a href=&quot;http://freecode.com/projects/libfaketime&quot;&gt;FakeTime Preload Library&lt;/a&gt; to fake time system wide while running tests on a web application.&lt;/p&gt;
&lt;p&gt;First I need to install faketimelib as described on the librarys &lt;a href=&quot;http://www.code-wizards.com/projects/libfaketime/&quot;&gt;homepage&lt;/a&gt;.&lt;br /&gt;
In short:&lt;/p&gt;
&lt;pre class=&quot;brush: bash; title: ;&quot;&gt;
wget http://www.code-wizards.com/projects/libfaketime/libfaketime-0.8.1.tar.gz
tar -xvzf libfaketime-0.8.1.tar.gz
cd libfaketime-0.8.1
vim README
make
sudo make install
export LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1
&lt;/pre&gt;
&lt;p&gt;For the demonstration I will use a php script like this:&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ;&quot;&gt;
&amp;lt;?php
printf( &amp;quot;The current time of the server is: %s\n&amp;quot;, date('l F j. Y [H:i:s]') );
&lt;/pre&gt;
&lt;p&gt;Running this script should yield something like:&lt;/p&gt;
&lt;pre class=&quot;brush: bash; title: ;&quot;&gt;
$ php time.php
The current time of the server is: Friday December 16. 2011 [08:02:43]
&lt;/pre&gt;
&lt;p&gt;Now I create a file in my home folder, faketimerc, with a new future time. I will use this file in different ways to show how I can manipulate the time.&lt;/p&gt;
&lt;pre class=&quot;brush: bash; title: ;&quot;&gt;
echo &amp;quot;@2012-12-21 12:12:12&amp;quot; &amp;gt; faketimerc
&lt;/pre&gt;
&lt;p&gt;If you now create an environment variable, FAKETIME, give it a future time, and running the same script would yield something like this:&lt;/p&gt;
&lt;pre class=&quot;brush: bash; title: ;&quot;&gt;
$ php time.php
The current time of the server is: Friday December 16. 2011 [08:19:39]
$ export FAKETIME=$(cat faketimerc)
$ php time.php
The current time of the server is: Friday December 21. 2012 [12:12:12]
$ unset FAKETIME
$ php time.php
The current time of the server is: Friday December 16. 2011 [08:19:56]
&lt;/pre&gt;
&lt;p&gt;As you can see, the processes you run while the environment variable is set to a future time will get a fake time. Once the variable is unset new processes will get normal time.&lt;/p&gt;
&lt;p&gt;This can be achieved also by creating a file. &amp;#8220;.faketimerc&amp;#8221; in your home folder:&lt;/p&gt;
&lt;pre class=&quot;brush: bash; title: ;&quot;&gt;
$ php time.php
The current time of the server is: Friday December 16. 2011 [08:23:12]
$ cp faketimerc .faketimerc
$ php time.php
The current time of the server is: Friday December 21. 2012 [12:12:12]
$ rm -f .faketimerc
$ php time.php
The current time of the server is: Friday December 16. 2011 [08:23:36]
&lt;/pre&gt;
&lt;p&gt;If you want to change time for a php application that runs though apache you may want to set the fake time system wide so that the php processes spowned use the faked time. To do this you need to create a file, /etc/.faketimerc, just the same as the one I created in my home folder.&lt;/p&gt;
&lt;p&gt;I will use w3m for this demonstration. I assume a normal ubuntu server with apache2 installed.&lt;/p&gt;
&lt;pre class=&quot;brush: bash; title: ;&quot;&gt;
sudo cp time.php /var/www
sudo cp faketimerc /etc/
$ sudo /etc/init.d/apache2 restart
 * Restarting web server apache2                                                                                                                                                                                                                                                   ... waiting
$ php /var/www/time.php
The current time of the server is: Friday December 21. 2012 [12:12:12]
$ date
fr. 21. des. 12:12:12 +0100 2012
$ w3m -dump localhost/time.php
The current time of the server is: Friday December 16. 2011 [11:16:24]
&lt;/pre&gt;
&lt;p&gt;As you can see, the date command and when rendering the script with php, gives me the fake time, but when rendering the script through apache I loose the fake time. This is because the environment variable LD_PRELOAD is not set for the apache process.&lt;/p&gt;
&lt;p&gt;To fix this I need to set LD_PRELOAD for apache by editing /etc/apache/envvars. Lets test it again:&lt;/p&gt;
&lt;pre class=&quot;brush: bash; title: ;&quot;&gt;
$ sudo bash -c &amp;quot;echo \&amp;quot;export LD_PRELOAD='/usr/local/lib/faketime/libfaketime.so.1'\&amp;quot; &amp;gt;&amp;gt; /etc/apache2/envvars&amp;quot;
$ sudo /etc/init.d/apache2 restart
 * Restarting web server apache2                                                                                                                                                                                                                                                   ... waiting
$ w3m -dump localhost/time.php
The current time of the server is: Friday December 21. 2012 [12:12:16]
&lt;/pre&gt;
&lt;p&gt;Fake time! &lt;img src=&quot;http://elephpants.blog.redpill-linpro.com/wp-includes/images/smilies/icon_smile.gif&quot; alt=&quot;:)&quot; class=&quot;wp-smiley&quot; /&gt; &lt;/p&gt;
&lt;p&gt;PS! If you also want your PostgreSQL server to use fake time:&lt;/p&gt;
&lt;pre class=&quot;brush: bash; title: ;&quot;&gt;
$ sudo bash -c &amp;quot;echo \&amp;quot;LD_PRELOAD='/usr/local/lib/faketime/libfaketime.so.1'\&amp;quot; &amp;gt;&amp;gt; /etc/postgresql/8.4/main/environment&amp;quot;
$ sudo /etc/init.d/postgresql-8.4 restart
&lt;/pre&gt;</description>
	<pubDate>Sun, 18 Dec 2011 11:47:48 +0000</pubDate>
</item>
<item>
	<title>Ingvar Hagelund: Unquiet Ubuntu’s grub</title>
	<guid>http://ingvar.blog.redpill-linpro.com/2011/12/14/</guid>
	<link>http://ingvar.blog.redpill-linpro.com/2011/12/14/unquiet-ubuntus-grub/</link>
	<description>&lt;p&gt;When working with servers or debugging a workstation, or even just out of curiosity, it&amp;#8217;s geek friendly to make your linux kernel boot rather more than less verbose. In Ubuntu 8.04.4 LTS, and probably other Debian derivates as well, the default is to be rather quiet, and it&amp;#8217;s a bit difficult to find how to make it verbose, without hard coding changes to /boot/grub/menu.lst. Such changes will be overwritten by update-grub, so that&amp;#8217;s probably a bad idea.&lt;/p&gt;
&lt;p&gt;This fixes it:&lt;/p&gt;
&lt;pre&gt;
# echo 'supports_quiet=false' &amp;gt;&amp;gt; /etc/default/grub
# update-grub
&lt;/pre&gt;</description>
	<pubDate>Wed, 14 Dec 2011 07:47:12 +0000</pubDate>
</item>
<item>
	<title>Ingvar Hagelund: Setting an address on the HP iLO from Linux</title>
	<guid>http://ingvar.blog.redpill-linpro.com/2011/12/09/</guid>
	<link>http://ingvar.blog.redpill-linpro.com/2011/12/09/setting-the-ip-address-on-hp-ilo-from-linux/</link>
	<description>&lt;p&gt;So, we put this nice DL360 G7 in production, and found that networking on the iLO (integrated lights-out management) was not configured correctly. Now, the box was already running software, so it was a bit unpopluar to reboot it just to get iLO access again. Just for fun (sorry, I had not high hopes on their Linux support), I called HP support. They stated of course that this was not possible without rebooting the server and access the iLO setup through its BIOS.&lt;/p&gt;
&lt;p&gt;Now, the HP iLO 3 should support IPMI, so after a bit of fiddling around, I came up with this, and it actually works. The following was executed on RHEL5.&lt;/p&gt;
&lt;p&gt;First find the LAN channel&lt;/p&gt;
&lt;pre&gt;
# for i in `seq 1 14`; do ipmitool lan print $i 2&amp;gt;/dev/null | grep -q ^Set &amp;amp;&amp;amp; echo Channel $i; done

Channel 2
&lt;/pre&gt;
&lt;p&gt;So, on this system, channel 2 is the LAN channel.&lt;/p&gt;
&lt;pre&gt;
# ipmitool lan print 2

Set in Progress         : Set Complete
Auth Type Support       :
IP Address Source       : DHCP Address
IP Address              : 0.0.0.0
Subnet Mask             : 0.0.0.0
MAC Address             : c0:ff:ee:c0:ff:ee
BMC ARP Control         : ARP Responses Enabled, Gratuitous ARP Disabled
Default Gateway IP      : 0.0.0.0
802.1q VLAN ID          : Disabled
802.1q VLAN Priority    : 0
Cipher Suite Priv Max   : Not Available
&lt;/pre&gt;
&lt;p&gt;Okay, so if you have a DHCP server on your management network, you may be content with this, and just give it an address by DHCP. I wanted to set a static address, though.&lt;/p&gt;
&lt;pre&gt;
# ipmitool lan set 2 ipsrc static
# ipmitool lan set 2 ipaddr 192.168.42.36
# ipmitool lan set 2 netmask 255.255.255.0
# ipmitool lan set 2 defgw ipaddr 192.168.42.1
# ipmitool mc reset cold
&lt;/pre&gt;
&lt;p&gt;That&amp;#8217;s it actually. Exchange the LAN channel and network addresses with your own, of course. &lt;/p&gt;</description>
	<pubDate>Fri, 09 Dec 2011 16:27:22 +0000</pubDate>
</item>
<item>
	<title>Edward Bjarte Fjellskål: PassiveDNS update (v0.2.4)</title>
	<guid>http://www.gamelinux.org/?p=372</guid>
	<link>http://www.gamelinux.org/?p=372</link>
	<description>&lt;p&gt;It has been some while since I had time to code on my C projects. But the last week I got some time and used it to get &lt;a href=&quot;https://github.com/gamelinux/passivedns&quot;&gt;&lt;strong&gt;PassiveDNS&lt;/strong&gt;&lt;/a&gt; into a state where Im more relaxed about it. Previous version (V0.1.1) used to spit out all DNS data it saw. The latest version caches DNS data internally in memory and only prints out a DNS record when it sees if for the first time, or if it is a active domain, it prints it out again after 24 hours and so on (once a day). The previous version would give me Gigabytes of DNS data daily in my test setup, while this version gives me about 2 Megabytes. This version also just gives you&lt;strong&gt; A, AAAA, PTR&lt;/strong&gt; and &lt;strong&gt;CNAME&lt;/strong&gt; records at the moment. I&amp;#8217;m open for suggestions for more (use-cases would be great too!).&lt;/p&gt;
&lt;p&gt;In my tests and in feedback from people who has tried it, &lt;strong&gt;PassiveDNS&lt;/strong&gt; is very resource friendly when it comes to CPU usage (more or less idling). In current version (v0.2.4) there is not implemented any limitation on memory usage, so if your network sees a lot of DNS traffic, you might end up using some hundreds of Megabytes RAM for the internal cache. The most I&amp;#8217;ve seen is around 100 MB at the moment. My plan is to implement some sort of &amp;#8220;soft-limit&amp;#8221; on memory usage, so that you can specify how much memory PassiveDNS should maximum use. The &amp;#8220;downside&amp;#8221; of this though, is that PassiveDNS would have to expire domains from its cache faster. That might end up in bigger log files with duplicate entries. When I say &amp;#8220;downside&amp;#8221;, its not a real downside as I see it. From my tests with the example scripts &lt;strong&gt;pdns2db.pl&lt;/strong&gt; and &lt;strong&gt;search-pdns.pl&lt;/strong&gt;, it is not much of a problem keeping up with insertions to the DB (MySQL) and your last seen timestamp will be a bit more accurate. I guess this kind of data though, is better suited for a NoSQL solution, if you are collecting lots of it.&lt;/p&gt;
&lt;p&gt;If you have read this, and you are into Network Security Monitoring, and you don&amp;#8217;t use passive DNS in your work, I recommend you too Google it and read a bit about it.&lt;/p&gt;</description>
	<pubDate>Thu, 08 Dec 2011 20:27:41 +0000</pubDate>
</item>
<item>
	<title>Kacper Wysocki: CPM 0.26 the Console Password Manager</title>
	<guid>http://kacper.blog.redpill-linpro.com/archives/403</guid>
	<link>http://kacper.blog.redpill-linpro.com/archives/403</link>
	<description>&lt;p&gt;Some of you might &lt;a href=&quot;http://kacper.blog.redpill-linpro.com/archives/176&quot;&gt;have noticed&lt;/a&gt; that I&amp;#8217;ve &lt;a href=&quot;http://kacper.blog.redpill-linpro.com/archives/135&quot;&gt;adopted this little program&lt;/a&gt; while its original author is MIA, and that my efforts have resulted in its &lt;a href=&quot;http://packages.debian.org/wheezy/cpm&quot;&gt;inclusion into debian wheezy&lt;/a&gt; earlier this year.&lt;/p&gt;
&lt;p&gt;This is great news and makes it a breeze to &lt;a href=&quot;https://github.com/comotion/cpm/wiki&quot;&gt;get up and running with CPM&lt;/a&gt; with a simple &lt;code&gt;apt-get install cpm&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;However, it seems that most people are interested in running CPM on older distributions, realistically the &lt;code&gt;stable&lt;/code&gt; distribution codenamed &lt;code&gt;squeeze&lt;/code&gt; is a favorite, as well as the Ubuntu LTS release 10.4 codenamed &lt;code&gt;lucid lynx&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;So I have built some updated packages of CPM for these oldies but goodies:&lt;br /&gt;
* &lt;a href=&quot;http://u.delta9.pl/packages/cpm/cpm_0.26-1_i386_squeeze.deb&quot;&gt;CPM for squeeze i386&lt;/a&gt;&lt;br /&gt;
* &lt;a href=&quot;http://u.delta9.pl/packages/cpm/cpm_0.26-1_amd64_squeeze.deb&quot;&gt;CPM for squeeze amd64&lt;/a&gt;&lt;br /&gt;
* &lt;a href=&quot;http://u.delta9.pl/packages/cpm/cpm_0.26-1_i386_lucid.deb&quot;&gt;CPM for lucid i386&lt;/a&gt;&lt;br /&gt;
* &lt;a href=&quot;http://u.delta9.pl/packages/cpm/cpm_0.26-1_amd64_lucid.deb&quot;&gt;CPM for lucid amd64&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Remember&lt;/strong&gt; to install the dependencies though. On squeeze, they are:&lt;/p&gt;
&lt;pre&gt;
me@mine:~# apt-get install \
    libcdk5 libcrack2 libdotconf1.0 libgpg-error0 \
    libgpgme11 libxml2 libxml2-utils libpth20
&lt;/pre&gt;
&lt;p&gt;&lt;a href=&quot;https://github.com/comotion/cpm/issues/new&quot;&gt;File us a ticket&lt;/a&gt; if you run into trouble with these packages or need cpm working on some other distribution.&lt;/p&gt;
&lt;p&gt;CPM is a simple, paranoid password manager for the console with some cool features that make it stand out:&lt;/p&gt;
&lt;p&gt;* data files can be encrypted for more than one person&lt;br /&gt;
* data files are signed by the last person who saved it so forging data files is not possible&lt;br /&gt;
* data files are en- and decryptable directly by gpg and gzip&lt;br /&gt;
* the application memory is protected from paging, core dumps, ptrace attacks and runtime environment&lt;br /&gt;
* data is validated using an internal DTD&lt;br /&gt;
* several passwords per account are possible to store&lt;br /&gt;
* it&amp;#8217;s possible to handle several data files, each encrypted for different people&lt;br /&gt;
* cracklib checks of password strength and warnings about weak passwords&lt;br /&gt;
* user definable hierarchy with unlimited depth&lt;br /&gt;
* long comments for any node in the hierarchy&lt;br /&gt;
* password generator&lt;br /&gt;
* only one password visible at a time&lt;br /&gt;
* searchable database from the command line&lt;br /&gt;
* user definable search patterns (e.g. user@hostname)&lt;br /&gt;
* several hits can be displayed at once (e.g. several accounts per host)&lt;br /&gt;
* conversion scripts for Password Management System (pms), Password Safe and CSV files&lt;/p&gt;</description>
	<pubDate>Mon, 05 Dec 2011 16:12:24 +0000</pubDate>
</item>
<item>
	<title>Ingvar Hagelund: Gingerbread AT-AT Walker</title>
	<guid>http://ingvar.blog.redpill-linpro.com/2011/12/03/</guid>
	<link>http://ingvar.blog.redpill-linpro.com/2011/12/03/gingerbread-at-at-walker/</link>
	<description>&lt;p&gt;Two years ago, we built the &lt;a href=&quot;http://ingvar.blog.redpill-linpro.com/?p=365&quot;&gt;Gingerbread Millennium Falcon&lt;/a&gt;. Last year, we built the &lt;a href=&quot;http://ingvar.blog.redpill-linpro.com/?p=1047&quot;&gt;Gingerbread Vader&amp;#8217;s Tie Fighter&lt;/a&gt;. What should we build this year? More Star Wars vehicles? After a bit heavy thinking, we came up with the emperial AT-AT Walker. Luckily, the web is full of pictures and sketches, so we found plenty of inspiration.&lt;/p&gt;
&lt;p&gt;After four hours, the result exceeded all expectations! Happy advent everybody!&lt;/p&gt;
&lt;p&gt;Update: The Friendly Fredrik &lt;a href=&quot;http://bit.ly/tq6LpS&quot;&gt;posted some more pictures&lt;/a&gt; of the building process.&lt;/p&gt;
&lt;div id=&quot;attachment_1371&quot; class=&quot;wp-caption aligncenter&quot;&gt;&lt;a href=&quot;http://ingvar.blog.redpill-linpro.com/files/DSC00510-1.jpg&quot;&gt;&lt;img src=&quot;http://ingvar.blog.redpill-linpro.com/files/DSC00510-1-300x225.jpg&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;225&quot; class=&quot;size-medium wp-image-1371&quot; /&gt;&lt;/a&gt;&lt;p class=&quot;wp-caption-text&quot;&gt;Parts ready for the oven&lt;/p&gt;&lt;/div&gt;
&lt;div id=&quot;attachment_1372&quot; class=&quot;wp-caption aligncenter&quot;&gt;&lt;a href=&quot;http://ingvar.blog.redpill-linpro.com/files/DSC00518-1.jpg&quot;&gt;&lt;img src=&quot;http://ingvar.blog.redpill-linpro.com/files/DSC00518-1-300x225.jpg&quot; alt=&quot;AT-AT Walker #7&quot; width=&quot;300&quot; height=&quot;225&quot; class=&quot;size-medium wp-image-1372&quot; /&gt;&lt;/a&gt;&lt;p class=&quot;wp-caption-text&quot;&gt;That&amp;#039;s a lot of parts&lt;/p&gt;&lt;/div&gt;
&lt;div id=&quot;attachment_1374&quot; class=&quot;wp-caption aligncenter&quot;&gt;&lt;a href=&quot;http://ingvar.blog.redpill-linpro.com/files/DSC00528.jpg&quot;&gt;&lt;img src=&quot;http://ingvar.blog.redpill-linpro.com/files/DSC00528-300x225.jpg&quot; alt=&quot;Assembly of the AT-AT Walker&quot; width=&quot;300&quot; height=&quot;225&quot; class=&quot;size-medium wp-image-1374&quot; /&gt;&lt;/a&gt;&lt;p class=&quot;wp-caption-text&quot;&gt;Assembly by melted sugar. Hot stuff!&lt;/p&gt;&lt;/div&gt;
&lt;div id=&quot;attachment_1356&quot; class=&quot;wp-caption aligncenter&quot;&gt;&lt;a href=&quot;http://ingvar.blog.redpill-linpro.com/files/IMG_2384.jpg&quot;&gt;&lt;img src=&quot;http://ingvar.blog.redpill-linpro.com/files/IMG_2384-300x225.jpg&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;225&quot; class=&quot;size-medium wp-image-1356&quot; /&gt;&lt;/a&gt;&lt;p class=&quot;wp-caption-text&quot;&gt;AT-AT Walker #1&lt;/p&gt;&lt;/div&gt;
&lt;div id=&quot;attachment_1357&quot; class=&quot;wp-caption aligncenter&quot;&gt;&lt;a href=&quot;http://ingvar.blog.redpill-linpro.com/files/IMG_2385.jpg&quot;&gt;&lt;img src=&quot;http://ingvar.blog.redpill-linpro.com/files/IMG_2385-300x225.jpg&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;225&quot; class=&quot;size-medium wp-image-1357&quot; /&gt;&lt;/a&gt;&lt;p class=&quot;wp-caption-text&quot;&gt;AT-AT Walker #2&lt;/p&gt;&lt;/div&gt;
&lt;div id=&quot;attachment_1359&quot; class=&quot;wp-caption aligncenter&quot;&gt;&lt;a href=&quot;http://ingvar.blog.redpill-linpro.com/files/IMG_2382.jpg&quot;&gt;&lt;img src=&quot;http://ingvar.blog.redpill-linpro.com/files/IMG_2382-300x225.jpg&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;225&quot; class=&quot;size-medium wp-image-1359&quot; /&gt;&lt;/a&gt;&lt;p class=&quot;wp-caption-text&quot;&gt;AT-AT Walker #3&lt;/p&gt;&lt;/div&gt;
&lt;div id=&quot;attachment_1360&quot; class=&quot;wp-caption aligncenter&quot;&gt;&lt;a href=&quot;http://ingvar.blog.redpill-linpro.com/files/IMG_2383.jpg&quot;&gt;&lt;img src=&quot;http://ingvar.blog.redpill-linpro.com/files/IMG_2383-300x225.jpg&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;225&quot; class=&quot;size-medium wp-image-1360&quot; /&gt;&lt;/a&gt;&lt;p class=&quot;wp-caption-text&quot;&gt;AT-AT Walker #4&lt;/p&gt;&lt;/div&gt;
&lt;div id=&quot;attachment_1365&quot; class=&quot;wp-caption aligncenter&quot;&gt;&lt;a href=&quot;http://ingvar.blog.redpill-linpro.com/files/IMG_2386.jpg&quot;&gt;&lt;img src=&quot;http://ingvar.blog.redpill-linpro.com/files/IMG_2386-300x225.jpg&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;225&quot; class=&quot;size-medium wp-image-1365&quot; /&gt;&lt;/a&gt;&lt;p class=&quot;wp-caption-text&quot;&gt;AT-AT Walker #5&lt;/p&gt;&lt;/div&gt;
&lt;div id=&quot;attachment_1369&quot; class=&quot;wp-caption aligncenter&quot;&gt;&lt;a href=&quot;http://ingvar.blog.redpill-linpro.com/files/IMG_23891.jpg&quot;&gt;&lt;img src=&quot;http://ingvar.blog.redpill-linpro.com/files/IMG_23891-300x225.jpg&quot; alt=&quot;&quot; width=&quot;300&quot; height=&quot;225&quot; class=&quot;size-medium wp-image-1369&quot; /&gt;&lt;/a&gt;&lt;p class=&quot;wp-caption-text&quot;&gt;AT-AT Walker #6&lt;/p&gt;&lt;/div&gt;</description>
	<pubDate>Sat, 03 Dec 2011 19:21:58 +0000</pubDate>
</item>
<item>
	<title>Ingvar Hagelund: @ingvarha – that’s me</title>
	<guid>http://ingvar.blog.redpill-linpro.com/2011/12/02/</guid>
	<link>http://ingvar.blog.redpill-linpro.com/2011/12/02/ingvarha-thats-me/</link>
	<description>&lt;p&gt;So, I finally thought I should try this social media thingie, and got myself a twitter account. Who should have thought, after all these years&amp;#8230;&lt;/p&gt;
&lt;p&gt;So if you wonder, &lt;a href=&quot;http://twitter.com/#!/ingvarha&quot;&gt;@ingvarha&lt;/a&gt; &amp;#8211; that&amp;#8217;s me.&lt;/p&gt;</description>
	<pubDate>Fri, 02 Dec 2011 09:38:14 +0000</pubDate>
</item>
<item>
	<title>Lars Strand: Security architectures in telephony systems</title>
	<guid>tag:blogger.com,1999:blog-5601918809570247446.post-3435197545018095772</guid>
	<link>http://blog.larsstrand.org/2011/11/security-architectures-in-telephony.html</link>
	<description>As tradition dictates, before I could &lt;a href=&quot;http://www.mn.uio.no/ifi/forskning/aktuelt/arrangementer/disputaser/2011/LarsStrand.html&quot;&gt;defend my Ph.D. dissertation 22th November&lt;/a&gt;, I had to give a 45 minutes trial lecture. I was given only the title, and had 14 days to prepare. My title was:&lt;br /&gt;&lt;br /&gt;&amp;nbsp; &quot;The development of security architecture in fixed and mobile telephone systems&quot;&lt;br /&gt;&lt;br /&gt;One of the toughest tasks was to interpret the title and limit the scope of the lecture. I discussed with my supervisors and co-researchers and received several tips and relevant references. Then started two intense weeks with study and preparation.&lt;br /&gt;&lt;br /&gt;I was satisfied with the disposition and result, and felt comfortable presenting the lecture.&lt;br /&gt;&lt;br /&gt;For those interested, &lt;a href=&quot;http://www.larsstrand.org/writings/studies/PhD-Trial-LarsStrand.pdf&quot;&gt;the slides can be downloaded here &lt;/a&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/5601918809570247446-3435197545018095772?l=blog.larsstrand.org&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</description>
	<pubDate>Fri, 25 Nov 2011 01:51:00 +0000</pubDate>
	<author>noreply@blogger.com (Lars Strand)</author>
</item>
<item>
	<title>Simeon Simeonovface = tux-default.png: Working with database schemas in SQLAlchemy</title>
	<guid>https://blogs.pichove.org/blackmore/view/711/</guid>
	<link>https://blogs.pichove.org/blackmore/view/711/</link>
	<description>Database schema objects are often neglected when designing systems and applications. One of the main reasons may be the developers' poor understanding of the advantages that come along when using schemas.
&lt;br /&gt;
&lt;br /&gt;A database contains one or more named schemas, which in turn contain tables.
&lt;br /&gt;
&lt;br /&gt;Unlike databases, schemas are not rigidly separated: a user can access objects in any of the schemas in the database he is connected to, if he has privileges to do so. 
&lt;br /&gt;
&lt;br /&gt;Imagine that you are building a system that consists of two logical parts: a book archive and a back office authentication. 
&lt;br /&gt;If both of them require table named 'users', there is a potential problem with name-collision.
&lt;br /&gt;
&lt;br /&gt;Instead of using &quot;smart&quot; / namespaced table names &quot;ba_users, bo_users&quot;, a more elegant solution is to isolate the two logical parts of the system - each in its own schema within the same database.
&lt;br /&gt;
&lt;br /&gt;Schemas are analogous to directories at the operating system level, except that schemas cannot be nested. 
&lt;br /&gt;
&lt;br /&gt;The obvious advantages are:
&lt;br /&gt;
...  &lt;a class=&quot;plinks&quot; href=&quot;http://blogs.pichove.org/blackmore/view/711/&quot;&gt;more&lt;/a&gt;</description>
	<pubDate>Mon, 14 Nov 2011 08:18:55 +0000</pubDate>
</item>
<item>
	<title>Sigvard Lyth: Juleønsker</title>
	<guid>tag:blogger.com,1999:blog-7850101855375546752.post-6556553587280844498</guid>
	<link>http://sigvard-lyth.blogspot.com/2011/11/julensker.html</link>
	<description>&lt;a href=&quot;http://www.amazon.com/Kindle-Wi-Fi-Ink-Display-international/&quot; target=&quot;_blank&quot;&gt;amazon kindle&lt;/a&gt;&amp;nbsp;med en&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/Kindle-Leather-Updated-Design-Keyboard/dp/B004JXVOD6/ref=pd_rhf_se_shvl_tab0_cpp_2&quot; target=&quot;_blank&quot;&gt;slik&lt;/a&gt;&amp;nbsp;eller en&lt;br /&gt;&lt;a href=&quot;http://www.barnesandnoble.com/p/nook-simple-touch-barnes-noble/1102344735&quot; target=&quot;_blank&quot;&gt;Nook&lt;/a&gt;, eller&amp;nbsp;&lt;a href=&quot;http://www.bookeen.com/en/cybook/?id=3&quot; target=&quot;_blank&quot;&gt;cybook&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;disse fyller samme funksjon.&lt;br /&gt;&lt;br /&gt;på dem vil vi gjerne ha masse barnebøker og eventyr sånn at vi kan lese samen (jeg og mathilda.)&lt;br /&gt;&lt;br /&gt;Asus transformer 2 pad, evt,&amp;nbsp;&lt;a href=&quot;http://www.amazon.com/gp/product/B0051VVOB2/ref=famstripe_kf&quot; target=&quot;_blank&quot;&gt;kindle fire&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Til jul ønsker vi oss også bøker:&lt;br /&gt;&lt;br /&gt;Vi har bestemt oss for å samle på Roald Dahl og Astrid Lindgren bøker. Alle sammen.&lt;br /&gt;&amp;nbsp;&lt;a href=&quot;http://www.amazon.co.uk/mn/search/?ref_=nb_sb_noss&amp;amp;url=node%3D341689031&amp;amp;field-keywords=roald%20dahl&amp;amp;x=0&amp;amp;y=0&amp;amp;rd=1&quot; target=&quot;_blank&quot;&gt;her er en samling&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Disse er jo på engelsk, men pappa finner ikke så mye på norsk.dere kan jo ta en titt på&amp;nbsp;&lt;a href=&quot;http://www.digitalbok.no/norsk/skjoennlitteratur/(katnavn)/Barn%20%26%20unge/(id)/JUV000000&quot; target=&quot;_blank&quot;&gt;http://www.digitalbok.no/&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Ganske triste saker dette med norsk forlagsbransje og digitalbøker... Men vi tar også imot fysiske bøker ;)&lt;br /&gt;&lt;br /&gt;Det er alltid plass til mere duplo brikker&lt;br /&gt;&lt;br /&gt;Bok til Pappa:&amp;nbsp;My Friend the Mercenary, av&amp;nbsp;&lt;em&gt;James Brabazon&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;&lt;em&gt;&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/7850101855375546752-6556553587280844498?l=sigvard-lyth.blogspot.com&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</description>
	<pubDate>Sun, 13 Nov 2011 07:24:00 +0000</pubDate>
	<author>noreply@blogger.com (Sigvard)</author>
</item>
<item>
	<title>Magnus Hagander: PGConf.EU 2011 - the speakers and the presentations</title>
	<guid>http://blog.hagander.net/archives/201-guid.html</guid>
	<link>http://blog.hagander.net/archives/201-PGConf.EU-2011-the-speakers-and-the-presentations.html</link>
	<description>&lt;div&gt;
                &lt;p&gt;This part of the feedback is almost turning into a repost year from year. But it's a good thing to be reposting if any, so I'm doing it anyway. To start with, just take a look at these graphs:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://photos.smugmug.com/photos/i-Bs8mPP7/0/O/i-Bs8mPP7.png&quot; width=&quot;400&quot; height=&quot;200&quot; alt=&quot;i-Bs8mPP7.png&quot; /&gt; &lt;img src=&quot;http://photos.smugmug.com/photos/i-LjQPx85/0/O/i-LjQPx85.png&quot; width=&quot;400&quot; height=&quot;200&quot; alt=&quot;i-LjQPx85.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Those are pretty fantastic ratings. A full 84% rated the content quality as 4 or 5, and only 1% rated it as less than 3. That basically comes down to there being no talks of bad quality. This confirms the feeling that we had when we tried to pick out the talks for this year - the number of great submissions where just huge. We had to reject around half the talks submitted, and there were only a few of those that we rejected because we thought they weren't very good. Most were simply rejected because we didn't have the time and space to accept them all.&lt;/p&gt;

&lt;p&gt;The ratings people have given our speakers confirm what we have always thought to be one of the reasons people like the conference - and many other PostgreSQL conferences as well: you get to listen to and talk to the people who &lt;i&gt;really&lt;/i&gt; know what they are talking about. Often because they are the very people who wrote the software in question. A whole &lt;i&gt;96%&lt;/i&gt; of all the ratings gave our speakers a score of 4 or 5 for their knowledge of the topic. And &lt;i&gt;nobody&lt;/i&gt; scored lower than 3. These truly are the experts you get to meet!&lt;/p&gt;

&lt;p&gt;Most of our speakers also scored very high on the Speaker Quality metric. Our top speakers this year were:&lt;/p&gt;



&lt;table&gt;
    &lt;tr&gt;
        &lt;td&gt;&lt;strong&gt;Speaker&lt;/strong&gt;&lt;/td&gt;
        &lt;td&gt;&lt;strong&gt;Rating&lt;/strong&gt;&lt;/td&gt;
        &lt;td&gt;&lt;strong&gt;Vote count&lt;/strong&gt;&lt;/td&gt;
        &lt;td&gt;&lt;strong&gt;Standard deviation&lt;/strong&gt;&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Bruce Momjian&lt;/td&gt;
        &lt;td&gt;4.8&lt;/td&gt;
        &lt;td&gt;31&lt;/td&gt;
        &lt;td&gt;0.4&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Ram Mohan&lt;/td&gt;
        &lt;td&gt;4.7&lt;/td&gt;
        &lt;td&gt;36&lt;/td&gt;
        &lt;td&gt;0.5&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Selena Deckelmann&lt;/td&gt;
        &lt;td&gt;4.7&lt;/td&gt;
        &lt;td&gt;38&lt;/td&gt;
        &lt;td&gt;0.5&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Magnus Hagander&lt;/td&gt;
        &lt;td&gt;4.6&lt;/td&gt;
        &lt;td&gt;52&lt;/td&gt;
        &lt;td&gt;0.6&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Simon Riggs&lt;/td&gt;
        &lt;td&gt;4.6&lt;/td&gt;
        &lt;td&gt;43&lt;/td&gt;
        &lt;td&gt;0.6&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Stephen Frost&lt;/td&gt;
        &lt;td&gt;4.6&lt;/td&gt;
        &lt;td&gt;18&lt;/td&gt;
        &lt;td&gt;0.5&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Peter van Hardenberg&lt;/td&gt;
        &lt;td&gt;4.5&lt;/td&gt;
        &lt;td&gt;11&lt;/td&gt;
        &lt;td&gt;0.7&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Gavin M. Roy&lt;/td&gt;
        &lt;td&gt;4.5&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;0.5&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Greg Smith&lt;/td&gt;
        &lt;td&gt;4.5&lt;/td&gt;
        &lt;td&gt;68&lt;/td&gt;
        &lt;td&gt;0.7&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Harald Armin Massa&lt;/td&gt;
        &lt;td&gt;4.4&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;0.5&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Steve Singer&lt;/td&gt;
        &lt;td&gt;4.4&lt;/td&gt;
        &lt;td&gt;10&lt;/td&gt;
        &lt;td&gt;0.7&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Gianni Ciolli&lt;/td&gt;
        &lt;td&gt;4.4&lt;/td&gt;
        &lt;td&gt;32&lt;/td&gt;
        &lt;td&gt;0.8&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Dave Page&lt;/td&gt;
        &lt;td&gt;4.3&lt;/td&gt;
        &lt;td&gt;25&lt;/td&gt;
        &lt;td&gt;0.8&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Heikki Linnakangas&lt;/td&gt;
        &lt;td&gt;4.3&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;0.9&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Ed Boyajian&lt;/td&gt;
        &lt;td&gt;4.2&lt;/td&gt;
        &lt;td&gt;13&lt;/td&gt;
        &lt;td&gt;1.0&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Marc Balmer&lt;/td&gt;
        &lt;td&gt;4.1&lt;/td&gt;
        &lt;td&gt;12&lt;/td&gt;
        &lt;td&gt;0.7&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
        &lt;td&gt;Dimitri Fontaine&lt;/td&gt;
        &lt;td&gt;4&lt;/td&gt;
        &lt;td&gt;11&lt;/td&gt;
        &lt;td&gt;0.8&lt;/td&gt;
    &lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;This really is the reason why people come to the conference, and keep coming back the next year - our outstanding speakers! Thank you all for showing up this year to give your presentations, and we hope to see you again next year!&lt;/p&gt;

&lt;p&gt;That concludes the posts I'm going to make about pgconf.eu feedback this year. Some of you have already asked about next year, and I'm not going to post any information about the feedback we got there - yet. We are reviewing the feedback we received, and are soon going to start looking for a good venue for next year. We have made the mistake before of announcing a location before we had a venue secured, and we're not going to do that again. We are going to announce it as soon as we know, but that will not be until we have actually decided on an exact venue. But we are absolutely planning to do it again next year, and sometime around the same time of the year. Exactly where we don't know yet...&lt;/p&gt;

 
            &lt;/div&gt;</description>
	<pubDate>Sun, 06 Nov 2011 16:36:00 +0000</pubDate>
</item>
<item>
	<title>Magnus Hagander: PGConf.EU 2011 - the feedback is in</title>
	<guid>http://blog.hagander.net/archives/200-guid.html</guid>
	<link>http://blog.hagander.net/archives/200-PGConf.EU-2011-the-feedback-is-in.html</link>
	<description>&lt;div&gt;
                &lt;p&gt;Almost exactly a week later than what we said, I have finally closed down the feedback system for &lt;a href=&quot;http://2011.pgconf.eu/&quot;&gt;PostgreSQL Conference Europe 2011&lt;/a&gt;. I think we all needed slightly more time than we expected to recover and catch up properly...&lt;/p&gt;

&lt;p&gt;The detailed feedback for each speaker will be sent out during the day today, unless we run into any unforeseen technical issues, and I will try to summarize the conference-wide feedback here. If any particular note that you posted is not referred here, don't worry - we read them all, but there are far too many of them to post here.&lt;/p&gt;

&lt;p&gt;Starting with the conference organization itself and it's venue, I'm really happy to see that we have managed to deliver something that the majority of our attendees really like:&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://photos.smugmug.com/photos/i-kpsz6c3/0/O/i-kpsz6c3.png&quot; width=&quot;400&quot; height=&quot;200&quot; alt=&quot;i-kpsz6c3.png&quot; /&gt; &lt;img src=&quot;http://photos.smugmug.com/photos/i-N5rCKq7/0/O/i-N5rCKq7.png&quot; width=&quot;400&quot; height=&quot;200&quot; alt=&quot;i-N5rCKq7.png&quot; /&gt;&lt;/p&gt;

&lt;p&gt;Not a single vote less than 4, on a scale of 1-5, for the overall impression. And only one below 4 for the programme. I can only say a huge thanks to the big group of volunteers who ran this conference, and made it what it was. Clearly you did a good job!&lt;/p&gt;

 &lt;br /&gt;&lt;a href=&quot;http://blog.hagander.net/archives/200-PGConf.EU-2011-the-feedback-is-in.html#extended&quot;&gt;Continue reading &quot;PGConf.EU 2011 - the feedback is in&quot;&lt;/a&gt;
            &lt;/div&gt;</description>
	<pubDate>Fri, 04 Nov 2011 09:53:00 +0000</pubDate>
</item>
<item>
	<title>Faggruppe PHP: Practising the fundamentals: Function of the week/month</title>
	<guid>http://elephpants.blog.redpill-linpro.com/2011/11/01/</guid>
	<link>http://elephpants.blog.redpill-linpro.com/2011/11/01/tip/</link>
	<description>&lt;p&gt;When you need to see if any of the chars in $chars is in another string.. Whats the simplest way to search for them?&lt;br /&gt;
Hopefully none of the libraries have such functionality, so you need to go &amp;#8220;a bit lower&amp;#8221;.&lt;br /&gt;
The answer is, ofcourse, trivial:&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ;&quot;&gt;
$chars = &amp;quot;xy&amp;quot;;
$string = &amp;quot;the quick brown fox jumps over the lazy dog&amp;quot;;

$found = false;
for($l = 0; $l &amp;lt; strlen($chars); $l++) {
        if (strpos($string, $chars[$l]) !== false) {
                $found = true;
                break;
        }
}
if ($found) {
        /* Do stuff */
}
&lt;/pre&gt;
&lt;p&gt;But hang on. This feels a bit weird. Surely PHP must have a better way of doing this?&lt;br /&gt;
Browsing through the&lt;a href=&quot;http://php.net/strings&quot;&gt; string section in the PHP manual&lt;/a&gt; you&amp;#8217;ll notice PHP has bucketloads of native string functions. If you have a background from other languages, you could even just try and see if PHP has a function of the same name (which quite often it does) that solves the problem.&lt;/p&gt;
&lt;p&gt;And sure enough, it does: &lt;a title=&quot;String Pointer Break / Search a string for any of a set of characters&quot; href=&quot;http://php.net/strpbrk&quot;&gt;strpbrk&lt;/a&gt;!&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ;&quot;&gt;
$chars = &amp;quot;xy&amp;quot;;
$string = &amp;quot;the quick brown fox jumps over the lazy dog&amp;quot;;
if (strpbrk($string, $chars)) {
        /* do stuff */
}
&lt;/pre&gt;
&lt;p&gt;Just give the &amp;#8220;problem&amp;#8221; a second thought before going crazy with your coding, and keep in mind you aren&amp;#8217;t just working with Symfony, Drupal, SugarCRM, WordPress, &amp;#8230; Your good old pal, PHP, is there too.&lt;/p&gt;</description>
	<pubDate>Tue, 01 Nov 2011 19:35:06 +0000</pubDate>
</item>
<item>
	<title>Faggruppe PHP: Responsive Web Design</title>
	<guid>http://elephpants.blog.redpill-linpro.com/2011/10/22/</guid>
	<link>http://elephpants.blog.redpill-linpro.com/2011/10/22/responsive_web_design/</link>
	<description>&lt;p&gt;Which resolution web application should be optimized to, is a question with different answer mainly depended on time when asked. The average screen size and resolution have been growing as a result of technology evolution and falling prices of electronic equipment.&lt;br /&gt;
&lt;img src=&quot;http://wojak.u.bitbit.net/rwd_data/resolution_diagram.png&quot; alt=&quot;Resolution usage, Source: http://www.w3counter.com/&quot; /&gt;&lt;br /&gt;
&lt;em&gt;Resolution usage, Source: http://www.w3counter.com/&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;At the same time mobile devices, like pads and cell phones, with small screens and low resolution, became capable to browse Internet in a more effective way.&lt;br /&gt;
&lt;img src=&quot;http://wojak.u.bitbit.net/rwd_data/mobile_browsing.png&quot; alt=&quot;Mobile browsing, Source: http://gs.statcounter.com&quot; /&gt;&lt;br /&gt;
&lt;em&gt;Mobile browsing, Source: http://gs.statcounter.com&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;So, what to do if I have in my requirements support for IPhone 3GS 3,5” 320&amp;#215;480 and PC screen with high resolution 1920&amp;#215;1080. Somehow I must optimize my application to these two resolutions.&lt;/p&gt;
&lt;p&gt;One of the common solutions is to split the application on view level by implementing two versions of templates. One optimized for high and the other for low resolution devices. It is going to work, but is that really a good solution from design point of view. The main disadvantage is that the application is still not supporting all possible resolutions, is just optimized to high and low one. And of course another issue is maintainability and future compatibility.&lt;/p&gt;
&lt;p&gt;What if instead of optimizing application to a specific resolution, I could support all of them. It is actually not a new idea. It has been ages since I could use size=”100%” attribute in some html tags. By doing this html element is always scaled to the maximum available size. It gives some flexibility. However scaling has limitations, sooner or later I will reach a stress point where scaling is not effective anymore and I would need to change layout by relocation some elements of interface.&lt;/p&gt;
&lt;p&gt;So, to optimize web application to any resolution I would need to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;scale html objects&lt;/li&gt;
&lt;li&gt;dynamically change layout&lt;/li&gt;
&lt;li&gt;scale images&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Generally speaking, I need an ability to alter my application, in order to continually reflect the environmental conditions.&lt;/p&gt;
&lt;p&gt;This is what&lt;strong&gt; “Responsive Web Design” &lt;/strong&gt;stands for.&lt;/p&gt;
&lt;p&gt;In practice responsive web design is an intelligent use of flexible grids, layouts, images and CSS media queries.&lt;/p&gt;
&lt;h1&gt;Media Queries&lt;/h1&gt;
&lt;p&gt;With media queries I&amp;#8217;m able to resolve the first two first problems, I can scale html elements and change layout.&lt;/p&gt;
&lt;p&gt;Since CSS 2.1 there is a possibility to define custom style sheets for different media types.&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
@media print {&lt;br /&gt;
/* style sheet for print goes here */&lt;br /&gt;
}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt; &lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;@media screen {&lt;br /&gt;
/* style sheet for screen goes here */&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;CSS 3 offers an extension called media query, which allows to specify conditions when the specified style sheet will affect user interface.&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
@media screen and (max-width: 640px) {&lt;br /&gt;
/* Window size &amp;lt; 640px */&lt;br /&gt;
}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;@media screen and (max-width: 800px) and (min-width: 640px) {&lt;br /&gt;
/* Window size between 640px and 800px */&lt;br /&gt;
}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;@media screen and (max-width: 1024px) and (min-width: 800px),  (max-width: 640px){&lt;br /&gt;
/* Window size between 1024px and 800px or less than 640px */&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Here is an example of valid media query definitions:&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&amp;lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen and (max-width: 640px)&quot;  href=&quot;shetland.css&quot; /&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;@media screen and (max-width: 640px) {&lt;br /&gt;
/* Window size &amp;lt; 640px */&lt;br /&gt;
}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;@import url(&quot;style.css&quot;) screen and (max-width: 640px);&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;If a web browser does not support media queries css is loaded always without any conditions, this is unwanted behavior. If you want to prevent loading css with media queries on not supported web browsers you can add word “only” before media type:&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
/* add word «only» to be ignored on web browsers with out support */&lt;br /&gt;
@media only screen and (max-width: 640px) {&lt;br /&gt;
/* Window size &amp;lt; 640px */&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;There is quite many criterias available in CSS3, however the two first on the below list are the most usable.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;max-width / min-width&lt;/li&gt;
&lt;li&gt;max-device-width / min-device-width&lt;/li&gt;
&lt;li&gt;orientation (portrait/landscape)&lt;/li&gt;
&lt;li&gt;device-aspect-ratio&lt;/li&gt;
&lt;li&gt;min-resolution / max-resolution&lt;/li&gt;
&lt;li&gt;monochrome&lt;/li&gt;
&lt;li&gt;Min-color-index&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;See &lt;a href=&quot;http://www.w3.org/TR/css3-mediaqueries&quot;&gt;http://www.w3.org/TR/css3-mediaqueries&lt;/a&gt; for more&lt;/p&gt;
&lt;p&gt;CSS Media queries are supported by the following web browsers:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Firefox 3.5+&lt;/li&gt;
&lt;li&gt;Chrome&lt;/li&gt;
&lt;li&gt;Safari&lt;/li&gt;
&lt;li&gt;Opera 9.5+&lt;/li&gt;
&lt;li&gt;Opera Mini&lt;/li&gt;
&lt;li&gt;Android Browser&lt;/li&gt;
&lt;li&gt;Opera Mobile&lt;/li&gt;
&lt;li&gt;IE9+&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;CSS media queries are quite useful if the goal is to affecting mobile devices, it is supported by most of the web browsers used on mobile devices.&lt;br /&gt;
But if the goal is to support older web browsers Java Script comes with help.&lt;/p&gt;
&lt;p&gt;Here is an example of loadCss() and removeCss() methods that can be used to dynamically load and remove css files.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&lt;br /&gt;
/**&lt;br /&gt;
* Load CSS file&lt;br /&gt;
*/&lt;br /&gt;
function loadCss(filename){&lt;br /&gt;
var links = document.getElementsByTagName(&quot;link&quot;);&lt;br /&gt;
for (var i=0; i &amp;lt; links.length; i++) {&lt;br /&gt;
if(links[i].getAttribute(&quot;href&quot;) == filename) return;&lt;br /&gt;
}&lt;br /&gt;
var fr=document.createElement(&quot;link&quot;)&lt;br /&gt;
fr.setAttribute(&quot;rel&quot;, &quot;stylesheet&quot;)&lt;br /&gt;
fr.setAttribute(&quot;type&quot;, &quot;text/css&quot;)&lt;br /&gt;
fr.setAttribute(&quot;id&quot;, filename)&lt;br /&gt;
fr.setAttribute(&quot;href&quot;, filename)&lt;br /&gt;
document.getElementsByTagName(&quot;head&quot;)[0].appendChild(fr)&lt;br /&gt;
}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt;/**&lt;br /&gt;
* Remove CSS file&lt;br /&gt;
*/&lt;br /&gt;
function removeCss(filename) {&lt;br /&gt;
var links = document.getElementsByTagName(&quot;link&quot;);&lt;br /&gt;
var parent = document.getElementsByTagName(&quot;head&quot;)[0];&lt;br /&gt;
for (var i=0; i &amp;lt; links.length; i++) {&lt;br /&gt;
if(links[i].getAttribute(&quot;href&quot;) == filename) {&lt;br /&gt;
parent.removeChild(links[i]);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Adding below code to onResize event will be equal to:  @import url(&amp;#8220;mini.css&amp;#8221;) screen and (max-width: 400px);&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
/* Activate mini.css file if window size is less than 400px */&lt;br /&gt;
if(windowWidth&amp;lt;400) {&lt;br /&gt;
loadCss('mini.css');&lt;br /&gt;
} else {&lt;br /&gt;
removeCss('mini.css');&lt;br /&gt;
}&lt;br /&gt;
&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The above example should in theory by compatible with old web browsers (including IE6) .&lt;/p&gt;
&lt;h1&gt;Images&lt;/h1&gt;
&lt;p&gt;The last of my needs is to scale images, here are few ways how I can do it.&lt;/p&gt;
&lt;h2&gt;Fluid images&lt;/h2&gt;
&lt;p&gt;When user opens my application on a mobile device with small screen and low resolution or changes web browser window size, it might happen that my images will reach a stress point where they will consume more space that the window is able to offer. To avoid this problem I need to scale them proportionally.&lt;/p&gt;
&lt;p&gt;Fortunately there is a CSS property called max-width, if I set to  100% in theory I get all I need. My images will by default be displayed in their original size and will be proportionally scaled when needed.&lt;/p&gt;
&lt;p&gt;But in practice this solution is affected by few problems, the main is that I will need to load oversized images in low resolution which can be a problem for small mobile devices. The other problem is a poor quality of scaled images on IE.&lt;/p&gt;
&lt;h2&gt;Hiding images&lt;/h2&gt;
&lt;p&gt;Another possibility is to have alternative versions of an image, depending on the environment images can be visible or hidden, just like on the example below:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;.small-image {&lt;br /&gt;
display:none;&lt;br /&gt;
}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;@media only screen and (max-width: 600px) {&lt;br /&gt;
.default-image { display:none; }&lt;br /&gt;
.small-image { display:inline; }&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;&amp;lt;img class=&quot;default-image&quot; src=&quot;img1.jpg&quot;&amp;gt;&lt;br /&gt;
&amp;lt;img class=&quot;small-image&quot; src=&quot;img2.jpg&quot;&amp;gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;It works quite well, if windows size is below 600px (this is the stress point) small-image gets attribute display:inline; and default-image gets display:none;&lt;br /&gt;
Nice solution, compatible with all common web browsers, however  IE always loads both images even if one of them will never be showed and it is not quite clean code.&lt;/p&gt;
&lt;h2&gt;&amp;#8220;Content&amp;#8221; attribute&lt;/h2&gt;
&lt;p&gt;It is possible to show images with combination of content property and url value, see example below:&lt;br /&gt;
&lt;code&gt;@media screen and (max-width: 600px) {&lt;br /&gt;
.image1:before {&lt;br /&gt;
content:url(img2.jpg);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
@media screen and (min-width: 600px){&lt;br /&gt;
.image1:before {&lt;br /&gt;
content:url(img1.jpg);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;span class=&quot;image1&quot; /&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;code&gt; &lt;/code&gt;&lt;br /&gt;
But still, this code isn&amp;#8217;t clean and is not compatible with some common web browsers.&lt;/p&gt;
&lt;h2&gt;Java Script way&lt;/h2&gt;
&lt;p&gt;JS come here with help as well.&lt;/p&gt;
&lt;p&gt;One of the possibilities is to set a cookie with screen size information.&lt;br /&gt;
&lt;code&gt;document.cookie = &quot;screenWidth=&quot; + screen.width;&lt;/code&gt;&lt;br /&gt;
and then serve all images through media content, which will send the right image version depending on screenWidth value:&lt;br /&gt;
&lt;code&gt;&amp;lt;img src=&quot;media/?test.jpg&quot;&amp;gt;&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;CSS 3 way&lt;/h2&gt;
&lt;p&gt;In the future I&amp;#8217;m expecting below code to be supported in all CSS3 compatible web browsers,  for now only Opera supports this syntax partially.&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
&amp;lt;img src=&quot;test.jpg&quot;&lt;br /&gt;
img-400px=&quot;test-400px.jpg&quot;&lt;br /&gt;
&amp;gt;&lt;br /&gt;
@media (min-device-width:400px) {&lt;br /&gt;
img[img-400px] {&lt;br /&gt;
content: url(attr(img-400px));&lt;br /&gt;
}&lt;br /&gt;
}&lt;/code&gt;&lt;/p&gt;</description>
	<pubDate>Sat, 22 Oct 2011 18:47:22 +0000</pubDate>
</item>
<item>
	<title>Faggruppe PHP: Practising the fundamentals: Staying in touch</title>
	<guid>http://elephpants.blog.redpill-linpro.com/2011/10/20/</guid>
	<link>http://elephpants.blog.redpill-linpro.com/2011/10/20/stay-in-touch/</link>
	<description>&lt;p&gt;With the recent massive flood of frameworks, libraries and toolkits on the market these days it is easy to forget that underneath it all is the good old, plain and simple, PHP with all its kinks, quirks, and huuge set of builtin functionality.&lt;/p&gt;
&lt;p&gt;PHP has vast amount of &lt;a title=&quot;Extension reference&quot; href=&quot;http://php.net/funcref&quot; target=&quot;_blank&quot;&gt;extensions&lt;/a&gt; which solve all sort of problems. And if PHP doesn&amp;#8217;t have it built-in, we have an impressive amount of additional extensions both on &lt;a title=&quot;PECL Extensions&quot; href=&quot;http://pecl.php.net/packages.php&quot; target=&quot;_blank&quot;&gt;pecl&lt;/a&gt; and now recently more and more on github.&lt;br /&gt;
There is a high chance that someone else has been in your shoes already and solved the problem, so it is worth looking around over the horizon and see if the problem has been solved already.&lt;/p&gt;
&lt;p&gt;For some reason the current practice seems to be the &amp;#8220;&lt;a title=&quot;Ruby On Rails&quot; href=&quot;http://rubyonrails.org/&quot; target=&quot;_blank&quot;&gt;RoR&lt;/a&gt;&amp;#8221; idiocy where &amp;#8220;RoR developers&amp;#8221; barely even know that there is this Ruby some miles down the stack. PHP has hit this &amp;#8220;stepping stone&amp;#8221; already with WordPress, Drupal and even Symfony and that is a weird and scary thought. Remembering &amp;#8220;where you came from&amp;#8221; is an important fact to remember, even for those who specialize in specific products. Looking at how other projects work, comparing notes, work ethics, features and functionality is also very important. Getting different perspective and knowledge is how we can improve our solutions and work more efficiently. If your specific product doesn&amp;#8217;t have native support for something, why not look at a different framework/library/cms/toolkit/.. even PHP extensions?&lt;/p&gt;
&lt;p&gt;As June mentioned earlier, going &amp;#8216;back home&amp;#8217; and checkout the &lt;a href=&quot;http://php.net/manual&quot; target=&quot;_blank&quot;&gt;PHP manual&lt;/a&gt; pages is generally a good idea. Things change, manual pages are updated, improved, added, and you have different perspective, other problems to solve and so on. Even though you believe you know all the basics, you still need to practice them, and that includes browsing the manual from time to time, again and again &amp;#8211; no matter which project it is.&lt;/p&gt;
&lt;p&gt;So what is the best way to stay in touch? Kept up2date with new ways and offerings? New solutions to the same problem? &lt;a href=&quot;http://php.net/get-involved&quot; target=&quot;_blank&quot;&gt;Get involved&lt;/a&gt;!&lt;/p&gt;
&lt;p&gt;By far the best way is to get involved with the project you are using. Even just silently idling on the &lt;a href=&quot;http://php.net/mailing-lists&quot; target=&quot;_blank&quot;&gt;mailinglists&lt;/a&gt; and read the subjects. Subscribing to the commit lists is a fantastic way to see precisly what is going on and see which direction the project is taking. Who knows, after a while you may spot something the others didn&amp;#8217;t. Get an idea for a killer feature. Shed a light on different perspective the others didn&amp;#8217;t think of. After a while hanging on the lists you&amp;#8217;ll get a feeling for how the project works, and hopefully start chiming in. Give your 2cents, and who knows &amp;#8211; even cook up a patch or two.&lt;/p&gt;</description>
	<pubDate>Thu, 20 Oct 2011 15:37:46 +0000</pubDate>
</item>
<item>
	<title>Erik Inge Bolsø: Terra firma</title>
	<guid>tag:blogger.com,1999:blog-660024223227219722.post-1189157706696280486</guid>
	<link>http://useofwords.blogspot.com/2011/10/terra-firma.html</link>
	<description>Ok.&lt;br /&gt;&lt;br /&gt;Jeg har i dag oppdatert firmware - på ei mus.&lt;br /&gt;&lt;br /&gt;Når ble de lure nok til å trenge firmware? Antagelig sammen med led/optikk-variantene.&lt;br /&gt;&lt;br /&gt;Og hva hindrer dem fra å gro et virtuelt keyboard om natta og bedrive bruteforcing av passordet mitt? Ingenting jeg vet om.&lt;br /&gt;&lt;br /&gt;(Ok, feedback er et problem. Men det fins usb skjermkort... :p)&lt;div class=&quot;blogger-post-footer&quot;&gt;&lt;img width=&quot;1&quot; height=&quot;1&quot; src=&quot;https://blogger.googleusercontent.com/tracker/660024223227219722-1189157706696280486?l=useofwords.blogspot.com&quot; alt=&quot;&quot; /&gt;&lt;/div&gt;</description>
	<pubDate>Mon, 17 Oct 2011 19:14:00 +0000</pubDate>
	<author>noreply@blogger.com (Erik Inge Bolsø)</author>
</item>
<item>
	<title>Faggruppe PHP: Optimising a PHP (symfony 1.x/Doctrine 1.x) application</title>
	<guid>http://elephpants.blog.redpill-linpro.com/2011/10/07/</guid>
	<link>http://elephpants.blog.redpill-linpro.com/2011/10/07/optimising_a_php_symfony_doctrine_application-2/</link>
	<description>&lt;h2&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Whilst everyone is buzzing and creating fancy new Symfony2/Doctrine 2 applications, and perhaps even a shift to new frameworks/no frameworks, a great deal of us are still maintaining legacy apps and will be for some time to come. As these apps grow, we occasionally need to look back and scream at our old code and wonder why we didn&amp;#8217;t make it more scalable or use neat optimisation tricks back when it was first conceived. The fact is, many of these &amp;#8220;tricks&amp;#8221; are not necessary at the time for a virgin app, and we need to develop code that is relevant to the task at hand.&lt;/p&gt;
&lt;p&gt;That said, being aware of some of the case studies I will present to you now may help you to optimise old code, but may also allow you to think twice when you are working with new code &amp;#8211; as the things I will describe do not take too much time to implement first time round.&lt;/p&gt;
&lt;h2&gt;Case study: Working with large resultsets and array_merge&lt;/h2&gt;
&lt;p&gt;In my sample application, the database contained many different types of organisation stored in different tables, and due to the structure of the data and the criteria for each organisation, there was no easy way to retrieve several organisations at once using pure SQL and joins (well, no convenient way). The solution is relatively simple, one query per organisation then combine the results, in this case as we go along:&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ;&quot;&gt;
$membershipClasses = array(&amp;quot;Entity1&amp;quot;, &amp;quot;Entity2&amp;quot;, &amp;quot;Entity3&amp;quot;, &amp;quot;Entity4&amp;quot;, &amp;quot;Entity5&amp;quot;);
    $results = array();
    foreach ($membershipClasses as $joinedTable)
    {
      $query = $this-&amp;gt;createQuery()-&amp;gt;from(&amp;quot;TablePrefix&amp;quot;.$joinedTable.&amp;quot; t&amp;quot;);
      // Lots of differing criteria based on which class we were dealing with
      ...

      $results = array_merge($query-&amp;gt;execute(array(), $hydration), $results);
    }
&lt;/pre&gt;
&lt;p&gt;This logic was used to generate a report with approximately 50,000 rows, used 1.2GB of internal memory and took around 20 minutes to complete &amp;#8211; often failing or bringing the system to a halt.&lt;/p&gt;
&lt;p&gt;One optimisation used in this case (many more are surely possible but lets focus on one) involves the last line &amp;#8211; using PHP&amp;#8217;s array_merge function. Simply switching this out to use a simple array traversal brought the execution time down to under 2 minutes, however there was no change in memory usage.&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ;&quot;&gt;

$theseResults = $query-&amp;gt;execute(array(), $hydration);
foreach ($theseResults as $aResult)
{
  $results[] = $aResult;
}
&lt;/pre&gt;
&lt;p&gt;Why is this so much faster? And why can&amp;#8217;t we use += instead?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The &amp;#8220;problem&amp;#8221; with array_merge, is that even though it discards numeric keys, it still has to *check* them all first, which is a lot of overhead on 50,000 rows. We can&amp;#8217;t use += in this case either, because that would respect the numeric keys which would start from 0 each time, and therefore the results would not &amp;#8220;stack&amp;#8221; as intended, unless we tell Doctrine to index the results with some unique key.&lt;/p&gt;
&lt;p&gt;Why it takes *so* much longer is a bit of a mystery to me. I&amp;#8217;ve looked at the c code behind it (ext/standard/array.c) and it&amp;#8217;s, well quite frankly voodoo.&lt;/p&gt;
&lt;h2&gt;Case study: Limiting results&lt;/h2&gt;
&lt;p&gt;Something that was &amp;#8220;fixed&amp;#8221; (read: removed) in Doctrine 2 was the ability to limit results returned from queries, at least the &amp;#8220;magic&amp;#8221; part of it. The problem with limiting hydrated results is that you need to know exactly how many rows each sub-tree will contain before you can limit the query as a whole. Imagine a person with many addresses, and you want an array limited to 5 people &amp;#8211; you can&amp;#8217;t list add &amp;#8220;LIMIT 5&amp;#8243; to the end of the query, because when this is hydrated you will most likely end up with one or 2 people, the second of whom may not have all their addresses, because you&amp;#8217;ve told your database manager to return 5 *rows*, it has no idea how these rows relate to your model.&lt;/p&gt;
&lt;p&gt;In Doctrine 1, adding a limit clause would cause all sorts of magic to happen, the resulting query ending up as a collection of complex subqueries each with their own limit clause, the more joins you introduced, and the more levels of join, the more complicated it becomes. First level joining is not so bad, but joining several levels deep soon starts to get heavy, and your execution speed will suffer for it. Couple this with a large resultset and you will see the smoke drifting from the server room in no time.&lt;/p&gt;
&lt;p&gt;So, what&amp;#8217;s the solution? Well, this one is not so clear cut &amp;#8211; you have to experiment. Sometimes, doing it the &amp;#8220;magic&amp;#8221; way will work just fine, and is totally acceptable, but when the query becomes &amp;#8220;heavy&amp;#8221; you have a few options:&lt;/p&gt;
&lt;h3&gt;Work out your subset first&lt;/h3&gt;
&lt;p&gt;This is the default Doctrine 2 approach, it&amp;#8217;s quite simple &amp;#8211; you use one query to get all the ids of the subset of top level elements, then pass these IDs to another query in a &amp;#8220;WHERE IN&amp;#8221; clause. When you look at the resulting SQL, it can be quite scary, especially if you are dealing with many results &amp;#8211; you can easily be saying &amp;#8220;WHERE IN (1,2,3,4&amp;#8230;..9999999999)&amp;#8221;. Most dbms will handle this surprisingly well, as long as you are using the primary keys, so experiment with it and it might be the way to go.&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ;&quot;&gt;

if ($limit)
{
  $subQuery = $this-&amp;gt;createQuery(&amp;quot;foo&amp;quot;)
                   -&amp;gt;select(&amp;quot;foo.id&amp;quot;)
                   -&amp;gt; //
                   -&amp;gt;limit(50);
  $ids      = $subQuery-&amp;gt;execute(array(), DOCTRINE_CORE::HYDRATE_SINGLE_SCALAR);
  $query-&amp;gt;andWhereIn(&amp;quot;cf.id&amp;quot;, $ids);
}
&lt;/pre&gt;
&lt;p&gt;Note the use of &amp;#8220;single scalar hydration&amp;#8221; &amp;#8211; we have no need for more than this (to be really picky could go straight to PDO here but for consistency this is ok). In this case, the single scalar hydration will give us a resulting array of raw IDs, which is exactly what we need to pass to the main query.&lt;/p&gt;
&lt;h3&gt;Make your own subquery&lt;/h3&gt;
&lt;p&gt;A variation on the above is to embed the &amp;#8220;ID sucking&amp;#8221; query into your main query, some database engines may prefer this style, but I have not noticed any significant performance gain or loss doing this so prefer the above option as it&amp;#8217;s cleaner in the PHP code.&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ;&quot;&gt;

$query-&amp;gt;whereIn('SELECT id FROM my_other_table WHERE blah LIMIT 50');
&lt;/pre&gt;
&lt;p&gt;In a perfect world, this is the kind of thing Doctrine could have done instead of the subquery magic, but there are so many factors to consider here that I can understand why they did not go down that route.&lt;/p&gt;
&lt;h3&gt;Stick with the magic, but simplify&lt;/h3&gt;
&lt;p&gt;It is also possible to continue using the magic, but greatly improve performance by simplifying. Remove all those second+ level joins and use separate queries to get hold of the data you need. How often have you added a chain of joins just to get one snippet of data from the last node? Scrap all the joins and make a new query later where you can pass in all the IDs from your main query and get the data you need. Now you don&amp;#8217;t need a limit clause, because you are asking for exactly the data you need in the first place.&lt;/p&gt;
&lt;h2&gt;Start with the fastest hydration mode and work upwards&lt;/h2&gt;
&lt;p&gt;This one I can&amp;#8217;t stress enough &amp;#8211; an ORM such as Doctrine is there to give you the tools you need when you need them, but it is often the case that applications are built with all the overhead and magic just because it can be, or because it&amp;#8217;s the default behaviour. Stop. Look at what data you *actually* need, and especially ask yourself if you need objects in your results. Perhaps you are retrieving all your users and listing them with their profile data, but you are hydrating them as objects because you need some custom functions you&amp;#8217;ve written, classic examples are getAge() or getFullName() which are derived from other fields. If this is the only reason you are object hydrating, consider something like this:&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ;&quot;&gt;

class User
{
  function getAge()
  {
    return self::getAgeFromDOB($this[&amp;quot;dob&amp;quot;]);
  }

  function getFullName()
  {
    return self::getFullNameFromUserArray($this);
  }

  public static function getAgeFromDOB($dob)
  {
    $dob = strtotime($dob);

    $year_diff  = date(&amp;quot;Y&amp;quot;) - date(&amp;quot;Y&amp;quot;, $dob);
    $month_diff = date(&amp;quot;m&amp;quot;) - date(&amp;quot;m&amp;quot;, $dob);
    $day_diff   = date(&amp;quot;d&amp;quot;) - date(&amp;quot;d&amp;quot;, $dob);

    if ($month_diff &amp;amp;lt; 0 || ($month_diff == 0 &amp;amp;amp;&amp;amp;amp; $day_diff &amp;amp;lt; 0))
    {
      $year_diff--;
    }
    return $year_diff;
  }

  public static function getFullNameFromUserArray($user)
  {
    return $user[&amp;amp;quot;first_name&amp;amp;quot;] . &amp;amp;quot; &amp;amp;quot; . $user[&amp;amp;quot;first_name&amp;amp;quot;];
  }
}
&lt;/pre&gt;
&lt;p&gt;In this example, we&amp;#8217;ve kept the sideways compatibility of the getFullName function with array/object hydration, so it will work whether an object is passed or an array (sanity checking needed of course). This method could be expanded to support more &amp;#8220;raw&amp;#8221; hydration methods also. Now in our templates, we can just use:&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ;&quot;&gt;
&amp;lt;li&amp;gt;&amp;lt;?php echo $user[&amp;quot;username&amp;quot;]; ?&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;?php echo $user[&amp;quot;Addresses&amp;quot;][0][&amp;quot;city&amp;quot;]; ?&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;?php echo User::getFullNameFromUserArray($user); ?&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;?php echo User::getAgeFromDOB($user[&amp;quot;dob&amp;quot;]); ?&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;...&amp;lt;/li&amp;gt;
&lt;/pre&gt;
&lt;p&gt;This can massively speed up your application if you have long lists or are generally dealing with lots of data, especially data than spans several levels.&lt;/p&gt;
&lt;p&gt;Lets also take a second to consider the super fast hydration methods, if we are really struggling for resources (perhaps working with large downloadable reports) and we can live with slightly less friendly arrays of data, scalar hydration can save the day. Shifting to scalar hydration means we lose the ability to later instantly switch to object hydration due to the alternate syntax and lack of nesting, but if we are considering scalar hydration in the first place we are probably in a situation where object hydration will never be practical.&lt;/p&gt;
&lt;pre class=&quot;brush: php; title: ;&quot;&gt;
&amp;lt;li&amp;gt;&amp;lt;?php echo $results[&amp;quot;u_username&amp;quot;]; ?&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;?php echo $results[&amp;quot;a_city&amp;quot;]; ?&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;?php echo User::getFullNameFromUserArray(array(&amp;quot;first_name&amp;quot; =&amp;gt; $results[&amp;quot;u_first_name&amp;quot;], &amp;quot;last_name&amp;quot; =&amp;gt; $[&amp;quot;u_last_name&amp;quot;])); ?&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;&amp;lt;?php echo User::getAgeFromDOB($results[&amp;quot;u_dob&amp;quot;]); ?&amp;gt;&amp;lt;/li&amp;gt;
&amp;lt;li&amp;gt;...&amp;lt;/li&amp;gt;
&lt;/pre&gt;
&lt;p&gt;I could go on and on but I hope these points have given you some food for thought!&lt;/p&gt;</description>
	<pubDate>Fri, 07 Oct 2011 13:35:12 +0000</pubDate>
</item>
<item>
	<title>Magnus Hagander: Stockholm PUG finally off the ground</title>
	<guid>http://blog.hagander.net/archives/199-guid.html</guid>
	<link>http://blog.hagander.net/archives/199-Stockholm-PUG-finally-off-the-ground.html</link>
	<description>&lt;div&gt;
                &lt;p&gt;Last night, we &lt;i&gt;finally&lt;/i&gt; got a PostgreSQL User Group in Stockholm started. We've discussed this for &lt;i&gt;years&lt;/i&gt;, but never got around to making it actually happen. Well, with big thanks to Claes who took care of the main organization tasks, we finally did - and I'll happily declare it a big success. It was our first meeting, and we actually didn't promote it very well (so bad that at least one fairly well-connected PostgreSQL community guy didn't realize it was on until registration was already closed - I'm sure others missed it too), and we still managed to get more than 30 people there! Awesome!&lt;/p&gt;

&lt;p&gt;Hopefully we can keep the numbers at this level. For now, we are planning to meet around once every three months or so, which means we'll be looking at the next meeting sometime in January. Exact date, and also location, yet to be decided upon.&lt;/p&gt;

&lt;p&gt;Claes is supposed to be setting us up with a website (we have plenty of domains already...) and an associated mailinglist, and I guess a registered IRC channel as well. Hopefully soon. But given that he set us up with a room, a projector, pizza and beer last night (thanks, btw, and thanks to Glue for picking up the bill), I think we can give him a couple of hours before we start complaining...&lt;/p&gt;

&lt;p&gt;So - see you at the next Stockholm PUG meeting!&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;http://mha.smugmug.com/photos/i-D9twsjx/0/M/i-D9twsjx-M.jpg&quot; width=&quot;600&quot; height=&quot;450&quot; alt=&quot;i-D9twsjx-M.jpg&quot; /&gt;&lt;/p&gt;

 
            &lt;/div&gt;</description>
	<pubDate>Wed, 05 Oct 2011 08:54:00 +0000</pubDate>
</item>
<item>
	<title>Kacper Wysocki: oh noes, o cert my *sniff* cert</title>
	<guid>http://kacper.blog.redpill-linpro.com/archives/360</guid>
	<link>http://kacper.blog.redpill-linpro.com/archives/360</link>
	<description>&lt;p&gt;&lt;img src=&quot;http://comotion.delta9.pl/i/certfail4-papersplease.png&quot; alt=&quot;papieren bitte&quot; align=&quot;right&quot; /&gt;I&amp;#8217;m not going to tell you about &lt;a href=&quot;http://www.darkreading.com/authentication/167901072/security/attacks-breaches/231601790/diginotar-hacked-out-of-business.html&quot;&gt;DigiNotar, whose file of bankruptcy&lt;/a&gt; this month held shock for no one after recently having &lt;a href=&quot;https://www.securelist.com/en/blog/208193107/More_on_DigiNotar&quot;&gt;lost the keys to the grand vault&lt;/a&gt;, in which the government held much stock. Though I have many comments upon the sophistication of the player that so thoroughly owned the most trusted agencies of the digital age&amp;#8230;. &lt;/p&gt;
&lt;p&gt;The cracker hardly needed them skillz, considering it has been a challenge to keep that whole corrupt industry accountable. The trouble with the central authority system is that even if only one of the keys is compromised, the system is broken and gives no assurances whatsoever. No warning bells either. Just a sweet silent man in the middle, passing along all the best parts to his lover. &lt;/p&gt;
&lt;p&gt;It&amp;#8217;s not a joke for the &lt;a href=&quot;http://www.eff.org/deeplinks/2011/09/post-mortem-iranian-diginotar-attack&quot;&gt;300,000+ people who documentedly had their emails and facepalms compromised&lt;/a&gt;. We thought he was kind to give &lt;a href=&quot;http://pastebin.com/85WV10EL&quot;&gt;an interview&lt;/a&gt; and we wait in awe for his next move.&lt;/p&gt;
&lt;p&gt;I&amp;#8217;m not going to mention the fatal flaws in certificate revocation that became embarrassingly apparent when the damage was done.&lt;br /&gt;
What&amp;#8217;s hardly the matter since this kind of thing is bound to crop up, that &lt;a href=&quot;http://threatpost.com/en_us/blogs/new-attack-breaks-confidentiality-model-ssl-allows-theft-encrypted-cookies-091611&quot;&gt;hole in TLS&lt;/a&gt; was deemed unexploitable &amp;#8211; now there&amp;#8217;s a Titanic if I ever saw one. Un sinkable. Too fat to die.&lt;br /&gt;
&lt;img src=&quot;http://comotion.delta9.pl/i/certfail1.png&quot; alt=&quot;cert failure&quot; align=&quot;top&quot; /&gt;&lt;/p&gt;
&lt;p&gt;SSL is an open book for those who dare to look, and it&amp;#8217;s got more than a &lt;a href=&quot;http://bugs.debian.org/cgi-bin/pkgreport.cgi?pkg=openssl;dist=unstable&quot;&gt;couple old bugs&lt;/a&gt;. It&amp;#8217;s okay though, we can patch it, they will say. Dare to look the other way!&lt;br /&gt;
Not that you need those anyway, since there are &lt;a href=&quot;https://www.youtube.com/watch?v=gXXx-Uafps4&quot;&gt;some &lt;/a&gt; really &lt;a href=&quot;http://www.securitytube.net/video/157&quot;&gt;nice sslsnarfing techniques&lt;/a&gt; out there that entirely forgo attacks on SSL as &amp;#8220;too inefficient&amp;#8221;. &lt;/p&gt;
&lt;p&gt;But I say nay! Unacceptable. There is another way.. and we&amp;#8217;re already doing it! We sign our own signatures and we back each other&amp;#8217;s signatures.&lt;br /&gt;
Now that&amp;#8217;s business, something that the companies on your CA trusted list were painfully aware of when they laid down the law of the code and put themselves on the trust list. Yet still &lt;a href=&quot;http://cacert.org&quot;&gt;ca-cert&lt;/a&gt; is not on your trust list, and warning bells fly off on some of the most trustworthy sites- self-signed ones.&lt;/p&gt;
&lt;p&gt;Just don&amp;#8217;t ask them why or how, or anything that isn&amp;#8217;t directly relevant. Do you even know what is on your trust list? You might just be surprised at what you can find.&lt;/p&gt;
&lt;p&gt;# ls -al /etc/ssl/certs | wc -l&lt;br /&gt;
479&lt;/p&gt;
&lt;p&gt;How many of these do you trust? How many of these should you trust? I&amp;#8217;ll tell you:&lt;strong&gt; *none*.&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;We should not be adding static lists of central signing authorities to our systems. This is a brittle and dangerous system. We knew this, but hackers have now thankfully demonstrated it.&lt;br /&gt;
A better way is for every person (and by extension every browser) to keep their own list of signing certs, and to exchange these certs with their friends (automagically, if you like). Your friends lists can come out of a social network, any social network, and it will mean that any site that has been vetted by one or more of your friends will likely be safe for you to use as well. It&amp;#8217;s even better than that, you can check certs from multiple friends and detect discrepancies.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;http://comotion.delta9.pl/i/padlock-green.png&quot; alt=&quot;green padlock&quot; align=&quot;left&quot; /&gt;&lt;br /&gt;
That, my friends, is called the Web of Trust, and is a design that is heading in the right direction. &lt;a href=&quot;http://convergence.io&quot;&gt;convergence.io&lt;/a&gt; is doing something similar already to a Firefox near you, while GPG has worked like this for three decades! &lt;/p&gt;
&lt;p&gt;It has to be simple. It has to be very simple. And it has to be chemically free of one word: &amp;#8216;central&amp;#8217;.&lt;/p&gt;
&lt;p&gt;One real easy way to do this on linux would be using git and signed manifests. I already do this in &lt;a href=&quot;http://github.com/comotion/gone&quot;&gt;gone&lt;/a&gt; to assure that only files on a manifest signed by a trusted key get installed.&lt;/p&gt;</description>
	<pubDate>Mon, 26 Sep 2011 12:26:26 +0000</pubDate>
</item>

</channel>
</rss>

