1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-01 09:21:26 +03:00

seccomp-util: add parse_syscall_archs()

This commit is contained in:
Yu Watanabe 2017-08-02 13:46:45 +09:00
parent 29ea9f0f42
commit b16bd5350f
2 changed files with 34 additions and 0 deletions

View File

@ -30,7 +30,9 @@
#include "macro.h"
#include "nsflags.h"
#include "seccomp-util.h"
#include "set.h"
#include "string-util.h"
#include "strv.h"
#include "util.h"
#include "errno-list.h"
@ -1313,3 +1315,33 @@ int seccomp_restrict_archs(Set *archs) {
return seccomp_load(seccomp);
}
int parse_syscall_archs(char **l, Set **archs) {
_cleanup_set_free_ Set *_archs;
char **s;
int r;
assert(l);
assert(archs);
r = set_ensure_allocated(&_archs, NULL);
if (r < 0)
return r;
STRV_FOREACH(s, l) {
uint32_t a;
r = seccomp_arch_from_string(*s, &a);
if (r < 0)
return -EINVAL;
r = set_put(_archs, UINT32_TO_PTR(a + 1));
if (r < 0)
return -ENOMEM;
}
*archs = _archs;
_archs = NULL;
return 0;
}

View File

@ -84,3 +84,5 @@ extern const uint32_t seccomp_local_archs[];
(arch) = seccomp_local_archs[++_i])
DEFINE_TRIVIAL_CLEANUP_FUNC(scmp_filter_ctx, seccomp_release);
int parse_syscall_archs(char **l, Set **archs);