blob: 09b90beb3833b182285a4a2d1f48c1fe46b8cc0a [file] [log] [blame]
Mike Frysinger50e31fa2018-01-19 18:59:49 -05001/* Copyright 2016 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
Jorge Lucangeli Obesf16d6d12016-09-29 20:25:27 -04005
6#include <stdio.h>
7
8#include "bpf.h"
9#include "syscall_filter.h"
10#include "util.h"
11
12/* TODO(jorgelo): Use libseccomp disassembler here. */
13int main(int argc, char **argv) {
Luis Hector Chavez114a9302017-09-05 20:36:58 -070014 init_logging(LOG_TO_FD, STDERR_FILENO, LOG_INFO);
15
Jorge Lucangeli Obesf16d6d12016-09-29 20:25:27 -040016 if (argc < 2) {
17 fprintf(stderr, "Usage: %s <policy file>\n", argv[0]);
18 return 1;
19 }
20
21 FILE *f = fopen(argv[1], "r");
22 if (!f) {
23 pdie("fopen(%s) failed", argv[1]);
24 }
25
26 struct sock_fprog fp;
Luis Hector Chavez7624e712017-08-28 19:30:59 -070027 int res = compile_filter(argv[1], f, &fp, 0, 0);
Jorge Lucangeli Obesf16d6d12016-09-29 20:25:27 -040028 if (res != 0) {
29 die("compile_filter failed");
30 }
31 dump_bpf_prog(&fp);
32
33 free(fp.filter);
34 fclose(f);
35 return 0;
36}