labs-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dr...@apache.org
Subject svn commit: r604142 - in /labs/badca: build/python.m4 configure.ac openssl/certmodule.c openssl/setup.py.in
Date Fri, 14 Dec 2007 10:04:39 GMT
Author: dreid
Date: Fri Dec 14 02:04:38 2007
New Revision: 604142

URL: http://svn.apache.org/viewvc?rev=604142&view=rev
Log:
Correct build for Python 2.4
Use correct python executable path for determining the
build directories
Correctly handle Py_ssize_t based on version of python
Report version of python and the path we're using for it

This corrects issues pointed out by Mads Toftum.

Modified:
    labs/badca/build/python.m4
    labs/badca/configure.ac
    labs/badca/openssl/certmodule.c
    labs/badca/openssl/setup.py.in

Modified: labs/badca/build/python.m4
URL: http://svn.apache.org/viewvc/labs/badca/build/python.m4?rev=604142&r1=604141&r2=604142&view=diff
==============================================================================
--- labs/badca/build/python.m4 (original)
+++ labs/badca/build/python.m4 Fri Dec 14 02:04:38 2007
@@ -7,39 +7,44 @@
 AC_DEFUN(PY_PROG_PYTHON,
   [AC_ARG_WITH(python,
   [  --with-python=CMD       name of python executable],,[with_python=no])
+  AC_MSG_CHECKING(for python)
   if test "x$with_python" != xno && test -x "$with_python"; then
-    AC_MSG_CHECKING(for python)
     PYTHON="$with_python"
     AC_MSG_RESULT($PYTHON)
     AC_SUBST(PYTHON)
-  else
+  else    
     AC_PATH_PROG(PYTHON, python, python)
+    AC_MSG_RESULT($PYTHON)
   fi]
 )
 
 dnl Check for python version
 AC_DEFUN(PY_PYTHON_VERSION,
   [AC_REQUIRE([PY_PROG_PYTHON])
-  AC_ARG_WITH(python-version,
-    [  --with-python-version=VERSION
-                          overide guessed python version],,
-    [with_python_version=no])
-  if test "x$with_python_version" != xno; then
-    PYTHON_VERSION="$with_python_version"
-  fi
   AC_MSG_CHECKING(python version)
-  if test -z "$PYTHON_VERSION"; then
-    AC_CACHE_VAL(py_cv_python_version, [changequote((_,_))
-    py_cv_python_version=`$PYTHON -c 'import sys; print sys.version[:3]'`
-    changequote([,])])
-  else
-    py_cv_python_version="$PYTHON_VERSION"
+
+  AC_CACHE_VAL(py_cv_major, [changequote((_,_))
+    py_cv_major=`$PYTHON -c 'import sys; print str(sys.version_info[0])'`
+    changequote([,])
+  ])
+  AC_CACHE_VAL(py_cv_minor, [changequote((_,_))
+    py_cv_minor=`$PYTHON -c 'import sys; print str(sys.version_info[1])'`
+    changequote([,])
+  ])
+  if test "$py_cv_major" != "2"; then
+    AC_ERROR([You need at least python version 2.4 to build/run BaDCA])
   fi
-  PYTHON_VERSION="$py_cv_python_version"
+  if test "$py_cv_minor" != "4" && test "$py_cv_minor" != "5"; then
+    AC_ERROR([You need at least python version 2.4 to build/run BaDCA])
+  fi
+
+  PYTHON_VERSION="$py_cv_major.$py_cv_minor"
   AC_MSG_RESULT($PYTHON_VERSION)
   VERSION=$PYTHON_VERSION
+  PY_VERSION="$py_cv_major$py_cv_minor"
   AC_SUBST(VERSION)
   AC_SUBST(PYTHON_VERSION)
+  AC_SUBST(PY_VERSION)
 ])
 
 dnl Check python installation prefix

Modified: labs/badca/configure.ac
URL: http://svn.apache.org/viewvc/labs/badca/configure.ac?rev=604142&r1=604141&r2=604142&view=diff
==============================================================================
--- labs/badca/configure.ac (original)
+++ labs/badca/configure.ac Fri Dec 14 02:04:38 2007
@@ -23,7 +23,7 @@
 dnl Use a simple paython script to find the path that our extensions
 dnl will be built in. This is used to allow tests to be run without the
 dnl need to install the extensions.
-EXT_PATH=`$top_srcdir/build/extensionPath.py`
+EXT_PATH=`$PYTHON $top_srcdir/build/extensionPath.py`
 AC_MSG_RESULT([Extensions will be built in $EXT_PATH])
 AC_SUBST(EXT_PATH)
 

Modified: labs/badca/openssl/certmodule.c
URL: http://svn.apache.org/viewvc/labs/badca/openssl/certmodule.c?rev=604142&r1=604141&r2=604142&view=diff
==============================================================================
--- labs/badca/openssl/certmodule.c (original)
+++ labs/badca/openssl/certmodule.c Fri Dec 14 02:04:38 2007
@@ -200,7 +200,11 @@
 static int 
 removeNameFields(X509_NAME *subj, PyObject *list)
 {
+#ifdef PYTHON25
     Py_ssize_t sz = PyList_Size(list), pos = 0;
+#else
+    int sz = PyList_Size(list), pos = 0;
+#endif
 
     for (pos = 0; pos < sz; pos++) {
         PyObject *pVal = PyList_GetItem(list, pos);
@@ -228,7 +232,11 @@
 mergeSubjects(X509_NAME *to, X509_NAME *from, PyObject *ignore)
 {
     int i, sz = X509_NAME_entry_count(from);
+#ifdef PYTHON25
     Py_ssize_t iSz = 0, iPos = 0;
+#else
+    int iSz = 0, iPos = 0;
+#endif
     int *nids = NULL;
 
     if (ignore) {
@@ -488,9 +496,10 @@
         PyObject *pkdict = PyDict_New();
 
         /* Public Key Algorithm */
-/*        {
+        {
+            X509_PUBKEY *pk = X509_get_X509_PUBKEY(cert);
             BIO *bp = BIO_new(BIO_s_mem());
-            if (bp && i2a_ASN1_OBJECT(bp, pkey->algor->algorithm) > 0) {
+            if (bp && i2a_ASN1_OBJECT(bp, pk->algor->algorithm) > 0) {
                 char *strPtr = NULL;
                 long sz = BIO_get_mem_data(bp, &strPtr);
                 (void)BIO_set_close(bp, BIO_NOCLOSE);
@@ -499,7 +508,7 @@
                                PyString_FromStringAndSize(strPtr, sz));
             }
         }
-*/
+
         /* Public key Strength */
         if (pkey->type == EVP_PKEY_RSA) 
             PyDict_SetItem(pkdict, Py_BuildValue("s", "strength"),
@@ -553,6 +562,10 @@
 
         }
     }
+    /* Get the list of attributes */
+    {
+
+    }
 
 
     return dict;
@@ -608,16 +621,6 @@
         goto out;
     }
 
-    /* The certificate has 2 X509_NAMEstructures, one for the issuer and one
-     * for the certificate (termed the subject). We now create these and set
-     * them into the certificate.
-     *
-     *   1) copy the subject from the issuing certificate
-     *   2) delete the CN and emailAddress from the issuer subject
-     *   3) add fields from the request that we permit (basically anything other
-     *      than CN, O & OU)
-     */
-
     {
         X509_NAME *issuerSubject = X509_get_subject_name(issuer);
 
@@ -671,9 +674,10 @@
     if (X509_set_subject_name(cert, subject) != 1) {
         PyErr_SetString(PyExc_RuntimeError, "Unable to set the subject "
                                       "name of the new certificate");
-        X509_NAME_free(subject);
         goto out;
     }
+    X509_NAME_free(subject);
+    subject = NULL;
 
     /* The public key associated with the generated certificate is the
      * one that was used to create the signing request. Extract the 
@@ -687,6 +691,7 @@
     }
     rv = X509_set_pubkey(cert, pkey);
     EVP_PKEY_free(pkey);
+    pkey = NULL;
     if (rv != 1) {
         PyErr_SetString(PyExc_RuntimeError, "Unable to set the public "
                                       "key of the new certificate");
@@ -713,12 +718,14 @@
     if (attrDict && addV3Attributes(cert, issuer, attrDict) != 1)
         goto out;
 
-
     /* Claim credit for the creation... 
      * We don't care if this fails ;-)
      */
     certificateAddExtension(cert, &ctx, "nsComment", "Created by BaDCA");
 
+    /* Finally, sign the certificate with the private key of the issuing
+     * certificate. Once this is done, the certificate is complete.
+     */
     if (signCertificateWithKey(cert, key) == 0)
         goto out;
 
@@ -727,6 +734,10 @@
 
     /* below this is used for error cases */
 out:
+    if (subject)
+        X509_NAME_free(subject);
+    if (pkey)
+        EVP_PKEY_free(pkey);
     if (cert)
         X509_free(cert);
     return NULL;

Modified: labs/badca/openssl/setup.py.in
URL: http://svn.apache.org/viewvc/labs/badca/openssl/setup.py.in?rev=604142&r1=604141&r2=604142&view=diff
==============================================================================
--- labs/badca/openssl/setup.py.in (original)
+++ labs/badca/openssl/setup.py.in Fri Dec 14 02:04:38 2007
@@ -17,6 +17,7 @@
                       sources = ['csrmodule.c']
                      )
 certModule = Extension('cert',
+                       extra_compile_args = ['-DPYTHON@PY_VERSION@' ],
                        extra_link_args = ['-shared'],
                        include_dirs= ['@openssl_INCDIR@'],
                        library_dirs= ['@openssl_LIBDIR@'],



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@labs.apache.org
For additional commands, e-mail: commits-help@labs.apache.org


Mime
View raw message