Skip to content

Commit fa11c14

Browse files
committed
Change project name to avoid conflict with the pmem/syscall_intercept library
1 parent 7f43e58 commit fa11c14

8 files changed

Lines changed: 82 additions & 28 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,5 @@ config.log
66
src/Makefile
77
src/syscall_intercept
88
src/.libs
9+
src/syscall.h
10+
src/unistd_64.h

config.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
log_file: /dev/kmsg
1+
log_file: /dev/log
22
syscalls:
33
- umount2:
44
log: true
55
block: true
66
arg0: "/usr"
77
arg1: "rw"
8-
- remove:
8+
- mount:
99
log: false
1010
block: true
1111
arg0: "/etc/important"
12-
- remove:
12+
- fsmount:
1313
log: true
1414
block: false
1515
arg0: "/etc/abroot.conf"

configure

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/sh
22
# Guess values for system-dependent variables and create Makefiles.
3-
# Generated by GNU Autoconf 2.71 for syscall_intercept 1.0.
3+
# Generated by GNU Autoconf 2.71 for syscall_interceptor 1.0.
44
#
55
# Report bugs to <axtlos@disroot.org>.
66
#
@@ -619,10 +619,10 @@ MFLAGS=
619619
MAKEFLAGS=
620620

621621
# Identity of this package.
622-
PACKAGE_NAME='syscall_intercept'
623-
PACKAGE_TARNAME='syscall_intercept'
622+
PACKAGE_NAME='syscall_interceptor'
623+
PACKAGE_TARNAME='syscall_interceptor'
624624
PACKAGE_VERSION='1.0'
625-
PACKAGE_STRING='syscall_intercept 1.0'
625+
PACKAGE_STRING='syscall_interceptor 1.0'
626626
PACKAGE_BUGREPORT='axtlos@disroot.org'
627627
PACKAGE_URL=''
628628

@@ -1350,7 +1350,7 @@ if test "$ac_init_help" = "long"; then
13501350
# Omit some internal or obsolete options to make the list less imposing.
13511351
# This message is too long to be a string in the A/UX 3.1 sh.
13521352
cat <<_ACEOF
1353-
\`configure' configures syscall_intercept 1.0 to adapt to many kinds of systems.
1353+
\`configure' configures syscall_interceptor 1.0 to adapt to many kinds of systems.
13541354
13551355
Usage: $0 [OPTION]... [VAR=VALUE]...
13561356
@@ -1400,7 +1400,7 @@ Fine tuning of the installation directories:
14001400
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
14011401
--mandir=DIR man documentation [DATAROOTDIR/man]
14021402
--docdir=DIR documentation root
1403-
[DATAROOTDIR/doc/syscall_intercept]
1403+
[DATAROOTDIR/doc/syscall_interceptor]
14041404
--htmldir=DIR html documentation [DOCDIR]
14051405
--dvidir=DIR dvi documentation [DOCDIR]
14061406
--pdfdir=DIR pdf documentation [DOCDIR]
@@ -1422,7 +1422,7 @@ fi
14221422

14231423
if test -n "$ac_init_help"; then
14241424
case $ac_init_help in
1425-
short | recursive ) echo "Configuration of syscall_intercept 1.0:";;
1425+
short | recursive ) echo "Configuration of syscall_interceptor 1.0:";;
14261426
esac
14271427
cat <<\_ACEOF
14281428
@@ -1532,7 +1532,7 @@ fi
15321532
test -n "$ac_init_help" && exit $ac_status
15331533
if $ac_init_version; then
15341534
cat <<\_ACEOF
1535-
syscall_intercept configure 1.0
1535+
syscall_interceptor configure 1.0
15361536
generated by GNU Autoconf 2.71
15371537
15381538
Copyright (C) 2021 Free Software Foundation, Inc.
@@ -1750,7 +1750,7 @@ cat >config.log <<_ACEOF
17501750
This file contains any messages produced by compilers while
17511751
running configure, to aid debugging if configure makes a mistake.
17521752
1753-
It was created by syscall_intercept $as_me 1.0, which was
1753+
It was created by syscall_interceptor $as_me 1.0, which was
17541754
generated by GNU Autoconf 2.71. Invocation command line was
17551755
17561756
$ $0$ac_configure_args_raw
@@ -12303,7 +12303,7 @@ fi
1230312303

1230412304

1230512305
# Define the identity of the package.
12306-
PACKAGE='syscall_intercept'
12306+
PACKAGE='syscall_interceptor'
1230712307
VERSION='1.0'
1230812308

1230912309

@@ -14162,7 +14162,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
1416214162
# report actual input values of CONFIG_FILES etc. instead of their
1416314163
# values after options handling.
1416414164
ac_log="
14165-
This file was extended by syscall_intercept $as_me 1.0, which was
14165+
This file was extended by syscall_interceptor $as_me 1.0, which was
1416614166
generated by GNU Autoconf 2.71. Invocation command line was
1416714167
1416814168
CONFIG_FILES = $CONFIG_FILES
@@ -14230,7 +14230,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
1423014230
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
1423114231
ac_cs_config='$ac_cs_config_escaped'
1423214232
ac_cs_version="\\
14233-
syscall_intercept config.status 1.0
14233+
syscall_interceptor config.status 1.0
1423414234
configured by $0, generated by GNU Autoconf 2.71,
1423514235
with options \\"\$ac_cs_config\\"
1423614236

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([syscall_intercept], [1.0], [axtlos@disroot.org])
1+
AC_INIT([syscall_interceptor], [1.0], [axtlos@disroot.org])
22
LT_INIT
33
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
44
AC_CONFIG_MACRO_DIRS([m4])

libtool

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#! /bin/sh
2-
# Generated automatically by config.status (syscall_intercept) 1.0
2+
# Generated automatically by config.status (syscall_interceptor) 1.0
33
# Libtool was configured on host bonsai:
44
# NOTE: Changes made to this file will be lost: look at ltmain.sh.
55

parse_config.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@ header_template = """
1616
#include <stdlib.h>
1717
#include <stdbool.h>
1818
#include <string.h>
19+
#include <sys/syscall.h>
1920
2021
#define LOG_FILE "{PYLOGFILE}"
2122
2223
struct syscall {{
23-
char *name; // TODO: change to long
24+
long callnum;
2425
bool log;
2526
bool block;
2627
char *arg0;
@@ -44,7 +45,7 @@ return {FIRSTVARNAME};
4445

4546
structbuild_template = {
4647
"var_define": "struct syscall *{varname} = (struct syscall *) malloc(sizeof(struct syscall));\n",
47-
"set_name": '{varname}->name = (char *) malloc(strlen("{name}")+1);\nstrcpy({varname}->name, "{name}");\n',
48+
"set_name": '{varname}->callnum = {name};\n',
4849
"set_log": "{varname}->log = {log};\n",
4950
"set_block": "{varname}->block = {block};\n",
5051
"set_arg": '{varname}->{argname} = (char *) malloc(strlen("{arg}")+1);\nstrcpy({varname}->{argname}, "{arg}");\n',
@@ -88,14 +89,21 @@ class Syscall:
8889

8990
def build_c_code(self, varname: str) -> str:
9091
c_code = structbuild_template["var_define"].format(varname=varname)
91-
c_code = c_code + structbuild_template["set_name"].format(
92-
varname=varname, name=self.name
93-
)
92+
if self.name.startswith("SYS_"):
93+
c_code = c_code + structbuild_template["set_name"].format(
94+
varname=varname, name=self.name.lower()
95+
)
96+
else:
97+
c_code = c_code + structbuild_template["set_name"].format(
98+
varname=varname, name="SYS_"+self.name.lower()
99+
)
100+
101+
94102
c_code = c_code + structbuild_template["set_log"].format(
95-
varname=varname, log=self.log
103+
varname=varname, log=str(self.log).lower()
96104
)
97105
c_code = c_code + structbuild_template["set_block"].format(
98-
varname=varname, block=self.block
106+
varname=varname, block=str(self.block).lower()
99107
)
100108
if self.arg0 != "":
101109
c_code = c_code + structbuild_template["set_arg"].format(

src/Makefile.am

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1-
lib_LTLIBRARIES = libsyscall_intercept.la
2-
libsyscall_intercept_la_SOURCES = main.c
3-
libsyscall_intercept_la_CFLAGS = -fpic
4-
libsyscall_intercept_la_LDFLAGS = -version-info 1:0:0
1+
bin_PROGRAMS = syscall_interceptor
2+
syscall_interceptor_SOURCES = main.c
3+
4+
lib_LTLIBRARIES = libsyscall_interceptor.la
5+
libsyscall_interceptor_la_SOURCES = main.c
6+
libsyscall_interceptor_la_CFLAGS = -fpic
7+
libsyscall_interceptor_la_LDFLAGS = -version-info 1:0:0
58

src/main.c

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,51 @@
11
#include <config.h>
2+
#include <calls.h>
3+
#include <limits.h>
24
#include <stdio.h>
5+
#include <libsyscall_intercept_hook_point.h>
6+
#include <syscall.h>
7+
#include <errno.h>
8+
#include <strings.h>
9+
10+
static int
11+
hook (long syscall_number,
12+
long arg0, long arg1,
13+
long arg2, long arg3,
14+
long arg4, long arg5,
15+
long *result) {
16+
17+
struct syscall *calls = get_calls();
18+
struct syscall *curr_call = calls;
19+
while(true) {
20+
if (curr_call->callnum == syscall_number) {
21+
// puts ((char*) arg0);
22+
puts("here");
23+
*result = -ENOTSUP;
24+
return 0;
25+
}
26+
if (!curr_call->next) {
27+
return 1;
28+
}
29+
curr_call = curr_call->next;
30+
}
31+
}
32+
33+
static __attribute__((constructor)) void
34+
init(void) {
35+
intercept_hook_point = hook;
36+
}
337

438
int
539
main (void)
640
{
41+
struct syscall *calls = get_calls();
42+
743
puts ("Hello World!");
844
puts ("This is " PACKAGE_STRING ".");
45+
puts (LOG_FILE);
46+
// printf ("%ld", calls->callnum);
47+
long *result = (long *) malloc(LONG_MAX);
48+
hook(SYS_umount2, 0, 0, 0, 0, 0, 0, result);
49+
printf("%ld", *result);
950
return 0;
1051
}

0 commit comments

Comments
 (0)