aboutsummaryrefslogtreecommitdiffstats
path: root/src/fbuilder/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/fbuilder/main.c')
-rw-r--r--src/fbuilder/main.c93
1 files changed, 0 insertions, 93 deletions
diff --git a/src/fbuilder/main.c b/src/fbuilder/main.c
deleted file mode 100644
index ef5dee7d9..000000000
--- a/src/fbuilder/main.c
+++ /dev/null
@@ -1,93 +0,0 @@
1/*
2 * Copyright (C) 2014-2018 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[=profile-file] 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 FILE *fp = stdout;
42 int prof_file = 0;
43
44 // parse arguments and extract program index
45 for (i = 1; i < argc; i++) {
46 if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-?") ==0) {
47 usage();
48 return 0;
49 }
50 else if (strcmp(argv[i], "--debug") == 0)
51 arg_debug = 1;
52 else if (strcmp(argv[i], "--build") == 0)
53 ; // do nothing, this is passed down from firejail
54 else if (strncmp(argv[i], "--build=", 8) == 0) {
55 // this option is only supported for non-root users
56 if (getuid() == 0) {
57 fprintf(stderr, "Error fbuild: --build=profile-name is not supported for root user.\n");
58 exit(1);
59 }
60
61 // check file access
62 fp = fopen(argv[i] + 8, "w");
63 if (!fp) {
64 fprintf(stderr, "Error fbuild: cannot open profile file.\n");
65 exit(1);
66 }
67 prof_file = 1;
68 // do nothing, this is passed down from firejail
69 }
70 else {
71 if (*argv[i] == '-') {
72 fprintf(stderr, "Error fbuilder: invalid program\n");
73 usage();
74 exit(1);
75 }
76 prog_index = i;
77 break;
78 }
79 }
80
81 if (prog_index == 0) {
82 fprintf(stderr, "Error fbuilder: program and arguments required\n");
83 usage();
84 if (prof_file)
85 fclose(fp);
86 exit(1);
87 }
88
89 build_profile(argc, argv, prog_index, fp);
90 if (prof_file)
91 fclose(fp);
92 return 0;
93}