pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/devel



Module Name:    pkgsrc
Committed By:   riastradh
Date:           Sat Sep  6 18:27:52 UTC 2025

Modified Files:
        pkgsrc/devel: Makefile
Added Files:
        pkgsrc/devel/nss_wrapper: DESCR Makefile PLIST buildlink3.mk distinfo
        pkgsrc/devel/nss_wrapper/patches: patch-ConfigureChecks.cmake
            patch-config.h.cmake patch-src_nss__wrapper.c
            patch-tests_nss__nwrap.c patch-tests_test__nwrap__disabled.c

Log Message:
devel/nss_wrapper: Import nss_wrapper-1.1.16

nss_wrapper is an LD_PRELOAD wrapper for the user, group and hosts
NSS API for automatically testing applications using the getpwent(3),
getgrent(3), gethostent(3), and getaddrinfo(3) families of functions.


To generate a diff of this commit:
cvs rdiff -u -r1.4520 -r1.4521 pkgsrc/devel/Makefile
cvs rdiff -u -r0 -r1.1 pkgsrc/devel/nss_wrapper/DESCR \
    pkgsrc/devel/nss_wrapper/Makefile pkgsrc/devel/nss_wrapper/PLIST \
    pkgsrc/devel/nss_wrapper/buildlink3.mk pkgsrc/devel/nss_wrapper/distinfo
cvs rdiff -u -r0 -r1.1 \
    pkgsrc/devel/nss_wrapper/patches/patch-ConfigureChecks.cmake \
    pkgsrc/devel/nss_wrapper/patches/patch-config.h.cmake \
    pkgsrc/devel/nss_wrapper/patches/patch-src_nss__wrapper.c \
    pkgsrc/devel/nss_wrapper/patches/patch-tests_nss__nwrap.c \
    pkgsrc/devel/nss_wrapper/patches/patch-tests_test__nwrap__disabled.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/devel/Makefile
diff -u pkgsrc/devel/Makefile:1.4520 pkgsrc/devel/Makefile:1.4521
--- pkgsrc/devel/Makefile:1.4520        Sat Sep  6 18:26:56 2025
+++ pkgsrc/devel/Makefile       Sat Sep  6 18:27:51 2025
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4520 2025/09/06 18:26:56 riastradh Exp $
+# $NetBSD: Makefile,v 1.4521 2025/09/06 18:27:51 riastradh Exp $
 #
 
 COMMENT=       Development utilities
@@ -1249,6 +1249,7 @@ SUBDIR+=  nsis
 SUBDIR+=       nspr
 SUBDIR+=       nspr-reference
 SUBDIR+=       nss
+SUBDIR+=       nss_wrapper
 SUBDIR+=       objfw
 SUBDIR+=       ocaml-angstrom
 SUBDIR+=       ocaml-astring

Added files:

Index: pkgsrc/devel/nss_wrapper/DESCR
diff -u /dev/null pkgsrc/devel/nss_wrapper/DESCR:1.1
--- /dev/null   Sat Sep  6 18:27:52 2025
+++ pkgsrc/devel/nss_wrapper/DESCR      Sat Sep  6 18:27:51 2025
@@ -0,0 +1,15 @@
+There are projects which provide daemons needing to be able to create,
+modify and delete Unix users.  Or just switch user ids to interact with
+the system e.g. a user space file server.  To be able to test that you
+need the privilege to modify the passwd and groups file.  With
+nss_wrapper it is possible to define your own passwd and groups file
+which will be used by software to act correctly while under test.
+
+If you have a client and server under test they normally use functions
+to resolve network names to addresses (dns) or vice versa.  The
+nss_wrappers allow you to create a hosts file to setup name resolution
+for the addresses you use with socket_wrapper.
+
+- Provides information for user and group accounts.
+- Network name resolution using a hosts file.
+- Loading and testing of NSS modules.
Index: pkgsrc/devel/nss_wrapper/Makefile
diff -u /dev/null pkgsrc/devel/nss_wrapper/Makefile:1.1
--- /dev/null   Sat Sep  6 18:27:52 2025
+++ pkgsrc/devel/nss_wrapper/Makefile   Sat Sep  6 18:27:51 2025
@@ -0,0 +1,26 @@
+# $NetBSD: Makefile,v 1.1 2025/09/06 18:27:51 riastradh Exp $
+
+DISTNAME=      nss_wrapper-1.1.16
+CATEGORIES=    devel
+MASTER_SITES=  https://ftp.samba.org/pub/cwrap/
+
+MAINTAINER=    pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE=      https://cwrap.org/nss_wrapper.html
+COMMENT=       LD_PRELOAD wrapper for the user, group and hosts NSS API
+LICENSE=       modified-bsd
+
+USE_TOOLS+=    perl:run
+
+REPLACE_PERL+= nss_wrapper.pl
+
+CMAKE_CONFIGURE_ARGS+= -DUNIT_TESTING:BOOL=TRUE
+
+BUILDLINK_DEPMETHOD.cmocka=    build # for automatic tests only
+
+# All tests should pass on NetBSD 9/amd64.
+
+TEST_TARGET=   test
+
+.include "../../devel/cmake/build.mk"
+.include "../../devel/cmocka/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
Index: pkgsrc/devel/nss_wrapper/PLIST
diff -u /dev/null pkgsrc/devel/nss_wrapper/PLIST:1.1
--- /dev/null   Sat Sep  6 18:27:52 2025
+++ pkgsrc/devel/nss_wrapper/PLIST      Sat Sep  6 18:27:52 2025
@@ -0,0 +1,9 @@
+@comment $NetBSD: PLIST,v 1.1 2025/09/06 18:27:52 riastradh Exp $
+bin/nss_wrapper.pl
+lib/cmake/nss_wrapper/nss_wrapper-config-version.cmake
+lib/cmake/nss_wrapper/nss_wrapper-config.cmake
+lib/libnss_wrapper.so
+lib/libnss_wrapper.so.0
+lib/libnss_wrapper.so.0.3.5
+lib/pkgconfig/nss_wrapper.pc
+man/man1/nss_wrapper.1
Index: pkgsrc/devel/nss_wrapper/buildlink3.mk
diff -u /dev/null pkgsrc/devel/nss_wrapper/buildlink3.mk:1.1
--- /dev/null   Sat Sep  6 18:27:52 2025
+++ pkgsrc/devel/nss_wrapper/buildlink3.mk      Sat Sep  6 18:27:52 2025
@@ -0,0 +1,13 @@
+# $NetBSD: buildlink3.mk,v 1.1 2025/09/06 18:27:52 riastradh Exp $
+
+BUILDLINK_TREE+=       nss_wrapper
+
+.if !defined(NSS_WRAPPER_BUILDLINK3_MK)
+
+BUILDLINK_API_DEPENDS.nss_wrapper+=    nss_wrapper>=1.1.16
+BUILDLINK_ABI_DEPENDS.nss_wrapper+=    nss_wrapper>=1.1.16
+BUILDLINK_PKGSRCDIR.nss_wrapper=       ../../devel/nss_wrapper
+
+.endif
+
+BUILDLINK_TREE+=       -nss_wrapper
Index: pkgsrc/devel/nss_wrapper/distinfo
diff -u /dev/null pkgsrc/devel/nss_wrapper/distinfo:1.1
--- /dev/null   Sat Sep  6 18:27:52 2025
+++ pkgsrc/devel/nss_wrapper/distinfo   Sat Sep  6 18:27:52 2025
@@ -0,0 +1,10 @@
+$NetBSD: distinfo,v 1.1 2025/09/06 18:27:52 riastradh Exp $
+
+BLAKE2s (nss_wrapper-1.1.16.tar.gz) = 4af66e57f96e015c5bf4027617600add8a7542bd51dc47306e6556bba5db73cc
+SHA512 (nss_wrapper-1.1.16.tar.gz) = 684845c25dd7ff48c07f25908d6eef9fa77a098d8d02eb1e8d6f0f6f103a3b4bdfbe4504605015f104fc7092b1224b26fe7096cb9e72e3d8bfc635c276efd036
+Size (nss_wrapper-1.1.16.tar.gz) = 190469 bytes
+SHA1 (patch-ConfigureChecks.cmake) = 1fc07a9e69b1cd1f632ea1a0f71669e44ce6f7a8
+SHA1 (patch-config.h.cmake) = 5e7b9f5f2c88b389dbc789693d63584b390858aa
+SHA1 (patch-src_nss__wrapper.c) = ba0677b362c443f19580088c726ffe409fa61a5e
+SHA1 (patch-tests_nss__nwrap.c) = f9f1ad721012df26dd1832fbb98a200ab7ed77a2
+SHA1 (patch-tests_test__nwrap__disabled.c) = fd3dacb4bc9af21f481e5123ce63a08bd2f04cb3

Index: pkgsrc/devel/nss_wrapper/patches/patch-ConfigureChecks.cmake
diff -u /dev/null pkgsrc/devel/nss_wrapper/patches/patch-ConfigureChecks.cmake:1.1
--- /dev/null   Sat Sep  6 18:27:52 2025
+++ pkgsrc/devel/nss_wrapper/patches/patch-ConfigureChecks.cmake        Sat Sep  6 18:27:52 2025
@@ -0,0 +1,28 @@
+$NetBSD: patch-ConfigureChecks.cmake,v 1.1 2025/09/06 18:27:52 riastradh Exp $
+
+Add NetBSD support.
+
+--- ConfigureChecks.cmake.orig 2024-07-05 05:53:08.000000000 +0000
++++ ConfigureChecks.cmake
+@@ -53,6 +53,7 @@ check_include_file(pwd.h HAVE_PWD_H)
+ check_include_file(shadow.h HAVE_SHADOW_H)
+ check_include_file(grp.h HAVE_GRP_H)
+ check_include_file(nss.h HAVE_NSS_H)
++check_include_file(nsswitch.h HAVE_NSSWITCH_H)
+ check_include_file(nss_common.h HAVE_NSS_COMMON_H)
+ check_include_file(gnu/lib-names.h HAVE_GNU_LIB_NAMES_H)
+ 
+@@ -74,11 +75,13 @@ check_function_exists(getgrent_r HAVE_GE
+ 
+ check_function_exists(getgrouplist HAVE_GETGROUPLIST)
+ 
++if (NOT NETBSD)
+ check_function_exists(gethostbyaddr_r HAVE_GETHOSTBYADDR_R)
+ check_function_exists(gethostbyname_r HAVE_GETHOSTBYNAME_R)
+ 
+ check_function_exists(gethostbyname2 HAVE_GETHOSTBYNAME2)
+ check_function_exists(gethostbyname2_r HAVE_GETHOSTBYNAME2_R)
++endif (NOT NETBSD)
+ 
+ check_function_exists(getprogname HAVE_GETPROGNAME)
+ check_function_exists(getexecname HAVE_GETEXECNAME)
Index: pkgsrc/devel/nss_wrapper/patches/patch-config.h.cmake
diff -u /dev/null pkgsrc/devel/nss_wrapper/patches/patch-config.h.cmake:1.1
--- /dev/null   Sat Sep  6 18:27:52 2025
+++ pkgsrc/devel/nss_wrapper/patches/patch-config.h.cmake       Sat Sep  6 18:27:52 2025
@@ -0,0 +1,14 @@
+$NetBSD: patch-config.h.cmake,v 1.1 2025/09/06 18:27:52 riastradh Exp $
+
+Add NetBSD support.
+
+--- config.h.cmake.orig        2024-07-05 05:53:08.000000000 +0000
++++ config.h.cmake
+@@ -20,6 +20,7 @@
+ #cmakedefine HAVE_GRP_H 1
+ #cmakedefine HAVE_NSS_H 1
+ #cmakedefine HAVE_NSS_COMMON_H 1
++#cmakedefine HAVE_NSSWITCH_H 1
+ #cmakedefine HAVE_GNU_LIB_NAMES_H 1
+ 
+ /*************************** FUNCTIONS ***************************/
Index: pkgsrc/devel/nss_wrapper/patches/patch-src_nss__wrapper.c
diff -u /dev/null pkgsrc/devel/nss_wrapper/patches/patch-src_nss__wrapper.c:1.1
--- /dev/null   Sat Sep  6 18:27:52 2025
+++ pkgsrc/devel/nss_wrapper/patches/patch-src_nss__wrapper.c   Sat Sep  6 18:27:52 2025
@@ -0,0 +1,95 @@
+$NetBSD: patch-src_nss__wrapper.c,v 1.1 2025/09/06 18:27:52 riastradh Exp $
+
+Add NetBSD support.  See https://wiki.NetBSD.org/symbol_versions for
+reference about symbol versioning.
+
+Avoid ctype(3) abuse.
+
+--- src/nss_wrapper.c.orig     2024-07-05 08:31:02.000000000 +0000
++++ src/nss_wrapper.c
+@@ -87,6 +87,31 @@
+ 
+ #include <dlfcn.h>
+ 
++#ifdef __NetBSD__
++static void *
++wrap_dlsym(void *handle, const char *symbol)
++{
++      static const struct {
++              const char *public, *internal;
++      } renames[] = {
++              { "getpwent", "__getpwent50" },
++              { "getpwent_r", "__getpwent_r50" },
++              { "getpwnam", "__getpwnam50" },
++              { "getpwnam_r", "__getpwnam_r50" },
++              { "getpwuid", "__getpwuid50" },
++              { "getpwuid_r", "__getpwuid_r50" },
++      };
++      size_t i;
++
++      for (i = 0; i < sizeof(renames)/sizeof(renames[0]); i++) {
++              if (strcmp(symbol, renames[i].public) == 0)
++                      return dlsym(handle, renames[i].internal);
++      }
++      return dlsym(handle, symbol);
++}
++#define       dlsym           wrap_dlsym
++#endif
++
+ #if defined(HAVE_NSS_H)
+ /* Linux and BSD */
+ #include <nss.h>
+@@ -104,6 +129,16 @@ typedef nss_status_t NSS_STATUS;
+ # define NSS_STATUS_NOTFOUND    NSS_NOTFOUND
+ # define NSS_STATUS_UNAVAIL     NSS_UNAVAIL
+ # define NSS_STATUS_TRYAGAIN    NSS_TRYAGAIN
++#elif defined(HAVE_NSSWITCH_H)
++/* NetBSD */
++#include <nsswitch.h>
++
++typedef int NSS_STATUS;
++
++# define NSS_STATUS_SUCCESS     NS_SUCCESS
++# define NSS_STATUS_NOTFOUND    NS_NOTFOUND
++# define NSS_STATUS_UNAVAIL     NS_UNAVAIL
++# define NSS_STATUS_TRYAGAIN    NS_TRYAGAIN
+ #else
+ # error "No nsswitch support detected"
+ #endif
+@@ -1394,7 +1429,7 @@ static inline void str_tolower(char *dst
+       register char *dst_tmp = dst;
+ 
+       while (*src_tmp != '\0') {
+-              *dst_tmp = tolower(*src_tmp);
++              *dst_tmp = tolower((unsigned char)*src_tmp);
+               ++src_tmp;
+               ++dst_tmp;
+       }
+@@ -5317,6 +5352,7 @@ int initgroups(const char *user, gid_t g
+               return libc_initgroups(user, group);
+       }
+ 
++
+       return nwrap_initgroups(user, group);
+ }
+ 
+@@ -5612,7 +5648,7 @@ static int nwrap_getgrouplist(const char
+                             gid_t **groupsp,
+                             long int limit)
+ {
+-      enum nss_status status = NSS_STATUS_UNAVAIL;
++      NSS_STATUS status = NSS_STATUS_UNAVAIL;
+       /* Start is one, because we have the first group as parameter.  */
+       long int start = 1;
+       size_t i;
+@@ -5960,6 +5996,10 @@ struct hostent *gethostbyaddr(const void
+       return nwrap_gethostbyaddr(addr, len, type);
+ }
+ 
++#ifndef AI_V4MAPPED
++#define       AI_V4MAPPED     0
++#endif
++
+ static const struct addrinfo default_hints =
+ {
+       .ai_flags = AI_ADDRCONFIG|AI_V4MAPPED,
Index: pkgsrc/devel/nss_wrapper/patches/patch-tests_nss__nwrap.c
diff -u /dev/null pkgsrc/devel/nss_wrapper/patches/patch-tests_nss__nwrap.c:1.1
--- /dev/null   Sat Sep  6 18:27:52 2025
+++ pkgsrc/devel/nss_wrapper/patches/patch-tests_nss__nwrap.c   Sat Sep  6 18:27:52 2025
@@ -0,0 +1,23 @@
+$NetBSD: patch-tests_nss__nwrap.c,v 1.1 2025/09/06 18:27:52 riastradh Exp $
+
+Add NetBSD support.
+
+--- tests/nss_nwrap.c.orig     2023-07-28 07:24:34.000000000 +0000
++++ tests/nss_nwrap.c
+@@ -28,6 +28,16 @@ typedef nss_status_t NSS_STATUS;
+ # define NSS_STATUS_NOTFOUND    NSS_NOTFOUND
+ # define NSS_STATUS_UNAVAIL     NSS_UNAVAIL
+ # define NSS_STATUS_TRYAGAIN    NSS_TRYAGAIN
++#elif defined(HAVE_NSSWITCH_H)
++/* NetBSD */
++#include <nsswitch.h>
++
++typedef int NSS_STATUS;
++
++# define NSS_STATUS_SUCCESS     NS_SUCCESS
++# define NSS_STATUS_NOTFOUND    NS_NOTFOUND
++# define NSS_STATUS_UNAVAIL     NS_UNAVAIL
++# define NSS_STATUS_TRYAGAIN    NS_TRYAGAIN
+ #else
+ # error "No nsswitch support detected"
+ #endif
Index: pkgsrc/devel/nss_wrapper/patches/patch-tests_test__nwrap__disabled.c
diff -u /dev/null pkgsrc/devel/nss_wrapper/patches/patch-tests_test__nwrap__disabled.c:1.1
--- /dev/null   Sat Sep  6 18:27:52 2025
+++ pkgsrc/devel/nss_wrapper/patches/patch-tests_test__nwrap__disabled.c        Sat Sep  6 18:27:52 2025
@@ -0,0 +1,51 @@
+$NetBSD: patch-tests_test__nwrap__disabled.c,v 1.1 2025/09/06 18:27:52 riastradh Exp $
+
+Don't pass static getpwuid(...)->pw_name buffer back into getpwnam,
+which may overwrite the same buffer as it works, causing trouble on
+NetBSD:
+
+[ RUN      ] test_nwrap_passwd_group
+[  ERROR   ] --- pwd
+[   LINE   ] --- /home/riastradh/pkgsrc/current/work/devel/nss_wrapper/work/nss_wrapper-1.1.16/tests/test_nwrap_disabled.c:29: error: Failure!
+[  FAILED  ] test_nwrap_passwd_group
+
+--- tests/test_nwrap_disabled.c.orig   2020-03-17 17:23:32.000000000 +0000
++++ tests/test_nwrap_disabled.c
+@@ -2,6 +2,7 @@
+ 
+ #include <stdarg.h>
+ #include <stddef.h>
++#include <stdlib.h>
+ #include <setjmp.h>
+ #include <cmocka.h>
+ 
+@@ -17,6 +18,7 @@
+ 
+ static void test_nwrap_passwd_group(void **state)
+ {
++      char *name;
+       struct passwd *pwd;
+       struct group *grp;
+ 
+@@ -25,14 +27,20 @@ static void test_nwrap_passwd_group(void
+       pwd = getpwuid(getuid());
+       assert_non_null(pwd);
+ 
+-      pwd = getpwnam(pwd->pw_name);
++      name = strdup(pwd->pw_name);
++      assert_non_null(name);
++      pwd = getpwnam(name);
+       assert_non_null(pwd);
++      free(name);
+ 
+       grp = getgrgid(pwd->pw_gid);
+       assert_non_null(grp);
+ 
++      name = strdup(grp->gr_name);
++      assert_non_null(name);
+       grp = getgrnam(grp->gr_name);
+       assert_non_null(grp);
++      free(name);
+ }
+ 
+ /* Test libnsl */



Home | Main Index | Thread Index | Old Index