[patch 2/6] make checkers.py compatible to Linux

1 view
Skip to first unread message

Felix Schwarz

unread,
Mar 12, 2008, 4:42:03 PM3/12/08
to authori...@googlegroups.com

checkers.py used some libraries which are only available on Windows.

--
Felix Schwarz
Dipl.-Informatiker

Gubener Str. 38
10243 Berlin
Germany

www.schwarz.eu - software development and consulting


linux_compatibility

Kevin Horn

unread,
Mar 12, 2008, 7:38:42 PM3/12/08
to authori...@googlegroups.com
diff -r 70c6c8cc352b authority/checkers/checkers.py
--- a/authority/checkers/checkers.py    Wed Mar 12 16:44:08 2008 +0100
+++ b/authority/checkers/checkers.py    Wed Mar 12 16:45:09 2008 +0100
@@ -90,9 +90,6 @@ class HtpasswdChecker(AuthenticationChec
        raise NotImplementedError


-from win32security import LogonUser
-from win32security import LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT
-from win32security import error as LogonError


 class SMBChecker(AuthenticationChecker):
@@ -108,6 +105,9 @@ class SMBChecker(AuthenticationChecker):
        # set default domain?  config-provided or user-provided?

    def check_credentials(self, cred):
+        from win32security import LogonUser
+        from win32security import LOGON32_LOGON_NETWORK, LOGON32_PROVIDER_DEFAULT
+        from win32security import error as LogonError
        try:
            token = LogonUser(cred['user'],
                              cred['domain'],




Should the imports be really done in __call__ ?  Wouldn't __init__ be a better place to put these, or am I missing something?

Kevin Horn

Felix Schwarz

unread,
Mar 13, 2008, 5:48:28 PM3/13/08
to authori...@googlegroups.com
Kevin Horn wrote:
> Should the imports be really done in __call__ ? Wouldn't __init__ be a
> better place to put these, or am I missing something?

If you put the imports in __init__ the symbol LogonUser (and others) are
not available in check_credentials(). The best solution (IMHO) would be to
split the current checkers module so that the Windows-specific stuff is
encapsulated in its own module so that all other tests will work on a
non-Windows OS.

Kevin Horn

unread,
Mar 13, 2008, 7:19:10 PM3/13/08
to authori...@googlegroups.com
That's more or less what I was planning to do, just hadn't gotten around to it yet.  Maybe tonight...hopefully this weekend.

Kevin Horn
Reply all
Reply to author
Forward
0 new messages