diff options
author | netblue30 <netblue30@protonmail.com> | 2021-07-28 08:30:24 -0400 |
---|---|---|
committer | netblue30 <netblue30@protonmail.com> | 2021-07-28 08:30:24 -0400 |
commit | a627071b33b42dd24a90070236d2f85eeebc423c (patch) | |
tree | 5388f450044f8b205812e5f6e740874d40b4dd62 /src/fids/db_exclude.c | |
parent | Merge pull request #4410 from kmk3/revert-allow-deny-etc (diff) | |
download | firejail-a627071b33b42dd24a90070236d2f85eeebc423c.tar.gz firejail-a627071b33b42dd24a90070236d2f85eeebc423c.tar.zst firejail-a627071b33b42dd24a90070236d2f85eeebc423c.zip |
intrusion detection system
Diffstat (limited to 'src/fids/db_exclude.c')
-rw-r--r-- | src/fids/db_exclude.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/fids/db_exclude.c b/src/fids/db_exclude.c new file mode 100644 index 000000000..994e6f9df --- /dev/null +++ b/src/fids/db_exclude.c | |||
@@ -0,0 +1,56 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014-2021 Firejail Authors | ||
3 | * | ||
4 | * This file is part of firejail project | ||
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, | ||
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | * GNU General Public License for more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | */ | ||
20 | #include"fids.h" | ||
21 | |||
22 | typedef struct db_exclude_t { | ||
23 | struct db_exclude_t *next; | ||
24 | char *fname; | ||
25 | int len; | ||
26 | } DB_EXCLUDE; | ||
27 | static DB_EXCLUDE *database = NULL; | ||
28 | |||
29 | void db_exclude_add(const char *fname) { | ||
30 | assert(fname); | ||
31 | |||
32 | DB_EXCLUDE *ptr = malloc(sizeof(DB_EXCLUDE)); | ||
33 | if (!ptr) | ||
34 | errExit("malloc"); | ||
35 | |||
36 | ptr->fname = strdup(fname); | ||
37 | if (!ptr->fname) | ||
38 | errExit("strdup"); | ||
39 | ptr->len = strlen(fname); | ||
40 | ptr->next = database; | ||
41 | database = ptr; | ||
42 | } | ||
43 | |||
44 | int db_exclude_check(const char *fname) { | ||
45 | assert(fname); | ||
46 | |||
47 | DB_EXCLUDE *ptr = database; | ||
48 | while (ptr != NULL) { | ||
49 | if (strncmp(fname, ptr->fname, ptr->len) == 0) | ||
50 | return 1; | ||
51 | ptr = ptr->next; | ||
52 | } | ||
53 | |||
54 | return 0; | ||
55 | } | ||
56 | |||