[PATCH 0/1] OAuth2 for mbsync

  • Open
  • quality assurance status badge
Details
4 participants
  • dan
  • Ludovic Courtès
  • (
  • peter
Owner
unassigned
Submitted by
peter
Severity
normal
Merged with
P
P
peter wrote on 4 Nov 2022 18:56
(address . guix-patches@gnu.org)(name . Peter Polidoro)(address . peter@polidoro.io)
cover.1667583886.git.peter@polidoro.io
From: Peter Polidoro <peter@polidoro.io>

I am trying to get OAuth2 working for mbsync so I can check an email account
that has discontinued basic authorization.

Following these steps:

I am at the point of needing the xoauth2 sasl plugin to make mbsync work with
the XOAUTH2 AuthMech. Perhaps that is already a part of Guix, but I was unable
to find it.

Here is an implementation of the xoaut2 sasl plugin that I attempted to package:

It seems to compile correctly, but I was unsure of how to do the configuration
in order to make it install into the proper location. It defaults into
installing it to:
/usr/lib/sasl2

Perhaps it instead needs to go into the /lib/sasl2 directory within the
cyrus-sasl package, but I do not know how to specify that in this package's
configuration.

I assume that if cyrus-sasl is able to detect and use this plugin then it will
have the ability to use XOAUTH2 making mbsync work correctly, but that would
have to be tested to make sure more configuration is not needed.

Peter Polidoro (1):
gnu: Add cyrus-sasl-xoauth2.

gnu/packages/cyrus-sasl.scm | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)

--
2.38.0
D
(no subject)
(address . 59018@debbugs.gnu.org)
87a6533hv7.fsf@dan.games
He peter,

Thanks for the work. Did you just forget to submit the patch
file?

--
dan
-----BEGIN PGP SIGNATURE-----

iQJABAEBCAAqFiEENywBMxcNCHYJ4/aIR1rKxpmiJ40FAmNoI9AMHGlAZGFuLmdh
bWVzAAoJEEdaysaZoieNImEQAL7coNvp6lmPfcL4J4xNKlmZqHjpEwqdmGc76Mph
n9r4k9VHWSHOEBYgIz/xFtbvss70kjwm+oJGD8I4KkKYilhSLWvtfT6PXYLd0a2d
HTkNhaPlJkYjz2JAW3ZPfrxe2ZTtF4PM37CLpnqYlzu7R07i2vE5mCRJeHxTH8nh
3klsRlLhCkqXqbHYTMB2SPyIjIfCA6fhFloZNx0ixZLtyhfETzQseUNFfq3i7Unw
ZdvrZ+yNQras3F+DBMT1Uz7I4Dh9nIpxUYHanCX8aV0gI2AESqOvCX25iPEgi/Vp
OwyhCp7NONxTCAiJs+Ob5Ne8GuVwFi4oQlsKOOmBQF16MYwgY3cNCwS2we9ANMrb
rC6MrL5C8udP31DDeGHaHxzgtd3KDCjJDlyks5aQ90IgGYCrraji7DmUzwrvF+Nh
d7vouX0A3zSaShZT7pU7NXjzhNiwdA5CjvwkrULOS4vjdAzaYqv9X7y7FR84z+R1
6eUGsBOGPrcvL5okA3gemZnMmAjIGIpGag99R9iDSJEu2Qo0Vs7kbjV+ttA/xM2t
uCEjGZ0szEpj3juVAzKayFoDBtCBA58TbkVYPIEIEbgN8LNqXpdp7il1g3fA38MI
F9P9Iv3KhXsMEiwNWiny9Yh4jVfq+wCbAFvTotYygRTQmR5BQKH6EVVf75Rp8uCJ
Bbf2
=0Alu
-----END PGP SIGNATURE-----

(
CO5IY2QE6ME5.32ZB12BJ5I3PZ@guix-framework
On Sun Nov 6, 2022 at 9:12 PM GMT, dan wrote:
Toggle quote (3 lines)
> Thanks for the work. Did you just forget to submit the patch
> file?

Funny. The patch seems to have appeared in my inbox, but not on mumi's or debbugs' UI...

-- (
D
(name . ()(address . paren@disroot.org)(address . 59018@debbugs.gnu.org)
d4ef9728-6e5c-441d-b27a-1ad2587d64c3@dan.games
Nov 7, 2022 5:18:25 AM ( <paren@disroot.org>:

Toggle quote (11 lines)
> On Sun Nov 6, 2022 at 9:12 PM GMT, dan wrote:
>> Thanks for the work.  Did you just forget to submit the patch
>> file?
>
> Funny. The patch seems to have appeared in my inbox, but not on mumi's
> or debbugs' UI...
>
>     -- (
> Funny. The patch seems to have appeared in my inbox, but not on mumi's
> or debbugs' UI...

My bad, it's actually #59019
L
L
Ludovic Courtès wrote on 15 Nov 2022 11:42
control message for bug #59019
(address . control@debbugs.gnu.org)
87wn7wmrcm.fsf@gnu.org
merge 59019 59018
quit
L
L
Ludovic Courtès wrote on 15 Nov 2022 11:49
Re: bug#59018: [PATCH 0/1] OAuth2 for mbsync
(address . peter@polidoro.io)(address . 59018@debbugs.gnu.org)
87sfikmr0x.fsf@gnu.org
Hi,

peter@polidoro.io skribis:

Toggle quote (9 lines)
> It seems to compile correctly, but I was unsure of how to do the configuration
> in order to make it install into the proper location. It defaults into
> installing it to:
> /usr/lib/sasl2
>
> Perhaps it instead needs to go into the /lib/sasl2 directory within the
> cyrus-sasl package, but I do not know how to specify that in this package's
> configuration.

Adding files to another package is not possible.

Packages usually have a search path environment variable for plugins. I
don’t see one for cyrus-sasl (I just grepped for “getenv” so I might
have overlooked it). The “Guix way” would be to have cyrus-sasl honor,
say, $CYRUS_SASL_PLUGIN_PATH and look for plugins in those directories,
add a search path to the package¹, and have the plugin installed in
$prefix/lib/sasl2 like you did.

Could you check whether cyrus-sasl already has such a mechanism, or add
one (possibly discussing with upstream), and send updated patches?

Nitpick:

Toggle quote (2 lines)
> + (description "XOAUTH2 mechanism plugin for cyrus-sasl.")

P
P
Peter Polidoro wrote on 15 Nov 2022 15:55
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 59018@debbugs.gnu.org)
87k03wtfeu.fsf@polidoro.io
Hi,

Ludovic Courtès <ludo@gnu.org> writes:

Toggle quote (17 lines)
> Packages usually have a search path environment variable for
> plugins. I
> don’t see one for cyrus-sasl (I just grepped for “getenv” so I
> might
> have overlooked it). The “Guix way” would be to have cyrus-sasl
> honor,
> say, $CYRUS_SASL_PLUGIN_PATH and look for plugins in those
> directories,
> add a search path to the package¹, and have the plugin installed
> in
> $prefix/lib/sasl2 like you did.
>
> Could you check whether cyrus-sasl already has such a mechanism,
> or add
> one (possibly discussing with upstream), and send updated
> patches?

Thank you for your help on this package.

According to the Cyrus SASL quickstart guide:

"Note that the library can use the environment variable SASL_PATH
to locate the directory where the mechanisms are; this should be a
colon-separated list of directories containing plugins."[1]

Unfortunately I still do not know enough about Guix packaging to
set this environment variable properly, nor do I know how to
properly set the installation path in the package configuration.

This plugin's build and installation instructions are:

./autogen.sh
./configure
sudo make install

Footnotes:
[1]
From d5e9f604531dbf9cf7a16a107a3745d0203e1dd7 Mon Sep 17 00:00:00 2001
Message-Id: <d5e9f604531dbf9cf7a16a107a3745d0203e1dd7.1668524316.git.peter@polidoro.io>
From: Peter Polidoro <peter@polidoro.io>
Date: Tue, 15 Nov 2022 09:50:51 -0500
Subject: [PATCH] gnu: Add cyrus-sasl-xoauth2.

* gnu/packages/cyrus-sasl.scm (cyrus-sasl-xoauth2): New variable.
---
gnu/packages/cyrus-sasl.scm | 27 +++++++++++++++++++++++++++
1 file changed, 27 insertions(+)

Toggle diff (51 lines)
diff --git a/gnu/packages/cyrus-sasl.scm b/gnu/packages/cyrus-sasl.scm
index 2cd18f3e5e..abc0bc0c2b 100644
--- a/gnu/packages/cyrus-sasl.scm
+++ b/gnu/packages/cyrus-sasl.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2022 Peter Polidoro <peter@polidoro.io>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -28,6 +29,7 @@ (define-module (gnu packages cyrus-sasl)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix download)
+ #:use-module (guix git-download)
#:use-module (guix build-system gnu))
(define-public cyrus-sasl
@@ -78,3 +80,28 @@ (define-public cyrus-sasl
(license (license:non-copyleft "file://COPYING"
"See COPYING in the distribution."))
(home-page "https://cyrusimap.org/sasl/")))
+
+(define-public cyrus-sasl-xoauth2
+ (package
+ (name "cyrus-sasl-xoauth2")
+ (version "0.2")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/moriyoshi/cyrus-sasl-xoauth2")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1py9f1mn5k5xihrk0lfrwr6723c22gjb7lmgya83ibvislm2x3wl"))))
+ (build-system gnu-build-system)
+ (native-inputs (list autoconf automake libtool))
+ (inputs (list cyrus-sasl))
+ (home-page "https://github.com/moriyoshi/cyrus-sasl-xoauth2")
+ (synopsis "XOAUTH2 mechanism plugin for cyrus-sasl")
+ (description "This package adds the Open Authorization standard, OAuth2,
+authentication mechanism to cyrus-sasl as a plugin. OAuth is an open standard
+for access delegation, commonly used as a way for internet users to grant
+websites or applications access to their information on other websites but
+without giving them the passwords.")
+ (license (list license:expat license:expat))))
--
2.38.1
L
L
Ludovic Courtès wrote on 17 Nov 2022 18:27
(name . Peter Polidoro)(address . peter@polidoro.io)(address . 59018@debbugs.gnu.org)
8735ahh4p1.fsf@gnu.org
Peter Polidoro <peter@polidoro.io> skribis:

Toggle quote (10 lines)
> According to the Cyrus SASL quickstart guide:
>
> "Note that the library can use the environment variable SASL_PATH to
> locate the directory where the mechanisms are; this should be a
> colon-separated list of directories containing plugins."[1]
>
> Unfortunately I still do not know enough about Guix packaging to set
> this environment variable properly, nor do I know how to properly set
> the installation path in the package configuration.

We’d need to add a ‘native-search-paths’ field for “SASL_PATH” to
cyrus-sasl, as explained in the “Search Paths” section of the manual.
But that can come as a separate patch.

Toggle quote (8 lines)
> From d5e9f604531dbf9cf7a16a107a3745d0203e1dd7 Mon Sep 17 00:00:00 2001
> Message-Id: <d5e9f604531dbf9cf7a16a107a3745d0203e1dd7.1668524316.git.peter@polidoro.io>
> From: Peter Polidoro <peter@polidoro.io>
> Date: Tue, 15 Nov 2022 09:50:51 -0500
> Subject: [PATCH] gnu: Add cyrus-sasl-xoauth2.
>
> * gnu/packages/cyrus-sasl.scm (cyrus-sasl-xoauth2): New variable.

It fails to build:

Toggle snippet (7 lines)
starting phase `install'
make[1]: Entering directory '/tmp/guix-build-cyrus-sasl-xoauth2-0.2.drv-0/source'
/gnu/store/d251rfgc9nm2clzffzhgiipdvfvzkvwi-coreutils-8.32/bin/mkdir -p '/usr/lib/sasl2'
/gnu/store/d251rfgc9nm2clzffzhgiipdvfvzkvwi-coreutils-8.32/bin/mkdir: cannot create directory ‘/usr’: Permission denied
make[1]: *** [Makefile:418: install-pkglibLTLIBRARIES] Error 1

Could you send an updated patch? TIA!

Ludo’.
P
P
Peter Polidoro wrote on 18 Nov 2022 16:50
(name . Ludovic Courtès)(address . ludo@gnu.org)(address . 59018@debbugs.gnu.org)
87y1s817r6.fsf@polidoro.io
Ludovic Courtès <ludo@gnu.org> writes:
Toggle quote (5 lines)
>
> Could you send an updated patch? TIA!
>
> Ludo’.

I was able to get the package to build by adding a
"--with-cyrus-sasl" configure-flag.

I am not sure if I used the correct value for this flag, however.

The package's configure file says:

--with-cyrus-sasl=PREFIX
Installation prefix of Cyrus-SASL
(defaults to /usr)

That seems to imply that should be the install location of the
cyrus-sasl package and that the cyrus-sasl-xoauth2 package will
get installed into the location specified by the "--prefix"
configure-flag.

The build failed, though, since it was trying to install into the
/usr directory, even though "--prefix" was set to something else.
So I set "--with-cyrus-sasl" to be the path of the
cyrus-sasl-xoauth2 package out and that seems to work now. I
assume the compilation would have failed if "--with-cyrus-sasl"
needed to point to the cyrus-sasl location for dependency reasons.

Now hopefully adding the correct search path to the cyrus-sasl
package will get the cyrus-sasl-xoauth2 properly recognized as a
plugin. I can work on that patch when I have some time.

Thank you for your all of your help and patience as I am still
learning how to create guix packages.
From ba3fe6dff1d2dbf1cb4d3c383acad57e40f79367 Mon Sep 17 00:00:00 2001
Message-Id: <ba3fe6dff1d2dbf1cb4d3c383acad57e40f79367.1668793140.git.peter@polidoro.io>
From: Peter Polidoro <peter@polidoro.io>
Date: Fri, 18 Nov 2022 12:38:06 -0500
Subject: [PATCH] gnu: Add cyrus-sasl-xoauth2.

* gnu/packages/cyrus-sasl.scm (cyrus-sasl-xoauth2): New variable.
---
gnu/packages/cyrus-sasl.scm | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

Toggle diff (54 lines)
diff --git a/gnu/packages/cyrus-sasl.scm b/gnu/packages/cyrus-sasl.scm
index 2cd18f3e5e..1134996d34 100644
--- a/gnu/packages/cyrus-sasl.scm
+++ b/gnu/packages/cyrus-sasl.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
;;; Copyright © 2016 Leo Famulari <leo@famulari.name>
;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2022 Peter Polidoro <peter@polidoro.io>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -28,6 +29,7 @@ (define-module (gnu packages cyrus-sasl)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix download)
+ #:use-module (guix git-download)
#:use-module (guix build-system gnu))
(define-public cyrus-sasl
@@ -78,3 +80,31 @@ (define-public cyrus-sasl
(license (license:non-copyleft "file://COPYING"
"See COPYING in the distribution."))
(home-page "https://cyrusimap.org/sasl/")))
+
+(define-public cyrus-sasl-xoauth2
+ (package
+ (name "cyrus-sasl-xoauth2")
+ (version "0.2")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/moriyoshi/cyrus-sasl-xoauth2")
+ (commit (string-append "v" version))))
+ (file-name (git-file-name name version))
+ (sha256
+ (base32
+ "1py9f1mn5k5xihrk0lfrwr6723c22gjb7lmgya83ibvislm2x3wl"))))
+ (build-system gnu-build-system)
+ (arguments
+ '(#:configure-flags (list (string-append "--with-cyrus-sasl="
+ (assoc-ref %outputs "out")))))
+ (native-inputs (list autoconf automake libtool))
+ (inputs (list cyrus-sasl))
+ (home-page "https://github.com/moriyoshi/cyrus-sasl-xoauth2")
+ (synopsis "XOAUTH2 mechanism plugin for cyrus-sasl")
+ (description "This package adds the Open Authorization standard, OAuth2,
+authentication mechanism to cyrus-sasl as a plugin. OAuth is an open standard
+for access delegation, commonly used as a way for internet users to grant
+websites or applications access to their information on other websites but
+without giving them the passwords.")
+ (license (list license:expat license:expat))))
--
2.38.1
?