diff options
Diffstat (limited to 'src/fnettrace/runprog.c')
-rw-r--r-- | src/fnettrace/runprog.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/fnettrace/runprog.c b/src/fnettrace/runprog.c new file mode 100644 index 000000000..e30d8a16c --- /dev/null +++ b/src/fnettrace/runprog.c | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014-2023 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 "fnettrace.h" | ||
21 | |||
22 | int runprog(const char *program) { | ||
23 | assert(program); | ||
24 | FILE *fp = popen(program, "r"); | ||
25 | if (!fp) { | ||
26 | fprintf(stderr, "Error: cannot run %s\n", program); | ||
27 | return -1; | ||
28 | } | ||
29 | |||
30 | return fileno(fp); | ||
31 | } | ||