aboutsummaryrefslogtreecommitdiffstats
path: root/src/fbuilder/main.c
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@yahoo.com>2017-09-16 08:49:05 -0400
committerLibravatar netblue30 <netblue30@yahoo.com>2017-09-16 08:49:05 -0400
commit280f37eba89ebc211d0c02848d3d47d086458b25 (patch)
tree1398c5dfc53c4d286d7b6b528d5a3c1585a67325 /src/fbuilder/main.c
parentMerge pull request #1552 from SpotComms/mf (diff)
downloadfirejail-280f37eba89ebc211d0c02848d3d47d086458b25.tar.gz
firejail-280f37eba89ebc211d0c02848d3d47d086458b25.tar.zst
firejail-280f37eba89ebc211d0c02848d3d47d086458b25.zip
--build
Diffstat (limited to 'src/fbuilder/main.c')
-rw-r--r--src/fbuilder/main.c71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/fbuilder/main.c b/src/fbuilder/main.c
new file mode 100644
index 000000000..83217ef98
--- /dev/null
+++ b/src/fbuilder/main.c
@@ -0,0 +1,71 @@
1/*
2 * Copyright (C) 2014-2017 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 "fbuilder.h"
21int arg_debug = 0;
22
23static void usage(void) {
24 printf("Firejail profile builder\n");
25 printf("Usage: firejail [--debug] --build program-and-arguments\n");
26}
27
28int main(int argc, char **argv) {
29#if 0
30{
31system("cat /proc/self/status");
32int i;
33for (i = 0; i < argc; i++)
34 printf("*%s* ", argv[i]);
35printf("\n");
36}
37#endif
38
39 int i;
40 int prog_index = 0;
41
42 // parse arguments and extract program index
43 for (i = 1; i < argc; i++) {
44 if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-?") ==0) {
45 usage();
46 return 0;
47 }
48 else if (strcmp(argv[i], "--debug") == 0)
49 arg_debug = 1;
50 else if (strcmp(argv[i], "--build") == 0)
51 ; // do nothing, this is passed down from firejail
52 else {
53 if (*argv[i] == '-') {
54 fprintf(stderr, "Error fbuilder: invalid program\n");
55 usage();
56 exit(1);
57 }
58 prog_index = i;
59 break;
60 }
61 }
62
63 if (prog_index == 0) {
64 fprintf(stderr, "Error fbuilder: program and arguments required\n");
65 usage();
66 exit(1);
67 }
68
69 build_profile(argc, argv, prog_index);
70 return 0;
71}