Disconnecting from PPTP VPN – no network

I’m working with a client that has a PPTP VPN connection to get into their network. After disconnecting from the VPN, I would loose my connectivity to everything.
The routing table looked good, i.e. no default gateway or similar pointing to an incorrect gateway. Did some googling but couldn’t find any solution for it.

A workaround would be to disconnect and then connect to my LAN again. So after some more research I found out that you can create scripts in /etc/NetworkManager/dispatcher.d. These scripts will be feeded with two arguments: interface and state.

Create /etc/NetworkManager/dispatcher.d/80-ppp-vpn-down with the following contents:

#!/usr/bin/env bash

##
# The environment contains more information about the interface and the connection:
# DEVICE_IFACE - The interface name of the control interface of the device

main() {
        local interface="$1"
        local event="$2"

        if [[ "${interface}" =~ "ppp"* && "${event}" == "vpn-down" ]]; then
                local connection
                connection="$(nmcli -t -f NAME,DEVICE connection show --active | awk -F: '/'"${DEVICE_IFACE}"'/ {print $1}')" || return 1

                nmcli connection down id "${connection}"
                nmcli connection up id "${connection}"
        fi
}

main "$@"
exit $?

Don’t forget to make it executable:

chmod +x /etc/NetworkManager/dispatcher.d/80-ppp-vpn-down

Now when disconnecting from a PPTP connection, your connection used on the control interface will be toggled and you’ll have network connectivity again.

Ubuntu 18.04: Bad password, when trying to unlock LUKS encrypted device

I upgraded my two laptops from Ubuntu 17.10 to Ubuntu 18.04.

The first laptop (my backup) had two failed packages (shim-signed and grub-efi-amd64-signed). Since I don’t have secured boot enabled, I just removed these packages and everything was fine.

The second laptop (my primary) had one failed package (ca-certificates), which seemed a little less problematic then the other two packages, so I rebooted.
When asked for the passphrase to unlock my encrypted root device, I just got “bad password or options?”. Enter panic mode.

A google search showed a lot of `cryptsetup` problems in 18.04. However none seems to be the same problem as I had.

I tried booting a live usb-stick to unlock and mount the device there, but once again: “bad password”.

Gave it up for a couple of days when I finally got around to try with a 16.04 live usb-stick, same problem though.

For some reason, I tried entering the password with the characters that it should’ve been if I was using US layout.
Say my password contained = (swedish layout), I replaced those characters with ) (the character that the same key in US layout will give) and it actually worked! Note that I always changed to Swedish layout on the live system.

So it seemed like the upgrade actually changed my passphrase. There has probably been a bug that cryptsetup passphrases has been entered with US layout, and a the passphrase prompt it has always been US layout, and now it is fixed, so the passphrase prompt is with what the layout used in the system. Hence the old passphrase is not working. Re-reading this answer (and the comments that has been added since I read it the first time) actually makes a lot more sense now.

After successfully unlocking my root device, I added a “new” passphrase and removed the old one (actually a bunch of reboots inbetween to make sure the passphrases worked):

sudo cryptsetup luksAddKey /dev/sdXY
sudo cryptsetup luksRemoveKey /dev/sdXY

DisplayLink and Ubuntu 17.04 (intel)

I had a problem with DisplayLink drivers on my Dell Precision 5510 (XPS 15) after upgrading to Ubuntu 17.04.

The monitors connected to the DisplayLink device was enabled and identified, but the screens stayed all black.

Of course, there’s a solution. I found this evdi issue, containing a solution.

Create the file (and directory) /etc/X11/xorg.conf.d/20-intel.conf, with the content:

Section "Device"
  Identifier "Intel Graphics"
  Driver "Intel"
  Option "AccelMethod" "sna"
  Option "TearFree" "true"
  Option "TripleBuffer" "true"
  Option "MigrationHeuristic" "greedy"
  Option "Tiling" "true"
  Option "Pageflip" "true"
  Option "ExaNoComposite" "false"
  Option "Tiling" "true"
  Option "Pageflip" "true"
EndSection

Credit goes to github/ajbogh.

Make Thunderbird great again!

I have many times tried finding a modern replacement for Thunderbird, but it always ends without success.

There’s Nylas Mail, Hiri etc, but there has always been some needed feature (for me) missing.

Then I heard about Monterail, which basically is a functional theme based on a Thunderbird mock up. And just recently an Arc (theme) integration for Thunderbird has been released.

The two together makes Thunderbird quite pleasant to look at.

Dual boot Linux and Windows – BIOS system time incorrect

I, unfortunately, have to dual boot to Windows once and a while, due to requirements where I currently have an assignment.

What I’ve noticed and that really grind my gears, is that when booting Windows after I have been running Linux the BIOS System time is incorrect by -2 hours.

After searching for information how to solve this, I found a thread on the Microsoft forum with a user that had the same problem and learned something new:

Windows uses BIOS time to hold ‘local’ time (UTC+offset+daylight savings according to the time zone used) and Linux uses BIOS time to hold Universal Time (UTC).

That got me to the ever so good Arch Linux Wiki (this is an area that I think Ubuntu has become weaker in; updated and good information in a community wiki. Don’t get me wrong, I love askubuntu.com).

Open Windows Powershell and run it as administrator:

reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\TimeZoneInformation" /v RealTimeIsUniversal /d 1 /t REG_DWORD /f

If this does not solve it, try changing REG_DWORD to REG_QWORD.