+++ /dev/null
-/*
- * Unix SMB/CIFS implementation.
- *
- * Replaceable functions by cwrap
- *
- * Copyright (c) 2014 Andreas Schneider <asn@samba.org>
- *
- * ** NOTE! The following LGPL license applies to the replace
- * ** library. This does NOT imply that all of Samba is released
- * ** under the LGPL
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 3 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "replace.h"
-
-bool nss_wrapper_enabled(void)
-{
- return false;
-}
-
-bool nss_wrapper_hosts_enabled(void)
-{
- return false;
-}
-
-bool socket_wrapper_enabled(void)
-{
- return false;
-}
-
-bool uid_wrapper_enabled(void)
-{
- return false;
-}
# endif /* HAVE_FALLTHROUGH_ATTRIBUTE */
#endif /* FALL_THROUGH */
-bool nss_wrapper_enabled(void);
-bool nss_wrapper_hosts_enabled(void);
-bool socket_wrapper_enabled(void);
-bool uid_wrapper_enabled(void);
+struct __rep_cwrap_enabled_state {
+ const char *fnname;
+ bool cached;
+ bool retval;
+};
+
+static inline bool __rep_cwrap_enabled_fn(struct __rep_cwrap_enabled_state *state)
+{
+ bool (*__wrapper_enabled_fn)(void) = NULL;
+
+ if (state->cached) {
+ return state->retval;
+ }
+ state->retval = false;
+ state->cached = true;
+
+ __wrapper_enabled_fn = dlsym(RTLD_DEFAULT, state->fnname);
+ if (__wrapper_enabled_fn == NULL) {
+ return state->retval;
+ }
+
+ state->retval = __wrapper_enabled_fn();
+ return state->retval;
+}
+
+static inline bool nss_wrapper_enabled(void)
+{
+ struct __rep_cwrap_enabled_state state = {
+ .fnname = "nss_wrapper_enabled",
+ };
+ return __rep_cwrap_enabled_fn(&state);
+}
+static inline bool nss_wrapper_hosts_enabled(void)
+{
+ struct __rep_cwrap_enabled_state state = {
+ .fnname = "nss_wrapper_hosts_enabled",
+ };
+ return __rep_cwrap_enabled_fn(&state);
+}
+static inline bool socket_wrapper_enabled(void)
+{
+ struct __rep_cwrap_enabled_state state = {
+ .fnname = "socket_wrapper_enabled",
+ };
+ return __rep_cwrap_enabled_fn(&state);
+}
+static inline bool uid_wrapper_enabled(void)
+{
+ struct __rep_cwrap_enabled_state state = {
+ .fnname = "uid_wrapper_enabled",
+ };
+ return __rep_cwrap_enabled_fn(&state);
+}
static inline bool _hexcharval(char c, uint8_t *val)
{