AIX

From PortaWiki

Jump to: navigation, search

Contents

getaddrinfo(3), getnameinfo(3)

getaddrinfo, getnameinfo and friends exhibit various degrees of brokenness.

Older versions (all 4.3.3, 5.1 up to ML?, 5.2 up to ML?):

  • Passing a NULL name to getaddrinfo will fail.

All known versions:

  • getnameinfo on the wildcard IPv6 address (ie an address of all-zeros) and NI_MUMERICHOST will fail rather than returning a usable string indicating a wildcard address (ie "::"). Depending on how you squint while reading RFC3493 this may be compliant (but useless) behaviour.

linker fun

AIX's linker will, by default, embed any paths supplied as "-L" options into the binary's "libpath" (think: LD_LIBRARY_PATH), which means these will be searched at runtime for shared libraries.

If you, eg, use "-L." to pick up static libraries from the current directory duing build, that will be prepended the current directory to the library path in the binary. This is really bad if eg, your binaries are setuid or it's something that may run eg from /tmp.

The fix is to use something like "-blibpath:/usr/lib" (xlc) "-Wl,-blibpath:/usr/lib" (gcc with native linker) or "-Wl,-rpath /usr/lib" (gcc with gnu linker).

OpenSSH Portable's configure has an example of how to select the correct options at build time.

passwdexpired(3)

AIX 5.3, despite what the passwdexpired(3) man page says, won't allocate the "msg" string unless the pointer is first initialized to NULL. AIX 5.2 and below are OK.

ptys and zero-length reads

AIX has an odd issue with reads on pty file descriptors: a zero length write on the pty slave will result in read(2) on the pty master returning zero.

POSIX says that read(2) can return zero for STREAMS socket, however I'm not sure AIX's ptys are STREAMS-based and, even if they are, a descriptor opened on as device special (ie /dev/ptxx) constitutes a "STREAMS socket".

This behaviour was introduces in AIX 4.3.3 ML4 and is present in all known 5.x versions.

The only way we've found to deal with it is setting errno to zero beforehand, then doing "if (read(fd, ...) == 0 && errno != 0) close_connection();".

Other resources

IBM Redbook: Developing and Porting C and C++ Applications on AIX

Also: AIX Linking and Loading (Gary R. Hook et al). Seems to be not available from IBM any more, though.

Personal tools