libs/nixio: allow building without shadow password support

This commit is contained in:
Jo-Philipp Wich 2011-08-11 23:21:06 +00:00
parent 11ff9204cf
commit 0d73b6d411
2 changed files with 11 additions and 0 deletions

View file

@ -10,6 +10,7 @@ AXTLS_VERSION = 1.2.1
AXTLS_DIR = axTLS AXTLS_DIR = axTLS
AXTLS_FILE = $(AXTLS_DIR)-$(AXTLS_VERSION).tar.gz AXTLS_FILE = $(AXTLS_DIR)-$(AXTLS_VERSION).tar.gz
NIXIO_TLS ?= openssl NIXIO_TLS ?= openssl
NIXIO_SHADOW ?= $(shell echo 'int main(void){ return !getspnam("root"); }' | $(CC) -include shadow.h -xc -o/dev/null - 2>/dev/null && echo yes)
NIXIO_SO = nixio.so NIXIO_SO = nixio.so
NIXIO_LDFLAGS = NIXIO_LDFLAGS =
@ -45,6 +46,10 @@ ifeq ($(NIXIO_TLS),)
NIXIO_CFLAGS += -DNO_TLS NIXIO_CFLAGS += -DNO_TLS
endif endif
ifneq ($(NIXIO_SHADOW),yes)
NIXIO_CFLAGS += -DNO_SHADOW
endif
ifeq ($(OS),SunOS) ifeq ($(OS),SunOS)
NIXIO_LDFLAGS += -lsocket -lnsl -lsendfile NIXIO_LDFLAGS += -lsocket -lnsl -lsendfile

View file

@ -28,7 +28,9 @@
#include <pwd.h> #include <pwd.h>
#ifndef BSD #ifndef BSD
#ifndef NO_SHADOW
#include <shadow.h> #include <shadow.h>
#endif
#include <crypt.h> #include <crypt.h>
#endif #endif
@ -162,6 +164,7 @@ static int nixio_getpw(lua_State *L) {
} }
#ifndef BSD #ifndef BSD
#ifndef NO_SHADOW
static int nixio__push_spwd(lua_State *L, struct spwd *sp) { static int nixio__push_spwd(lua_State *L, struct spwd *sp) {
lua_createtable(L, 0, 9); lua_createtable(L, 0, 9);
lua_pushstring(L, sp->sp_namp); lua_pushstring(L, sp->sp_namp);
@ -216,6 +219,7 @@ static int nixio_getsp(lua_State *L) {
return nixio__push_spwd(L, sp); return nixio__push_spwd(L, sp);
} }
} }
#endif /* !NO_SHADOW */
#endif /* !BSD */ #endif /* !BSD */
static int nixio_crypt(lua_State *L) { static int nixio_crypt(lua_State *L) {
@ -239,7 +243,9 @@ static const luaL_reg R[] = {
{"getgr", nixio_getgr}, {"getgr", nixio_getgr},
{"getpw", nixio_getpw}, {"getpw", nixio_getpw},
#ifndef BSD #ifndef BSD
#ifndef NO_SHADOW
{"getsp", nixio_getsp}, {"getsp", nixio_getsp},
#endif
#endif #endif
{NULL, NULL} {NULL, NULL}
}; };