Bug 11969

Summary: Asks for OpenPGP passphrase multiple times
Product: Sisyphus Reporter: Andrey Rahmatullin <wrar>
Component: gnupg2Assignee: Alexey Gladkov <legion>
Status: CLOSED FIXED QA Contact: qa-sisyphus
Severity: normal    
Priority: P2 CC: legion, manowar, mike, rider, vvk
Version: unstable   
Hardware: all   
OS: Linux   
Attachments:
Description Flags
gnupg-2.0.10-agent-fix-password-requiest.patch none

Description Andrey Rahmatullin 2007-06-04 19:59:04 MSD
If I have 2 accounts with the same OpenPGP key, I'm asked for its passphrase 
two times.

Psi 0.10 asks only 1 time for 1 key.
Comment 1 Andrey Rahmatullin 2007-06-04 20:03:39 MSD
[22:00:54] <textshell> wRAR: most likely because you use gpg-agent and it 
doesn't handle that case correctly.
[22:02:40] <textshell> with concurrent gpg invokations gpg-agent is a bit 
stupid.
Comment 2 Andrey Rahmatullin 2007-06-04 20:06:52 MSD
[22:04:16] <wRAR> it is said that 0.10 works OK
[22:04:33] <textshell> right 0.10 doesn't use concurrent gpg invokations.
Comment 3 Anton Farygin 2007-06-07 09:44:40 MSD
Андрей, попробуйте пожалуйста версию 0.11-svn20070605
Comment 4 Andrey Rahmatullin 2007-06-08 09:39:00 MSD
Не помогло, конечно же.

Да, кстати.

18464 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
29 --command-fd 26 --always-trust --verify - -&24
18465 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
37 --command-fd 34 --always-trust --verify - -&32
18466 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
45 --command-fd 42 --always-trust --verify - -&40
18467 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
53 --command-fd 50 --always-trust --verify - -&48
18473 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
82 --command-fd 79 --always-trust --verify - -&76
18479 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
90 --command-fd 87 --always-trust --verify - -&85
23557 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
33 --command-fd 26 --always-trust --verify - -&24
23560 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
61 --command-fd 53 --always-trust --verify - -&42
23561 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
86 --command-fd 79 --always-trust --verify - -&76
23565 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
95 --command-fd 45 --always-trust --verify - -&26
23566 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
117 --command-fd 114 --always-trust --verify - -&112
23569 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
125 --command-fd 122 --always-trust --verify - -&120
 8344 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
76 --command-fd 49 --always-trust --verify - -&42
 8345 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
113 --command-fd 96 --always-trust --verify - -&86
 8358 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
149 --command-fd 143 --always-trust --verify - -&125
 8359 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
157 --command-fd 154 --always-trust --verify - -&152
 6142 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
136 --command-fd 113 --always-trust --verify - -&95
 6143 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
158 --command-fd 153 --always-trust --verify - -&149
10373 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
153 --command-fd 136 --always-trust --verify - -&96
10378 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
178 --command-fd 170 --always-trust --verify - -&164
10379 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
187 --command-fd 184 --always-trust --verify - -&182
10380 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
195 --command-fd 192 --always-trust --verify - -&190
18059 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
183 --command-fd 170 --always-trust --verify - -&164
18060 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
197 --command-fd 192 --always-trust --verify - -&190
18061 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
220 --command-fd 212 --always-trust --verify - -&206
18062 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
229 --command-fd 226 --always-trust --verify - -&224
18065 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
252 --command-fd 234 --always-trust --verify - -&230
18066 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
263 --command-fd 260 --always-trust --verify - -&258
10467 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
197 --command-fd 190 --always-trust --verify - -&170
10468 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
229 --command-fd 224 --always-trust --verify - -&212
10471 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
253 --command-fd 241 --always-trust --verify - -&234
20154 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
229 --command-fd 212 --always-trust --verify - -&190
20155 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
265 --command-fd 258 --always-trust --verify - -&241
26215 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
279 --command-fd 258 --always-trust --verify - -&241
26216 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
301 --command-fd 297 --always-trust --verify - -&294
26217 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
309 --command-fd 306 --always-trust --verify - -&304
26241 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
329 --command-fd 314 --always-trust --verify - -&310
26244 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
332 --command-fd 321 --always-trust --verify - -&309
26245 ?        SL     0:00 gpg --no-tty --enable-special-filenames --status-fd 
345 --command-fd 342 --always-trust --verify - -&340


До перезапуска psi эти процессы были его детьми.
Comment 5 Anton Farygin 2007-06-08 13:24:38 MSD
с gpg в версии psi0.11-0.11-alt2svn20070605
 точно нет этих проблем. Я версию обновлял только из-за утечки процессов.
Comment 6 Anton Farygin 2007-09-18 12:46:17 MSD
Как обстоят сейчас дела с запросом пароля несколько раз ?
Comment 7 Andrey Rahmatullin 2007-09-18 21:07:15 MSD
psi0.11-0.11-alt2svn20070917 - так же
Comment 8 Anton Farygin 2007-09-18 21:29:07 MSD
Мне кажется что стоит это повесить в mainstream, хотя его мнение понятно, но всё-же.
Comment 9 Michael Shigorin 2008-02-28 17:59:33 MSK
(как доедет) Проверяй psi0.12, 0.11 уже всё.
Comment 10 Andrey Rahmatullin 2008-03-12 22:46:26 MSK
Ну вроде ага.
Comment 11 Andrey Rahmatullin 2008-03-13 10:43:10 MSK
Не ага.
Если грохнуть gpg-agent, psi выдаёт (1 раз) какое-то своё (?) окошко, не 
похожее на pinentry.
Если gpg-agent есть, выдаётся 2 раза.
Comment 12 Andrey Rahmatullin 2009-02-20 20:55:29 MSK
psi-0.13-alt0.git3.57c98f2 - всё то же самое.
Comment 13 Anton Farygin 2009-03-03 14:00:28 MSK
Перевешиваю на gnupg2. Кусок кода с комментариями из gpg-agent'а говорит о том, что пароль должен спрашиваться один раз, даже если за ним приходит два одновременных запроса.
    retry:
      pw = agent_get_cache (hexgrip, cache_mode, &cache_marker);
      if (pw)
        {
          rc = agent_unprotect (*keybuf, pw, NULL, &result, &resultlen);
          agent_unlock_cache_entry (&cache_marker);
          if (!rc)
            {
              xfree (*keybuf);
              *keybuf = result;
              return 0;
            }
          rc  = 0;
        }

      /* If the pinentry is currently in use, we wait up to 60 seconds 
         for it to close and check the cache again.  This solves a common 
         situation where several requests for unprotecting a key have 
         been made but the user is still entering the passphrase for 
         the first request.  Because all requests to agent_askpin are 
         serialized they would then pop up one after the other to 
         request the passphrase - despite that the user has already 
         entered it and is then available in the cache.  This 
         implementation is not race free but in the worst case the 
         user has to enter the passphrase only once more. */
      if (pinentry_active_p (ctrl, 0))
        {
          /* Active - wait */
          if (!pinentry_active_p (ctrl, 60))
            {
              /* We need to give the other thread a chance to actually put 
                 it into the cache. */
              pth_sleep (1);.
              goto retry;
            }
          /* Timeout - better call pinentry now the plain way. */
        }
    }
Comment 14 Anton Farygin 2009-03-03 14:28:27 MSK
Created attachment 3347 [details]
gnupg-2.0.10-agent-fix-password-requiest.patch

Вот такой небольшой патч (копи-паст из другого куска gpg-agent'а) - решает проблему.
Comment 15 Sergey V Turchin 2009-03-03 17:53:08 MSK
gnupg2-2.0.11-alt1
Comment 16 Sergey V Turchin 2009-03-03 17:53:42 MSK
fixed
Comment 17 Andrey Rahmatullin 2009-03-04 20:34:46 MSK
Помогло, подтверждаю.
Comment 18 Andrey Rahmatullin 2009-03-06 19:56:30 MSK
Снова три раза спросило :-/
Comment 19 Andrey Rahmatullin 2009-03-06 20:50:51 MSK
Следующий раз не повторилось, как и следовало ожидать. Не знаю, как повторить.
Comment 20 Anton Farygin 2009-03-07 11:32:44 MSK
после неактивности ? сам на такое нарывался, пока не понимаю в чём проблема (ну явно в gpg-agent)
Comment 21 Andrey Rahmatullin 2009-03-07 11:58:49 MSK
(В ответ на комментарий №20)
> после неактивности ? 
Ну я сильно не сразу после вывода диалога пароль ввёл, если ты об этом.
Comment 22 Anton Farygin 2009-03-07 12:38:38 MSK
да да, именно об этом.

Нужно попробовать снова и понаблюдать - есть подозрение, что через 1 минуту будет вылезать новый запрос пароля, несмотря на наличие старого.
Comment 23 Anton Farygin 2009-03-07 12:52:29 MSK
нет, через 1, 2, 3 и т.д. минут - не вылез. 
В общем, Андрей... ты уже знаешь где смотреть - если сможешь отловить / исправить - пиши.
Comment 24 Anton Farygin 2009-03-07 12:54:23 MSK
Теперь это время от времени вылезает.. например, если оставить psi включённой и на часок-другой отойти - то вылезет несколько окон запроса пароля от pinentry.

Как ловить - я пока не знаю, любые идеи приветствуются.
Comment 25 Andrey Rahmatullin 2009-04-29 21:34:58 MSD
Отлично повторяется, если заставить psi показать pinentry и хотя бы минут 10 не отвечать.
Comment 26 Anton Farygin 2009-04-30 15:45:23 MSD
Подождал ... не воспроизвелось ;(
Comment 27 Andrey Rahmatullin 2009-04-30 15:56:09 MSD
Точнее так. 
<тут было про запуск пси при старте системы, но я это стёр, т.к. засомневался>
Выходим в онлайн, ждём отсыхания пассфразы в агенте, отходим от машины так, чтобы вызвался автостатус (вместо этого наверно можно и руками его переключить, но я этим не пользуюсь, потому не сталкивался). Возвращаемся - висит один pinentry, после ввода в него пассфразы авылезает следующий. При этом висит кучка процессов gpg (у меня было 6 после ввода где-то 2-3 пассфраз из ~5).
Comment 28 Anton Farygin 2009-04-30 15:59:58 MSD
Это стандартный алгоритм "пошёл пить чай - вернулся".

Я так делаю постоянно - не вылезает два pinentry.

нужно засекать время. Видимо, таймаут должен быть достаточно большим..
Comment 29 Dmitry V. Levin 2010-02-11 05:07:17 MSK
Просьба протестировать текущую версию (gnupg2 >= 2.0.14-alt6); если воспроизведётся -- напишите, я тогда посмотрю.
Comment 30 Andrey Rahmatullin 2010-02-11 08:27:55 MSK
Ну вообще последнее время после автостатуса вылезает окно pinentry и под ним окно psi, и после ввода пассфразы новых окон не вылезает. Это на alt5. Ещё попроверяю и можно будет закрывать.
Comment 31 Andrey Rahmatullin 2010-02-11 17:36:29 MSK
Not reproducible anymore with
gnupg2-2.0.14-alt6
psi-0.14-alt3