Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

Platform issue on AIX, gcc error when build #87

Open
lshengsn opened this issue Jun 14, 2021 · 1 comment
Open

Platform issue on AIX, gcc error when build #87

lshengsn opened this issue Jun 14, 2021 · 1 comment

Comments

@lshengsn
Copy link

running build
running build_ext
building 'kerberos' extension
creating build
creating build/temp.aix-7.2-3.7
creating build/temp.aix-7.2-3.7/src
gcc -maix64 -fPIC -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -I/usr/include -I/opt/freeware/include -I/opt/freeware/include/ncurses -DAIX_GENUINE_CPLUSCPLUS -D_LINUX_SOURCE_COMPAT -Wl,-brtl -O2 -fPIC -I/usr/include -I/opt/freeware/include -I/opt/freeware/include/ncurses -DAIX_GENUINE_CPLUSCPLUS -D_LINUX_SOURCE_COMPAT -Wl,-brtl -O2 -fPIC -I/opt/misc/aaas/jacob_s3_mercury/vvenv/include -I/opt/freeware/include/python3.7m -c src/base64.c -o build/temp.aix-7.2-3.7/src/base64.o -I/opt/freeware/include
gcc -maix64 -fPIC -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -I/usr/include -I/opt/freeware/include -I/opt/freeware/include/ncurses -DAIX_GENUINE_CPLUSCPLUS -D_LINUX_SOURCE_COMPAT -Wl,-brtl -O2 -fPIC -I/usr/include -I/opt/freeware/include -I/opt/freeware/include/ncurses -DAIX_GENUINE_CPLUSCPLUS -D_LINUX_SOURCE_COMPAT -Wl,-brtl -O2 -fPIC -I/opt/misc/aaas/jacob_s3_mercury/vvenv/include -I/opt/freeware/include/python3.7m -c src/kerberos.c -o build/temp.aix-7.2-3.7/src/kerberos.o -I/opt/freeware/include
gcc -maix64 -fPIC -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -I/usr/include -I/opt/freeware/include -I/opt/freeware/include/ncurses -DAIX_GENUINE_CPLUSCPLUS -D_LINUX_SOURCE_COMPAT -Wl,-brtl -O2 -fPIC -I/usr/include -I/opt/freeware/include -I/opt/freeware/include/ncurses -DAIX_GENUINE_CPLUSCPLUS -D_LINUX_SOURCE_COMPAT -Wl,-brtl -O2 -fPIC -I/opt/misc/aaas/jacob_s3_mercury/vvenv/include -I/opt/freeware/include/python3.7m -c src/kerberosbasic.c -o build/temp.aix-7.2-3.7/src/kerberosbasic.o -I/opt/freeware/include
gcc -maix64 -fPIC -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -I/usr/include -I/opt/freeware/include -I/opt/freeware/include/ncurses -DAIX_GENUINE_CPLUSCPLUS -D_LINUX_SOURCE_COMPAT -Wl,-brtl -O2 -fPIC -I/usr/include -I/opt/freeware/include -I/opt/freeware/include/ncurses -DAIX_GENUINE_CPLUSCPLUS -D_LINUX_SOURCE_COMPAT -Wl,-brtl -O2 -fPIC -I/opt/misc/aaas/jacob_s3_mercury/vvenv/include -I/opt/freeware/include/python3.7m -c src/kerberosgss.c -o build/temp.aix-7.2-3.7/src/kerberosgss.o -I/opt/freeware/include
gcc -maix64 -fPIC -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -I/usr/include -I/opt/freeware/include -I/opt/freeware/include/ncurses -DAIX_GENUINE_CPLUSCPLUS -D_LINUX_SOURCE_COMPAT -Wl,-brtl -O2 -fPIC -I/usr/include -I/opt/freeware/include -I/opt/freeware/include/ncurses -DAIX_GENUINE_CPLUSCPLUS -D_LINUX_SOURCE_COMPAT -Wl,-brtl -O2 -fPIC -I/opt/misc/aaas/jacob_s3_mercury/vvenv/include -I/opt/freeware/include/python3.7m -c src/kerberospw.c -o build/temp.aix-7.2-3.7/src/kerberospw.o -I/opt/freeware/include
src/kerberospw.c: In function 'change_user_krb5pwd':
src/kerberospw.c:134:17: warning: implicit declaration of function 'asprintf'; did you mean 'wsprintf'? [-Wimplicit-function-declaration]
bytes = asprintf(
^~~~~~~~
wsprintf
creating build/lib.aix-7.2-3.7

/opt/freeware/lib/python3.7/config-3.7m/ld_so_aix gcc -maix64 -fPIC -pthread -bI:/opt/freeware/lib/python3.7/config-3.7m/python.exp -L. -L/opt/freeware/lib/pthread/ppc64 -L/opt/freeware/lib64 -L/opt/freeware/lib -L/usr/lib -Wl,-brtl -Wl,-blibpath:/opt/freeware/lib/pthread/ppc64:/opt/freeware/lib64:/opt/freeware/lib:/usr/lib -L. -L/opt/freeware/lib/pthread/ppc64 -L/opt/freeware/lib64 -L/opt/freeware/lib -L/usr/lib -Wl,-brtl -Wl,-blibpath:/opt/freeware/lib/pthread/ppc64:/opt/freeware/lib64:/opt/freeware/lib:/usr/lib build/temp.aix-7.2-3.7/src/base64.o build/temp.aix-7.2-3.7/src/kerberos.o build/temp.aix-7.2-3.7/src/kerberosbasic.o build/temp.aix-7.2-3.7/src/kerberosgss.o build/temp.aix-7.2-3.7/src/kerberospw.o -L/opt/freeware/lib64 -o build/lib.aix-7.2-3.7/kerberos.so -L/opt/freeware/lib64 -Wl,-blibpath:/opt/freeware/lib64:/opt/freeware/lib:/usr/lib:/lib -L/opt/freeware/lib64 -L/opt/freeware/lib -Wl,-brtl -lpthreads -lgssapi_krb5 -lkrb5 -lk5crypto -lcom_err
ld: 0711-317 ERROR: Undefined symbol: .asprintf
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: error: ld returned 8 exit status
error: command '/opt/freeware/lib/python3.7/config-3.7m/ld_so_aix' failed with exit status 1

@stevenpackardblp
Copy link

The following patches should allow the module to build on AIX and work well at run time. I can submit them in a pull request if they'd be accepted.

--- a/src/kerberospw.c
+++ b/src/kerberospw.c
@@ -131,24 +131,33 @@
     }
     if (result_code) {
         char *message = NULL;
-        bytes = asprintf(
-            &message, "%.*s: %.*s",
-            (int) result_code_string.length,
-            (char *) result_code_string.data,
-            (int) result_string.length,
-            (char *) result_string.data
-        );
-        if (bytes == -1)
-        {
-            PyErr_NoMemory();
+        int msgSz =
+            (int) result_code_string.length +
+            (int) result_string.length + 2 + 1; // as per format string + null term
+        message = (char *)malloc(msgSz);
+        if (message) {
+            int rc = snprintf(
+                message, msgSz, "%.*s: %.*s",
+                (int) result_code_string.length,
+                (char *) result_code_string.data,
+                (int) result_string.length,
+                (char *) result_string.data
+            );
+            if (rc > 0 && rc <= msgSz) {
+                PyErr_SetObject(
+                    PwdChangeException_class,
+                    Py_BuildValue("((s:i))", message, result_code)
+                );
+            }
+            else
+            {
+                PyErr_NoMemory();
+            }
+            free(message);
         }
         else
         {
-            PyErr_SetObject(
-                PwdChangeException_class,
-                Py_BuildValue("((s:i))", message, result_code)
-            );
-            free(message);
+            PyErr_NoMemory();
         }
         goto end;
     }
--- a/src/kerberosgss.c
+++ b/src/kerberosgss.c
@@ -34,6 +34,14 @@
 extern PyObject *GssException_class;
 extern PyObject *KrbException_class;

+#if defined(__xlC__) || defined(_AIX) || (defined(__SVR4) && defined(__sun))
+void *
+mempcpy (void *dest, const void *src, size_t len)
+{
+    return memcpy (dest, src, len) + len;
+}
+#endif
+
 char* server_principal_details(const char* service, const char* hostname)
 {
     char match[1024];

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants