Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kdepim-runtime: use XOAUTH2 SASL plugin from libkgapi #177410

Merged
merged 2 commits into from
Aug 24, 2022

Conversation

matshch
Copy link
Contributor

@matshch matshch commented Jun 12, 2022

Description of changes

Some mail servers like Gmail use SASL XOAUTH2 mechanism to authenticate clients with OAuth token instead of password. Unfortunately, Cyrus SASL does not have authentication plugin for this mechanism out of the box, so clients that use this library and want to authenticate at such mail servers should bring their own plugin for XOAUTH2. KMail (or KDE PIM in general) have such plugin as part of LibKGAPI, and on FHS systems LibKGAPI puts its plugin right next to other Cyrus SASL plugins, so it can be picked up by library automatically. In NixOS, this plugin end up in other directory, which has no references to it, so akonadi_imap_resource fails with next error message when tries to authenticate at such mail servers:

org.kde.pim.kimap: sasl_client_start failed with: -4 "SASL(-4): no mechanism available: No worthy mechs found"

In result, no mail is fetched (progress bar in KMail is stuck at 0%), and user after reading logs is left wondering why no worthy mechs were found.

This commit sets SASL_PATH environment variable, so Cyrus SASL can find both its own plugins and one provided by LibKGAPI. With this change, KMail can successfully fetch mail from Gmail.

This fix is based on discussion in #108480 about means for merging SASL plugins folders from different packages. I think setting SASL_PATH is the most straightforward way of doing this in Nix, but maybe it should be automated somehow, like it is done with XDG_DATA_DIRS in wrapQtAppsHook. However, I do not know easy way to do so in non-breaking manner, so lets leave it to package maintainers for now.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
    NB: nixpkgs-review tries to build packages that are marked as broken. All non-broken packages build successfully with this changes.
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.11 Release Notes (or backporting 22.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

Some mail servers like Gmail [use SASL XOAUTH2 mechanism][1] to authenticate
clients with OAuth token instead of password. Unfortunately, Cyrus SASL
does not have authentication plugin for this mechanism out of the box,
so clients that use this library and want to authenticate at such mail
servers should bring their own plugin for XOAUTH2. KMail (or KDE PIM
in general) have such plugin as [part of LibKGAPI][2], and on FHS systems
LibKGAPI puts its plugin right next to other Cyrus SASL plugins, so it
can be picked up by library automatically. In NixOS, this plugin end up in
other directory, which has no references to it, so `akonadi_imap_resource`
fails with next error message when tries to authenticate at such mail servers:

    org.kde.pim.kimap: sasl_client_start failed with: -4 "SASL(-4): no mechanism available: No worthy mechs found"

In result, no mail is fetched (progress bar in KMail is stuck at 0%), and user
after reading logs is left wondering why no worthy mechs were found.

This commit sets `SASL_PATH` environment variable, so Cyrus SASL can find both
its own plugins and one provided by LibKGAPI. With this change, KMail can
successfully fetch mail from Gmail.

[1]: https://developers.google.com/gmail/imap/xoauth2-protocol#the_sasl_xoauth2_mechanism
[2]: https://github.com/KDE/libkgapi/tree/master/src/saslplugin
@matshch
Copy link
Contributor Author

matshch commented Jun 12, 2022

I guess this could be backported to release-22.05 without any problems, works for me on nixos-22.05 channel.

Copy link
Contributor

@niknetniko niknetniko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me locally.

@matshch
Copy link
Contributor Author

matshch commented Aug 17, 2022

@ttuegel, hello, can you review this PR please?

@matshch
Copy link
Contributor Author

matshch commented Aug 23, 2022

Double checked with new commit: fix still work, both from kdepim-sasl-path branch and kdepim-sasl-path-22.05 rebased on nixos-22.05.

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
@SuperSandro2000 SuperSandro2000 merged commit 44c79a0 into NixOS:master Aug 24, 2022
@@ -23,4 +23,7 @@ mkDerivation {
pimcommon libkgapi libsecret
qca-qt5 qtkeychain qtnetworkauth qtspeech qtxmlpatterns
];
qtWrapperArgs = [
"--prefix SASL_PATH : ${lib.makeSearchPath "lib/sasl2" [ cyrus_sasl libkgapi ]}"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you probably want cyrus_sasl.out here, cyrus_sasl uses the bin output (there's no lib/sasl2 there), which makes all plugins unavailable.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, you are right. Will fix it now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matshch matshch deleted the kdepim-sasl-path branch September 9, 2022 13:44
matshch added a commit to matshch/nixpkgs that referenced this pull request Sep 9, 2022
In NixOS#177410 `SASL_PATH` was set for kdepim-runtime binaries to allow usage of plugin for XOAUTH2, which is required for some mail servers like Gmail. Unfortunately in that PR wrong output of cyrus_sasl was chosen, fixing it in this PR.
@matshch matshch mentioned this pull request Sep 9, 2022
13 tasks
niknetniko added a commit to niknetniko/nixpkgs that referenced this pull request Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants