diff --git a/blog/2020/03/16/appgate-sdp-on-arch-linux/index.html b/blog/2020/03/16/appgate-sdp-on-arch-linux/index.html index bb44f29d..61d05e93 100644 --- a/blog/2020/03/16/appgate-sdp-on-arch-linux/index.html +++ b/blog/2020/03/16/appgate-sdp-on-arch-linux/index.html @@ -151,81 +151,81 @@ As of right now, the latest AUR is 4.2.2-1.

These steps highlight how to get it working with Python3.8 by making a 1 line modification to AppGate source code.

Packaging

We already know the community package is currently out of date, so let’s clone it:

-
git clone https://aur.archlinux.org/appgate-sdp.git
-cd appgate-sdp
+
git clone https://aur.archlinux.org/appgate-sdp.git
+cd appgate-sdp
 

You’ll likely notice that the version is not what we want, so let’s modify the PKGBUILD to the following:

-
# Maintainer: Pawel Mosakowski <pawel at mosakowski dot net>
-pkgname=appgate-sdp
-conflicts=('appgate-sdp-headless')
-pkgver=4.3.2
-_download_pkgver=4.3
-pkgrel=1
-epoch=
-pkgdesc="Software Defined Perimeter - GUI client"
-arch=('x86_64')
-url="https://www.cyxtera.com/essential-defense/appgate-sdp/support"
-license=('custom')
-# dependecies calculated by namcap
-depends=('gconf' 'libsecret' 'gtk3' 'python' 'nss' 'libxss' 'nodejs' 'dnsmasq')
-source=("https://sdpdownloads.cyxtera.com/AppGate-SDP-${_download_pkgver}/clients/${pkgname}_${pkgver}_amd64.deb"
-        "appgatedriver.service")
-options=(staticlibs)
-prepare() {
+
# Maintainer: Pawel Mosakowski <pawel at mosakowski dot net>
+pkgname=appgate-sdp
+conflicts=('appgate-sdp-headless')
+pkgver=4.3.2
+_download_pkgver=4.3
+pkgrel=1
+epoch=
+pkgdesc="Software Defined Perimeter - GUI client"
+arch=('x86_64')
+url="https://www.cyxtera.com/essential-defense/appgate-sdp/support"
+license=('custom')
+# dependecies calculated by namcap
+depends=('gconf' 'libsecret' 'gtk3' 'python' 'nss' 'libxss' 'nodejs' 'dnsmasq')
+source=("https://sdpdownloads.cyxtera.com/AppGate-SDP-${_download_pkgver}/clients/${pkgname}_${pkgver}_amd64.deb"
+        "appgatedriver.service")
+options=(staticlibs)
+prepare() {
     tar -xf data.tar.xz
-}
-package() {
-    cp -dpr "${srcdir}"/{etc,lib,opt,usr} "${pkgdir}"
-    mv -v "$pkgdir/lib/systemd/system" "$pkgdir/usr/lib/systemd/"
-    rm -vrf "$pkgdir/lib"
-    cp -v "$srcdir/appgatedriver.service" "$pkgdir/usr/lib/systemd/system/appgatedriver.service"
-    mkdir -vp "$pkgdir/usr/share/licenses/appgate-sdp"
-    cp -v "$pkgdir/usr/share/doc/appgate/copyright" "$pkgdir/usr/share/licenses/appgate-sdp"
-    cp -v "$pkgdir/usr/share/doc/appgate/LICENSE.github" "$pkgdir/usr/share/licenses/appgate-sdp"
-    cp -v "$pkgdir/usr/share/doc/appgate/LICENSES.chromium.html.bz2" "$pkgdir/usr/share/licenses/appgate-sdp"
-}
-md5sums=('17101aac7623c06d5fbb95f50cf3dbdc'
-         '002644116e20b2d79fdb36b7677ab4cf')
+}
+package() {
+    cp -dpr "${srcdir}"/{etc,lib,opt,usr} "${pkgdir}"
+    mv -v "$pkgdir/lib/systemd/system" "$pkgdir/usr/lib/systemd/"
+    rm -vrf "$pkgdir/lib"
+    cp -v "$srcdir/appgatedriver.service" "$pkgdir/usr/lib/systemd/system/appgatedriver.service"
+    mkdir -vp "$pkgdir/usr/share/licenses/appgate-sdp"
+    cp -v "$pkgdir/usr/share/doc/appgate/copyright" "$pkgdir/usr/share/licenses/appgate-sdp"
+    cp -v "$pkgdir/usr/share/doc/appgate/LICENSE.github" "$pkgdir/usr/share/licenses/appgate-sdp"
+    cp -v "$pkgdir/usr/share/doc/appgate/LICENSES.chromium.html.bz2" "$pkgdir/usr/share/licenses/appgate-sdp"
+}
+md5sums=('17101aac7623c06d5fbb95f50cf3dbdc'
+         '002644116e20b2d79fdb36b7677ab4cf')
 
 

Let’s first make sure we have some dependencies. If you do not have yay, check it out.

-
yay -S dnsmasq gconf
+
yay -S dnsmasq gconf
 

Now, let’s install it:

-
makepkg -si
+
makepkg -si
 

Running the client

Ok, let’s run the client by executing appgate.

It complains about not being able to connect.

Easy fix:

-
sudo systemctl start appgatedriver.service
+
sudo systemctl start appgatedriver.service
 

Now we should be connected… but DNS is not working?

Fixing the DNS

Running resolvectl should display that something is not right.

Why is the DNS not being set by appgate?

-
$ head -3 /opt/appgate/linux/set_dns
-#!/usr/bin/env python3
-'''
-This is used to set and unset the DNS.
+
$ head -3 /opt/appgate/linux/set_dns
+#!/usr/bin/env python3
+'''
+This is used to set and unset the DNS.
 

It seems like python3 is required for the DNS setting to happen. Let’s try to run it.

-
$ sudo /opt/appgate/linux/set_dns
-/opt/appgate/linux/set_dns:88: SyntaxWarning: "is" with a literal. Did you mean "=="?
-  servers = [( socket.AF_INET if x.version is 4 else socket.AF_INET6, map(int, x.packed)) for x in servers]
-Traceback (most recent call last):
-  File "/opt/appgate/linux/set_dns", line 30, in <module>
+
$ sudo /opt/appgate/linux/set_dns
+/opt/appgate/linux/set_dns:88: SyntaxWarning: "is" with a literal. Did you mean "=="?
+  servers = [( socket.AF_INET if x.version is 4 else socket.AF_INET6, map(int, x.packed)) for x in servers]
+Traceback (most recent call last):
+  File "/opt/appgate/linux/set_dns", line 30, in <module>
     import dbus
-ModuleNotFoundError: No module named 'dbus'
+ModuleNotFoundError: No module named 'dbus'
 

Ok, let’s install it:

-
$ sudo python3.8 -m pip install dbus-python
+
$ sudo python3.8 -m pip install dbus-python
 

Will it work now? Not yet. There’s another issue:

-
$ sudo /opt/appgate/linux/set_dns
-/opt/appgate/linux/set_dns:88: SyntaxWarning: "is" with a literal. Did you mean "=="?
-  servers = [( socket.AF_INET if x.version is 4 else socket.AF_INET6, map(int, x.packed)) for x in servers]
-module 'platform' has no attribute 'linux_distribution'
+
$ sudo /opt/appgate/linux/set_dns
+/opt/appgate/linux/set_dns:88: SyntaxWarning: "is" with a literal. Did you mean "=="?
+  servers = [( socket.AF_INET if x.version is 4 else socket.AF_INET6, map(int, x.packed)) for x in servers]
+module 'platform' has no attribute 'linux_distribution'
 

This is a breaking change in Python3.8.

So what is calling platform.linux_distribution?

Let’s search for it:

-
$ sudo grep -r 'linux_distribution' /opt/appgate/linux/
-/opt/appgate/linux/nm.py:    if platform.linux_distribution()[0] != 'Fedora':
+
$ sudo grep -r 'linux_distribution' /opt/appgate/linux/
+/opt/appgate/linux/nm.py:    if platform.linux_distribution()[0] != 'Fedora':
 

Aha! So this is in the local AppGate source code. This should be an easy fix. Let’s just replace this line with:

-
if True: # Since we are not using Fedora :)
+
if True: # Since we are not using Fedora :)
 

Wrapping up

It turns out there are breaking changes in Python3.8.

The docs say Deprecated since version 3.5, will be removed in version 3.8: See alternative like the distro package.

diff --git a/blog/2021/09/08/why-i-threw-out-my-dotfiles/index.html b/blog/2021/09/08/why-i-threw-out-my-dotfiles/index.html index 66fdf500..f9c61abe 100644 --- a/blog/2021/09/08/why-i-threw-out-my-dotfiles/index.html +++ b/blog/2021/09/08/why-i-threw-out-my-dotfiles/index.html @@ -159,25 +159,25 @@ lrwxr-xr-x 73 root 31 Dec 1969 /run/current-system/sw/bin/dig -> /nix/store/

⚠️ If you run this on your main machine, make sure you backup your configuration files first. home-manager is pretty good about not overwriting existing configuration, but it is better to have a backup! Alternatively, you could test this out on a VM or cloud instance.

The first thing you should do is install nix:

-
curl -L https://nixos.org/nix/install | sh
+
curl -L https://nixos.org/nix/install | sh
 

It’s not a good idea to curl and execute files from the internet (without verifying integrity), so you might want to download the install script first and take a peak before executing it!

Open up a new shell in your terminal and running nix should work. If not, run . ~/.nix-profile/etc/profile.d/nix.sh

Now, install home-manager:

-
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
+
nix-channel --add https://github.com/nix-community/home-manager/archive/master.tar.gz home-manager
 nix-channel --update
-nix-shell '<home-manager>' -A install
+nix-shell '<home-manager>' -A install
 

You should see a wave of /nix/store/* paths being displayed on your screen.

Now, to start off with a basic configuration, open up ~/.config/nixpkgs/home.nix in the editor of your choice and paste this in (you will want to change userName and homeDirectory):

-
{ config, pkgs, ... }:
+
{ config, pkgs, ... }:
 
 {
-  programs.home-manager.enable = true;
+  programs.home-manager.enable = true;
 
-  home = {
-    username = "dave";
-    homeDirectory = "/home/dave";
-    stateVersion = "21.11";
-    packages = with pkgs; [
+  home = {
+    username = "dave";
+    homeDirectory = "/home/dave";
+    stateVersion = "21.11";
+    packages = with pkgs; [
       bind
       exa
       fd
@@ -185,83 +185,83 @@ nix-shell '<home-manager>' -A ins
     ];
   };
 
-  programs = {
+  programs = {
 
-    git = {
-      enable = true;
-      aliases = {
-        aa = "add -A .";
-        br = "branch";
-        c = "commit -S";
-        ca = "commit -S --amend";
-        cb = "checkout -b";
-        co = "checkout";
-        d = "diff";
-        l =
-          "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit";
+    git = {
+      enable = true;
+      aliases = {
+        aa = "add -A .";
+        br = "branch";
+        c = "commit -S";
+        ca = "commit -S --amend";
+        cb = "checkout -b";
+        co = "checkout";
+        d = "diff";
+        l =
+          "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit";
       };
 
-      delta = {
-        enable = true;
+      delta = {
+        enable = true;
 
-        options = {
-          features = "line-numbers decorations";
-          whitespace-error-style = "22 reverse";
-          plus-style = "green bold ul '#198214'";
-          decorations = {
-            commit-decoration-style = "bold yellow box ul";
-            file-style = "bold yellow ul";
-            file-decoration-style = "none";
+        options = {
+          features = "line-numbers decorations";
+          whitespace-error-style = "22 reverse";
+          plus-style = "green bold ul '#198214'";
+          decorations = {
+            commit-decoration-style = "bold yellow box ul";
+            file-style = "bold yellow ul";
+            file-decoration-style = "none";
           };
         };
       };
 
-      extraConfig = {
-        push = { default = "current"; };
-        pull = { rebase = true; };
+      extraConfig = {
+        push = { default = "current"; };
+        pull = { rebase = true; };
       };
 
     };
 
-    starship = {
-      enable = true;
-      enableZshIntegration = true;
+    starship = {
+      enable = true;
+      enableZshIntegration = true;
 
-      settings = {
-        add_newline = false;
-        scan_timeout = 10;
+      settings = {
+        add_newline = false;
+        scan_timeout = 10;
       };
     };
 
-    zsh = {
-      enable = true;
-      enableAutosuggestions = true;
-      enableSyntaxHighlighting = true;
-      history.size = 1000000;
+    zsh = {
+      enable = true;
+      enableAutosuggestions = true;
+      enableSyntaxHighlighting = true;
+      history.size = 1000000;
 
-      localVariables = {
-        CASE_SENSITIVE = "true";
-        DISABLE_UNTRACKED_FILES_DIRTY = "true";
-        RPROMPT = ""; # override because macOS defaults to filepath
-        ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE = "fg=#838383,underline";
-        ZSH_DISABLE_COMPFIX = "true";
+      localVariables = {
+        CASE_SENSITIVE = "true";
+        DISABLE_UNTRACKED_FILES_DIRTY = "true";
+        RPROMPT = ""; # override because macOS defaults to filepath
+        ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE = "fg=#838383,underline";
+        ZSH_DISABLE_COMPFIX = "true";
       };
 
-      initExtra = ''
-        export PAGER=less
-      '';
+      initExtra = ''
+        export PAGER=less
+      '';
 
-      shellAliases = {
-        ".." = "cd ..";
-        grep = "rg --smart-case";
-        ls = "exa -la --git";
+      shellAliases = {
+        ".." = "cd ..";
+        grep = "rg --smart-case";
+        ls = "exa -la --git";
       };
 
-      "oh-my-zsh" = {
-        enable = true;
-        plugins = [
-          "gitfast"
-          "last-working-dir"
+      "oh-my-zsh" = {
+        enable = true;
+        plugins = [
+          "gitfast"
+          "last-working-dir"
         ];
       };