freebsd-ports/net/socketbind/Makefile
Eugene Grosbein 03a9755147
net/socketbind: unbreak the library
The code has multiple issues making it unusable with modern FreeBSD:

* it uses long gone ascii2addr() function removed in 2007;
* it passes hardcoded "/usr/lib/libc.so" path to dlopen(),
  but now it is plain text hint file;
* this IPv4-only code neglects to check passed domain for PF_INET
  messing with sockets in other domains (like PF_INET6, PF_LOCAL).

Still, it is very useful while dealing with software like Nagios
that does not support binding to specific IPv4 address
for outgoing connections. The library solves the problem with single line
in /etc/rc.conf:

nagios_env="LD_PRELOAD=/usr/local/lib/libsocketbind.so.1 BINDTO=192.168.6.1"

This changes unbreaks the library making it usable again.
2023-10-05 20:16:51 +07:00

29 lines
1.1 KiB
Makefile

PORTNAME= socketbind
PORTVERSION= 1
PORTREVISION= 1
CATEGORIES= net
MASTER_SITES= # none
DISTFILES= # none
MAINTAINER= nm@web.am
COMMENT= Library to bind applications on multihomed machines to specific IP address
USE_LDCONFIG= YES
INSTALL_TARGET=
post-extract:
${MKDIR} ${WRKSRC}
${CP} -R ${PATCHDIR}/ ${WRKSRC}
pre-install:
${INSTALL_PROGRAM} ${WRKSRC}/libsocketbind.so.1 ${STAGEDIR}${PREFIX}/lib
${LN} -s ${PREFIX}/lib/libsocketbind.so.1 ${STAGEDIR}${PREFIX}/lib/libsocketbind.so
${MKDIR} ${STAGEDIR}${DOCSDIR}
${ECHO} "This library allows to bind arbitrary program, " >> ${STAGEDIR}${DOCSDIR}/README
${ECHO} "which is dynamically linked to libc.so." >> ${STAGEDIR}${DOCSDIR}/README
${ECHO} "Load library before your program (set environment " >> ${STAGEDIR}${DOCSDIR}/README
${ECHO} "variable LD_PRELOAD=${PREFIX}/lib/libsocketbind.so.1) " >> ${STAGEDIR}${DOCSDIR}/README
${ECHO} "and set address to bind to (set environment variable " >> ${STAGEDIR}${DOCSDIR}/README
${ECHO} "BINDTO=ip address to bind)" >> ${STAGEDIR}${DOCSDIR}/README
.include <bsd.port.mk>