[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: bug in PtyProcess ???
From:       Andre Charbonneau <yoamwmvs () umail ! corel ! com>
Date:       2000-12-08 18:58:20
[Download RAW message or body]



Waldo Bastian wrote:

> On Thursday 07 December 2000 14:37, Andre Charbonneau wrote:
> > The above peice of code causes the kdepasswd application to hang on my
> > system.  The reason for this is that a line containing a '\n' but not
> > ending with a '\n' is read by the "read()" system call.  The left part
> > (before the '\n' is parsed, but because of the above code, the right part
> > is not parsed since its not ending with a '\n'.  This will cause the
> > kdepasswd app to hand since it will call the "read()" system call again
> > while the passwd utility is waiting for user input.
> >
> > To fix this problem, I suggest we do something like this:
>
> Isn't the current behaviour, the behaviour you would expect from a readLine
> function? This is also what the comment states:
>
>      * Read a line from the program's standard out. Depending on the @em block
>      * parameter, this call blocks until a single, full line is read.
>      * @param block Block until a full line is read?
>      * @return The output string.
>
> As long as there is no '\n', the line is not complete.
>
> I would say that the real problem is the fact that this function appearantly
> is used to read a password prompt.
>
> You could of course decide that the comment of the readLine function is
> incorrect but then I would be interested to know what the criteria for
> reading a line becomes?
>
> Could the function return "Pass" as well? Or would it always return
> "Password: "? Why does it wait for the "word: " part but not for the "***"
> part?
>
> Cheers,
> Waldo

Hi,
I understand what you are saying.  But still I thing there is a bug in
PtyProcess.  What happened is that during the first readLine call, a line like the
following was read inside PtyProcess's buffer:
[Changing password for andrec\ncurrent (UNIX) password:]
The first PtyProcess::readLine function call returnes the following:
[Changing password for andrec]
And the rest of the line stayed in the buffer.  This causes the next
PtyProcess::readLine to hang (on the system call read()) since what is left in the
internal buffer of PtyProcess is ignored (because it does not end with a \n) and
the passwd utility is waiting for some input at that point..
My modifications to PtyProcess make the next PtyProcess::readLine function return
the following:
[current (UNIX) password:]
instead of hanging on the read() function.  Therefore, my password changing
program can detect that passwd is requesting a password and I send it through
PtyProcess::writeLine and everything works fine.

What do you think we should do about this one?  I think there are two things we
could do,

1. Leave the PtyProcess like it is and not use it for commands that contains
prompts that are not ending with a \n character.
2. Modify PtyProcess so that when a readLine call is made, if the internal buffer
contains something, then return it, else use the system read() call to get the
next input.

I'm more in favor of solution #2.

Also, is KDE's kdepasswd hangs on your system?

Thanks,
Andre.

-- 
The address in the headers is not the poster's real email address.  Do not send
private mail to the poster using your mailer's "reply" feature.  CC's of mail 
to mailing lists are OK.  Problem reports to "postmaster@umail.corel.com".  
The poster's email address is "andrec@corel.com".

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic