Sunday, February 8, 2015

PC-BSD: Running QT applications from within a Warden "Ports" jail (for X11 applications)

I've been running PC-BSD 10.1.1 with great success. However, there are a few "bleeding edge" applications that I want to compile and run; most notably, Anki, my favorite flash-carding application / learning aid.

I started out by creating a "Ports Jail (insecure, allows running X applications)," which automatically downloads and installs the FreeBSD ports tree (a large library of applications that can be compiled to run on a FreeBSD system). I installed a few packages (binary, precompiled programs), including the ssh daemon and sudo.

From there, I descended into the ports tree in /usr/ports/games/anki, and then I executed a recursive make command, to automatically compile everything
/usr/bin/nice -n 19 make DISABLE_VULNERABILITIES=yes -DBATCH
This worked swimmingly, and a subsequent make install successfully integrated Anki into my jailed environment. However, a few issues remain:

  1. X11 over SSH:  ssh -Y username@ports_jail does NOT forward X11 correctly. Launching any X11 program results in the following message:
    X11 connection rejected because of wrong authentication.
    Error: Can't open display: localhost:11.0
    If you're SSHing in via a shell within your computer's X11 environment, this can be rectified with:
    export DISPLAY=":0.0"
    However, this doesn't really fix the ssh X11 forwarding problem, and I'm still at an impasse.
  2. QT doesn't render correctly. When launched without environmental variables, I get the following results:
    • A number of X11 errors when launching from the command line:

      QNativeImage: Unable to attach to shared memory segment.
      X Error: BadDrawable (invalid Pixmap or Window parameter) 9
      Major opcode: 62 (X_CopyArea)
        Resource id: 0x0
      X Error: BadDrawable (invalid Pixmap or Window parameter) 9
      Major opcode: 62 (X_CopyArea)
      Resource id: 0x0
    • The initial screen is rendered improperly: gray windows, weird artifacts. 
    To solve, modify the QT_GRAPHICSSYSTEM environment variable:
    QT_GRAPHICSSYSTEM=native anki
I'm going to post my experiences to the PC-BSD forums, and see if some folks have some ideas about how to fix the issue.

Saturday, January 17, 2015

PC-BSD: FreeBSD 10.0 -> 10.1 upgrade using freebsd-update

I was having problems getting pc-sysupdate to work properly. For some reason, purging the pkg cache and forcing updates through pkg update -f resulted in package size mismatches, so I decided to try to upgrade my PC-BSD system manually. It took a while, but I think I figured out how to get it going.

First, I created a boot environment for my new upgrade:

beadm create fbsd_10.1_update
beadm mount fbsd_10.1_update /.updateStage


Next, I performed the freebsd-update on this new boot environment:

freebsd-update -b /.updateStage fetch
freebsd-update -b /.updateStage install


Eventually, the script finished its business. I then switched to the new environment:

beadm umount fbsd_10.1_update
beadm activate fbsd_10.1_update


All done, right? Here's what happened next. I rebooted the machine, and was dropped to a grub> prompt. What? beadm didn't handle grub gracefully?

Ugh. After digging, I figured out how to manhandle grub to boot my ZFS partition. The first trick, to save time, is to set an environment variable to the root filesystem. This saves a LOT of typing. Use "tab" completion to figure out what filesystems are available to you:

set P=(hd0,msdos2)/ROOT/fbsd_10.1_update/@/


Now, we can tell grub to load all the things (tab completion works with the $P expansion! brilliant!):

kfreebsd $P/boot/kernel/kernel
kfreebsd_loadenv $P/boot/device.hints
kfreebsd_module_elf $P/boot/kernel/opensolaris.ko
kfreebsd_module_elf $P/boot/kernel/zfs.ko
kfreebsd_module $P/boot/zfs/zpool.cache type=/boot/zfs/zpool.cache
set kFreeBSD.vfs.root.mountfrom=zfs:tank/ROOT/fbsd_10.1_update


boot


Voila! System working again. But I still need to repair GRUB... after the system boots into the correct boot environment:

grub-mkconfig -o /boot/grub/grub.cfg

Unfortunately, that last step didn't actually fix my grub installation. I'm puzzled as to how to fix it. But for now, at least I can get the machine running.

Monday, January 5, 2015

Reward dollars: Macy's, Nike, Brooks Brother's, and Barnes & Noble gift cards 10% off on American Express rewards portal until 1/15

Get the most out of your Blue Cash cards. American Express has select gift cards on sale now:
Barnes & Noble Gift Card
Barnes & Noble Gift Card
Sale: 45.00 Reward Dollars
Sale: 45.00 Reward Dollars

Sale: 45.00 Reward Dollars
Sale: 45.00 Reward Dollars
Offer ends 01/15/2015 or while supplies last

Thursday, December 18, 2014

 is Wingdings for →

Today, when importing a Windows document from one of my colleagues, I kept finding Unicode character F0E0 boxes everywhere. These should simply be replaced with the rightwards arrow character (→).

Monday, August 11, 2014

How to download Echo360 videos

TL;DR for techies: Change your web browser’s user agent to an Android phone; e.g.: Mozilla/5.0 (Android 4.2; rv:19.0) Gecko/20121129 Firefox/19.0

Steps to install User Agent Switcher


This first section only needs to be done once. there are other ways of modifying the User-Agent: string in Firefox, but I find this to be most convenient. Similar extensions are available for Chrome.

  1. Install Firefox (if you don’t have it already)
  2. Install the User Agent Switcher extension (click on the link)
  3. Download the User Agent List. Save this XML file to somewhere convenient.
  4. Press the Alt key to temporarily display Firefox’ old-style menus (or go to this tutorial to enable them permanently, which is my preferred style).
  5. Use the tools menu. Tools ➔ Default User Agent ➔ Edit User Agents
  6. Click the Import… button, and choose the User Agent List XML file that you downloaded in the previous step.

Once that’s all installed, go to Sakai. Before you navigate to the Echo360 website to download lectures, you must change your user agent.

Navigate Echo360 and pretend to be an Android device


  1. Hit the Alt key
  2. Using the revealed menu, select Tools ➔ Default User Agent ➔ Mobile Devices ➔ OS ➔ Android ➔ Android 4.2 Firefox 19.0.
  3. Click on the Echo360 website.
  4. Select a video to download. Right-click on it and choose to download the video.
  5. Remember to change your user agent back through Tools ➔ Android 4.2 Firefox 19.0 ➔ Default User Agent.

The end result of this process is that the video will be displayed with a HTML5 tag, and will be downloadable as an mp4 file.
 
UPDATE:
austynguo has another method that works by using an Apple user agent:
For all the University of Sydney people out there I've written a quick guide on how to download recordings by using a web browser (Chrome) to find the necessary links and VLC player to capture and export the stream. Not sure if this method works with other university streaming systems though.

It's a little involved but works well at the moment.

Find the guide here: https://github.com/austynguo/echo360-downloader

Sunday, July 13, 2014

Enigmail: Key not found or not valid? Install pinentry

I recently upgraded PC-BSD from scratch, and was dismayed to find that Enigmail no longer worked correctly and provided me with a rather misleading dialog box:
Send operation aborted. Key 0xABCDEF01 not found or not valid. The (sub-)key might have expired.
After bashing my head against the wall for a little while, I finally had the bright idea of trying to encrypt a message from the command line:
baitisj@foo:/tmp$ gpg -e -r adele@gnupp.de -a -s
gpg-agent[10380]: can't connect to the PIN entry module: IPC connect call failed
gpg-agent[10380]: command get_passphrase failed: No pinentry
...
baitisj@foo:/tmp$ sudo pkg install pinentry-gtk2
Victory!