Bug#723024: caff: fails if stdin is not a TTY

2014-02-24 Thread Guilhem Moulin
That's cool!  I cannot think of any side effect either, short of

  - that'll only work on POSIX systems (unsure if we care, but it'd
still be possible to fallback to STDIN on non-POSIX systems), and

  - one would not longer be able to answer the questions with things like
‘yes | caff …’. (That wouldn't really make sense anyway, as there
are configuration options for that).

Also, rather than keeping opening/closing the TTY for each question
asked, an improvement would be to do it once and for all at the
beginning.  One could even close STDIN and re-open it as /dev/tty; This
behavior can be emulated in a POSIX shell, and is one of the workaround
to the bad interaction between xargs and caff (or generally any program
proceeding its user interaction over STDIN):

xargs sh -c '/dev/tty caff $@' /path/to/fprs


I second that patch anyway ;-)  If no one objects I'll merge the slight
modification outlined above.

Cheers,
-- 
Guilhem.


signature.asc
Description: Digital signature


Bug#723024: caff: fails if stdin is not a TTY

2013-09-15 Thread Julius Seemayer
Package: signing-party
Version: 1.1.4-1
Severity: normal
Tags: patch

caff  from  package  signing-party  tries to read the send mail to xyz? (and
other)  answers  from  stdin,  which  is not necessary but breaks the usage of
xargs or similar tools:

(simulated, ^\.\.\.$ means cropped line(s))
$ caff  /dev/null

[NOTICE] Import failed for: .
Some keys could not be imported - continue anyway? [y/N] 

End of STDIN reached.  Are you using xargs?  Caff wants to read from STDIN,
so you can't really use it with xargs.  A patch against caff to read from
the terminal would be appreciated.
For now instead of   cat keys | xargs caff  do  caff `cat keys`
$ 

This  is pretty annoying because usually you don't have any y/n prompts before
the  mail signatures  part  is running. This means that you have to re-check
all the signatures made in that session so far.

I'd suggest to read from /dev/tty instead, like the gpg shell does. A patch to
accomplish that would look like:

--- /usr/bin/caff   2011-11-01 20:01:39.0 +0100
+++ /tmp/tmp.EQNI9gJkxx/caff2013-09-15 15:21:40.388893938 +0200
@@ -649,6 +649,8 @@
 
-   $answer = STDIN;
+   open TTY, /dev/tty or die(Cannot open TTY: $!\n);
+   $answer = TTY;
+   close TTY;
if (!defined $answer) {
$OUTPUT_AUTOFLUSH = 1;
-   die \n\n.
+   die \n\n. # XXX obsolte?
End of STDIN reached.  Are you using xargs?  Caff 
wants to read from STDIN,\n.

I'm  no  Perl  guru, so I'm not sure if that patch will have side effects. But
alternatively  caff could/should warn the user at the very beginning, which is
to be accomplished with that second patch:

--- /usr/bin/caff   2011-11-01 20:01:39.0 +0100
+++ /tmp/tmp.EQNI9gJkxx/caff2013-09-15 15:21:40.388893938 +0200
@@ -1110,2 +1112,4 @@
 
+mywarn(stdin is not a TTY, don't use xargs if you do (caff will explode 
later)) unless (-t STDIN);
+
 for my $hashkey (qw{local-user no-download no-sign no-mail mail 
keys-from-gnupg}) {

That would look like:

(again, simulated; note the [WARN] line)
$ /tmp/tmp.EQNI9gJkxx/caff  /dev/null
[WARN] stdin is not a TTY, don't use xargs if you do (caff will explode later)

[NOTICE] Import failed for: .
Some keys could not be imported - continue anyway? [y/N] 

End of STDIN reached.  Are you using xargs?  Caff wants

$ 

I'd  suggest  to  /check/ and apply the first patch only; if unsure, ignore it
and apply only the second one.


Cheers,

Julius



-- System Information:
Debian Release: 7.1
  APT prefers stable
  APT policy: (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.2.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages signing-party depends on:
ii  gnupg  1.4.12-7+deb7u1
ii  libc6  2.13-38
ii  libclass-methodmaker-perl  2.18-1+b1
ii  libgnupg-interface-perl0.45-1
ii  libmailtools-perl  2.09-1
ii  libmime-tools-perl 5.503-1
ii  libterm-readkey-perl   2.30-4+b2
ii  libtext-template-perl  1.45-2
ii  perl   5.14.2-21
ii  qprint 1.0.dfsg.2-2

Versions of packages signing-party recommends:
ii  dialog 1.1-20120215-2
pn  libgd-gd2-noxpm-perl | libgd-gd2-perl  none
ii  libpaper-utils 1.1.24+nmu2
ii  libtext-iconv-perl 1.7-5
ii  postfix [mail-transport-agent] 2.9.6-2
ii  whiptail   0.52.14-11.1

Versions of packages signing-party suggests:
ii  imagemagick8:6.7.7.10-5+deb7u2
ii  mutt   1.5.21-6.2
ii  texlive-latex-recommended  2012.20120611-5
pn  wipe   none

-- no debconf information


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org