unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
* correct way to anticipate decryption failures
@ 2015-09-15 22:48 Rasmus
  2015-09-15 23:01 ` John Mastro
  0 siblings, 1 reply; 3+ messages in thread
From: Rasmus @ 2015-09-15 22:48 UTC (permalink / raw)
  To: help-gnu-emacs

Hi,

What is the correct way to handle decryption errors when using
auth-source?  I have something like,

    (auth-source-search :host "worldwide.net"
                        :user "rasmus"
                        :max 1 :require '(:user :secret))

This throws a decryption error when I haven't plugged in my (physical)
security token.

Depending on the arguments, sometimes this is called at init time causing
my daemon window to vanish, which is sort of annoying.

Should I ignore-errors or is there a better way to test if I'm currently
able to decrypt .authinfo.gpg?  Could I re-throw the warning without it
being an error?

Thanks,
Rasmus

-- 
ツ




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: correct way to anticipate decryption failures
  2015-09-15 22:48 correct way to anticipate decryption failures Rasmus
@ 2015-09-15 23:01 ` John Mastro
  2015-09-15 23:06   ` Rasmus
  0 siblings, 1 reply; 3+ messages in thread
From: John Mastro @ 2015-09-15 23:01 UTC (permalink / raw)
  To: help-gnu-emacs@gnu.org

Rasmus <rasmus@gmx.us> wrote:
> What is the correct way to handle decryption errors when using
> auth-source?  I have something like,
>
>     (auth-source-search :host "worldwide.net"
>                         :user "rasmus"
>                         :max 1 :require '(:user :secret))
>
> This throws a decryption error when I haven't plugged in my (physical)
> security token.
>
> Depending on the arguments, sometimes this is called at init time causing
> my daemon window to vanish, which is sort of annoying.
>
> Should I ignore-errors or is there a better way to test if I'm currently
> able to decrypt .authinfo.gpg?  Could I re-throw the warning without it
> being an error?

You can probably use `with-demoted-errors'. Something like:

    (with-demoted-errors "Auth source error: %s"
      (auth-source-search :host "worldwide.net"
                          :user "rasmus"
                          :max 1 :require '(:user :secret)))

It catches the error and simply prints the message.

-- 
john



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: correct way to anticipate decryption failures
  2015-09-15 23:01 ` John Mastro
@ 2015-09-15 23:06   ` Rasmus
  0 siblings, 0 replies; 3+ messages in thread
From: Rasmus @ 2015-09-15 23:06 UTC (permalink / raw)
  To: help-gnu-emacs

John Mastro <john.b.mastro@gmail.com> writes:

> Rasmus <rasmus@gmx.us> wrote:
>> What is the correct way to handle decryption errors when using
>> auth-source?  I have something like,
>
>>
>>     (auth-source-search :host "worldwide.net"
>>                         :user "rasmus"
>>                         :max 1 :require '(:user :secret))
>>
>> This throws a decryption error when I haven't plugged in my (physical)
>> security token.
>>
>> Depending on the arguments, sometimes this is called at init time causing
>> my daemon window to vanish, which is sort of annoying.
>>
>> Should I ignore-errors or is there a better way to test if I'm currently
>> able to decrypt .authinfo.gpg?  Could I re-throw the warning without it
>> being an error?
>
> You can probably use `with-demoted-errors'. Something like:
>
>     (with-demoted-errors "Auth source error: %s"
>       (auth-source-search :host "worldwide.net"
>                           :user "rasmus"
>                           :max 1 :require '(:user :secret)))

Indeed, this works nicely,

    emacs -q --eval "(progn (require 'auth-source) (with-demoted-errors \"Auth source error: %s\" (auth-source-search :host \"worldwide.net\" :user \"rasmus\" :max 1 :require '(:user :secret))))"

Thanks!

Rasmus

-- 
It was you, Jezebel, it was you




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-09-15 23:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-15 22:48 correct way to anticipate decryption failures Rasmus
2015-09-15 23:01 ` John Mastro
2015-09-15 23:06   ` Rasmus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).