Skip to content
Snippets Groups Projects
Commit ea9cebf2 authored by Simon McVittie's avatar Simon McVittie
Browse files

init: Automatically exclude glibc from encapsulation

parent 218f0df1
No related branches found
No related tags found
1 merge request!311Build capsule-capture-libs from a bundled copy of libcapsule
...@@ -50,6 +50,34 @@ ...@@ -50,6 +50,34 @@
cap->ns->combined_exclude , \ cap->ns->combined_exclude , \
cap->ns->combined_export);}) cap->ns->combined_export);})
/*
* never_encapsulated:
*
* Array of SONAMEs that never have a private copy inside a capsule.
* Only one copy of each of these will be loaded, and they will always
* be loaded without respecting the #capsule_namespace's @prefix, even
* if loaded from inside a capsule.
*
* This currently contains the libraries built by the glibc source package.
*/
static const char * const never_encapsulated[] =
{
"libBrokenLocale.so.1",
"libanl.so.1",
"libc.so.6",
"libcidn.so.1",
"libcrypt.so.1",
"libdl.so.2",
"libm.so.6",
"libmvec.so.1",
"libnsl.so.1",
"libpthread.so.0",
"libresolv.so.2",
"librt.so.1",
"libthread_db.so.1",
"libutil.so.1",
};
static ptr_list *namespaces = NULL; static ptr_list *namespaces = NULL;
ptr_list *_capsule_list = NULL; ptr_list *_capsule_list = NULL;
...@@ -202,22 +230,29 @@ get_capsule_metadata (struct link_map *map, const char *only) ...@@ -202,22 +230,29 @@ get_capsule_metadata (struct link_map *map, const char *only)
/** /**
* cook_list: * cook_list:
* @list: a ptr_list containing statically-allocated strings * @list: a ptr_list containing statically-allocated strings
* @extras: (array length=n_extras): extra entries to be added
* @n_extras: number of extra entries
* *
* Return @list as an array of strings. The strings are not copied, so * Return @list + @extras as an array of strings. The strings are not
* the result is only valid as long as the strings are. * copied, so the result is only valid as long as the strings are.
* *
* Returns: (transfer container) (array zero-terminated=1) (element-type utf8): * Returns: (transfer container) (array zero-terminated=1) (element-type utf8):
* a shallow copy of @list * a shallow copy of everything in either @list or @extras
*/ */
static char ** static char **
cook_list (ptr_list *list) cook_list (ptr_list *list,
const char * const *extras,
size_t n_extras)
{ {
char **cooked = calloc( list->next + 1, sizeof(char *) ); char **cooked = calloc( list->next + n_extras + 1, sizeof(char *) );
for( size_t j = 0; j < list->next; j++ ) for( size_t j = 0; j < list->next; j++ )
*(cooked + j) = (char *)ptr_list_nth_ptr( list, j ); cooked[j] = (char *)ptr_list_nth_ptr( list, j );
for( size_t j = 0; j < n_extras; j++ )
cooked[j + list->next] = (char *)extras[j];
*(cooked + list->next) = NULL; *(cooked + list->next + n_extras) = NULL;
return cooked; return cooked;
} }
...@@ -335,8 +370,10 @@ update_namespaces (void) ...@@ -335,8 +370,10 @@ update_namespaces (void)
free_strv( ns->combined_exclude ); free_strv( ns->combined_exclude );
free_strv( ns->combined_export ); free_strv( ns->combined_export );
ns->combined_exclude = cook_list( ns->exclusions ); ns->combined_exclude = cook_list( ns->exclusions,
ns->combined_export = cook_list( ns->exports ); never_encapsulated,
N_ELEMENTS( never_encapsulated ) );
ns->combined_export = cook_list( ns->exports, NULL, 0 );
} }
} }
......
...@@ -227,12 +227,11 @@ static const char soname[] = "$proxied_dso"; ...@@ -227,12 +227,11 @@ static const char soname[] = "$proxied_dso";
// _int_dlopen() from libcapsule or a locally overridden version // _int_dlopen() from libcapsule or a locally overridden version
#include "capsule/_int_dlopen.h" #include "capsule/_int_dlopen.h"
// should we exclude libpthread here? // Array of SONAMEs that will not have a private copy inside a capsule.
// in any case, these are DSOs we do _not_ want to isolate // Only one copy of each of these will be loaded, and they will
// be loaded without respecting the #capsule_namespace's @prefix.
static const char *exclude[] = static const char *exclude[] =
{ // MUST NOT be pulled from the capsule {
// prefixed filesystem tree:
"libdl.so.2",
EOF EOF
while read excluded x; while read excluded x;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment