aboutsummaryrefslogtreecommitdiff
blob: b64a5ac9020f09d7e2accffe48b80d3327d70de3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
 * get_sandbox_lib.c
 *
 * Util functions.
 *
 * Copyright 1999-2008 Gentoo Foundation
 * Licensed under the GPL-2
 *
 * Some parts might have Copyright:
 *   Copyright (C) 2002 Brad House <brad@mainstreetsoftworks.com>
 */

#include "headers.h"
#include "sbutil.h"

/* Always let the dynamic loader do the searching rather than hard coding the
 * full path.  This way, things like multilib, testing, local runs work easier.
 *
 * Make an exception for non-standard setups (i.e. prefix) where libsandbox is
 * installed into a path that is not in ld.so.conf.
 */
void get_sandbox_lib(char *path)
{
	save_errno();
	strcpy(path, LIB_NAME);
	if (strncmp("/usr/lib", LIBSANDBOX_PATH, 8)) {
		void *hndl = dlopen(path, RTLD_LAZY);
		if (!hndl)
			snprintf(path, SB_PATH_MAX, "%s/%s", LIBSANDBOX_PATH, LIB_NAME);
		else
			dlclose(hndl);
	}
	restore_errno();
}