diff mbox

[v5,17/25] wpaspy: add debug support for Ctrl UDP class

Message ID 1457083241-7492-18-git-send-email-janusz.dziedzic@tieto.com
State Changes Requested
Headers show

Commit Message

Janusz.Dziedzic@tieto.com March 4, 2016, 9:20 a.m. UTC
Add debug support for Ctrl class. This is
useful for debuging purpose for UDP connection.

Signed-off-by: Janusz Dziedzic <janusz.dziedzic@tieto.com>
---
 wpaspy/wpaspy.py | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Comments

Jouni Malinen March 5, 2016, 2:50 p.m. UTC | #1
On Fri, Mar 04, 2016 at 10:20:33AM +0100, Janusz Dziedzic wrote:
> Add debug support for Ctrl class. This is
> useful for debuging purpose for UDP connection.

While this may be useful for some debugging purposes, this would also
unconditionally add logger.debug() calls for private information that
may include passwords. I don't think this is appropriate since wpaspy.py
can be used outside testing environment.
Janusz.Dziedzic@tieto.com March 6, 2016, 11:01 a.m. UTC | #2
On 5 March 2016 at 15:50, Jouni Malinen <j@w1.fi> wrote:
> On Fri, Mar 04, 2016 at 10:20:33AM +0100, Janusz Dziedzic wrote:
>> Add debug support for Ctrl class. This is
>> useful for debuging purpose for UDP connection.
>
> While this may be useful for some debugging purposes, this would also
> unconditionally add logger.debug() calls for private information that
> may include passwords. I don't think this is appropriate since wpaspy.py
> can be used outside testing environment.
>
Yes, but added only for UDP path. While UDP CTRL (no encryption)
should be used only for test purpose, will that be a problem?

BR
Janusz
> --
> Jouni Malinen                                            PGP id EFC895FA
Jouni Malinen March 7, 2016, 8:58 a.m. UTC | #3
On Sun, Mar 06, 2016 at 12:01:07PM +0100, Janusz Dziedzic wrote:
> On 5 March 2016 at 15:50, Jouni Malinen <j@w1.fi> wrote:
> > On Fri, Mar 04, 2016 at 10:20:33AM +0100, Janusz Dziedzic wrote:
> >> Add debug support for Ctrl class. This is
> >> useful for debuging purpose for UDP connection.
> >
> > While this may be useful for some debugging purposes, this would also
> > unconditionally add logger.debug() calls for private information that
> > may include passwords. I don't think this is appropriate since wpaspy.py
> > can be used outside testing environment.
> >
> Yes, but added only for UDP path. While UDP CTRL (no encryption)
> should be used only for test purpose, will that be a problem?

One could claim so, but I'm not sure I really see the point of wpaspy
having these debug prints with the contents of the messages for one of
the mechanisms. Those debug prints are already in place in run-tests.py
anyway.
Janusz.Dziedzic@tieto.com March 7, 2016, 4:55 p.m. UTC | #4
On 7 March 2016 at 09:58, Jouni Malinen <j@w1.fi> wrote:
> On Sun, Mar 06, 2016 at 12:01:07PM +0100, Janusz Dziedzic wrote:
>> On 5 March 2016 at 15:50, Jouni Malinen <j@w1.fi> wrote:
>> > On Fri, Mar 04, 2016 at 10:20:33AM +0100, Janusz Dziedzic wrote:
>> >> Add debug support for Ctrl class. This is
>> >> useful for debuging purpose for UDP connection.
>> >
>> > While this may be useful for some debugging purposes, this would also
>> > unconditionally add logger.debug() calls for private information that
>> > may include passwords. I don't think this is appropriate since wpaspy.py
>> > can be used outside testing environment.
>> >
>> Yes, but added only for UDP path. While UDP CTRL (no encryption)
>> should be used only for test purpose, will that be a problem?
>
> One could claim so, but I'm not sure I really see the point of wpaspy
> having these debug prints with the contents of the messages for one of
> the mechanisms. Those debug prints are already in place in run-tests.py
> anyway.
>
Yes, I see they are in wpa_supplicant.py/hostapd.py. So, we don't need
them in wpaspy.py

> --
> Jouni Malinen                                            PGP id EFC895FA
diff mbox

Patch

diff --git a/wpaspy/wpaspy.py b/wpaspy/wpaspy.py
index 30bb652..76ac785 100644
--- a/wpaspy/wpaspy.py
+++ b/wpaspy/wpaspy.py
@@ -10,7 +10,9 @@  import os
 import stat
 import socket
 import select
+import logging
 
+logger = logging.getLogger()
 counter = 0
 
 class Ctrl:
@@ -54,7 +56,7 @@  class Ctrl:
                 self.cookie = reply
                 self.port = port
             except:
-                print "connect exception ", path, str(port)
+                logger.debug("connect exception " + str(path) + "/" + str(port))
                 if self.s != None:
                     self.s.close()
                 raise
@@ -79,12 +81,13 @@  class Ctrl:
 
     def request(self, cmd, timeout=10):
         if self.udp == True:
+            logger.debug(self.path + "/" + str(self.port) + " request: " + cmd)
             self.s.sendto(self.cookie + cmd, self.sockaddr)
         else:
             self.s.send(cmd)
         [r, w, e] = select.select([self.s], [], [], timeout)
         if r:
-            return self.s.recv(4096)
+            return self.recv()
         raise Exception("Timeout on waiting response")
 
     def attach(self):
@@ -115,4 +118,6 @@  class Ctrl:
 
     def recv(self):
         res = self.s.recv(4096)
+        if self.udp == True:
+           logger.debug(self.path + "/" + str(self.port) + " recv: " + res)
         return res