nwrap: Support FreeBSD 'struct passwd' members
authorAndreas Schneider <asn@samba.org>
Thu, 21 Jan 2016 12:47:27 +0000 (13:47 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 16 Mar 2016 22:17:41 +0000 (15:17 -0700)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
ConfigureChecks.cmake
config.h.cmake
src/nss_wrapper.c

index 1b6ba01e45e5cef97cb40edb8dc700c80ed8a29e..462b166928cc109bd826ee8a2407d3f7da221aff 100644 (file)
@@ -191,6 +191,9 @@ check_prototype_definition(getnameinfo
 
 # STRUCT MEMBERS
 check_struct_has_member("struct sockaddr" sa_len "sys/socket.h netinet/in.h" HAVE_STRUCT_SOCKADDR_SA_LEN)
+check_struct_has_member("struct passwd" pw_class "pwd.h" HAVE_STRUCT_PASSWD_PW_CLASS)
+check_struct_has_member("struct passwd" pw_change "pwd.h" HAVE_STRUCT_PASSWD_PW_CHANGE)
+check_struct_has_member("struct passwd" pw_expire "pwd.h" HAVE_STRUCT_PASSWD_PW_EXPIRE)
 
 # IPV6
 check_c_source_compiles("
index f00c2a4988c94870783b865481c375273c60b959..75c92ede1fb4e5ad8eaf9508516575eabc2368fa 100644 (file)
 #cmakedefine HAVE_LINUX_GETNAMEINFO_UNSIGNED 1
 
 #cmakedefine HAVE_STRUCT_SOCKADDR_SA_LEN 1
+#cmakedefine HAVE_STRUCT_PASSWD_PW_CLASS 1
+#cmakedefine HAVE_STRUCT_PASSWD_PW_CHANGE 1
+#cmakedefine HAVE_STRUCT_PASSWD_PW_EXPIRE 1
+
 #cmakedefine HAVE_IPV6 1
 
 #cmakedefine HAVE_ATTRIBUTE_PRINTF_FORMAT 1
index c4f1b33e4965250d8d83786a17929f2403d15dd2..808945359f55d52599630de7e48907a584ce2d18 100644 (file)
@@ -154,6 +154,14 @@ typedef nss_status_t NSS_STATUS;
 #define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
 #endif
 
+#ifndef discard_const
+#define discard_const(ptr) ((void *)((uintptr_t)(ptr)))
+#endif
+
+#ifndef discard_const_p
+#define discard_const_p(type, ptr) ((type *)discard_const(ptr))
+#endif
+
 #ifdef HAVE_IPV6
 #define NWRAP_INET_ADDRSTRLEN INET6_ADDRSTRLEN
 #else
@@ -1963,6 +1971,28 @@ static bool nwrap_pw_parse_line(struct nwrap_cache *nwrap, char *line)
 
        NWRAP_LOG(NWRAP_LOG_TRACE, "gid[%u]\n", pw->pw_gid);
 
+#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
+       pw->pw_class = discard_const_p(char, "");
+
+       NWRAP_LOG(NWRAP_LOG_TRACE, "class[%s]", pw->pw_class);
+#endif /* HAVE_STRUCT_PASSWD_PW_CLASS */
+
+#ifdef HAVE_STRUCT_PASSWD_PW_CHANGE
+       pw->pw_change = 0;
+
+       NWRAP_LOG(NWRAP_LOG_TRACE,
+                 "change[%lu]",
+                 (unsigned long)pw->pw_change);
+#endif /* HAVE_STRUCT_PASSWD_PW_CHANGE */
+
+#ifdef HAVE_STRUCT_PASSWD_PW_EXPIRE
+       pw->pw_expire = 0;
+
+       NWRAP_LOG(NWRAP_LOG_TRACE,
+                 "expire[%lu]",
+                 (unsigned long)pw->pw_expire);
+#endif /* HAVE_STRUCT_PASSWD_PW_EXPIRE */
+
        /* gecos */
        p = strchr(c, ':');
        if (!p) {