Unix & Linux
debian gnome3 command-substitution gnome-keyring reportbug
Updated Thu, 22 Sep 2022 09:01:25 GMT

How to configure reportbug to use smtp password from gnome-keyring?


When configuring reportbug, I have an option to store the password for the remote smtp service in $HOME/.reportbugrc. How can I make it use an existing password stored by GNOME Web (Epiphany) or Evolution in GNOME keyring instead, so that I do not need to update $HOME/.reportbugrc if the password in GNOME keyring changes?

I found that I can read the password from GNOME keyring with secret-tools command, which is provided by libsecret-tools package, and use command substitution with $() to invoke secret-tools and use its output like this:

$ reportbug --smtppasswd=$(secret-tool lookup uri https://webmail.example.invalid)

or this:

$ reportbug --smtppasswd=$(secret-tool lookup target_origin https://webmail.example.invalid username user@example.invalid)

Unfortunately, reportbug does not seem to perform substitution in ~/.reportbugrc. I tried like this:

smtppasswd "$(secret-tool lookup target_origin https://webmail.example.invalid username user@example.invalid)"

Is there a workaround to this?




Solution

Ended up defining an alias in ~\.bash_aliases.

alias reportbug-pass='reportbug --smtppasswd="$(secret-tool lookup eds-origin evolution-data-server e-source-uid 7f1e149e069bd66ab5aa1a734baa113943cdf0ee)"'

Using that alias instead of calling reportbug directly invokes reportbug with --smtppasswd already passed to it. Now, if I want to pass my SMTP password to reportbug, I can type that alias instead. You can pass other parameters to it, like the name of the package reported, as you would to reportbug.

$ reportbug-pass

Instead of an alias, the same result can be achieved by defining a function in ~\.bash_aliases

function reportbug-pass() {
    reportbug --smtppasswd="$(secret-tool lookup eds-origin evolution-data-server e-source-uid pdljjhvbuo6uvc7mydavpmbjqqhxqq2jyhqdndpmcvamknbih8cifgfg)" "$@"
}

In this function, the "$@" parameter expends to arguments passed to it, so that you could pass the name of the package, for example.

In this case, whether it is an alias or a function, the query against the keyring happens when you call it from the command line. If the keyring is locked, you get a usual graphical prompt to unlock the keyring.