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

List:       kde-commits
Subject:    kdelibs/kdesu
From:       Adriaan de Groot <adridg () cs ! kun ! nl>
Date:       2003-11-18 23:41:40
[Download RAW message or body]

CVS commit by adridg: 

Better prompt detection: the last line printed should be the password: prompt, not \
the first one. See discussion with Ossi & Waldo on -devel.


  M +14 -3     su.cpp   1.32


--- kdelibs/kdesu/su.cpp  #1.31:1.32
@@ -177,5 +177,5 @@ int SuProcess::ConverseSU(const char *pa
         if (line.isNull())
             return ( state == HandleStub ? notauthorized : error);
-        // kdDebug(900) << k_lineinfo << "Read line <" << line << ">" << endl;
+        kdDebug(900) << k_lineinfo << "Read line <" << line << ">" << endl;
 
         switch (state) 
@@ -189,4 +189,16 @@ int SuProcess::ConverseSU(const char *pa
             }
 
+            while(waitMS(m_Fd,100)>0)
+            {
+                // There is more output available, so the previous line
+                // couldn't have been a password prompt (the definition
+                // of prompt being that  there's a line of output followed 
+                // by a colon, and then the process waits).
+                QCString more = readLine();
+                if (more.isEmpty()) break;
+                line = more;
+                kdDebug(900) << k_lineinfo << "Read line <" << more << ">" << endl;
+            }
+            
             // Match "Password: " with the regex ^[^:]+:[\w]*$.
             for (i=0,j=0,colon=0; i<line.length(); i++) 
@@ -204,5 +216,4 @@ int SuProcess::ConverseSU(const char *pa
                 if (password == 0L)
                     return killme;
-                waitMS(m_Fd,100);
                 if (!checkPid(m_Pid))
                 {


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

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