Skip to content

Commit dd3ef2a

Browse files
authored
feature: add warn command (#6710)
And use it in etc/inc/disable-X11.inc. This allows printing a warning message from inside a profile. Everything after the command is printed in a warning message as is (that is, without macro expansion). Example: $ firejail --noprofile --include=/etc/firejail/disable-X11.inc true Reading profile /etc/firejail/disable-X11.inc Warning: /etc/firejail/disable-X11.inc:5: This file is deprecated; use disable-x11.inc (lowercase) instead. Reading profile /etc/firejail/disable-x11.inc [...] Relates to #6294. This is a follow-up to #6709.
1 parent 9c58cfa commit dd3ef2a

File tree

5 files changed

+16
-1
lines changed

5 files changed

+16
-1
lines changed

contrib/syntax/lists/profile_commands_arg1.list

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ shell
7979
timeout
8080
tmpfs
8181
veth-name
82+
warn
8283
whitelist
8384
whitelist-ro
8485
x11

etc/inc/disable-X11.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Persistent customizations should go in a .local file.
33
include disable-X11.local
44

5-
# Warning: This file is deprecated; use disable-x11.inc (lowercase) instead.
5+
warn This file is deprecated; use disable-x11.inc (lowercase) instead.
66

77
# Redirect
88
include disable-x11.inc

etc/templates/profile.template

+2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ include globals.local
5959
##ignore noexec ${HOME}
6060
##ignore noexec /tmp
6161

62+
##warn foo
63+
6264
# It is common practice to add files/dirs containing program-specific configuration
6365
# (often ${HOME}/PROGRAMNAME or ${HOME}/.config/PROGRAMNAME) into disable-programs.inc
6466
# (keep list sorted) and then disable blacklisting below.

src/firejail/profile.c

+5
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,11 @@ int profile_check_line(char *ptr, int lineno, const char *fname) {
295295
return 0;
296296
}
297297

298+
if (strncmp(ptr, "warn ", 5) == 0) {
299+
fwarning("%s:%d: %s\n", fname, lineno, ptr + 5);
300+
return 0;
301+
}
302+
298303
if (strncmp(ptr, "keep-fd ", 8) == 0) {
299304
if (strcmp(ptr + 8, "all") == 0)
300305
arg_keep_fd_all = 1;

src/man/firejail-profile.5.in

+7
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,13 @@ Example: "ignore net eth0"
235235
Disable Firejail's output. This should be the first uncommented command in the profile file.
236236

237237
Example: "quiet"
238+
.TP
239+
\fBwarn message
240+
Print a warning message to stderr.
241+
Everything after the command is printed in a warning message as is (that is,
242+
without macro expansion).
243+
244+
Example: "warn This file is deprecated; use foo instead."
238245

239246
.SH Filesystem
240247
These profile entries define a chroot filesystem built on top of the existing

0 commit comments

Comments
 (0)