Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.26k stars 3.86k forks source link

[Az.Accounts] Return warning "org.freedesktop.DBus.Error.ServiceUnknown" when dbus-user-session package is installed #14207

Open al-cheb opened 3 years ago

al-cheb commented 3 years ago

Description

After installing dbus-user-session package on Ubuntu 18.04 , Import-Module Az.Accounts has returned ** Message: 17:43:58.624: Remote error from secret service: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files which has broken our CI due to writing to the stderr. This issue doesn't reproduce on Ubuntu 20.04 where the dbus-user-session package is pre-installed by default or using sudo.

Steps to reproduce

apt-get install -y dbus-user-session
reboot

Environment data

No LSB modules are available.
Distributor ID:Ubuntu
Description:Ubuntu 18.04.5 LTS
Release:18.04
Codename:bionic

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.2.5                 Az.Accounts                         {Add-AzEnvironment, Clear-AzContext, Clear-AzDefault, Connect-AzAccount…}

Error output

$ pwsh -command "Import-Module Az.Accounts"
** Message: 17:43:58.624: Remote error from secret service: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files
** Message: 17:43:58.630: Remote error from secret service: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files
** Message: 17:43:58.633: Remote error from secret service: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files 

journalclt -e 
Feb 15 17:43:58  powershell[16735]: Microsoft.Identity.Client.Extensions.TraceSource Error: 0 :
Feb 15 17:43:58  powershell[16735]: [MSAL.Extension][2021-02-15T17:43:58.6249328Z] An error was encountered while saving secret to keyring in the MsalCacheStorage domain:'95' co
Feb 15 17:43:58  powershell[16735]: Microsoft.Identity.Client.Extensions.TraceSource Error: 0 :
Feb 15 17:43:58  powershell[16735]: [MSAL.Extension][2021-02-15T17:43:58.6308996Z] An error was encountered while reading secret from keyring in the MsalCacheStorage domain:'95'
Feb 15 17:43:58  powershell[16735]: Microsoft.Identity.Client.Extensions.TraceSource Error: 0 :
Feb 15 17:43:58  powershell[16735]: [MSAL.Extension][2021-02-15T17:43:58.6340969Z] An error was encountered while clearing secret from keyring in the MsalCacheStorage domain:'95
dingmeng-xue commented 3 years ago

We will report this question to owner of MSAL extension.

bgavrilMS commented 3 years ago

Hi @al-cheb - what Ubuntu distro should I install to reproduce this? The desktop image or the server image or some other image?

al-cheb commented 3 years ago

Hi @al-cheb - what Ubuntu distro should I install to reproduce this? The desktop image or the server image or some other image?

Hi, @bgavrilMS. We use an image template from Azure marketplace:

"imageReference": {
                        "publisher": "Canonical",
                        "offer": "UbuntuServer",
                        "sku": "18.04-LTS",
                        "version": "latest"
                    }

image

bgavrilMS commented 3 years ago

Ok, so I think what's happening here is that the internal secret storage library MsalCacheExtension is unable to write to the dbus due to the error above. The root cause of the error is related to the fact that dbus requires X11, so the error it expected on a CI machine.

AzureCLI and PowerShell normally detect this kind of error (via the ValidatePersistence call), and will fallback to storing secrets in a plaintext file, as far as I know. @erich-wang can keep me honest here.

What happens here though is that Import-Module Az.Accounts outputs some messages on stderr, via standard tracing mechanism. And then pwsh -command thinks Import-Module has failed because it logged messages to stderr. I am not a pwsh expert, but there should be a way to ignore stderr?

odero commented 2 years ago

For anyone else looking into this, try installing the following packages sudo apt install gnupg2 pass

johncrim commented 2 years ago

We're seeing the same issue. @odero 's workaround did not work for us.

This just started showing up in our AzurePowerShell@4 tasks in Azure pipelines, running on Ubuntu 18.04. It occurs as part of the task setup, before any user powershell code is run. Since it's written to stdout, all builds using Powershell tasks are failing.

/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -ExecutionPolicy Unrestricted -Command . '/home/vsts/work/_temp/1703e74e-73cf-49f0-ac09-b80b429464eb.ps1'
Saved!
Import-Module -Name /usr/share/az_7.5.0/Az.Accounts/2.9.0/Az.Accounts.psd1 -Global
** Message: 15:52:37.608: Remote error from secret service: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files
** Message: 15:52:37.615: Remote error from secret service: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files
** Message: 15:52:37.618: Remote error from secret service: org.freedesktop.DBus.Error.ServiceUnknown: The name org.freedesktop.secrets was not provided by any .service files
Clear-AzContext -Scope CurrentUser -Force -ErrorAction SilentlyContinue
Clear-AzContext -Scope Process
...
mtwelve commented 2 years ago

We're seeing the same issue.

Any updates on a resolution or workarounds other than @odero's?

dingmeng-xue commented 2 years ago

@johncrim and @mtwelve , I am reading this issue https://github.com/Foundry376/Mailspring/issues/681. Could you try whether sudo apt install gnome-keyring can solve this issue?

isra-fel commented 2 years ago

We are currently experiencing this issue in our pipeline since this week. After investigation we found out that the only difference between a successful and a failed wrong is the vm image version.

Successful run, Environment: ubuntu-18.04, Version: 20220626.1 Failed run, Environment: ubuntu-18.04, Version: 20220710.1

johncrim commented 2 years ago

@dingmeng-xue - thank you for the possible patch. It's not convenient to test that out right now, but I can confirm that switching to ubuntu 20.04 makes the error go away.