]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4397. [bug] Update Windows python support. [RT #42538]
authorMark Andrews <marka@isc.org>
Fri, 24 Jun 2016 06:04:10 +0000 (16:04 +1000)
committerMark Andrews <marka@isc.org>
Fri, 24 Jun 2016 06:04:10 +0000 (16:04 +1000)
13 files changed:
CHANGES
bin/dnssec/win32/dsfromkey.vcxproj.in
bin/python/dnssec-checkds.py.in
bin/python/dnssec-coverage.py.in
bin/python/dnssec-keymgr.py.in
bin/python/isc/utils.py.in
configure.in
lib/isc/win32/libisc.vcxproj.in
win32utils/Configure
win32utils/build.txt
win32utils/legacy/BuildPost.bat.in
win32utils/legacy/BuildSetup.bat.in
win32utils/readme1st.txt

diff --git a/CHANGES b/CHANGES
index 1049556a05d1b648db2477f2e4299636fa87ffb8..38f140022f67328dcd280af6a4e14c0901310895 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,5 @@
+4397.  [bug]           Update Windows python support. [RT #42538]
+
 4396.  [func]          dnssec-keymgr now takes a '-r randomfile' option.
                        [RT #42455]
 
index 4fa6afdadb36ae1c4b5f81883d88265594f5806a..4d57bedef3685ea22646460d00b71e57a751390d 100644 (file)
       <Command>cd ..\..\python
 copy /Y dnssec-checkds.py ..\..\Build\$(Configuration)\dnssec-checkds.py
 copy /Y dnssec-coverage.py ..\..\Build\$(Configuration)\dnssec-coverage.py
+copy /Y dnssec-keymgr.py ..\..\Build\$(Configuration)\dnssec-keymgr.py
+cd isc
+@PYTHON@ policy.py parse \dev\nul > nul
+set PYTHONPATH=.
+@PYTHON@ -m parsetab
 </Command>
     </PostBuildEvent>
 @END PYTHON
@@ -113,6 +118,11 @@ copy /Y dnssec-coverage.py ..\..\Build\$(Configuration)\dnssec-coverage.py
       <Command>cd ..\..\python
 copy /Y dnssec-checkds.py ..\..\Build\$(Configuration)\dnssec-checkds.py
 copy /Y dnssec-coverage.py ..\..\Build\$(Configuration)\dnssec-coverage.py
+copy /Y dnssec-keymgr.py ..\..\Build\$(Configuration)\dnssec-keymgr.py
+cd isc
+@PYTHON@ policy.py parse \dev\nul > nul
+set PYTHONPATH=.
+@PYTHON@ -m parsetab
 </Command>
     </PostBuildEvent>
 @END PYTHON
@@ -123,4 +133,4 @@ copy /Y dnssec-coverage.py ..\..\Build\$(Configuration)\dnssec-coverage.py
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
index 16774fb5012ce95165c6f38fa30d5657c8aaaa97..ef75646bc59bb92eb9968c16198f6c85eda85637 100644 (file)
@@ -19,7 +19,8 @@ import os
 import sys
 
 sys.path.insert(0, os.path.dirname(sys.argv[0]))
-sys.path.insert(1, os.path.join('@prefix@', 'lib'))
+if os.name != 'nt':
+    sys.path.insert(1, os.path.join('@prefix@', 'lib'))
 
 import isc.checkds
 
index af33331a222970400ed5cb634117fa77951b34ea..5d897ba2d61aea5eb87d333a4c2e42d5ee679b52 100644 (file)
@@ -19,7 +19,8 @@ import os
 import sys
 
 sys.path.insert(0, os.path.dirname(sys.argv[0]))
-sys.path.insert(1, os.path.join('@prefix@', 'lib'))
+if os.name != 'nt':
+    sys.path.insert(1, os.path.join('@prefix@', 'lib'))
 
 import isc.coverage
 
index c300c018b68768ef831b794a9844750ed31c4a25..3e757d47067435125539b99606db5e0d7e6f767a 100644 (file)
@@ -19,7 +19,8 @@ import os
 import sys
 
 sys.path.insert(0, os.path.dirname(sys.argv[0]))
-sys.path.insert(1, os.path.join('@prefix@', 'lib'))
+if os.name != 'nt':
+    sys.path.insert(1, os.path.join('@prefix@', 'lib'))
 
 import isc.keymgr
 
index cac42e8ab48da96d69ddde26b32b26da4168e6d9..0065a931a3ab62164a21ec89bb9a68645f86ba6d 100644 (file)
@@ -26,13 +26,32 @@ def prefix(bindir=''):
     if os.name != 'nt':
         return os.path.join('@prefix@', bindir)
 
+    hklm = win32con.HKEY_LOCAL_MACHINE
     bind_subkey = "Software\\ISC\\BIND"
+    sam = win32con.KEY_READ
     h_key = None
     key_found = True
+    # can fail if the registry redirected for 32/64 bits
     try:
-        h_key = win32api.RegOpenKeyEx(win32con.HKEY_LOCAL_MACHINE, bind_subkey)
+        h_key = win32api.RegOpenKeyEx(hklm, bind_subkey, 0, sam)
     except:
         key_found = False
+    # retry for 32 bit python with 64 bit bind9
+    if not key_found:
+        key_found = True
+        sam64 = sam | win32con.KEY_WOW64_64KEY
+        try:
+            h_key = win32api.RegOpenKeyEx(hklm, bind_subkey, 0, sam64)
+        except:
+            key_found = False
+    # retry 64 bit python with 32 bit bind9
+    if not key_found:
+        key_found = True
+        sam32 = sam | win32con.KEY_WOW64_32KEY
+        try:
+            h_key = win32api.RegOpenKeyEx(hklm, bind_subkey, 0, sam32)
+        except:
+            key_found = False
     if key_found:
         try:
             (named_base, _) = win32api.RegQueryValueEx(h_key, "InstallDir")
@@ -51,4 +70,7 @@ def shellquote(s):
 
 
 version = '@BIND9_VERSION@'
-sysconfdir = '@expanded_sysconfdir@'
+if os.name != 'nt':
+    sysconfdir = '@expanded_sysconfdir@'
+else:
+    sysconfdir = prefix('etc')
index 5226f1b6ef287c60a6878c14774b4248ac41a853..6550d2a896a4f7daa6e666d7d4ee36418147466b 100644 (file)
@@ -231,7 +231,7 @@ AC_ARG_WITH(python,
 [  --with-python=PATH      specify path to python interpreter],
     use_python="$withval", use_python="unspec")
 
-python="python python3 python3.4 python3.3 python3.2 python3.1 python3.0 python2 python2.7 python2.6 python2.5 python2.4"
+python="python python3 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2 python2.7 python2.6 python2.5 python2.4"
 
 testargparse='try: import argparse
 except: exit(1)'
index a7cc5d8d7dbbe2f6ad9703b946e9be08e67333fa..10d68f8192d61bdf2f0673f80ede5515206b4b8c 100644 (file)
@@ -215,6 +215,7 @@ copy ..\bin\dnssec\dnssec-importkey.html ..\Build\Release
 @IF PYTHON
 copy ..\bin\python\dnssec-checkds.html ..\Build\Release
 copy ..\bin\python\dnssec-coverage.html ..\Build\Release
+copy ..\bin\python\dnssec-keymgr.html ..\Build\Release
 @END PYTHON
 @IF PKCS11
 copy ..\bin\pkcs11\pkcs11-keygen.html ..\Build\Release
index 7fd1a5d0c57f24211696b5fb7c4a16498b4106c5..f05c05fa10ec140cd1b6afe999b59a6ab0d6d893 100644 (file)
@@ -80,6 +80,8 @@ my @filelist = ("..\\bin\\check\\win32\\checktool.dsp",
                 "..\\bin\\pkcs11\\win32\\pk11tokens.mak",
                 "..\\bin\\python\\dnssec-checkds.py",
                 "..\\bin\\python\\dnssec-coverage.py",
+                "..\\bin\\python\\dnssec-keymgr.py",
+                "..\\bin\\python\\isc\\utils.py",
                 "..\\bin\\rndc\\win32\\rndc.dsp",
                 "..\\bin\\rndc\\win32\\rndc.mak",
                 "..\\bin\\rndc\\win32\\rndcutil.dsp",
@@ -447,6 +449,7 @@ my @substvar = ("BIND9_VERSION",
                 "COPTMLD",
                 "COPTX",
                 "COPTY",
+                "expanded_sysconfdir",
                 "INTRINSIC",
                 "MACHINE",
                 "OPENSSL_PATH",
@@ -2371,23 +2374,84 @@ if ($use_python eq "no") {
     }
     my $pythonret = `python -c "quit()" 2>&1`;
     if ($? != 0) {
-        die "can't launch the python interpreter: $pythonret\n";
+        print STDERR "can't launch the python interpreter: $pythonret\n";
+        $use_python = "no";
     }
-    $use_python = "yes";
 }
 if ($use_python ne "no") {
-    if ($verbose) {
+    if ($use_python ne "auto") {
+        if ($verbose) {
+           print "checking for $python_command\n";
+        }
         my $pythonret = `"$python_command" -c "quit()" 2>&1`;
         if ($? != 0) {
-            print STDERR
-                "can't lanch the local python interpreter: $pythonret\n";
+            die "can't launch $python_command: $pythonret\n";
+        }
+    }
+    if ($verbose) {
+        print "checking for python module 'argparse'\n";
+    }
+    my $pythonret = `"$python_command" -c "import argparse" 2>&1`;
+    if ($? != 0) {
+        if ($use_python ne "auto") {
+            die "can't find python module 'argparse': $pythonret\n";
+        } else {
+            print STDERR "can't find python module 'argparse': $pythonret\n";
+            $use_python = "no";
+        }
+    }
+    if ($use_python ne "no") {
+        if ($verbose) {
+            print "checking for python module 'ply'\n";
+        }
+        $pythonret = `"$python_command" -c "from ply import *" 2>&1`;
+        if ($? != 0) {
+            if ($use_python ne "auto") {
+                die "can't find python module 'ply': $pythonret\n";
+            } else {
+                print STDERR "can't find python module 'ply': $pythonret\n";
+                $use_python = "no";
+            }
+        }
+    }
+    if ($use_python ne "no") {
+        if ($verbose) {
+            print "checking for python module 'win32api'\n";
+        }
+        $pythonret = `"$python_command" -c "import win32api" 2>&1`;
+        if ($? != 0) {
+            if ($use_python ne "auto") {
+                die "can't find python module 'win32api': $pythonret\n";
+            } else {
+                print STDERR
+                    "can't find python module 'win32api': $pythonret\n";
+                $use_python = "no";
+            }
+        }
+    }
+    if ($use_python ne "no") {
+        if ($verbose) {
+            print "checking for python module 'win32con'\n";
+        }
+        $pythonret = `"$python_command" -c "import win32con" 2>&1`;
+        if ($? != 0) {
+            if ($use_python ne "auto") {
+                die "can't find python module 'win32con': $pythonret\n";
+            } else {
+                print STDERR
+                    "can't find python module 'win32con': $pythonret\n";
+                $use_python = "no";
+            }
         }
     }
-    $configcond{"PYTHON"} = 1;
-    $configdefd{"USE_PYTHON"} = "USE_PYTHON";
-    $configvar{"PYTHON"} = "$python_command";
-    # Only a default!
-    $configvar{"prefix"} = "C:\\Program Files\ISC BIND 9";
+    if ($use_python ne "no") {
+        $configcond{"PYTHON"} = 1;
+        $configdefd{"USE_PYTHON"} = "USE_PYTHON";
+        $configvar{"PYTHON"} = "$python_command";
+        # Doesn't matter
+        $configvar{"prefix"} = "__prefix__";
+        $configvar{"expanded_sysconfdir"} = "__prefix__\\etc";
+    }
 }
 
 # with-vcredist
@@ -2999,9 +3063,10 @@ sub makeinstallfile {
         print LOUT "pkcs11-list.exe-BNFF\n";
         print LOUT "pkcs11-tokens.exe-BNFF\n";
     }
-    if ($use_python eq "yes") {
+    if ($use_python ne "no") {
         print LOUT "dnssec-checkds.py-BNFF\n";
         print LOUT "dnssec-coverage.py-BNFF\n";
+        print LOUT "dnssec-keymgr.py-BNFF\n";
     }
     print LOUT "readme1st.txt-BTFT\n";
     close LOUT;
index 459468a3d07764c02519c0a60f968ac4920a48cc..9d1185bbce23bb30e920dd4e0d78a2d08a5a07d6 100644 (file)
@@ -27,6 +27,9 @@ If you wish to use zlib/deflate on the statistics channel, zlib
 must be downloaded and built on the system on which you are building
 BIND.
 
+If you wish to use python tools, you need a python (version 2 or 3)
+interpreter with its standard libraries.
+
 If you wish to use readline, the readline library must be downloaded
 and built on the system on which you are building BIND.
 
@@ -134,7 +137,25 @@ Step 4: Download and build GeoIP
   This patch has been submitted upstream, and will be included in
   future versions of libGeoIP.
 
-Step 5: Download and build Readline
+Step 5: Enable python tools
+
+  Some python packages are required: argparse, ply, win32con and win32api.
+  Last CPython's (version 2 or 3) from http://www.python.org include
+  the pip package manager which can install missing packages, for
+  instance for the 2 last packages 'pip install pypiwin32' downloads and
+  installs win32con and win32api.
+
+  Note when the python interpreter is in the command path and
+  the required packages available the Configure script will detect
+  them and add python tools to the BIND build.
+
+  To be used a python tool must be invoked with python (e.g.,
+  python dnssec-checkds.py <args>) as the shebang doesn't work
+  on Windows. The isc package should be installed too, cf step 11.
+  At the opposite of Unix this isc package uses the Registry to
+  learn where BIND was installed in step 10.
+
+Step 6: Download and build Readline
 
   The readline library adds command-line editing in nslookup and nsupdate.
   If you wish to build BIND 9 without support for this feature, skip to
@@ -150,7 +171,7 @@ Step 5: Download and build Readline
   Note: Windows command (cmd.exe) provides an integrated line edition
   feature so it is not recommended to configure bind with readline.
 
-Step 6: Make the redistributable runtime object available
+Step 7: Make the redistributable runtime object available
 
   Check that the Microsoft redistributable object (vcredist_x86.exe or
   vcredist_x64.exe) is available to the build.  The file may be placed
@@ -162,7 +183,7 @@ Step 6: Make the redistributable runtime object available
   step 7). If none of these options is used, Configure will attempt to
   find the redistributable based on clues in the build environment.
 
-Step 7: Configuring the BIND build
+Step 8: Configuring the BIND build
 
   From the command prompt, cd to the win32utils directory under
   the BIND 9 root:
@@ -186,7 +207,7 @@ Step 7: Configuring the BIND build
 
     perl Configure clean
 
-Step 8: Building BIND
+Step 9: Building BIND
 
   To build using 'nmake' or older versions of Visual Studio (e.g.
   VS 2005 or VS 2008), go to the legacy subdirectory:
@@ -210,7 +231,10 @@ Step 8: Building BIND
 
   Note: This mode does not support building for Windows XP.
 
-Step 9: Install
+  After this step this documentation applies to external or remote
+  builds, i.e., is common with installation.
+
+Step 10: Install
 
   Installation is accomplished by running the BINDInstall program. All
   DLL's are copied to the Program Files area and all applications
@@ -233,5 +257,18 @@ Step 9: Install
   The idea is to be able to use any BINDInstall.exe binary so
   a non-free version of Visual Studio is no longer required.
 
+Step 11: Python package install
+
+  When BIND was built with python support, the isc python package
+  must be installed locally by:
+
+   cd <top-bind9-directory>
+   cd bin/python
+   python setup.py install
+
+  (replace 'python' by the path of your python interpreter if needed.)
+
+  BIND python tools should work with version 2 or 3, 32 or 64 bits.
+
 Please report bugs, whether in the process of building the application
 or in BIND 9 itself, to bind9-bugs@isc.org.
index cdcdbb1cf450c6662342c34e9ff820792ae08ab5..a775f9f260c9cfbed7a60c4402508184d32e1dfa 100644 (file)
@@ -34,6 +34,17 @@ copy /Y ..\..\bin\python\dnssec-checkds.py ..\..\Build\Release\dnssec-checkds.py
 copy /Y ..\..\bin\python\dnssec-checkds.py ..\..\Build\Debug\dnssec-checkds.py
 copy /Y ..\..\bin\python\dnssec-coverage.py ..\..\Build\Release\dnssec-coverage.py
 copy /Y ..\..\bin\python\dnssec-coverage.py ..\..\Build\Debug\dnssec-coverage.py
+copy /Y ..\..\bin\python\dnssec-keymgr.py ..\..\Build\Release\dnssec-keymgr.py
+copy /Y ..\..\bin\python\dnssec-keymgr.py ..\..\Build\Debug\dnssec-keymgr.py
+
+echo Build python parser
+
+cd ..\..\bin\python\isc
+@PYTHON@ policy.py parse \dev\nul
+set PYTHONPATH=.
+@PYTHON@ -m parsetab
+cd ..\..\..\win32utils\legacy
+
 @END PYTHON
 
 echo Done.
index 61f73573753f34c167e8124d836e8e3b6f484ead..6d730ee996304e37d3185466ad863d032a06b4f8 100644 (file)
@@ -74,6 +74,7 @@ copy ..\..\bin\dnssec\dnssec-importkey.html ..\..\Build\Release
 @IF PYTHON
 copy ..\..\bin\python\dnssec-checkds.html ..\..\Build\Release
 copy ..\..\bin\python\dnssec-coverage.html ..\..\Build\Release
+copy ..\..\bin\python\dnssec-keymgr.html ..\..\Build\Release
 @END PYTHON
 @IF PKCS11
 copy ..\..\bin\pkcs11\pkcs11-keygen.html ..\..\Build\Release
index 489d8918f076819cb2262bef2200b06fed821ca4..9c72f7195741247663f5910f85d2623a0bac84d5 100644 (file)
@@ -1,4 +1,4 @@
-Copyright (C) 2004, 2005, 2007-2009, 2012-2015  Internet Systems Consortium, Inc. ("ISC")
+Copyright (C) 2004, 2005, 2007-2009, 2012-2016  Internet Systems Consortium, Inc. ("ISC")
 Copyright (C) 2001, 2003  Internet Software Consortium.
 See COPYRIGHT in the source root or http://isc.org/copyright.html for terms.
 
@@ -13,6 +13,19 @@ Unpack the kit into any convenient directory and run the BINDInstall
 program.  This will install the named and associated programs into
 the correct directories and set up the required registry keys.
 
+Usually BINDInstall must be run by/as Administrator or it can fail
+to operate on the filesystem or the registery or even return messages
+like 'A referral was returned from the server". The best way to
+avoid this kind of problems on Windows 7 or newer is:
+ - open a "file explorer" aka finder windows
+ - goes where the distribution was expanded
+ - click right on the BINDInstall application
+ - open "Properties" (last) menu
+ - open "Compatibility" (second) tab
+ - check on the (last) "Run this program as an administrator"
+Unfortunately this is not saved by zip (or any archiver?) as
+it is a property saved in the Registry.
+
 BINDInstall requires that you install it under an account with
 restricted privileges. The installer will prompt you for an account
 name (the default is "named") and a password for that account. It