aboutsummaryrefslogtreecommitdiffstats
path: root/src/profstats
diff options
context:
space:
mode:
authorLibravatar netblue30 <netblue30@protonmail.com>2021-12-10 09:29:47 -0500
committerLibravatar netblue30 <netblue30@protonmail.com>2021-12-10 09:29:47 -0500
commit30e754610f1acfcba1644520a8070f87c3decede (patch)
tree5f5f6848c5f189a3bc20cb98a5ece854ecec4070 /src/profstats
parentMerge pull request #4748 from kmk3/readme-clarify-ubuntu (diff)
downloadfirejail-30e754610f1acfcba1644520a8070f87c3decede.tar.gz
firejail-30e754610f1acfcba1644520a8070f87c3decede.tar.zst
firejail-30e754610f1acfcba1644520a8070f87c3decede.zip
profstats fix (#4733)
Diffstat (limited to 'src/profstats')
-rw-r--r--src/profstats/Makefile.in2
-rw-r--r--src/profstats/main.c27
2 files changed, 20 insertions, 9 deletions
diff --git a/src/profstats/Makefile.in b/src/profstats/Makefile.in
index e025f5939..fa1b4f200 100644
--- a/src/profstats/Makefile.in
+++ b/src/profstats/Makefile.in
@@ -3,7 +3,7 @@ all: profstats
3 3
4include ../common.mk 4include ../common.mk
5 5
6%.o : %.c $(H_FILE_LIST) 6%.o : %.c $(H_FILE_LIST) ../include/common.h
7 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@ 7 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(INCLUDE) -c $< -o $@
8 8
9profstats: $(OBJS) 9profstats: $(OBJS)
diff --git a/src/profstats/main.c b/src/profstats/main.c
index a472ce259..bc5047bfe 100644
--- a/src/profstats/main.c
+++ b/src/profstats/main.c
@@ -17,10 +17,8 @@
17 * with this program; if not, write to the Free Software Foundation, Inc., 17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/ 19*/
20#include <stdio.h> 20
21#include <stdlib.h> 21#include "../include/common.h"
22#include <string.h>
23#include <assert.h>
24 22
25#define MAXBUF 2048 23#define MAXBUF 2048
26// stats 24// stats
@@ -99,8 +97,9 @@ static void usage(void) {
99 printf("\n"); 97 printf("\n");
100} 98}
101 99
102void process_file(const char *fname) { 100static void process_file(char *fname) {
103 assert(fname); 101 assert(fname);
102 char *tmpfname = NULL;
104 103
105 if (arg_debug) 104 if (arg_debug)
106 printf("processing #%s#\n", fname); 105 printf("processing #%s#\n", fname);
@@ -109,9 +108,19 @@ void process_file(const char *fname) {
109 108
110 FILE *fp = fopen(fname, "r"); 109 FILE *fp = fopen(fname, "r");
111 if (!fp) { 110 if (!fp) {
112 fprintf(stderr, "Warning: cannot open %s, while processing %s\n", fname, profile); 111 // the file was not found in the current directory
113 level--; 112 // look for it in /etc/firejail directory
114 return; 113 if (asprintf(&tmpfname, "%s/%s", SYSCONFDIR, fname) == -1)
114 errExit("asprintf");
115
116 fp = fopen(tmpfname, "r");
117 if (!fp) {
118 fprintf(stderr, "Warning: cannot open %s or %s, while processing %s\n", fname, tmpfname, profile);
119 free(tmpfname);
120 level--;
121 return;
122 }
123 fname = tmpfname;
115 } 124 }
116 125
117 int have_include_local = 0; 126 int have_include_local = 0;
@@ -204,6 +213,8 @@ void process_file(const char *fname) {
204 if (!have_include_local) 213 if (!have_include_local)
205 printf("No include .local found in %s\n", fname); 214 printf("No include .local found in %s\n", fname);
206 level--; 215 level--;
216 if (tmpfname)
217 free(tmpfname);
207} 218}
208 219
209int main(int argc, char **argv) { 220int main(int argc, char **argv) {