Now that we dlopen() so many deps, it might happen by accident that we end up dlopen()ening stuff when we entered a container, which we should really avoid, to not mix host and container libraries. Let's add a global variable we can set when we want to block dlopen() to ever succeed. This is then checked primarily in dlopen_many_sym_or_warn(), where we'll generate EPERM plus a log message. There are a couple of other places we invoke dlopen(), without going through dlopen_many_sym_or_warn(). This adds the same check there.
21 lines
481 B
C
21 lines
481 B
C
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
|
|
#include <dlfcn.h>
|
|
#include <stdlib.h>
|
|
|
|
#include "dlfcn-util.h"
|
|
#include "shared-forward.h"
|
|
|
|
int main(int argc, char **argv) {
|
|
void *handles[argc - 1];
|
|
int i;
|
|
|
|
for (i = 0; i < argc - 1; i++)
|
|
assert_se(dlopen_safe(argv[i + 1], handles + i, /* reterr_dlerror= */ NULL) >= 0);
|
|
|
|
for (i--; i >= 0; i--)
|
|
assert_se(dlclose(handles[i]) == 0);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|