Comment 1 for bug 1821752

Revision history for this message
In , Mike Frysinger (vapier) wrote :

it looks like the change landed for bug 16046 broke static dlopening of nss modules. if you try to use getaddrinfo/getpwnam/etc..., they just return errors immediately.

example tests:
$ cat test.c
#include <sys/types.h>
#include <pwd.h>
#include <stdio.h>
int main() {
    void *p = getpwnam("root");
    printf("%p\n", p);
    return p == NULL ? 1 : 0;
}

$ gcc test.c && ./a.out
0x7f6aec59a0e0
$ gcc -static test.c && ./a.out
(nil)

$ cat test.c
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <netinet/in.h>
#include <net/if.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <netdb.h>
#include <string.h>

int main(int argc, char *argv[])
{
        const char *host = argv[1];
        int rc;
        struct addrinfo *result = NULL;
        struct addrinfo hint;

        memset(&hint, 0 , sizeof(hint));
        hint.ai_family = AF_INET;
        hint.ai_socktype = SOCK_STREAM;
        hint.ai_flags = AF_UNSPEC;
        rc = getaddrinfo(host, NULL, &hint, &result);
        if (rc || !result) {
                printf("bad address '%s'\n", host);
                return 1;
        } else
                return 0;
}

$ gcc test.c && ./a.out localhost
$ gcc -static test.c && ./a.out localhost
bad address 'localhost'