Database administration for fun and profit

Populate a DB2 database table with pseudo-random BLOBs

How do we quickly populate a database table with arbitrary LOB data? This question often comes up when we need to generate some data for performance testing or tuning. We can, of course, write a little utility in our favourite programming language, such as Java or Perl.

The Java approach can be found in DB2 documentation, for example, here. It shows a stored procedure, but we can see how this idea can be used in a standalone application as well. All we need to do now is write the code, compile it hoping there are no errors (as if!), and wait while a few hundred thousand of LOBs get inserted over a JDBC connection. Fun!

But is there a quicker way? How about three simple Bash commands? Read More

Security Bulletin: DB2 Escalation of Privilege Vulnerability

A vulnerability has been found in the Tivoli Monitoring Agent (ITMA) that ships with DB2 9.5 and 9.7. It allows a local user to run arbitrary code with elevated (root) privileges.

If you are using ITMA, take a note of how to apply the workaround: http://www.ibm.com/support/docview.wss?uid=swg21576372&myns=swgimgmt&mynp=OCSSEPGG&mync=E

Apparently, the Response File Generator utility, db2rspgn, is also affected: http://osvdb.org/show/osvdb/76456

A perl one-liner to extract all URLs from an HTML document

Just in case I ever forget how I did it… I was trying to download some 40 page PDF brochure from a government web site – I wanted to print it out and read it off-line. However, it was cleverly split into 20 different PDFs – no doubt for convenience. Instead of spending 20 minutes clicking on those various links and printing 20 document fragments, I chose to spend twice that time trying to automate the process. And here it is, in all its glory:

curl -s "http://www.datori.org" \
| perl -n -e 'chomp;s/.*?(?:(?i)href)="([^"]+)".*?(?:$|(?=(?i)href))/$1\n/xg and print'

The “thing” downloads the specified page and extracts all linked URLs from it, as indicated by the “href” tags. You’ve got to appreciate the enormity of perl…