aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/etc-cleanup/main.c15
-rw-r--r--src/fbuilder/main.c7
-rw-r--r--src/fcopy/main.c17
-rw-r--r--src/fids/main.c5
-rw-r--r--src/firecfg/main.c14
-rw-r--r--src/firejail/checkcfg.c67
-rw-r--r--src/firejail/firejail.h3
-rw-r--r--src/firejail/main.c9
-rw-r--r--src/firejail/usage.c15
-rw-r--r--src/firemon/firemon.c2
-rw-r--r--src/firemon/firemon.h1
-rw-r--r--src/firemon/usage.c13
-rw-r--r--src/fldd/main.c11
-rw-r--r--src/fnet/main.c24
-rw-r--r--src/fnetfilter/main.c7
-rw-r--r--src/fnettrace-dns/main.c10
-rw-r--r--src/fnettrace-icmp/main.c10
-rw-r--r--src/fnettrace-sni/main.c9
-rw-r--r--src/fnettrace/main.c24
-rw-r--r--src/fsec-optimize/main.c7
-rw-r--r--src/fsec-print/main.c7
-rw-r--r--src/fseccomp/main.c57
-rw-r--r--src/ftee/main.c5
-rw-r--r--src/jailcheck/main.c9
-rw-r--r--src/profstats/main.c52
25 files changed, 219 insertions, 181 deletions
diff --git a/src/etc-cleanup/main.c b/src/etc-cleanup/main.c
index 6c7bea6d6..f15ba53cd 100644
--- a/src/etc-cleanup/main.c
+++ b/src/etc-cleanup/main.c
@@ -212,13 +212,16 @@ static void process_file(const char *fname) {
212 } 212 }
213} 213}
214 214
215static const char *const usage_str =
216 "usage: cleanup-etc [options] file.profile [file.profile]\n"
217 "Group and clean private-etc entries in one or more profile files.\n"
218 "Options:\n"
219 " --debug - print debug messages\n"
220 " -h, -?, --help - this help screen\n"
221 " --replace - replace profile file\n";
222
215static void usage(void) { 223static void usage(void) {
216 printf("usage: cleanup-etc [options] file.profile [file.profile]\n"); 224 puts(usage_str);
217 printf("Group and clean private-etc entries in one or more profile files.\n");
218 printf("Options:\n");
219 printf(" --debug - print debug messages\n");
220 printf(" -h, -?, --help - this help screen\n");
221 printf(" --replace - replace profile file\n");
222} 225}
223 226
224int main(int argc, char **argv) { 227int main(int argc, char **argv) {
diff --git a/src/fbuilder/main.c b/src/fbuilder/main.c
index 7fdf9af68..a85d4a931 100644
--- a/src/fbuilder/main.c
+++ b/src/fbuilder/main.c
@@ -21,9 +21,12 @@
21int arg_debug = 0; 21int arg_debug = 0;
22int arg_appimage = 0; 22int arg_appimage = 0;
23 23
24static const char *const usage_str =
25 "Firejail profile builder\n"
26 "Usage: firejail [--debug] --build[=profile-file] program-and-arguments\n";
27
24static void usage(void) { 28static void usage(void) {
25 printf("Firejail profile builder\n"); 29 puts(usage_str);
26 printf("Usage: firejail [--debug] --build[=profile-file] program-and-arguments\n");
27} 30}
28 31
29int main(int argc, char **argv) { 32int main(int argc, char **argv) {
diff --git a/src/fcopy/main.c b/src/fcopy/main.c
index ce2efb295..a56e8a91b 100644
--- a/src/fcopy/main.c
+++ b/src/fcopy/main.c
@@ -416,18 +416,19 @@ static void duplicate_link(const char *src, const char *dest, struct stat *s) {
416 free(rdest); 416 free(rdest);
417} 417}
418 418
419static const char *const usage_str =
420 "Usage: fcopy [--follow-link] src dest\n"
421 "\n"
422 "Copy SRC to DEST/SRC. SRC may be a file, directory, or symbolic link.\n"
423 "If SRC is a directory it is copied recursively. If it is a symlink,\n"
424 "the link itself is duplicated, unless --follow-link is given,\n"
425 "in which case the destination of the link is copied.\n"
426 "DEST must already exist and must be a directory.\n";
419 427
420static void usage(void) { 428static void usage(void) {
421 fputs("Usage: fcopy [--follow-link] src dest\n" 429 fputs(usage_str, stderr);
422 "\n"
423 "Copy SRC to DEST/SRC. SRC may be a file, directory, or symbolic link.\n"
424 "If SRC is a directory it is copied recursively. If it is a symlink,\n"
425 "the link itself is duplicated, unless --follow-link is given,\n"
426 "in which case the destination of the link is copied.\n"
427 "DEST must already exist and must be a directory.\n", stderr);
428} 430}
429 431
430
431int main(int argc, char **argv) { 432int main(int argc, char **argv) {
432#if 0 433#if 0
433 { 434 {
diff --git a/src/fids/main.c b/src/fids/main.c
index f1dfdac8e..915edb6ca 100644
--- a/src/fids/main.c
+++ b/src/fids/main.c
@@ -318,10 +318,11 @@ static void process_config(const char *fname) {
318 include_level--; 318 include_level--;
319} 319}
320 320
321 321static const char *const usage_str =
322 "Usage: fids [--help|-h|-?] --init|--check homedir\n";
322 323
323void usage(void) { 324void usage(void) {
324 printf("Usage: fids [--help|-h|-?] --init|--check homedir\n"); 325 puts(usage_str);
325} 326}
326 327
327int main(int argc, char **argv) { 328int main(int argc, char **argv) {
diff --git a/src/firecfg/main.c b/src/firecfg/main.c
index e1ff7e17a..da962c35d 100644
--- a/src/firecfg/main.c
+++ b/src/firecfg/main.c
@@ -24,7 +24,7 @@ int arg_debug = 0;
24char *arg_bindir = "/usr/local/bin"; 24char *arg_bindir = "/usr/local/bin";
25int arg_guide = 0; 25int arg_guide = 0;
26 26
27static char *usage_str = 27static const char *const usage_str =
28 "Firecfg is the desktop configuration utility for Firejail software. The utility\n" 28 "Firecfg is the desktop configuration utility for Firejail software. The utility\n"
29 "creates several symbolic links to firejail executable. This allows the user to\n" 29 "creates several symbolic links to firejail executable. This allows the user to\n"
30 "sandbox applications automatically, just by clicking on a regular desktop\n" 30 "sandbox applications automatically, just by clicking on a regular desktop\n"
@@ -57,14 +57,17 @@ static char *usage_str =
57 " [...]\n" 57 " [...]\n"
58 "\n" 58 "\n"
59 "License GPL version 2 or later\n" 59 "License GPL version 2 or later\n"
60 "Homepage: https://firejail.wordpress.com\n\n"; 60 "Homepage: https://firejail.wordpress.com\n";
61
62static void print_version(void) {
63 printf("firecfg version %s\n\n", VERSION);
64}
61 65
62static void usage(void) { 66static void usage(void) {
63 printf("firecfg - version %s\n\n", VERSION); 67 print_version();
64 puts(usage_str); 68 puts(usage_str);
65} 69}
66 70
67
68static void list(void) { 71static void list(void) {
69 DIR *dir = opendir(arg_bindir); 72 DIR *dir = opendir(arg_bindir);
70 if (!dir) { 73 if (!dir) {
@@ -364,7 +367,7 @@ int main(int argc, char **argv) {
364 else if (strcmp(argv[i], "--debug") == 0) 367 else if (strcmp(argv[i], "--debug") == 0)
365 arg_debug = 1; 368 arg_debug = 1;
366 else if (strcmp(argv[i], "--version") == 0) { 369 else if (strcmp(argv[i], "--version") == 0) {
367 printf("firecfg version %s\n\n", VERSION); 370 print_version();
368 return 0; 371 return 0;
369 } 372 }
370 else if (strcmp(argv[i], "--clean") == 0) { 373 else if (strcmp(argv[i], "--clean") == 0) {
@@ -410,6 +413,7 @@ int main(int argc, char **argv) {
410 } 413 }
411 } 414 }
412 415
416 print_version();
413 if (arg_debug) 417 if (arg_debug)
414 printf("%s %d %d %d %d\n", user, getuid(), getgid(), geteuid(), getegid()); 418 printf("%s %d %d %d %d\n", user, getuid(), getgid(), geteuid(), getegid());
415 419
diff --git a/src/firejail/checkcfg.c b/src/firejail/checkcfg.c
index a39e8c667..d2289bb40 100644
--- a/src/firejail/checkcfg.c
+++ b/src/firejail/checkcfg.c
@@ -305,147 +305,128 @@ errout:
305 exit(1); 305 exit(1);
306} 306}
307 307
308void print_version(void) { 308static const char *const compiletime_support =
309 printf("firejail version %s\n", VERSION); 309 "Compile time support:"
310 printf("\n"); 310 "\n\t- always force nonewprivs support is "
311 print_compiletime_support();
312 printf("\n");
313}
314
315void print_compiletime_support(void) {
316 printf("Compile time support:\n");
317 printf("\t- always force nonewprivs support is %s\n",
318#ifdef HAVE_FORCE_NONEWPRIVS 311#ifdef HAVE_FORCE_NONEWPRIVS
319 "enabled" 312 "enabled"
320#else 313#else
321 "disabled" 314 "disabled"
322#endif 315#endif
323 );
324 316
325 printf("\t- AppArmor support is %s\n", 317 "\n\t- AppArmor support is "
326#ifdef HAVE_APPARMOR 318#ifdef HAVE_APPARMOR
327 "enabled" 319 "enabled"
328#else 320#else
329 "disabled" 321 "disabled"
330#endif 322#endif
331 );
332 323
333 printf("\t- AppImage support is %s\n", 324 "\n\t- AppImage support is "
334#ifdef LOOP_CTL_GET_FREE // test for older kernels; this definition is found in /usr/include/linux/loop.h 325#ifdef LOOP_CTL_GET_FREE // test for older kernels; this definition is found in /usr/include/linux/loop.h
335 "enabled" 326 "enabled"
336#else 327#else
337 "disabled" 328 "disabled"
338#endif 329#endif
339 );
340 330
341 printf("\t- chroot support is %s\n", 331 "\n\t- chroot support is "
342#ifdef HAVE_CHROOT 332#ifdef HAVE_CHROOT
343 "enabled" 333 "enabled"
344#else 334#else
345 "disabled" 335 "disabled"
346#endif 336#endif
347 );
348 337
349 printf("\t- D-BUS proxy support is %s\n", 338 "\n\t- D-BUS proxy support is "
350#ifdef HAVE_DBUSPROXY 339#ifdef HAVE_DBUSPROXY
351 "enabled" 340 "enabled"
352#else 341#else
353 "disabled" 342 "disabled"
354#endif 343#endif
355 );
356 344
357 printf("\t- file transfer support is %s\n", 345 "\n\t- file transfer support is "
358#ifdef HAVE_FILE_TRANSFER 346#ifdef HAVE_FILE_TRANSFER
359 "enabled" 347 "enabled"
360#else 348#else
361 "disabled" 349 "disabled"
362#endif 350#endif
363 );
364 351
365 printf("\t- firetunnel support is %s\n", 352 "\n\t- firetunnel support is "
366#ifdef HAVE_FIRETUNNEL 353#ifdef HAVE_FIRETUNNEL
367 "enabled" 354 "enabled"
368#else 355#else
369 "disabled" 356 "disabled"
370#endif 357#endif
371 );
372 358
373 printf("\t- IDS support is %s\n", 359 "\n\t- IDS support is "
374#ifdef HAVE_IDS 360#ifdef HAVE_IDS
375 "enabled" 361 "enabled"
376#else 362#else
377 "disabled" 363 "disabled"
378#endif 364#endif
379 );
380 365
381 printf("\t- networking support is %s\n", 366 "\n\t- networking support is "
382#ifdef HAVE_NETWORK 367#ifdef HAVE_NETWORK
383 "enabled" 368 "enabled"
384#else 369#else
385 "disabled" 370 "disabled"
386#endif 371#endif
387 );
388 372
389 printf("\t- output logging is %s\n", 373 "\n\t- output logging is "
390#ifdef HAVE_OUTPUT 374#ifdef HAVE_OUTPUT
391 "enabled" 375 "enabled"
392#else 376#else
393 "disabled" 377 "disabled"
394#endif 378#endif
395 ); 379
396 printf("\t- overlayfs support is %s\n", 380 "\n\t- overlayfs support is "
397#ifdef HAVE_OVERLAYFS 381#ifdef HAVE_OVERLAYFS
398 "enabled" 382 "enabled"
399#else 383#else
400 "disabled" 384 "disabled"
401#endif 385#endif
402 );
403 386
404 printf("\t- private-home support is %s\n", 387 "\n\t- private-home support is "
405#ifdef HAVE_PRIVATE_HOME 388#ifdef HAVE_PRIVATE_HOME
406 "enabled" 389 "enabled"
407#else 390#else
408 "disabled" 391 "disabled"
409#endif 392#endif
410 );
411 393
412 printf("\t- private-lib support is %s\n", 394 "\n\t- private-lib support is "
413#ifdef HAVE_PRIVATE_LIB 395#ifdef HAVE_PRIVATE_LIB
414 "enabled" 396 "enabled"
415#else 397#else
416 "disabled" 398 "disabled"
417#endif 399#endif
418 );
419 400
420 printf("\t- private-cache and tmpfs as user %s\n", 401 "\n\t- private-cache and tmpfs as user "
421#ifdef HAVE_USERTMPFS 402#ifdef HAVE_USERTMPFS
422 "enabled" 403 "enabled"
423#else 404#else
424 "disabled" 405 "disabled"
425#endif 406#endif
426 );
427 407
428 printf("\t- SELinux support is %s\n", 408 "\n\t- SELinux support is "
429#ifdef HAVE_SELINUX 409#ifdef HAVE_SELINUX
430 "enabled" 410 "enabled"
431#else 411#else
432 "disabled" 412 "disabled"
433#endif 413#endif
434 );
435 414
436 printf("\t- user namespace support is %s\n", 415 "\n\t- user namespace support is "
437#ifdef HAVE_USERNS 416#ifdef HAVE_USERNS
438 "enabled" 417 "enabled"
439#else 418#else
440 "disabled" 419 "disabled"
441#endif 420#endif
442 );
443 421
444 printf("\t- X11 sandboxing support is %s\n", 422 "\n\t- X11 sandboxing support is "
445#ifdef HAVE_X11 423#ifdef HAVE_X11
446 "enabled" 424 "enabled"
447#else 425#else
448 "disabled" 426 "disabled"
449#endif 427#endif
450 ); 428 "\n";
429
430void print_compiletime_support(void) {
431 puts(compiletime_support);
451} 432}
diff --git a/src/firejail/firejail.h b/src/firejail/firejail.h
index 2cde75463..d85b470e6 100644
--- a/src/firejail/firejail.h
+++ b/src/firejail/firejail.h
@@ -477,6 +477,8 @@ void tree(void);
477void top(void); 477void top(void);
478 478
479// usage.c 479// usage.c
480void print_version(void);
481void print_version_full(void);
480void usage(void); 482void usage(void);
481 483
482// process.c 484// process.c
@@ -856,7 +858,6 @@ extern char *config_seccomp_filter_add;
856extern char **whitelist_reject_topdirs; 858extern char **whitelist_reject_topdirs;
857 859
858int checkcfg(int val); 860int checkcfg(int val);
859void print_version(void);
860void print_compiletime_support(void); 861void print_compiletime_support(void);
861 862
862// appimage.c 863// appimage.c
diff --git a/src/firejail/main.c b/src/firejail/main.c
index 7e23cdc63..1835d8de2 100644
--- a/src/firejail/main.c
+++ b/src/firejail/main.c
@@ -369,7 +369,7 @@ static void run_cmd_and_exit(int i, int argc, char **argv) {
369 exit(0); 369 exit(0);
370 } 370 }
371 else if (strcmp(argv[i], "--version") == 0) { 371 else if (strcmp(argv[i], "--version") == 0) {
372 print_version(); 372 print_version_full();
373 exit(0); 373 exit(0);
374 } 374 }
375#ifdef HAVE_OVERLAYFS 375#ifdef HAVE_OVERLAYFS
@@ -1128,7 +1128,7 @@ int main(int argc, char **argv, char **envp) {
1128 EUID_USER(); 1128 EUID_USER();
1129 if (rv == 0) { 1129 if (rv == 0) {
1130 if (check_arg(argc, argv, "--version", 1)) { 1130 if (check_arg(argc, argv, "--version", 1)) {
1131 print_version(); 1131 print_version_full();
1132 exit(0); 1132 exit(0);
1133 } 1133 }
1134 1134
@@ -3010,6 +3010,11 @@ int main(int argc, char **argv, char **envp) {
3010 } 3010 }
3011 EUID_ASSERT(); 3011 EUID_ASSERT();
3012 3012
3013 // Note: Only attempt to print non-debug information to stdout after
3014 // all profiles have been loaded (because a profile may set arg_quiet)
3015 if (!arg_quiet)
3016 print_version();
3017
3013 // block X11 sockets 3018 // block X11 sockets
3014 if (arg_x11_block) 3019 if (arg_x11_block)
3015 x11_block(); 3020 x11_block();
diff --git a/src/firejail/usage.c b/src/firejail/usage.c
index b6b60d85c..e8758c807 100644
--- a/src/firejail/usage.c
+++ b/src/firejail/usage.c
@@ -19,7 +19,7 @@
19*/ 19*/
20#include "firejail.h" 20#include "firejail.h"
21 21
22static char *usage_str = 22static const char *const usage_str =
23 "Firejail is a SUID sandbox program that reduces the risk of security breaches by\n" 23 "Firejail is a SUID sandbox program that reduces the risk of security breaches by\n"
24 "restricting the running environment of untrusted applications using Linux\n" 24 "restricting the running environment of untrusted applications using Linux\n"
25 "namespaces.\n" 25 "namespaces.\n"
@@ -311,11 +311,18 @@ static char *usage_str =
311 "\tlist all running sandboxes\n" 311 "\tlist all running sandboxes\n"
312 "\n" 312 "\n"
313 "License GPL version 2 or later\n" 313 "License GPL version 2 or later\n"
314 "Homepage: https://firejail.wordpress.com\n" 314 "Homepage: https://firejail.wordpress.com\n";
315 "\n";
316 315
316void print_version(void) {
317 printf("firejail version %s\n\n", VERSION);
318}
319
320void print_version_full(void) {
321 print_version();
322 print_compiletime_support();
323}
317 324
318void usage(void) { 325void usage(void) {
319 printf("firejail - version %s\n\n", VERSION); 326 print_version();
320 puts(usage_str); 327 puts(usage_str);
321} 328}
diff --git a/src/firemon/firemon.c b/src/firemon/firemon.c
index d82f387ff..958fa1b03 100644
--- a/src/firemon/firemon.c
+++ b/src/firemon/firemon.c
@@ -145,7 +145,7 @@ int main(int argc, char **argv) {
145 return 0; 145 return 0;
146 } 146 }
147 else if (strcmp(argv[i], "--version") == 0) { 147 else if (strcmp(argv[i], "--version") == 0) {
148 printf("firemon version %s\n\n", VERSION); 148 print_version();
149 return 0; 149 return 0;
150 } 150 }
151 else if (strcmp(argv[i], "--debug") == 0) 151 else if (strcmp(argv[i], "--debug") == 0)
diff --git a/src/firemon/firemon.h b/src/firemon/firemon.h
index 8b6e75fc3..be83352bb 100644
--- a/src/firemon/firemon.h
+++ b/src/firemon/firemon.h
@@ -49,6 +49,7 @@ void firemon_sleep(int st);
49void procevent(pid_t pid) __attribute__((noreturn)); 49void procevent(pid_t pid) __attribute__((noreturn));
50 50
51// usage.c 51// usage.c
52void print_version(void);
52void usage(void); 53void usage(void);
53 54
54// top.c 55// top.c
diff --git a/src/firemon/usage.c b/src/firemon/usage.c
index 169ec9163..afd2b552a 100644
--- a/src/firemon/usage.c
+++ b/src/firemon/usage.c
@@ -19,7 +19,7 @@
19*/ 19*/
20#include "firemon.h" 20#include "firemon.h"
21 21
22static char *help_str = 22static const char *const usage_str =
23 "Usage: firemon [OPTIONS] [PID]\n\n" 23 "Usage: firemon [OPTIONS] [PID]\n\n"
24 "Monitor processes started in a Firejail sandbox. Without any PID specified,\n" 24 "Monitor processes started in a Firejail sandbox. Without any PID specified,\n"
25 "all processes started by Firejail are monitored. Descendants of these processes\n" 25 "all processes started by Firejail are monitored. Descendants of these processes\n"
@@ -75,10 +75,13 @@ static char *help_str =
75 "\tUser - The owner of the sandbox.\n" 75 "\tUser - The owner of the sandbox.\n"
76 "\n" 76 "\n"
77 "License GPL version 2 or later\n" 77 "License GPL version 2 or later\n"
78 "Homepage: https://firejail.wordpress.com\n" 78 "Homepage: https://firejail.wordpress.com\n";
79 "\n"; 79
80void print_version(void) {
81 printf("firemon version %s\n\n", VERSION);
82}
80 83
81void usage(void) { 84void usage(void) {
82 printf("firemon - version %s\n", VERSION); 85 print_version();
83 puts(help_str); 86 puts(usage_str);
84} 87}
diff --git a/src/fldd/main.c b/src/fldd/main.c
index 63398ce2e..c28cad72e 100644
--- a/src/fldd/main.c
+++ b/src/fldd/main.c
@@ -282,12 +282,13 @@ static void walk_directory(const char *dirname) {
282 } 282 }
283} 283}
284 284
285 285static const char *const usage_str =
286 "Usage: fldd program_or_directory [file]\n"
287 "Print a list of libraries used by program or store it in the file.\n"
288 "Print a list of libraries used by all .so files in a directory or store it in the file.\n";
286 289
287static void usage(void) { 290static void usage(void) {
288 printf("Usage: fldd program_or_directory [file]\n"); 291 puts(usage_str);
289 printf("Print a list of libraries used by program or store it in the file.\n");
290 printf("Print a list of libraries used by all .so files in a directory or store it in the file.\n");
291} 292}
292 293
293int main(int argc, char **argv) { 294int main(int argc, char **argv) {
@@ -363,4 +364,4 @@ int main(void) {
363 printf("Sorry, private lib is disabled in this build\n"); 364 printf("Sorry, private lib is disabled in this build\n");
364 return 0; 365 return 0;
365} 366}
366#endif \ No newline at end of file 367#endif
diff --git a/src/fnet/main.c b/src/fnet/main.c
index fc36ae977..d1c8170ca 100644
--- a/src/fnet/main.c
+++ b/src/fnet/main.c
@@ -35,19 +35,21 @@ void fmessage(char* fmt, ...) { // TODO: this function is duplicated in src/fire
35 fflush(0); 35 fflush(0);
36} 36}
37 37
38static const char *const usage_str =
39 "Usage:\n"
40 "\tfnet create veth dev1 dev2 bridge child\n"
41 "\tfnet create macvlan dev parent child\n"
42 "\tfnet moveif dev proc\n"
43 "\tfnet printif\n"
44 "\tfnet printif scan\n"
45 "\tfnet config interface dev ip mask mtu\n"
46 "\tfnet config mac addr\n"
47 "\tfnet config ipv6 dev ip\n"
48 "\tfnet ifup dev\n"
49 "\tfnet waitll dev\n";
38 50
39static void usage(void) { 51static void usage(void) {
40 printf("Usage:\n"); 52 puts(usage_str);
41 printf("\tfnet create veth dev1 dev2 bridge child\n");
42 printf("\tfnet create macvlan dev parent child\n");
43 printf("\tfnet moveif dev proc\n");
44 printf("\tfnet printif\n");
45 printf("\tfnet printif scan\n");
46 printf("\tfnet config interface dev ip mask mtu\n");
47 printf("\tfnet config mac addr\n");
48 printf("\tfnet config ipv6 dev ip\n");
49 printf("\tfnet ifup dev\n");
50 printf("\tfnet waitll dev\n");
51} 53}
52 54
53int main(int argc, char **argv) { 55int main(int argc, char **argv) {
diff --git a/src/fnetfilter/main.c b/src/fnetfilter/main.c
index 8c0f6c297..1b0335d68 100644
--- a/src/fnetfilter/main.c
+++ b/src/fnetfilter/main.c
@@ -45,9 +45,12 @@ static char *default_filter =
45"-A OUTPUT -p tcp --dport 3479 -j DROP\n" 45"-A OUTPUT -p tcp --dport 3479 -j DROP\n"
46"COMMIT\n"; 46"COMMIT\n";
47 47
48static const char *const usage_str =
49 "Usage:\n"
50 "\tfnetfilter netfilter-command destination-file\n";
51
48static void usage(void) { 52static void usage(void) {
49 printf("Usage:\n"); 53 puts(usage_str);
50 printf("\tfnetfilter netfilter-command destination-file\n");
51} 54}
52 55
53static void err_exit_cannot_open_file(const char *fname) { 56static void err_exit_cannot_open_file(const char *fname) {
diff --git a/src/fnettrace-dns/main.c b/src/fnettrace-dns/main.c
index 64feec5fe..1cde1942c 100644
--- a/src/fnettrace-dns/main.c
+++ b/src/fnettrace-dns/main.c
@@ -167,13 +167,13 @@ static void run_trace(void) {
167 167
168 close(s); 168 close(s);
169} 169}
170 170static const char *const usage_str =
171 "Usage: fnettrace-dns [OPTIONS]\n"
172 "Options:\n"
173 " --help, -? - this help screen\n";
171 174
172static void usage(void) { 175static void usage(void) {
173 printf("Usage: fnettrace-dns [OPTIONS]\n"); 176 puts(usage_str);
174 printf("Options:\n");
175 printf(" --help, -? - this help screen\n");
176 printf("\n");
177} 177}
178 178
179int main(int argc, char **argv) { 179int main(int argc, char **argv) {
diff --git a/src/fnettrace-icmp/main.c b/src/fnettrace-icmp/main.c
index 714917547..516a9fc5b 100644
--- a/src/fnettrace-icmp/main.c
+++ b/src/fnettrace-icmp/main.c
@@ -201,11 +201,13 @@ static void run_trace(void) {
201 close(s); 201 close(s);
202} 202}
203 203
204static const char *const usage_str =
205 "Usage: fnettrace-icmp [OPTIONS]\n"
206 "Options:\n"
207 " --help, -? - this help screen\n";
208
204static void usage(void) { 209static void usage(void) {
205 printf("Usage: fnettrace-icmp [OPTIONS]\n"); 210 puts(usage_str);
206 printf("Options:\n");
207 printf(" --help, -? - this help screen\n");
208 printf("\n");
209} 211}
210 212
211int main(int argc, char **argv) { 213int main(int argc, char **argv) {
diff --git a/src/fnettrace-sni/main.c b/src/fnettrace-sni/main.c
index b8490b4f7..e7782d656 100644
--- a/src/fnettrace-sni/main.c
+++ b/src/fnettrace-sni/main.c
@@ -204,12 +204,13 @@ static void run_trace(void) {
204 close(s); 204 close(s);
205} 205}
206 206
207static const char *const usage_str =
208 "Usage: fnettrace-sni [OPTIONS]\n"
209 "Options:\n"
210 " --help, -? - this help screen\n";
207 211
208static void usage(void) { 212static void usage(void) {
209 printf("Usage: fnettrace-sni [OPTIONS]\n"); 213 puts(usage_str);
210 printf("Options:\n");
211 printf(" --help, -? - this help screen\n");
212 printf("\n");
213} 214}
214 215
215int main(int argc, char **argv) { 216int main(int argc, char **argv) {
diff --git a/src/fnettrace/main.c b/src/fnettrace/main.c
index 2f421562e..178ac3631 100644
--- a/src/fnettrace/main.c
+++ b/src/fnettrace/main.c
@@ -668,18 +668,20 @@ void logprintf(char *fmt, ...) {
668 va_end(args); 668 va_end(args);
669} 669}
670 670
671static const char *const usage_str =
672 "Usage: fnettrace [OPTIONS]\n"
673 "Options:\n"
674 " --help, -? - this help screen\n"
675 " --log=filename - netlocker logfile\n"
676 " --netfilter - build the firewall rules and commit them.\n"
677 " --tail - \"tail -f\" functionality\n"
678 "Examples:\n"
679 " # fnettrace - traffic trace\n"
680 " # fnettrace --netfilter --log=logfile - netlocker, dump output in logfile\n"
681 " # fnettrace --tail --log=logifile - similar to \"tail -f logfile\"\n";
682
671static void usage(void) { 683static void usage(void) {
672 printf("Usage: fnettrace [OPTIONS]\n"); 684 puts(usage_str);
673 printf("Options:\n");
674 printf(" --help, -? - this help screen\n");
675 printf(" --log=filename - netlocker logfile\n");
676 printf(" --netfilter - build the firewall rules and commit them.\n");
677 printf(" --tail - \"tail -f\" functionality\n");
678 printf("Examples:\n");
679 printf(" # fnettrace - traffic trace\n");
680 printf(" # fnettrace --netfilter --log=logfile - netlocker, dump output in logfile\n");
681 printf(" # fnettrace --tail --log=logifile - similar to \"tail -f logfile\"\n");
682 printf("\n");
683} 685}
684 686
685int main(int argc, char **argv) { 687int main(int argc, char **argv) {
diff --git a/src/fsec-optimize/main.c b/src/fsec-optimize/main.c
index 0bc521c0d..38ba7c697 100644
--- a/src/fsec-optimize/main.c
+++ b/src/fsec-optimize/main.c
@@ -22,9 +22,12 @@
22 22
23int arg_seccomp_error_action = SECCOMP_RET_ERRNO | EPERM; // error action: errno, log or kill 23int arg_seccomp_error_action = SECCOMP_RET_ERRNO | EPERM; // error action: errno, log or kill
24 24
25static const char *const usage_str =
26 "Usage:\n"
27 "\tfsec-optimize file - optimize seccomp filter\n";
28
25static void usage(void) { 29static void usage(void) {
26 printf("Usage:\n"); 30 puts(usage_str);
27 printf("\tfsec-optimize file - optimize seccomp filter\n");
28} 31}
29 32
30int main(int argc, char **argv) { 33int main(int argc, char **argv) {
diff --git a/src/fsec-print/main.c b/src/fsec-print/main.c
index 696c6bc0c..4d3e38648 100644
--- a/src/fsec-print/main.c
+++ b/src/fsec-print/main.c
@@ -19,9 +19,12 @@
19*/ 19*/
20#include "fsec_print.h" 20#include "fsec_print.h"
21 21
22static const char *const usage_str =
23 "Usage:\n"
24 "\tfsec-print file - disassemble seccomp filter\n";
25
22static void usage(void) { 26static void usage(void) {
23 printf("Usage:\n"); 27 puts(usage_str);
24 printf("\tfsec-print file - disassemble seccomp filter\n");
25} 28}
26 29
27int arg_quiet = 0; 30int arg_quiet = 0;
diff --git a/src/fseccomp/main.c b/src/fseccomp/main.c
index 0b46daf65..e7823d3c5 100644
--- a/src/fseccomp/main.c
+++ b/src/fseccomp/main.c
@@ -22,34 +22,37 @@
22int arg_quiet = 0; 22int arg_quiet = 0;
23int arg_seccomp_error_action = SECCOMP_RET_ERRNO | EPERM; // error action: errno, log or kill 23int arg_seccomp_error_action = SECCOMP_RET_ERRNO | EPERM; // error action: errno, log or kill
24 24
25static const char *const usage_str =
26 "Usage:\n"
27 "\tfseccomp debug-syscalls\n"
28 "\tfseccomp debug-syscalls32\n"
29 "\tfseccomp debug-errnos\n"
30 "\tfseccomp debug-protocols\n"
31 "\tfseccomp protocol build list file\n"
32 "\tfseccomp secondary 64 file\n"
33 "\tfseccomp secondary 32 file\n"
34 "\tfseccomp secondary block file\n"
35 "\tfseccomp default file\n"
36 "\tfseccomp default file allow-debuggers\n"
37 "\tfseccomp default32 file\n"
38 "\tfseccomp default32 file allow-debuggers\n"
39 "\tfseccomp drop file1 file2 list\n"
40 "\tfseccomp drop file1 file2 list allow-debuggers\n"
41 "\tfseccomp drop32 file1 file2 list\n"
42 "\tfseccomp drop32 file1 file2 list allow-debuggers\n"
43 "\tfseccomp default drop file1 file2 list\n"
44 "\tfseccomp default drop file1 file2 list allow-debuggers\n"
45 "\tfseccomp default32 drop file1 file2 list\n"
46 "\tfseccomp default32 drop file1 file2 list allow-debuggers\n"
47 "\tfseccomp keep file1 file2 list\n"
48 "\tfseccomp keep32 file1 file2 list\n"
49 "\tfseccomp memory-deny-write-execute file\n"
50 "\tfseccomp memory-deny-write-execute.32 file\n"
51 "\tfseccomp restrict-namespaces file list\n"
52 "\tfseccomp restrict-namespaces.32 file list\n";
53
25static void usage(void) { 54static void usage(void) {
26 printf("Usage:\n" 55 puts(usage_str);
27 "\tfseccomp debug-syscalls\n"
28 "\tfseccomp debug-syscalls32\n"
29 "\tfseccomp debug-errnos\n"
30 "\tfseccomp debug-protocols\n"
31 "\tfseccomp protocol build list file\n"
32 "\tfseccomp secondary 64 file\n"
33 "\tfseccomp secondary 32 file\n"
34 "\tfseccomp secondary block file\n"
35 "\tfseccomp default file\n"
36 "\tfseccomp default file allow-debuggers\n"
37 "\tfseccomp default32 file\n"
38 "\tfseccomp default32 file allow-debuggers\n"
39 "\tfseccomp drop file1 file2 list\n"
40 "\tfseccomp drop file1 file2 list allow-debuggers\n"
41 "\tfseccomp drop32 file1 file2 list\n"
42 "\tfseccomp drop32 file1 file2 list allow-debuggers\n"
43 "\tfseccomp default drop file1 file2 list\n"
44 "\tfseccomp default drop file1 file2 list allow-debuggers\n"
45 "\tfseccomp default32 drop file1 file2 list\n"
46 "\tfseccomp default32 drop file1 file2 list allow-debuggers\n"
47 "\tfseccomp keep file1 file2 list\n"
48 "\tfseccomp keep32 file1 file2 list\n"
49 "\tfseccomp memory-deny-write-execute file\n"
50 "\tfseccomp memory-deny-write-execute.32 file\n"
51 "\tfseccomp restrict-namespaces file list\n"
52 "\tfseccomp restrict-namespaces.32 file list\n");
53} 56}
54 57
55int main(int argc, char **argv) { 58int main(int argc, char **argv) {
diff --git a/src/ftee/main.c b/src/ftee/main.c
index 0a492b41e..a34a76b26 100644
--- a/src/ftee/main.c
+++ b/src/ftee/main.c
@@ -180,8 +180,11 @@ static int is_link(const char *fname) {
180 return 0; 180 return 0;
181} 181}
182 182
183static const char *const usage_str =
184 "Usage: ftee filename\n";
185
183static void usage(void) { 186static void usage(void) {
184 printf("Usage: ftee filename\n"); 187 puts(usage_str);
185} 188}
186 189
187int main(int argc, char **argv) { 190int main(int argc, char **argv) {
diff --git a/src/jailcheck/main.c b/src/jailcheck/main.c
index 8e0aaa860..27da309ea 100644
--- a/src/jailcheck/main.c
+++ b/src/jailcheck/main.c
@@ -29,16 +29,19 @@ char *user_home_dir = NULL;
29char *user_run_dir = NULL; 29char *user_run_dir = NULL;
30int arg_debug = 0; 30int arg_debug = 0;
31 31
32static char *usage_str = 32static const char *const usage_str =
33 "Usage: jailcheck [options] directory [directory]\n\n" 33 "Usage: jailcheck [options] directory [directory]\n\n"
34 "Options:\n" 34 "Options:\n"
35 " --debug - print debug messages.\n" 35 " --debug - print debug messages.\n"
36 " --help, -? - this help screen.\n" 36 " --help, -? - this help screen.\n"
37 " --version - print program version and exit.\n"; 37 " --version - print program version and exit.\n";
38 38
39static void print_version(void) {
40 printf("jailcheck version %s\n\n", VERSION);
41}
39 42
40static void usage(void) { 43static void usage(void) {
41 printf("firetest - version %s\n\n", VERSION); 44 print_version();
42 puts(usage_str); 45 puts(usage_str);
43} 46}
44 47
@@ -62,7 +65,7 @@ int main(int argc, char **argv) {
62 return 0; 65 return 0;
63 } 66 }
64 else if (strcmp(argv[i], "--version") == 0) { 67 else if (strcmp(argv[i], "--version") == 0) {
65 printf("firetest version %s\n\n", VERSION); 68 print_version();
66 return 0; 69 return 0;
67 } 70 }
68 else if (strncmp(argv[i], "--hello=", 8) == 0) { // used by noexec test 71 else if (strncmp(argv[i], "--hello=", 8) == 0) { // used by noexec test
diff --git a/src/profstats/main.c b/src/profstats/main.c
index d5e57e7cc..49ed1637a 100644
--- a/src/profstats/main.c
+++ b/src/profstats/main.c
@@ -74,32 +74,34 @@ static int arg_restrict_namespaces = 0;
74 74
75static char *profile = NULL; 75static char *profile = NULL;
76 76
77static const char *const usage_str =
78 "profstats - print profile statistics\n"
79 "Usage: profstats [options] file[s]\n"
80 "Options:\n"
81 " --apparmor - print profiles without apparmor\n"
82 " --caps - print profiles without caps\n"
83 " --dbus-system-none - print profiles without \"dbus-system none\"\n"
84 " --dbus-user-none - print profiles without \"dbus-user none\"\n"
85 " --ssh - print profiles without \"include disable-common.inc\"\n"
86 " --noexec - print profiles without \"include disable-exec.inc\"\n"
87 " --noroot - print profiles without \"noroot\"\n"
88 " --private-bin - print profiles without private-bin\n"
89 " --private-dev - print profiles without private-dev\n"
90 " --private-etc - print profiles without private-etc\n"
91 " --private-tmp - print profiles without private-tmp\n"
92 " --print-blacklist - print all --blacklist for a profile\n"
93 " --print-whitelist - print all --private and --whitelist for a profile\n"
94 " --seccomp - print profiles without seccomp\n"
95 " --memory-deny-write-execute - print profiles without \"memory-deny-write-execute\"\n"
96 " --restrict-namespaces - print profiles without \"restrict-namespaces\"\n"
97 " --whitelist-home - print profiles whitelisting home directory\n"
98 " --whitelist-var - print profiles without \"include whitelist-var-common.inc\"\n"
99 " --whitelist-runuser - print profiles without \"include whitelist-runuser-common.inc\" or \"blacklist ${RUNUSER}\"\n"
100 " --whitelist-usrshare - print profiles without \"include whitelist-usr-share-common.inc\"\n"
101 " --debug\n";
102
77static void usage(void) { 103static void usage(void) {
78 printf("profstats - print profile statistics\n"); 104 puts(usage_str);
79 printf("Usage: profstats [options] file[s]\n");
80 printf("Options:\n");
81 printf(" --apparmor - print profiles without apparmor\n");
82 printf(" --caps - print profiles without caps\n");
83 printf(" --dbus-system-none - print profiles without \"dbus-system none\"\n");
84 printf(" --dbus-user-none - print profiles without \"dbus-user none\"\n");
85 printf(" --ssh - print profiles without \"include disable-common.inc\"\n");
86 printf(" --noexec - print profiles without \"include disable-exec.inc\"\n");
87 printf(" --noroot - print profiles without \"noroot\"\n");
88 printf(" --private-bin - print profiles without private-bin\n");
89 printf(" --private-dev - print profiles without private-dev\n");
90 printf(" --private-etc - print profiles without private-etc\n");
91 printf(" --private-tmp - print profiles without private-tmp\n");
92 printf(" --print-blacklist - print all --blacklist for a profile\n");
93 printf(" --print-whitelist - print all --private and --whitelist for a profile\n");
94 printf(" --seccomp - print profiles without seccomp\n");
95 printf(" --memory-deny-write-execute - print profiles without \"memory-deny-write-execute\"\n");
96 printf(" --restrict-namespaces - print profiles without \"restrict-namespaces\"\n");
97 printf(" --whitelist-home - print profiles whitelisting home directory\n");
98 printf(" --whitelist-var - print profiles without \"include whitelist-var-common.inc\"\n");
99 printf(" --whitelist-runuser - print profiles without \"include whitelist-runuser-common.inc\" or \"blacklist ${RUNUSER}\"\n");
100 printf(" --whitelist-usrshare - print profiles without \"include whitelist-usr-share-common.inc\"\n");
101 printf(" --debug\n");
102 printf("\n");
103} 105}
104 106
105static void process_file(char *fname) { 107static void process_file(char *fname) {