aboutsummaryrefslogtreecommitdiff
path: root/tests/tst-dlopen.c
diff options
context:
space:
mode:
authorSteve Langasek <steve.langasek@ubuntu.com>2019-01-03 17:05:01 -0800
committerSteve Langasek <steve.langasek@ubuntu.com>2019-01-03 17:27:13 -0800
commit419bd504587ec2bfc9085fe56e7a53433fd1eae6 (patch)
treed516c2ccae28dbd020cb69f50162f5d32acd7648 /tests/tst-dlopen.c
parentc68dce23face9f26b651917b418c7f80931fa7b7 (diff)
parent9c52e721044e7501c3d4567b36d222dc7326224a (diff)
downloadpam-419bd504587ec2bfc9085fe56e7a53433fd1eae6.tar.gz
pam-419bd504587ec2bfc9085fe56e7a53433fd1eae6.tar.bz2
pam-419bd504587ec2bfc9085fe56e7a53433fd1eae6.zip
merge upstream version 1.0.1
Diffstat (limited to 'tests/tst-dlopen.c')
-rw-r--r--tests/tst-dlopen.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/tests/tst-dlopen.c b/tests/tst-dlopen.c
new file mode 100644
index 00000000..e4770eea
--- /dev/null
+++ b/tests/tst-dlopen.c
@@ -0,0 +1,48 @@
+/*
+ Copyright (C) Nalin Dahyabhai <nalin@redhat.com> 2003
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+*/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <dlfcn.h>
+#include <stdio.h>
+#include <limits.h>
+#include <sys/stat.h>
+
+/* Simple program to see if dlopen() would succeed. */
+int main(int argc, char **argv)
+{
+#ifdef PAM_STATIC
+ return 77;
+#else
+ int i;
+ struct stat st;
+ char buf[PATH_MAX];
+
+ for (i = 1; i < argc; i++) {
+ if (dlopen(argv[i], RTLD_NOW)) {
+ fprintf(stdout, "dlopen() of \"%s\" succeeded.\n",
+ argv[i]);
+ } else {
+ snprintf(buf, sizeof(buf), "./%s", argv[i]);
+ if ((stat(buf, &st) == 0) && dlopen(buf, RTLD_NOW)) {
+ fprintf(stdout, "dlopen() of \"./%s\" "
+ "succeeded.\n", argv[i]);
+ } else {
+ fprintf(stdout, "dlopen() of \"%s\" failed: "
+ "%s\n", argv[i], dlerror());
+ return 1;
+ }
+ }
+ }
+ return 0;
+#endif
+}
+