Skip to content

Commit 208d3fe

Browse files
committed
firecfg: add ignore command and docs
Add ignore command (`!PROGRAM`), as suggested by @WhyNotHugo[1]. It prevents firecfg from creating a symlink for the given program. Also, document the paths used and the config file syntax. Note that `/etc/firejail/firecfg.d/*.conf` files are parsed before /etc/firejail/firecfg.config, so the former can ignore/override any item in the latter. Closes netblue30#2097. [1] netblue30#2097 (comment)
1 parent 88b92fa commit 208d3fe

File tree

2 files changed

+97
-5
lines changed

2 files changed

+97
-5
lines changed

src/firecfg/main.c

+44-1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,40 @@ static void clean(void) {
143143
printf("\n");
144144
}
145145

146+
#define ignorelist_maxlen 2048
147+
static const char *ignorelist[ignorelist_maxlen];
148+
static int ignorelist_len = 0;
149+
150+
static int append_ignorelist(const char *const str) {
151+
assert(str);
152+
if (ignorelist_len >= ignorelist_maxlen) {
153+
fprintf(stderr, "Warning: Ignore list is full (%d/%d), skipping %s\n",
154+
ignorelist_len, ignorelist_maxlen, str);
155+
return 0;
156+
}
157+
158+
printf(" ignoring '%s'\n", str);
159+
const char *const dup = strdup(str);
160+
if (!dup)
161+
errExit("strdup");
162+
163+
ignorelist[ignorelist_len] = dup;
164+
ignorelist_len++;
165+
166+
return 1;
167+
}
168+
169+
static int in_ignorelist(const char *const str) {
170+
assert(str);
171+
int i;
172+
for (i = 0; i < ignorelist_len; i++) {
173+
if (strcmp(str, ignorelist[i]) == 0)
174+
return 1;
175+
}
176+
177+
return 0;
178+
}
179+
146180
static void set_file(const char *name, const char *firejail_exec) {
147181
if (which(name) == 0)
148182
return;
@@ -206,8 +240,17 @@ static void set_links_firecfg(const char *cfgfile) {
206240
if (*start == '\0')
207241
continue;
208242

243+
// handle ignore command
244+
if (*start == '!') {
245+
append_ignorelist(start + 1);
246+
continue;
247+
}
248+
209249
// set link
210-
set_file(start, FIREJAIL_EXEC);
250+
if (!in_ignorelist(start))
251+
set_file(start, FIREJAIL_EXEC);
252+
else
253+
printf(" %s ignored\n", start);
211254
}
212255

213256
fclose(fp);

src/man/firecfg.1.in

+53-4
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,13 @@ desktop managers are supported in this moment
2727
To set it up, run "sudo firecfg" after installing Firejail software.
2828
The same command should also be run after
2929
installing new programs. If the program is supported by Firejail, the symbolic link in /usr/local/bin
30-
will be created. For a full list of programs supported by default run "cat /etc/firejail/firecfg.config".
31-
32-
For user-driven manual integration, see \fBDESKTOP INTEGRATION\fR section in \fBman 1 firejail\fR.
30+
will be created.
31+
.PP
32+
To configure the list of programs used by firecfg when creating symlinks, see
33+
\fBFILES\fR and \fBSYNTAX\fR.
34+
.PP
35+
For user-driven manual integration, see \fBDESKTOP INTEGRATION\fR section in
36+
\fBman 1 firejail\fR.
3337
.SH DEFAULT ACTIONS
3438
The following actions are implemented by default by running sudo firecfg:
3539

@@ -133,8 +137,53 @@ $ sudo firecfg --clean
133137
/usr/local/bin/vlc removed
134138
.br
135139
[...]
140+
.SH FILES
141+
.PP
142+
Configuration files are searched for and parsed in the following paths:
143+
.PP
144+
.RS
145+
1. /etc/firejail/firecfg.d/*.conf (in alphabetical order)
146+
.br
147+
2. /etc/firejail/firecfg.config
148+
.RE
149+
.PP
150+
The programs that are supported by default are listed in
151+
/etc/firejail/firecfg.config.
152+
It is recommended to leave it as is and put all customizations inside
153+
/etc/firejail/firecfg.d/.
154+
.PP
155+
Profile files are also searched in the user configuration directory:
156+
.PP
157+
.RS
158+
3. ~/.config/firejail/*.profile
159+
.RE
160+
.PP
161+
For every \fBPROGRAM.profile\fR file found, firecfg attempts to create a
162+
symlink for "PROGRAM", as if "PROGRAM" was listed in a configuration file.
163+
.SH SYNTAX
164+
Configuration file syntax:
165+
.PP
166+
A line that starts with \fB#\fR is considered a comment.
167+
.br
168+
A line that starts with \fB!PROGRAM\fR means to ignore "PROGRAM" when creating
169+
symlinks.
170+
.br
171+
A line that starts with anything else is considered to be the name of an
172+
executable and firecfg will attempt to create a symlink for it.
173+
.PP
174+
For example, to prevent firecfg from creating symlinks for "firefox" and
175+
"patch" while attempting to create a symlink for "myprog", the following lines
176+
could be added to /etc/firejail/firecfg.d/10-my.conf:
177+
.PP
178+
.RS
179+
!firefox
180+
.br
181+
!patch
182+
.br
136183

137-
184+
.br
185+
myprog
186+
.RE
138187
.SH LICENSE
139188
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
140189
.PP

0 commit comments

Comments
 (0)