Issue 1284289: AIX port from Elemental Security (original) (raw)
Logged In: YES user_id=6380
Here are Monte's notes.
Python was configured using:
./configure --with-gcc='xlc_r -q64' --with-cxx='xlC_r
-q64'
--disable-ipv6 AR='ar -q64'
Eventhough xlc_r is not gcc, configure produced better results when --with-gcc was used.
IPv6 was disabled, because configure reported that getaddrinfo() was buggy, and, at this time, Elemental Security does not require IPv6.
Note: the test suite still fails on: test_codecencodings_cn, test_codecmaps_cn, test_curses, test_mmap, and test_multibytecodec, as Elemental Security did not require these features. All other tests in the test suite that were not skipped passed.
These source changes were required:
This script uses nm to create an export list of global symbols for the AIX dynamic linker. Changed the script to include the nm -X32_64 option, which allows it to process both 32-bit and 64-bit object files. For backward compatibility, this option is added only if the nm command implements the option.
Include/import.h Python/import.c Modules/signalmodule.c
These files were modified to reallocate the import lock in the child process after a fork. This prevents the child process from receiving EACCES when performing operations on the import lock.
Include/import.h -- added prototype for _PyImport_ReInitLock.
Python/import.c -- added _PyImport_ReInitLock. This function was modeled after PyEval_ReInitThreads, which serves a similar purpose. The _PyImport_ReInitLock function reallocates the import_lock, if the import_lock has already been allocated. The code within _PyImport_ReInitLock is under #ifdef _AIX.
Modules/signalmodule.c -- added call to _PyImport_ReInitLock in PyOS_AfterFork.
Modules/socketmodule.c Modules/socketmodule.h
These files were modified to fix a memory corruption problem involving AF_UNIX sockets. AIX's struct sockaddr_un structure contains a path name which is the address of a UNIX socket. Unlike several other flavors of UNIX-like systems, the AIX declaration for struct sockaddr_un actually allocates enough space for any path name (PATH_MAX). This means a struct sockaddr_un takes up 1025 bytes. However, several places in socketmodule.c allocated only 256 bytes for a socket address. The first thing they do with the 256-byte socket address buffer is zero 1025 bytes. Not good!
Modules/socketmodule.h -- the PySocketSockObject typedef already defined a union sock_addr that allocates enough space for any socket address. Moved the union outside the PySocketSockObject struct into its own typedef, sock_addr_t.
Modules/socketmodule.c -- replaced the "char addrbuf[256]" definitions with "sock_addr_t addrbuf" and made other changes required by that.
Modules/grpmodule.c Modules/pwdmodule.c
UIDs and GIDs are unsigned. Changed pwd_getpwuid and grp_getgrgid to accept unsigned UIDs and GIDs. On AIX, the passwd and group files use the largest unsigned int for nobody.
Lib/test/test_ioctl.py -- Fixed bug in import statement for test.test_support. Fixed bug where the test would fail if the test suite was being run in the backgroud. In this case, the TIOCGPGRP ioctl on /dev/tty returns the session ID, not the process group ID.
Lib/test/regrtest.py -- added skips for aix5.