Debian Codegraph @

src/arch-syscall-check

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2
3 #
4 # libseccomp syscall build-time checking script
5 #
6 # Copyright (c) 2021 Microsoft Corporation. <[email protected]>
7 #
8 # Author: Paul Moore <[email protected]>
9 #
10
11 #
12 # This library is free software; you can redistribute it and/or modify it
13 # under the terms of version 2.1 of the GNU Lesser General Public License as
14 # published by the Free Software Foundation.
15 #
16 # This library is distributed in the hope that it will be useful, but WITHOUT
17 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
19 # for more details.
20 #
21 # You should have received a copy of the GNU Lesser General Public License
22 # along with this library; if not, see <http://www.gnu.org/licenses>.
23 #
24
25 # Based on an idea from GNU coreutils
26 abs_topsrcdir="$(unset CDPATH; cd $(dirnamescip-shell system . . dirname. $0)/.. && pwdscip-shell system . . pwd.)"
27
28 SYSCALL_CSV="$abs_topsrcdir/src/syscalls.csv"
29 SYSCALL_HDR="$abs_topsrcdir/include/seccomp-syscalls.h"
30
31 function check_snrscip-shell shell libseccomp 2.6.0-2 check_snr().() {
32 (export LC_ALL=C; diffscip-shell system . . diff. \
33 --label "CSV ($SYSCALL_CSV)" --label "HDR ($SYSCALL_HDR)" -u \
34 <(tailscip-shell system . . tail. -n+2 $SYSCALL_CSV | cutscip-shell system . . cut. -d',' -f1 | sortscip-shell system . . sort. -u) \
35 <(grepscip-shell system . . grep. __SNR_ $SYSCALL_HDR | awkscip-shell system . . awk. '{ print $2 }' | \
36 sed -e 's/^__SNR_//' | sortscip-shell system . . sort. -u))
37 return $?
38 }
39
40 function check_pnrscip-shell shell libseccomp 2.6.0-2 check_pnr().() {
41 # NOTE: we don't care if we have __PNR_ define that isn't needed, we
42 # likely want to preserve those values so they aren't mistakenly
43 # reused by a new __PNR_ in the future
44 (export LC_ALL=C; diffscip-shell system . . diff. \
45 <(tailscip-shell system . . tail. -n+2 $SYSCALL_CSV | grepscip-shell system . . grep. "PNR" | cutscip-shell system . . cut. -d',' -f1 | \
46 sort -u) \
47 <(grepscip-shell system . . grep. "#define __PNR_" $SYSCALL_HDR | awkscip-shell system . . awk. '{ print $2 }' | \
48 sed -e 's/^__PNR_//' | sortscip-shell system . . sort. -u) | \
49 grep "^<")
50 [[ $? -eq 1 ]] && return 0 || return 1
51 }
52
53 rc=0
54
55 echoscip-shell system . . echo. ">>> CHECKING FOR MISSING __SNR_syscall VALUES"
56 check_snrscip-shell shell libseccomp 2.6.0-2 check_snr().
57 rc=$(( $rc + $? ))
58
59 echoscip-shell system . . echo. ">>> CHECKING FOR MISSING __PNR_syscall VALUES"
60 check_pnrscip-shell shell libseccomp 2.6.0-2 check_pnr().
61 rc=$(( $rc + $? ))
62
63 exit $rc