Subject: bug#37369: Getting network-manager-openconnect to work

From: "pelzflorian (Florian Pelz)" <[email-masked]>
Date: Tue, 10 Sep 2019 13:21:20 +0200

On Tue, Sep 10, 2019 at 11:57:11AM +0200, Divan Santana wrote:
> Hi Guix,
> 
> I'm glad openconnect and network-manager-openconnect are now in Guix!
> 
> It would be nice to get it to work via network-manager, though I suppose
> it's not essential.
> 
> Using openconnect directly works for me.
> 
> $ sudo openconnect vpn.somewhere.com
> 
> Trying to get it work via network-manager gives an error like so:
> 
> $ sudo nmcli con up vpn-fnb --ask
> Error: openconnect failed: Could not find "openconnect" binary
> A password is required to connect to 'vpn-fnb'.
> Gateway (vpn.secrets.gateway):
> 
> Even though my services configuration has this vpn-plugins set.
> 
> (modify-services %desktop-services
>                  (network-manager-service-type
>                   config => (network-manager-configuration
>                              (inherit config)
>                              (dns "dnsmasq")
>                              (vpn-plugins (list network-manager-openconnect))
>                              ))
> 
> Anyone else seen this?

Cc’ing [email-masked]

I suspect something like the attached patch would help (and expand the
closure of network-manager to always include openconnect).

To test, follow section “Building from Git” from the manual or Laura’s
video 04-packaging-part-one.webm from
<https://lists.gnu.org/archive/html/guix-devel/2019-07/msg00249.html>,
but after the initial clone command, do

  git apply the-attached.patch

Then after make, do

  sudo -E ./pre-inst-env guix system reconfigure /etc/config.scm

(or whatever your configuration file is called).  I cannot test right
now and have never used openconnect.  It is quite possible I made a
mistake.

Regards,
Florian
>From 8de7675a2dc2c1385d312e35136f8fa9eb4f9825 Mon Sep 17 00:00:00 2001
From: Florian Pelz <[email-masked]>
Date: Tue, 10 Sep 2019 12:59:19 +0200
Subject: [PATCH] gnu: network-manager: Enable openconnect helper.

* gnu/packages/gnome.scm (network-manager): Add openconnect input.
Patch source to use it instead of searching /usr/bin.
---
 gnu/packages/gnome.scm | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/gnu/packages/gnome.scm b/gnu/packages/gnome.scm
index efe5206e53..a6ea09d8f6 100644
--- a/gnu/packages/gnome.scm
+++ b/gnu/packages/gnome.scm
@@ -5372,6 +5372,13 @@ users.")
                (("src/devices/tests/test-lldp") " ")
                (("src/tests/test-route-manager-linux") " "))
              #t))
+         (add-after 'unpack 'patch-source
+           (lambda* (#:key inputs #:allow-other-keys)
+             (begin
+               (substitute* "clients/common/nm-vpn-helpers.c"
+                 (("\\\"/usr/sbin/openconnect\\\"")
+                  (string-append openconnect "\"/bin/openconnect\"")))
+               #t)))
          (add-after 'unpack 'delete-failing-tests
            (lambda _
              ;; FIXME: These four tests fail for unknown reasons.
@@ -5434,6 +5441,7 @@ users.")
        ("libsoup" ,libsoup)
        ("modem-manager" ,modem-manager)
        ("newt" ,newt)                       ;for the 'nmtui' console interface
+       ("openconnect" ,openconnect)
        ("polkit" ,polkit)
        ("ppp" ,ppp)
        ("readline" ,readline)
-- 
2.23.0