[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Help on /dev/tty and su -c



On Thu, 15 Mar 2012 00:15:09 +0100 Vincent Fourmond wrote:

>   Hello,

Hi! Thanks for your kind reply!

> 
> On Wed, Mar 14, 2012 at 11:21 PM, Francesco Poli
> <invernomuto@paranoici.org> wrote:
[...]
> > Currently, apt-listbugs does all this by opening "/dev/tty", after the
> > input ends.
> 
>   Does it do that as root ?

It (typically) does the described steps as root, yes.

>  Why do you need su ?

It's *not* apt-listbugs that invokes  su -c "command" (except for one
case, see the first of the two bugs I am struggling with: #662865),
it's apt-listbugs that *may* be invoked inside an  su -c "command" ,
either explicitly by the user, or by aptitude ncurses interface (if run
as a regular user, aptitude ncurses interface asks the user for the root
password, whenever it needs root privileges to perform an operation and
invokes su -c "command" to perform it; see the second of the two bugs I
am struggling with: #662983).

> 
>   Could you try posting the output of
> 
>   p Dir["/proc/self/fd/*"].map {|x| begin File::readlink(x); rescue; end }
> 
>   just before opening /dev/tty ? If 2 or 1 is a /dev/pts, not all hope is lost.

I will try to get this output, but will it apply to all Debian systems?
I am trying to solve the issue for all apt-listbugs users in the most
portable way, not for me...

> 
>   I know this is probably a lot of work, but wouldn't it be just saner
> to use debconf rather than the terminal ? That would be more portable.

This is interesting, I have been asked in the past to implement a
debconf frontend (see msg #25 of bug #628996), but I don't know how I
could ask questions and output data through debconf from within a
program written in Ruby...
I had searched for something (a library?) to use debconf from Ruby, but
had found nothing.

Please tell me more: how can this be done from a Ruby program?

> 
>   You could also try prompting using readline, which may (? haven't
> checked) be able to find a tty even if /dev/tty isn't available.

Interesting: I see that libruby provides the virtual package
libreadline-ruby.
I assume that this means that the readline → ruby binding is included
in the Ruby standard library.
Could you please suggest some documentation on how to use readline from
Ruby programs?

> 
>   Hope that helps,

It may definitely help, let's see how it develops...
Thanks!

-- 
 http://www.inventati.org/frx/frx-gpg-key-transition-2010.txt
 New GnuPG key, see the transition document!
..................................................... Francesco Poli .
 GnuPG key fpr == CA01 1147 9CD2 EFDF FB82  3925 3E1C 27E1 1F69 BFFE

Attachment: pgpK22gcOvkpk.pgp
Description: PGP signature


Reply to: