Commit ba645789 authored by Simon McVittie's avatar Simon McVittie

capture-libs: Require globs to match something, unless configured

Signed-off-by: Simon McVittie's avatarSimon McVittie <smcv@collabora.com>
parent 9188f2c2
......@@ -143,6 +143,28 @@ run_ok([qw(bwrap --ro-bind / / --ro-bind /), $host,
like(readlink "$libdir/libjpeg.so.62", qr{^$LIBDIR/libjpeg\.so\.62(?:[0-9.]+)$},
'$libdir/libjpeg.so.62 is a symlink to /run/host + realpath of libjpeg-6b');
ok(! system('rm', '-fr', $libdir));
mkdir($libdir);
my $stderr;
my $result = run_verbose([qw(bwrap --ro-bind / / --ro-bind /), $host,
'--bind', $libdir, $libdir,
qw(--dev-bind /dev /dev),
$CAPSULE_CAPTURE_LIBS_TOOL, '--link-target=/',
"--dest=$libdir", "--provider=$host",
'soname-match:this*library*does?not?exist'],
'2>', \$stderr, '>&2');
ok(! $result, 'a non-matching wildcard should fail');
like($stderr, qr{"this\*library\*does\?not\?exist"});
ok(! system('rm', '-fr', $libdir));
mkdir($libdir);
run_ok([qw(bwrap --ro-bind / / --ro-bind /), $host,
'--bind', $libdir, $libdir,
qw(--dev-bind /dev /dev),
$CAPSULE_CAPTURE_LIBS_TOOL, '--link-target=/',
"--dest=$libdir", "--provider=$host",
'if-exists:soname-match:this*library*does?not?exist']);
SKIP: {
skip "not on Linux? Good luck!", 1 unless $^O eq 'linux';
my $stdout;
......
......@@ -442,7 +442,7 @@ typedef struct
{
const char *pattern;
capture_flags flags;
bool ret;
bool found;
ld_cache cache;
int *code;
char **message;
......@@ -467,6 +467,8 @@ cache_foreach_cb (const char *name, int flag, unsigned int osv,
{
DEBUG( DEBUG_TOOL, "%s matches %s", name, ctx->pattern );
ctx->found = true;
if( !capture_one( name, ctx->flags | CAPTURE_FLAG_IF_EXISTS,
ctx->code, ctx->message ) )
return 1;
......@@ -484,10 +486,11 @@ capture_soname_match( const char *pattern, capture_flags flags,
.pattern = pattern,
.flags = flags,
.cache = { .is_open = 0 },
.ret = false,
.found = false,
.code = code,
.message = message,
};
bool ret = false;
DEBUG( DEBUG_TOOL, "%s", pattern );
......@@ -500,13 +503,21 @@ capture_soname_match( const char *pattern, capture_flags flags,
if( ld_cache_foreach( &ctx.cache, cache_foreach_cb, &ctx ) != 0 )
goto out;
ctx.ret = true;
if( !ctx.found && !( flags & CAPTURE_FLAG_IF_EXISTS ) )
{
_capsule_set_error( code, message, ENOENT,
"no matches found for glob pattern \"%s\"",
pattern );
goto out;
}
ret = true;
out:
if( ctx.cache.is_open )
ld_cache_close( &ctx.cache );
return ctx.ret;
return ret;
}
#define strstarts(str, start) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment