Created
January 27, 2022 23:33
-
-
Save orgcontrib/86a5cbc3a5a1d2dfe2e54d849d21b307 to your computer and use it in GitHub Desktop.
nsschk.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Compile: gcc -o nsschk nsschk.c -ldl */ | |
/* Blog/info: http://tiny.cc/mozbigsig */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#include <dlfcn.h> | |
void bail(char *msg) { | |
fprintf(stderr,"%s\n",msg); | |
exit(1); | |
} | |
int main(int argc, char **argv) { | |
/* Use the command argument as the NSS library name, */ | |
/* otherwise pick a sensible default for your distro. */ | |
char *libname = argc>1 ? argv[1] : "/usr/lib64/libnss3.so"; | |
printf("Using library file: %s\n",libname); | |
void *nsslib = dlopen(libname,RTLD_LAZY); | |
if (nsslib == NULL) { bail("Can't dlopen() that file"); } | |
int (*initfn)(char *dir) = dlsym(nsslib,"NSS_NoDB_Init"); | |
char *(*getvfn)(void) = dlsym(nsslib,"NSS_GetVersion"); | |
if (initfn == NULL) { bail("Can't find NSS_NoDB_Init function"); } | |
if (getvfn == NULL) { bail("Can't find NSS_GetVersion function"); } | |
if ((*initfn)(".") != 0) { bail("Failed to initialise NSS"); } | |
printf("NSS Version: %s\n",(*getvfn)()); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment