buffer);
}
-struct nwrap_libc_fns {
- struct passwd *(*_libc_getpwnam)(const char *name);
- int (*_libc_getpwnam_r)(const char *name, struct passwd *pwd,
- char *buf, size_t buflen, struct passwd **result);
- struct passwd *(*_libc_getpwuid)(uid_t uid);
- int (*_libc_getpwuid_r)(uid_t uid, struct passwd *pwd, char *buf, size_t buflen, struct passwd **result);
- void (*_libc_setpwent)(void);
- struct passwd *(*_libc_getpwent)(void);
+/*****************
+ * LIBC
+ *****************/
+
+#define LIBC_NAME "libc.so"
+
+typedef struct passwd *(*__libc_getpwnam)(const char *name);
+
+typedef int (*__libc_getpwnam_r)(const char *name,
+ struct passwd *pwd,
+ char *buf,
+ size_t buflen,
+ struct passwd **result);
+
+typedef struct passwd *(*__libc_getpwuid)(uid_t uid);
+
+typedef int (*__libc_getpwuid_r)(uid_t uid,
+ struct passwd *pwd,
+ char *buf,
+ size_t buflen,
+ struct passwd **result);
+
+typedef void (*__libc_setpwent)(void);
+
+typedef struct passwd *(*__libc_getpwent)(void);
+
#ifdef HAVE_GETPWENT_R
-# ifdef HAVE_SOLARIS_GETPWENT_R
- struct passwd *(*_libc_getpwent_r)(struct passwd *pwbuf, char *buf, size_t buflen);
-# else /* HAVE_SOLARIS_GETPWENT_R */
- int (*_libc_getpwent_r)(struct passwd *pwbuf, char *buf, size_t buflen, struct passwd **pwbufp);
-# endif /* HAVE_SOLARIS_GETPWENT_R */
+# ifdef HAVE_SOLARIS_GETPWENT_R
+typedef struct passwd *(*__libc_getpwent_r)(struct passwd *pwbuf,
+ char *buf,
+ size_t buflen);
+# else /* HAVE_SOLARIS_GETPWENT_R */
+typedef int (*__libc_getpwent_r)(struct passwd *pwbuf,
+ char *buf,
+ size_t buflen,
+ struct passwd **pwbufp);
+# endif /* HAVE_SOLARIS_GETPWENT_R */
#endif /* HAVE_GETPWENT_R */
- void (*_libc_endpwent)(void);
- int (*_libc_initgroups)(const char *user, gid_t gid);
- struct group *(*_libc_getgrnam)(const char *name);
- int (*_libc_getgrnam_r)(const char *name, struct group *grp, char *buf, size_t buflen, struct group **result);
- struct group *(*_libc_getgrgid)(gid_t gid);
- int (*_libc_getgrgid_r)(gid_t gid, struct group *grp, char *buf, size_t buflen, struct group **result);
- void (*_libc_setgrent)(void);
- struct group *(*_libc_getgrent)(void);
+
+typedef void (*__libc_endpwent)(void);
+
+typedef int (*__libc_initgroups)(const char *user, gid_t gid);
+
+typedef struct group *(*__libc_getgrnam)(const char *name);
+
+typedef int (*__libc_getgrnam_r)(const char *name,
+ struct group *grp,
+ char *buf,
+ size_t buflen,
+ struct group **result);
+
+typedef struct group *(*__libc_getgrgid)(gid_t gid);
+
+typedef int (*__libc_getgrgid_r)(gid_t gid,
+ struct group *grp,
+ char *buf,
+ size_t buflen,
+ struct group **result);
+
+typedef void (*__libc_setgrent)(void);
+
+typedef struct group *(*__libc_getgrent)(void);
+
#ifdef HAVE_GETGRENT_R
-# ifdef HAVE_SOLARIS_GETGRENT_R
- struct group *(*_libc_getgrent_r)(struct group *group, char *buf, size_t buflen);
-# else /* HAVE_SOLARIS_GETGRENT_R */
- int (*_libc_getgrent_r)(struct group *group, char *buf, size_t buflen, struct group **result);
-# endif /* HAVE_SOLARIS_GETGRENT_R */
+# ifdef HAVE_SOLARIS_GETGRENT_R
+typedef struct group *(*__libc_getgrent_r)(struct group *group,
+ char *buf,
+ size_t buflen);
+# else /* HAVE_SOLARIS_GETGRENT_R */
+typedef int (*__libc_getgrent_r)(struct group *group,
+ char *buf,
+ size_t buflen,
+ struct group **result);
+# endif /* HAVE_SOLARIS_GETGRENT_R */
#endif /* HAVE_GETGRENT_R */
- void (*_libc_endgrent)(void);
- int (*_libc_getgrouplist)(const char *user, gid_t group, gid_t *groups, int *ngroups);
- void (*_libc_sethostent)(int stayopen);
- struct hostent *(*_libc_gethostent)(void);
- void (*_libc_endhostent)(void);
+typedef void (*__libc_endgrent)(void);
+
+typedef int (*__libc_getgrouplist)(const char *user,
+ gid_t group,
+ gid_t *groups,
+ int *ngroups);
+
+typedef void (*__libc_sethostent)(int stayopen);
+
+typedef struct hostent *(*__libc_gethostent)(void);
+
+typedef void (*__libc_endhostent)(void);
+
+typedef struct hostent *(*__libc_gethostbyname)(const char *name);
- struct hostent *(*_libc_gethostbyname)(const char *name);
#ifdef HAVE_GETHOSTBYNAME2 /* GNU extension */
- struct hostent *(*_libc_gethostbyname2)(const char *name, int af);
+typedef struct hostent *(*__libc_gethostbyname2)(const char *name, int af);
#endif
+
#ifdef HAVE_GETHOSTBYNAME2_R /* GNU extension */
- int (*_libc_gethostbyname2_r)(const char *name,
- int af,
+typedef int (*__libc_gethostbyname2_r)(const char *name,
+ int af,
+ struct hostent *ret,
+ char *buf,
+ size_t buflen,
+ struct hostent **result,
+ int *h_errnop);
+#endif
+
+typedef struct hostent *(*__libc_gethostbyaddr)(const void *addr,
+ socklen_t len,
+ int type);
+
+typedef int (*__libc_getaddrinfo)(const char *node,
+ const char *service,
+ const struct addrinfo *hints,
+ struct addrinfo **res);
+typedef int (*__libc_getnameinfo)(const struct sockaddr *sa,
+ socklen_t salen,
+ char *host,
+ size_t hostlen,
+ char *serv,
+ size_t servlen,
+ int flags);
+
+typedef int (*__libc_gethostname)(char *name, size_t len);
+
+#ifdef HAVE_GETHOSTBYNAME_R
+typedef int (*__libc_gethostbyname_r)(const char *name,
+ struct hostent *ret,
+ char *buf, size_t buflen,
+ struct hostent **result, int *h_errnop);
+#endif
+
+#ifdef HAVE_GETHOSTBYADDR_R
+typedef int (*__libc_gethostbyaddr_r)(const void *addr,
+ socklen_t len,
+ int type,
struct hostent *ret,
char *buf,
size_t buflen,
struct hostent **result,
int *h_errnop);
#endif
- struct hostent *(*_libc_gethostbyaddr)(const void *addr, socklen_t len, int type);
-
- int (*_libc_getaddrinfo)(const char *node, const char *service,
- const struct addrinfo *hints,
- struct addrinfo **res);
- int (*_libc_getnameinfo)(const struct sockaddr *sa, socklen_t salen,
- char *host, size_t hostlen,
- char *serv, size_t servlen,
- int flags);
- int (*_libc_gethostname)(char *name, size_t len);
+
+#define NWRAP_SYMBOL_ENTRY(i) \
+ union { \
+ __libc_##i f; \
+ void *obj; \
+ } _libc_##i
+
+struct nwrap_libc_symbols {
+ NWRAP_SYMBOL_ENTRY(getpwnam);
+ NWRAP_SYMBOL_ENTRY(getpwnam_r);
+ NWRAP_SYMBOL_ENTRY(getpwuid);
+ NWRAP_SYMBOL_ENTRY(getpwuid_r);
+ NWRAP_SYMBOL_ENTRY(setpwent);
+ NWRAP_SYMBOL_ENTRY(getpwent);
+#ifdef HAVE_GETPWENT_R
+ NWRAP_SYMBOL_ENTRY(getpwent_r);
+#endif
+ NWRAP_SYMBOL_ENTRY(endpwent);
+
+ NWRAP_SYMBOL_ENTRY(initgroups);
+ NWRAP_SYMBOL_ENTRY(getgrnam);
+ NWRAP_SYMBOL_ENTRY(getgrnam_r);
+ NWRAP_SYMBOL_ENTRY(getgrgid);
+ NWRAP_SYMBOL_ENTRY(getgrgid_r);
+ NWRAP_SYMBOL_ENTRY(setgrent);
+ NWRAP_SYMBOL_ENTRY(getgrent);
+#ifdef HAVE_GETGRENT_R
+ NWRAP_SYMBOL_ENTRY(getgrent_r);
+#endif
+ NWRAP_SYMBOL_ENTRY(endgrent);
+ NWRAP_SYMBOL_ENTRY(getgrouplist);
+
+ NWRAP_SYMBOL_ENTRY(sethostent);
+ NWRAP_SYMBOL_ENTRY(gethostent);
+ NWRAP_SYMBOL_ENTRY(endhostent);
+ NWRAP_SYMBOL_ENTRY(gethostbyname);
#ifdef HAVE_GETHOSTBYNAME_R
- int (*_libc_gethostbyname_r)(const char *name,
- struct hostent *ret,
- char *buf, size_t buflen,
- struct hostent **result, int *h_errnop);
+ NWRAP_SYMBOL_ENTRY(gethostbyname_r);
+#endif
+#ifdef HAVE_GETHOSTBYNAME2
+ NWRAP_SYMBOL_ENTRY(gethostbyname2);
#endif
+#ifdef HAVE_GETHOSTBYNAME2_R
+ NWRAP_SYMBOL_ENTRY(gethostbyname2_r);
+#endif
+ NWRAP_SYMBOL_ENTRY(gethostbyaddr);
#ifdef HAVE_GETHOSTBYADDR_R
- int (*_libc_gethostbyaddr_r)(const void *addr, socklen_t len, int type,
- struct hostent *ret,
- char *buf, size_t buflen,
- struct hostent **result, int *h_errnop);
+ NWRAP_SYMBOL_ENTRY(gethostbyaddr_r);
#endif
+ NWRAP_SYMBOL_ENTRY(getaddrinfo);
+ NWRAP_SYMBOL_ENTRY(getnameinfo);
+ NWRAP_SYMBOL_ENTRY(gethostname);
};
struct nwrap_module_nss_fns {
void *handle;
void *nsl_handle;
void *sock_handle;
- struct nwrap_libc_fns *fns;
+ struct nwrap_libc_symbols symbols;
};
struct nwrap_main {
return handle;
}
-static void *_nwrap_load_lib_function(enum nwrap_lib lib, const char *fn_name)
+static void *_nwrap_bind_symbol(enum nwrap_lib lib, const char *fn_name)
{
void *handle;
void *func;
return func;
}
-#define nwrap_load_lib_function(lib, fn_name) \
- if (nwrap_main_global->libc->fns->_libc_##fn_name == NULL) { \
- *(void **) (&nwrap_main_global->libc->fns->_libc_##fn_name) = \
- _nwrap_load_lib_function(lib, #fn_name); \
- }
+#define nwrap_bind_symbol_libc(sym_name) \
+ NWRAP_LOCK(libc_symbol_binding); \
+ if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \
+ nwrap_main_global->libc->symbols._libc_##sym_name.obj = \
+ _nwrap_bind_symbol(NWRAP_LIBC, #sym_name); \
+ } \
+ NWRAP_UNLOCK(libc_symbol_binding)
+
+#define nwrap_bind_symbol_libc_posix(sym_name) \
+ NWRAP_LOCK(libc_symbol_binding); \
+ if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \
+ nwrap_main_global->libc->symbols._libc_##sym_name.obj = \
+ _nwrap_bind_symbol(NWRAP_LIBC, "__posix_" #sym_name); \
+ } \
+ NWRAP_UNLOCK(libc_symbol_binding)
+
+#define nwrap_bind_symbol_libnsl(sym_name) \
+ NWRAP_LOCK(libc_symbol_binding); \
+ if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \
+ nwrap_main_global->libc->symbols._libc_##sym_name.obj = \
+ _nwrap_bind_symbol(NWRAP_LIBNSL, #sym_name); \
+ } \
+ NWRAP_UNLOCK(libc_symbol_binding)
+
+#define nwrap_bind_symbol_libsocket(sym_name) \
+ NWRAP_LOCK(libc_symbol_binding); \
+ if (nwrap_main_global->libc->symbols._libc_##sym_name.obj == NULL) { \
+ nwrap_main_global->libc->symbols._libc_##sym_name.obj = \
+ _nwrap_bind_symbol(NWRAP_LIBSOCKET, #sym_name); \
+ } \
+ NWRAP_UNLOCK(libc_symbol_binding)
/* INTERNAL HELPER FUNCTIONS */
static void nwrap_lines_unload(struct nwrap_cache *const nwrap)
*/
static struct passwd *libc_getpwnam(const char *name)
{
- nwrap_load_lib_function(NWRAP_LIBC, getpwnam);
+ nwrap_bind_symbol_libc(getpwnam);
- return nwrap_main_global->libc->fns->_libc_getpwnam(name);
+ return nwrap_main_global->libc->symbols._libc_getpwnam.f(name);
}
#ifdef HAVE_GETPWNAM_R
struct passwd **result)
{
#ifdef HAVE___POSIX_GETPWNAM_R
- if (nwrap_main_global->libc->fns->_libc_getpwnam_r == NULL) {
- *(void **) (&nwrap_main_global->libc->fns->_libc_getpwnam_r) =
- _nwrap_load_lib_function(NWRAP_LIBC, "__posix_getpwnam_r");
- }
+ nwrap_bind_symbol_libc_posix(getpwnam_r);
#else
- nwrap_load_lib_function(NWRAP_LIBC, getpwnam_r);
+ nwrap_bind_symbol_libc(getpwnam_r);
#endif
- return nwrap_main_global->libc->fns->_libc_getpwnam_r(name,
- pwd,
- buf,
- buflen,
- result);
+ return nwrap_main_global->libc->symbols._libc_getpwnam_r.f(name,
+ pwd,
+ buf,
+ buflen,
+ result);
}
#endif
static struct passwd *libc_getpwuid(uid_t uid)
{
- nwrap_load_lib_function(NWRAP_LIBC, getpwuid);
+ nwrap_bind_symbol_libc(getpwuid);
- return nwrap_main_global->libc->fns->_libc_getpwuid(uid);
+ return nwrap_main_global->libc->symbols._libc_getpwuid.f(uid);
}
#ifdef HAVE_GETPWUID_R
struct passwd **result)
{
#ifdef HAVE___POSIX_GETPWUID_R
- if (nwrap_main_global->libc->fns->_libc_getpwuid_r == NULL) {
- *(void **) (&nwrap_main_global->libc->fns->_libc_getpwuid_r) =
- _nwrap_load_lib_function(NWRAP_LIBC, "__posix_getpwuid_r");
- }
+ nwrap_bind_symbol_libc_posix(getpwuid_r);
#else
- nwrap_load_lib_function(NWRAP_LIBC, getpwuid_r);
+ nwrap_bind_symbol_libc(getpwuid_r);
#endif
- return nwrap_main_global->libc->fns->_libc_getpwuid_r(uid,
- pwd,
- buf,
- buflen,
- result);
+ return nwrap_main_global->libc->symbols._libc_getpwuid_r.f(uid,
+ pwd,
+ buf,
+ buflen,
+ result);
}
#endif
static void libc_setpwent(void)
{
- nwrap_load_lib_function(NWRAP_LIBC, setpwent);
+ nwrap_bind_symbol_libc(setpwent);
- nwrap_main_global->libc->fns->_libc_setpwent();
+ nwrap_main_global->libc->symbols._libc_setpwent.f();
}
static struct passwd *libc_getpwent(void)
{
- nwrap_load_lib_function(NWRAP_LIBC, getpwent);
+ nwrap_bind_symbol_libc(getpwent);
- return nwrap_main_global->libc->fns->_libc_getpwent();
+ return nwrap_main_global->libc->symbols._libc_getpwent.f();
}
#ifdef HAVE_GETPWENT_R
char *buf,
int buflen)
{
- nwrap_load_lib_function(NWRAP_LIBC, getpwent_r);
+ nwrap_bind_symbol_libc(getpwent_r);
- return nwrap_main_global->libc->fns->_libc_getpwent_r(pwdst,
- buf,
- buflen);
+ return nwrap_main_global->libc->symbols._libc_getpwent_r.f(pwdst,
+ buf,
+ buflen);
}
# else /* HAVE_SOLARIS_GETPWENT_R */
static int libc_getpwent_r(struct passwd *pwdst,
size_t buflen,
struct passwd **pwdstp)
{
- nwrap_load_lib_function(NWRAP_LIBC, getpwent_r);
+ nwrap_bind_symbol_libc(getpwent_r);
- return nwrap_main_global->libc->fns->_libc_getpwent_r(pwdst,
- buf,
- buflen,
- pwdstp);
+ return nwrap_main_global->libc->symbols._libc_getpwent_r.f(pwdst,
+ buf,
+ buflen,
+ pwdstp);
}
# endif /* HAVE_SOLARIS_GETPWENT_R */
#endif /* HAVE_GETPWENT_R */
static void libc_endpwent(void)
{
- nwrap_load_lib_function(NWRAP_LIBC, endpwent);
+ nwrap_bind_symbol_libc(endpwent);
- nwrap_main_global->libc->fns->_libc_endpwent();
+ nwrap_main_global->libc->symbols._libc_endpwent.f();
}
static int libc_initgroups(const char *user, gid_t gid)
{
- nwrap_load_lib_function(NWRAP_LIBC, initgroups);
+ nwrap_bind_symbol_libc(initgroups);
- return nwrap_main_global->libc->fns->_libc_initgroups(user, gid);
+ return nwrap_main_global->libc->symbols._libc_initgroups.f(user, gid);
}
static struct group *libc_getgrnam(const char *name)
{
- nwrap_load_lib_function(NWRAP_LIBC, getgrnam);
+ nwrap_bind_symbol_libc(getgrnam);
- return nwrap_main_global->libc->fns->_libc_getgrnam(name);
+ return nwrap_main_global->libc->symbols._libc_getgrnam.f(name);
}
#ifdef HAVE_GETGRNAM_R
struct group **result)
{
#ifdef HAVE___POSIX_GETGRNAM_R
- if (nwrap_main_global->libc->fns->_libc_getgrnam_r == NULL) {
- *(void **) (&nwrap_main_global->libc->fns->_libc_getgrnam_r) =
- _nwrap_load_lib_function(NWRAP_LIBC, "__posix_getgrnam_r");
- }
+ nwrap_bind_symbol_libc_posix(getgrnam_r);
#else
- nwrap_load_lib_function(NWRAP_LIBC, getgrnam_r);
+ nwrap_bind_symbol_libc(getgrnam_r);
#endif
- return nwrap_main_global->libc->fns->_libc_getgrnam_r(name,
- grp,
- buf,
- buflen,
- result);
+ return nwrap_main_global->libc->symbols._libc_getgrnam_r.f(name,
+ grp,
+ buf,
+ buflen,
+ result);
}
#endif
static struct group *libc_getgrgid(gid_t gid)
{
- nwrap_load_lib_function(NWRAP_LIBC, getgrgid);
+ nwrap_bind_symbol_libc(getgrgid);
- return nwrap_main_global->libc->fns->_libc_getgrgid(gid);
+ return nwrap_main_global->libc->symbols._libc_getgrgid.f(gid);
}
#ifdef HAVE_GETGRGID_R
struct group **result)
{
#ifdef HAVE___POSIX_GETGRGID_R
- if (nwrap_main_global->libc->fns->_libc_getgrgid_r == NULL) {
- *(void **) (&nwrap_main_global->libc->fns->_libc_getgrgid_r) =
- _nwrap_load_lib_function(NWRAP_LIBC, "__posix_getgrgid_r");
+ if (nwrap_main_global->libc->symbols._libc_getgrgid_r == NULL) {
+ *(void **) (&nwrap_main_global->libc->symbols._libc_getgrgid_r) =
+ _nwrap_bind_symbol_libc("__posix_getgrgid_r");
}
#else
- nwrap_load_lib_function(NWRAP_LIBC, getgrgid_r);
+ nwrap_bind_symbol_libc(getgrgid_r);
#endif
- return nwrap_main_global->libc->fns->_libc_getgrgid_r(gid,
- grp,
- buf,
- buflen,
- result);
+ return nwrap_main_global->libc->symbols._libc_getgrgid_r.f(gid,
+ grp,
+ buf,
+ buflen,
+ result);
}
#endif
static void libc_setgrent(void)
{
- nwrap_load_lib_function(NWRAP_LIBC, setgrent);
+ nwrap_bind_symbol_libc(setgrent);
- nwrap_main_global->libc->fns->_libc_setgrent();
+ nwrap_main_global->libc->symbols._libc_setgrent.f();
}
static struct group *libc_getgrent(void)
{
- nwrap_load_lib_function(NWRAP_LIBC, getgrent);
+ nwrap_bind_symbol_libc(getgrent);
- return nwrap_main_global->libc->fns->_libc_getgrent();
+ return nwrap_main_global->libc->symbols._libc_getgrent.f();
}
#ifdef HAVE_GETGRENT_R
char *buf,
size_t buflen)
{
- nwrap_load_lib_function(NWRAP_LIBC, getgrent_r);
+ nwrap_bind_symbol_libc(getgrent_r);
- return nwrap_main_global->libc->fns->_libc_getgrent_r(group,
- buf,
- buflen);
+ return nwrap_main_global->libc->symbols._libc_getgrent_r.f(group,
+ buf,
+ buflen);
}
# else /* HAVE_SOLARIS_GETGRENT_R */
static int libc_getgrent_r(struct group *group,
size_t buflen,
struct group **result)
{
- nwrap_load_lib_function(NWRAP_LIBC, getgrent_r);
+ nwrap_bind_symbol_libc(getgrent_r);
- return nwrap_main_global->libc->fns->_libc_getgrent_r(group,
- buf,
- buflen,
- result);
+ return nwrap_main_global->libc->symbols._libc_getgrent_r.f(group,
+ buf,
+ buflen,
+ result);
}
# endif /* HAVE_SOLARIS_GETGRENT_R */
#endif /* HAVE_GETGRENT_R */
static void libc_endgrent(void)
{
- nwrap_load_lib_function(NWRAP_LIBC, endgrent);
+ nwrap_bind_symbol_libc(endgrent);
- nwrap_main_global->libc->fns->_libc_endgrent();
+ nwrap_main_global->libc->symbols._libc_endgrent.f();
}
#ifdef HAVE_GETGROUPLIST
gid_t *groups,
int *ngroups)
{
- nwrap_load_lib_function(NWRAP_LIBC, getgrouplist);
+ nwrap_bind_symbol_libc(getgrouplist);
- return nwrap_main_global->libc->fns->_libc_getgrouplist(user,
- group,
- groups,
- ngroups);
+ return nwrap_main_global->libc->symbols._libc_getgrouplist.f(user,
+ group,
+ groups,
+ ngroups);
}
#endif
static void libc_sethostent(int stayopen)
{
- nwrap_load_lib_function(NWRAP_LIBNSL, sethostent);
+ nwrap_bind_symbol_libnsl(sethostent);
- nwrap_main_global->libc->fns->_libc_sethostent(stayopen);
+ nwrap_main_global->libc->symbols._libc_sethostent.f(stayopen);
}
static struct hostent *libc_gethostent(void)
{
- nwrap_load_lib_function(NWRAP_LIBNSL, gethostent);
+ nwrap_bind_symbol_libnsl(gethostent);
- return nwrap_main_global->libc->fns->_libc_gethostent();
+ return nwrap_main_global->libc->symbols._libc_gethostent.f();
}
static void libc_endhostent(void)
{
- nwrap_load_lib_function(NWRAP_LIBNSL, endhostent);
+ nwrap_bind_symbol_libnsl(endhostent);
- nwrap_main_global->libc->fns->_libc_endhostent();
+ nwrap_main_global->libc->symbols._libc_endhostent.f();
}
static struct hostent *libc_gethostbyname(const char *name)
{
- nwrap_load_lib_function(NWRAP_LIBNSL, gethostbyname);
+ nwrap_bind_symbol_libnsl(gethostbyname);
- return nwrap_main_global->libc->fns->_libc_gethostbyname(name);
+ return nwrap_main_global->libc->symbols._libc_gethostbyname.f(name);
}
#ifdef HAVE_GETHOSTBYNAME2 /* GNU extension */
static struct hostent *libc_gethostbyname2(const char *name, int af)
{
- nwrap_load_lib_function(NWRAP_LIBNSL, gethostbyname2);
+ nwrap_bind_symbol_libnsl(gethostbyname2);
- return nwrap_main_global->libc->fns->_libc_gethostbyname2(name, af);
+ return nwrap_main_global->libc->symbols._libc_gethostbyname2.f(name, af);
}
#endif
struct hostent **result,
int *h_errnop)
{
- nwrap_load_lib_function(NWRAP_LIBNSL, gethostbyname2_r);
+ nwrap_bind_symbol_libnsl(gethostbyname2_r);
- return nwrap_main_global->libc->fns->_libc_gethostbyname2_r(name,
- af,
- ret,
- buf,
- buflen,
- result,
- h_errnop);
+ return nwrap_main_global->libc->symbols._libc_gethostbyname2_r.f(name,
+ af,
+ ret,
+ buf,
+ buflen,
+ result,
+ h_errnop);
}
#endif
socklen_t len,
int type)
{
- nwrap_load_lib_function(NWRAP_LIBNSL, gethostbyaddr);
+ nwrap_bind_symbol_libnsl(gethostbyaddr);
- return nwrap_main_global->libc->fns->_libc_gethostbyaddr(addr,
- len,
- type);
+ return nwrap_main_global->libc->symbols._libc_gethostbyaddr.f(addr,
+ len,
+ type);
}
static int libc_gethostname(char *name, size_t len)
{
- nwrap_load_lib_function(NWRAP_LIBNSL, gethostname);
+ nwrap_bind_symbol_libnsl(gethostname);
- return nwrap_main_global->libc->fns->_libc_gethostname(name, len);
+ return nwrap_main_global->libc->symbols._libc_gethostname.f(name, len);
}
#ifdef HAVE_GETHOSTBYNAME_R
struct hostent **result,
int *h_errnop)
{
- nwrap_load_lib_function(NWRAP_LIBNSL, gethostbyname_r);
+ nwrap_bind_symbol_libnsl(gethostbyname_r);
- return nwrap_main_global->libc->fns->_libc_gethostbyname_r(name,
- ret,
- buf,
- buflen,
- result,
- h_errnop);
+ return nwrap_main_global->libc->symbols._libc_gethostbyname_r.f(name,
+ ret,
+ buf,
+ buflen,
+ result,
+ h_errnop);
}
#endif
struct hostent **result,
int *h_errnop)
{
- nwrap_load_lib_function(NWRAP_LIBNSL, gethostbyaddr_r);
+ nwrap_bind_symbol_libnsl(gethostbyaddr_r);
- return nwrap_main_global->libc->fns->_libc_gethostbyaddr_r(addr,
- len,
- type,
- ret,
- buf,
- buflen,
- result,
- h_errnop);
+ return nwrap_main_global->libc->symbols._libc_gethostbyaddr_r.f(addr,
+ len,
+ type,
+ ret,
+ buf,
+ buflen,
+ result,
+ h_errnop);
}
#endif
const struct addrinfo *hints,
struct addrinfo **res)
{
- nwrap_load_lib_function(NWRAP_LIBSOCKET, getaddrinfo);
+ nwrap_bind_symbol_libsocket(getaddrinfo);
- return nwrap_main_global->libc->fns->_libc_getaddrinfo(node,
- service,
- hints,
- res);
+ return nwrap_main_global->libc->symbols._libc_getaddrinfo.f(node,
+ service,
+ hints,
+ res);
}
static int libc_getnameinfo(const struct sockaddr *sa,
size_t servlen,
int flags)
{
- nwrap_load_lib_function(NWRAP_LIBSOCKET, getnameinfo);
+ nwrap_bind_symbol_libsocket(getnameinfo);
- return nwrap_main_global->libc->fns->_libc_getnameinfo(sa,
- salen,
- host,
- hostlen,
- serv,
- servlen,
- flags);
+ return nwrap_main_global->libc->symbols._libc_getnameinfo.f(sa,
+ salen,
+ host,
+ hostlen,
+ serv,
+ servlen,
+ flags);
}
/*********************************************************
*********************************************************/
static void *nwrap_load_module_fn(struct nwrap_backend *b,
- const char *fn_name)
+ const char *fn_name)
{
void *res = NULL;
char *s = NULL;
printf("Failed to allocate memory for libc");
exit(-1);
}
-
- r->libc->fns = calloc(1, sizeof(struct nwrap_libc_fns));
- if (r->libc->fns == NULL) {
- printf("Failed to allocate memory for libc functions");
- exit(-1);
- }
}
static void nwrap_backend_init(struct nwrap_main *r)
/* libc */
if (m->libc != NULL) {
- SAFE_FREE(m->libc->fns);
if (m->libc->handle != NULL) {
dlclose(m->libc->handle);
}