Some notes about Group Policy

I’m not a Windows admin.  However managing a Windows network has become my responsibility.  These are some useful things I learned today.  Most notably that gpresult is an indispensable tool for debugging GPO problems.  The /scope option can be used to specify the scope as the computer level but you MUST choose “run as administator” to do it.  Even logging in as an admin won’t work.

WMI filters are an intriguing way to set criteria for your GPO.  I found some examples online that would allow me to select based on 32 vs 64 bit architectures.  I needed this because our AV installer has two different installers based on CPU architecture.

gpupdate /force is how you update a client policy w/o (necessarily) rebooting.

Posted in Uncategorized | Leave a comment

Ncurses Appearance Via Putty

I ran into a situation where I wanted to run `make menuconfig` via putty.  All of the graphical characters looked wrong.  Apparently this is a deficiency in Putty handling vt100 commands.  There is a workaround.  Setting the evar below will tell ncurses not to use the ‘alternate character set’.  It’s not perfect but it’s an improvement.

`export NCURSES_NO_UTF8_ACS=1`



Posted in Uncategorized | Leave a comment

Mounting Partition from Disk Image

I’ve long known that you can mount a filesystem image using a loop device.  What I did not know until today is that you can mount partitions from a disk image using a loop device!

  1. Insert the loop module specifying the max_part parameter.  (e.g. #modprobe -v loop max_part=63)
  2. Use losetup to setup the loop devices (e.g. # losetup -f /path/to/disk/image.dd)
  3. You will not have block devices for the partitions inside your disk image (/dev/loop0p1, etc).
Posted in Uncategorized | Leave a comment

DD Progress

Sometimes you’ll want to know how far along ‘dd’ is in a copy. It’s not hard to do but it’s hard to remember. If you send a USR1 signal to the ‘dd’ process it will print the current progress. Here’s an example:

# dd if=image.dd of=/dev/sdb bs=$((1024*1024))&
# pgrep -l dd
2 kthreadd
4478 dd
# kill -USER1 4478
5122433+0 records in
5122433+0 records out
2622685696 bytes (2.6 GB) copied, 8161.5 s, 321 kB/s
Posted in Geek, Tips | 1 Comment

Serverside PUT Using PHP

It is possible to do an HTTP put, server side, in PHP without using a PECL extension or curl. This code is far from perfect but it shows how to accomplish the task.

function httpPut($url, $data, $optional_headers = null)
    $params = array('http' => array(
                        'method' => 'PUT',
                        'header'  => 'Content-Type: application/octet-stream',
                        'content' => $data
    if ($optional_headers !== null) {
        $params['http']['header'] = $optional_headers;
    $ctx = stream_context_create($params);
    $fp = @fopen($url, 'rb', false, $ctx);
    if (!$fp) {
        throw new Exception("Problem with $url, $php_errormsg");
    $response = @stream_get_contents($fp);
    if ($response === false) {
        throw new Exception("Problem reading data from $url, $php_errormsg");
    return $response;
Posted in Code, Geek | Leave a comment

No, It's Not OK

The code below is broken in a subtle way. There’s no way to know that ptr is aligned on a boundary that your CPU architecture may require. And I don’t think there is any way to know until runtime. Oh, C, I love thee and loath thee!

printf("%u", *(unsigned int *)ptr);
Posted in Code, Geek | Leave a comment

Mixing Static and Dynamic Linkage

Using GNU tools you can mix static and dynamic linkage using:

gcc foo.o -Wl,-Bstatic -lstatic1 -lstatic2 -Wl,-Bdynamic -ldynamic1

Just be careful. The way the linker resolves symbols in static libraries is not what you might expect. It would be nice if it made one big symbol table and resolved everything. But it doesn’t work that way. Instead it reads from left to right. You may have to carefully arrange the order of libraries specified in your Makefile. You’ll want to arrange it so your static libraries with the most unresolved symbols appear to the left.

Posted in Geek, Tips | Leave a comment