aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.in2
-rwxr-xr-xconfigure492
-rw-r--r--configure.ac23
-rw-r--r--etc/firejail-default129
-rw-r--r--src/firejail/Makefile.in6
-rw-r--r--src/firejail/sandbox.c12
-rw-r--r--todo3
7 files changed, 438 insertions, 229 deletions
diff --git a/Makefile.in b/Makefile.in
index e47e109d3..4d7526826 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -85,6 +85,8 @@ realinstall:
85 done 85 done
86 sh -c "if [ ! -f $(DESTDIR)/$(sysconfdir)/firejail/login.users ]; then install -c -m 0644 etc/login.users $(DESTDIR)/$(sysconfdir)/firejail/.; fi;" 86 sh -c "if [ ! -f $(DESTDIR)/$(sysconfdir)/firejail/login.users ]; then install -c -m 0644 etc/login.users $(DESTDIR)/$(sysconfdir)/firejail/.; fi;"
87 rm -fr .etc 87 rm -fr .etc
88 # install apparmor profile
89 sh -c "if [ -d /etc/apparmor.d ]; then install -c -m 0644 etc/firejail-default /etc/apparmor.d/firejail-default; fi;"
88 # man pages 90 # man pages
89 install -m 0755 -d $(DESTDIR)/$(mandir)/man1 91 install -m 0755 -d $(DESTDIR)/$(mandir)/man1
90 install -m 0755 -d $(DESTDIR)/$(mandir)/man5 92 install -m 0755 -d $(DESTDIR)/$(mandir)/man5
diff --git a/configure b/configure
index 050b4df9c..0f6f8f7fb 100755
--- a/configure
+++ b/configure
@@ -625,9 +625,6 @@ ac_includes_default="\
625ac_subst_vars='LTLIBOBJS 625ac_subst_vars='LTLIBOBJS
626LIBOBJS 626LIBOBJS
627HAVE_SECCOMP_H 627HAVE_SECCOMP_H
628EGREP
629GREP
630CPP
631HAVE_FATAL_WARNINGS 628HAVE_FATAL_WARNINGS
632HAVE_WHITELIST 629HAVE_WHITELIST
633HAVE_FILE_TRANSFER 630HAVE_FILE_TRANSFER
@@ -638,6 +635,11 @@ HAVE_GLOBALCFG
638HAVE_BIND 635HAVE_BIND
639HAVE_CHROOT 636HAVE_CHROOT
640HAVE_SECCOMP 637HAVE_SECCOMP
638EXTRA_LDFLAGS
639EGREP
640GREP
641CPP
642HAVE_APPARMOR
641RANLIB 643RANLIB
642INSTALL_DATA 644INSTALL_DATA
643INSTALL_SCRIPT 645INSTALL_SCRIPT
@@ -690,6 +692,7 @@ SHELL'
690ac_subst_files='' 692ac_subst_files=''
691ac_user_opts=' 693ac_user_opts='
692enable_option_checking 694enable_option_checking
695enable_apparmor
693enable_seccomp 696enable_seccomp
694enable_chroot 697enable_chroot
695enable_bind 698enable_bind
@@ -1319,6 +1322,7 @@ Optional Features:
1319 --disable-option-checking ignore unrecognized --enable/--with options 1322 --disable-option-checking ignore unrecognized --enable/--with options
1320 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) 1323 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
1321 --enable-FEATURE[=ARG] include FEATURE [ARG=yes] 1324 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
1325 --enable-apparmor enable apparmor
1322 --disable-seccomp disable seccomp 1326 --disable-seccomp disable seccomp
1323 --disable-chroot disable chroot 1327 --disable-chroot disable chroot
1324 --disable-bind disable bind 1328 --disable-bind disable bind
@@ -1462,52 +1466,6 @@ fi
1462 1466
1463} # ac_fn_c_try_compile 1467} # ac_fn_c_try_compile
1464 1468
1465# ac_fn_c_try_link LINENO
1466# -----------------------
1467# Try to link conftest.$ac_ext, and return whether this succeeded.
1468ac_fn_c_try_link ()
1469{
1470 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1471 rm -f conftest.$ac_objext conftest$ac_exeext
1472 if { { ac_try="$ac_link"
1473case "(($ac_try" in
1474 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1475 *) ac_try_echo=$ac_try;;
1476esac
1477eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1478$as_echo "$ac_try_echo"; } >&5
1479 (eval "$ac_link") 2>conftest.err
1480 ac_status=$?
1481 if test -s conftest.err; then
1482 grep -v '^ *+' conftest.err >conftest.er1
1483 cat conftest.er1 >&5
1484 mv -f conftest.er1 conftest.err
1485 fi
1486 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1487 test $ac_status = 0; } && {
1488 test -z "$ac_c_werror_flag" ||
1489 test ! -s conftest.err
1490 } && test -s conftest$ac_exeext && {
1491 test "$cross_compiling" = yes ||
1492 test -x conftest$ac_exeext
1493 }; then :
1494 ac_retval=0
1495else
1496 $as_echo "$as_me: failed program was:" >&5
1497sed 's/^/| /' conftest.$ac_ext >&5
1498
1499 ac_retval=1
1500fi
1501 # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
1502 # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
1503 # interfere with the next link command; also delete a directory that is
1504 # left behind by Apple's compiler. We do this before executing the actions.
1505 rm -rf conftest.dSYM conftest_ipa8_conftest.oo
1506 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1507 as_fn_set_status $ac_retval
1508
1509} # ac_fn_c_try_link
1510
1511# ac_fn_c_try_cpp LINENO 1469# ac_fn_c_try_cpp LINENO
1512# ---------------------- 1470# ----------------------
1513# Try to preprocess conftest.$ac_ext, and return whether this succeeded. 1471# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
@@ -1708,6 +1666,52 @@ $as_echo "$ac_res" >&6; }
1708 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno 1666 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1709 1667
1710} # ac_fn_c_check_header_compile 1668} # ac_fn_c_check_header_compile
1669
1670# ac_fn_c_try_link LINENO
1671# -----------------------
1672# Try to link conftest.$ac_ext, and return whether this succeeded.
1673ac_fn_c_try_link ()
1674{
1675 as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
1676 rm -f conftest.$ac_objext conftest$ac_exeext
1677 if { { ac_try="$ac_link"
1678case "(($ac_try" in
1679 *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
1680 *) ac_try_echo=$ac_try;;
1681esac
1682eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
1683$as_echo "$ac_try_echo"; } >&5
1684 (eval "$ac_link") 2>conftest.err
1685 ac_status=$?
1686 if test -s conftest.err; then
1687 grep -v '^ *+' conftest.err >conftest.er1
1688 cat conftest.er1 >&5
1689 mv -f conftest.er1 conftest.err
1690 fi
1691 $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
1692 test $ac_status = 0; } && {
1693 test -z "$ac_c_werror_flag" ||
1694 test ! -s conftest.err
1695 } && test -s conftest$ac_exeext && {
1696 test "$cross_compiling" = yes ||
1697 test -x conftest$ac_exeext
1698 }; then :
1699 ac_retval=0
1700else
1701 $as_echo "$as_me: failed program was:" >&5
1702sed 's/^/| /' conftest.$ac_ext >&5
1703
1704 ac_retval=1
1705fi
1706 # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
1707 # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
1708 # interfere with the next link command; also delete a directory that is
1709 # left behind by Apple's compiler. We do this before executing the actions.
1710 rm -rf conftest.dSYM conftest_ipa8_conftest.oo
1711 eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
1712 as_fn_set_status $ac_retval
1713
1714} # ac_fn_c_try_link
1711cat >config.log <<_ACEOF 1715cat >config.log <<_ACEOF
1712This file contains any messages produced by compilers while 1716This file contains any messages produced by compilers while
1713running configure, to aid debugging if configure makes a mistake. 1717running configure, to aid debugging if configure makes a mistake.
@@ -3069,189 +3073,23 @@ else
3069fi 3073fi
3070 3074
3071 3075
3072HAVE_SECCOMP="" 3076# Allow to build without apparmor support by calling:
3073# Check whether --enable-seccomp was given. 3077# ./configure --disable-apparmor
3074if test "${enable_seccomp+set}" = set; then : 3078# This makes it possible to run snaps in devmode on almost any host,
3075 enableval=$enable_seccomp; 3079# regardless of the kernel version.
3076fi 3080HAVE_APPARMOR=""
3077 3081# Check whether --enable-apparmor was given.
3078if test "x$enable_seccomp" != "xno"; then : 3082if test "${enable_apparmor+set}" = set; then :
3079 3083 enableval=$enable_apparmor;
3080 HAVE_SECCOMP="-DHAVE_SECCOMP"
3081
3082
3083fi
3084
3085HAVE_CHROOT=""
3086# Check whether --enable-chroot was given.
3087if test "${enable_chroot+set}" = set; then :
3088 enableval=$enable_chroot;
3089fi
3090
3091if test "x$enable_chroot" != "xno"; then :
3092
3093 HAVE_CHROOT="-DHAVE_CHROOT"
3094
3095
3096fi
3097
3098HAVE_BIND=""
3099# Check whether --enable-bind was given.
3100if test "${enable_bind+set}" = set; then :
3101 enableval=$enable_bind;
3102fi
3103
3104if test "x$enable_bind" != "xno"; then :
3105
3106 HAVE_BIND="-DHAVE_BIND"
3107
3108
3109fi
3110
3111HAVE_GLOBALCFG=""
3112# Check whether --enable-globalcfg was given.
3113if test "${enable_globalcfg+set}" = set; then :
3114 enableval=$enable_globalcfg;
3115fi
3116
3117if test "x$enable_globalcfg" != "xno"; then :
3118
3119 HAVE_GLOBALCFG="-DHAVE_GLOBALCFG"
3120
3121
3122fi
3123
3124HAVE_NETWORK=""
3125# Check whether --enable-network was given.
3126if test "${enable_network+set}" = set; then :
3127 enableval=$enable_network;
3128fi
3129
3130# Check whether --enable-network was given.
3131if test "${enable_network+set}" = set; then :
3132 enableval=$enable_network;
3133fi
3134
3135if test "x$enable_network" != "xno"; then :
3136
3137 HAVE_NETWORK="-DHAVE_NETWORK"
3138 if test "x$enable_network" = "xrestricted"; then :
3139
3140 HAVE_NETWORK="$HAVE_NETWORK -DHAVE_NETWORK_RESTRICTED"
3141
3142fi
3143
3144
3145fi
3146
3147HAVE_USERNS=""
3148# Check whether --enable-userns was given.
3149if test "${enable_userns+set}" = set; then :
3150 enableval=$enable_userns;
3151fi
3152
3153if test "x$enable_userns" != "xno"; then :
3154
3155 HAVE_USERNS="-DHAVE_USERNS"
3156
3157
3158fi
3159
3160HAVE_X11=""
3161# Check whether --enable-x11 was given.
3162if test "${enable_x11+set}" = set; then :
3163 enableval=$enable_x11;
3164fi
3165
3166if test "x$enable_x11" != "xno"; then :
3167
3168 HAVE_X11="-DHAVE_X11"
3169
3170
3171fi
3172
3173HAVE_FILE_TRANSFER=""
3174# Check whether --enable-file-transfer was given.
3175if test "${enable_file_transfer+set}" = set; then :
3176 enableval=$enable_file_transfer;
3177fi
3178
3179if test "x$enable_file_transfer" != "xno"; then :
3180
3181 HAVE_FILE_TRANSFER="-DHAVE_FILE_TRANSFER"
3182
3183
3184fi
3185
3186HAVE_WHITELIST=""
3187# Check whether --enable-whitelist was given.
3188if test "${enable_whitelist+set}" = set; then :
3189 enableval=$enable_whitelist;
3190fi
3191
3192if test "x$enable_whitelist" != "xno"; then :
3193
3194 HAVE_WHITELIST="-DHAVE_WHITELIST"
3195
3196
3197fi
3198
3199HAVE_FATAL_WARNINGS=""
3200# Check whether --enable-fatal_warnings was given.
3201if test "${enable_fatal_warnings+set}" = set; then :
3202 enableval=$enable_fatal_warnings;
3203fi
3204
3205if test "x$enable_fatal_warnings" = "xyes"; then :
3206
3207 HAVE_FATAL_WARNINGS="-W -Wall -Werror"
3208
3209
3210fi 3084fi
3211 3085
3086if test "x$enable_apparmor" = "xyes"; then :
3212 3087
3213# checking pthread library 3088 HAVE_APPARMOR="-DHAVE_APPARMOR"
3214
3215{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpthread" >&5
3216$as_echo_n "checking for main in -lpthread... " >&6; }
3217if ${ac_cv_lib_pthread_main+:} false; then :
3218 $as_echo_n "(cached) " >&6
3219else
3220 ac_check_lib_save_LIBS=$LIBS
3221LIBS="-lpthread $LIBS"
3222cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3223/* end confdefs.h. */
3224 3089
3225 3090
3226int
3227main ()
3228{
3229return main ();
3230 ;
3231 return 0;
3232}
3233_ACEOF
3234if ac_fn_c_try_link "$LINENO"; then :
3235 ac_cv_lib_pthread_main=yes
3236else
3237 ac_cv_lib_pthread_main=no
3238fi 3091fi
3239rm -f core conftest.err conftest.$ac_objext \
3240 conftest$ac_exeext conftest.$ac_ext
3241LIBS=$ac_check_lib_save_LIBS
3242fi
3243{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_main" >&5
3244$as_echo "$ac_cv_lib_pthread_main" >&6; }
3245if test "x$ac_cv_lib_pthread_main" = xyes; then :
3246 cat >>confdefs.h <<_ACEOF
3247#define HAVE_LIBPTHREAD 1
3248_ACEOF
3249 3092
3250 LIBS="-lpthread $LIBS"
3251
3252else
3253 as_fn_error $? "*** POSIX thread support not installed ***" "$LINENO" 5
3254fi
3255 3093
3256ac_ext=c 3094ac_ext=c
3257ac_cpp='$CPP $CPPFLAGS' 3095ac_cpp='$CPP $CPPFLAGS'
@@ -3650,6 +3488,208 @@ fi
3650done 3488done
3651 3489
3652 3490
3491if test "x$enable_apparmor" = "xyes"; then :
3492
3493 ac_fn_c_check_header_mongrel "$LINENO" "sys/apparmor.h" "ac_cv_header_sys_apparmor_h" "$ac_includes_default"
3494if test "x$ac_cv_header_sys_apparmor_h" = xyes; then :
3495
3496else
3497 as_fn_error $? "Couldn't find sys/apparmor.h... please install apparmor user space library and development files " "$LINENO" 5
3498fi
3499
3500
3501
3502fi
3503if test "x$enable_apparmor" = "xyes"; then :
3504
3505 EXTRA_LDFLAGS="-lapparmor"
3506
3507fi
3508
3509
3510HAVE_SECCOMP=""
3511# Check whether --enable-seccomp was given.
3512if test "${enable_seccomp+set}" = set; then :
3513 enableval=$enable_seccomp;
3514fi
3515
3516if test "x$enable_seccomp" != "xno"; then :
3517
3518 HAVE_SECCOMP="-DHAVE_SECCOMP"
3519
3520
3521fi
3522
3523HAVE_CHROOT=""
3524# Check whether --enable-chroot was given.
3525if test "${enable_chroot+set}" = set; then :
3526 enableval=$enable_chroot;
3527fi
3528
3529if test "x$enable_chroot" != "xno"; then :
3530
3531 HAVE_CHROOT="-DHAVE_CHROOT"
3532
3533
3534fi
3535
3536HAVE_BIND=""
3537# Check whether --enable-bind was given.
3538if test "${enable_bind+set}" = set; then :
3539 enableval=$enable_bind;
3540fi
3541
3542if test "x$enable_bind" != "xno"; then :
3543
3544 HAVE_BIND="-DHAVE_BIND"
3545
3546
3547fi
3548
3549HAVE_GLOBALCFG=""
3550# Check whether --enable-globalcfg was given.
3551if test "${enable_globalcfg+set}" = set; then :
3552 enableval=$enable_globalcfg;
3553fi
3554
3555if test "x$enable_globalcfg" != "xno"; then :
3556
3557 HAVE_GLOBALCFG="-DHAVE_GLOBALCFG"
3558
3559
3560fi
3561
3562HAVE_NETWORK=""
3563# Check whether --enable-network was given.
3564if test "${enable_network+set}" = set; then :
3565 enableval=$enable_network;
3566fi
3567
3568# Check whether --enable-network was given.
3569if test "${enable_network+set}" = set; then :
3570 enableval=$enable_network;
3571fi
3572
3573if test "x$enable_network" != "xno"; then :
3574
3575 HAVE_NETWORK="-DHAVE_NETWORK"
3576 if test "x$enable_network" = "xrestricted"; then :
3577
3578 HAVE_NETWORK="$HAVE_NETWORK -DHAVE_NETWORK_RESTRICTED"
3579
3580fi
3581
3582
3583fi
3584
3585HAVE_USERNS=""
3586# Check whether --enable-userns was given.
3587if test "${enable_userns+set}" = set; then :
3588 enableval=$enable_userns;
3589fi
3590
3591if test "x$enable_userns" != "xno"; then :
3592
3593 HAVE_USERNS="-DHAVE_USERNS"
3594
3595
3596fi
3597
3598HAVE_X11=""
3599# Check whether --enable-x11 was given.
3600if test "${enable_x11+set}" = set; then :
3601 enableval=$enable_x11;
3602fi
3603
3604if test "x$enable_x11" != "xno"; then :
3605
3606 HAVE_X11="-DHAVE_X11"
3607
3608
3609fi
3610
3611HAVE_FILE_TRANSFER=""
3612# Check whether --enable-file-transfer was given.
3613if test "${enable_file_transfer+set}" = set; then :
3614 enableval=$enable_file_transfer;
3615fi
3616
3617if test "x$enable_file_transfer" != "xno"; then :
3618
3619 HAVE_FILE_TRANSFER="-DHAVE_FILE_TRANSFER"
3620
3621
3622fi
3623
3624HAVE_WHITELIST=""
3625# Check whether --enable-whitelist was given.
3626if test "${enable_whitelist+set}" = set; then :
3627 enableval=$enable_whitelist;
3628fi
3629
3630if test "x$enable_whitelist" != "xno"; then :
3631
3632 HAVE_WHITELIST="-DHAVE_WHITELIST"
3633
3634
3635fi
3636
3637HAVE_FATAL_WARNINGS=""
3638# Check whether --enable-fatal_warnings was given.
3639if test "${enable_fatal_warnings+set}" = set; then :
3640 enableval=$enable_fatal_warnings;
3641fi
3642
3643if test "x$enable_fatal_warnings" = "xyes"; then :
3644
3645 HAVE_FATAL_WARNINGS="-W -Wall -Werror"
3646
3647
3648fi
3649
3650
3651# checking pthread library
3652{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lpthread" >&5
3653$as_echo_n "checking for main in -lpthread... " >&6; }
3654if ${ac_cv_lib_pthread_main+:} false; then :
3655 $as_echo_n "(cached) " >&6
3656else
3657 ac_check_lib_save_LIBS=$LIBS
3658LIBS="-lpthread $LIBS"
3659cat confdefs.h - <<_ACEOF >conftest.$ac_ext
3660/* end confdefs.h. */
3661
3662
3663int
3664main ()
3665{
3666return main ();
3667 ;
3668 return 0;
3669}
3670_ACEOF
3671if ac_fn_c_try_link "$LINENO"; then :
3672 ac_cv_lib_pthread_main=yes
3673else
3674 ac_cv_lib_pthread_main=no
3675fi
3676rm -f core conftest.err conftest.$ac_objext \
3677 conftest$ac_exeext conftest.$ac_ext
3678LIBS=$ac_check_lib_save_LIBS
3679fi
3680{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_pthread_main" >&5
3681$as_echo "$ac_cv_lib_pthread_main" >&6; }
3682if test "x$ac_cv_lib_pthread_main" = xyes; then :
3683 cat >>confdefs.h <<_ACEOF
3684#define HAVE_LIBPTHREAD 1
3685_ACEOF
3686
3687 LIBS="-lpthread $LIBS"
3688
3689else
3690 as_fn_error $? "*** POSIX thread support not installed ***" "$LINENO" 5
3691fi
3692
3653ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default" 3693ac_fn_c_check_header_mongrel "$LINENO" "pthread.h" "ac_cv_header_pthread_h" "$ac_includes_default"
3654if test "x$ac_cv_header_pthread_h" = xyes; then : 3694if test "x$ac_cv_header_pthread_h" = xyes; then :
3655 3695
@@ -4855,6 +4895,7 @@ echo " prefix: $prefix"
4855echo " sysconfdir: $sysconfdir" 4895echo " sysconfdir: $sysconfdir"
4856echo " seccomp: $HAVE_SECCOMP" 4896echo " seccomp: $HAVE_SECCOMP"
4857echo " <linux/seccomp.h>: $HAVE_SECCOMP_H" 4897echo " <linux/seccomp.h>: $HAVE_SECCOMP_H"
4898echo " apparmor: $HAVE_APPARMOR"
4858echo " global config: $HAVE_GLOBALCFG" 4899echo " global config: $HAVE_GLOBALCFG"
4859echo " chroot: $HAVE_CHROOT" 4900echo " chroot: $HAVE_CHROOT"
4860echo " bind: $HAVE_BIND" 4901echo " bind: $HAVE_BIND"
@@ -4866,6 +4907,7 @@ echo " file transfer support: $HAVE_FILE_TRANSFER"
4866echo " fatal warnings: $HAVE_FATAL_WARNINGS" 4907echo " fatal warnings: $HAVE_FATAL_WARNINGS"
4867printf " uid_min: "; grep UID_MIN uids.h 4908printf " uid_min: "; grep UID_MIN uids.h
4868printf " gid_min: "; grep GID_MIN uids.h 4909printf " gid_min: "; grep GID_MIN uids.h
4910printf " EXTRA_LDFLAGS: $EXTRA_LDFLAGS"
4869echo 4911echo
4870 4912
4871 4913
diff --git a/configure.ac b/configure.ac
index a84396ad4..315c25038 100644
--- a/configure.ac
+++ b/configure.ac
@@ -9,6 +9,27 @@ AC_PROG_CC
9AC_PROG_INSTALL 9AC_PROG_INSTALL
10AC_PROG_RANLIB 10AC_PROG_RANLIB
11 11
12# Allow to build without apparmor support by calling:
13# ./configure --disable-apparmor
14# This makes it possible to run snaps in devmode on almost any host,
15# regardless of the kernel version.
16HAVE_APPARMOR=""
17AC_ARG_ENABLE([apparmor],
18 AS_HELP_STRING([--enable-apparmor], [enable apparmor]))
19AS_IF([test "x$enable_apparmor" = "xyes"], [
20 HAVE_APPARMOR="-DHAVE_APPARMOR"
21 AC_SUBST(HAVE_APPARMOR)
22])
23
24AS_IF([test "x$enable_apparmor" = "xyes"], [
25 AC_CHECK_HEADER(sys/apparmor.h, , [AC_MSG_ERROR(
26 [Couldn't find sys/apparmor.h... please install apparmor user space library and development files] )])
27])
28AS_IF([test "x$enable_apparmor" = "xyes"], [
29 EXTRA_LDFLAGS="-lapparmor"
30])
31AC_SUBST([EXTRA_LDFLAGS])
32
12HAVE_SECCOMP="" 33HAVE_SECCOMP=""
13AC_ARG_ENABLE([seccomp], 34AC_ARG_ENABLE([seccomp],
14 AS_HELP_STRING([--disable-seccomp], [disable seccomp])) 35 AS_HELP_STRING([--disable-seccomp], [disable seccomp]))
@@ -117,6 +138,7 @@ echo " prefix: $prefix"
117echo " sysconfdir: $sysconfdir" 138echo " sysconfdir: $sysconfdir"
118echo " seccomp: $HAVE_SECCOMP" 139echo " seccomp: $HAVE_SECCOMP"
119echo " <linux/seccomp.h>: $HAVE_SECCOMP_H" 140echo " <linux/seccomp.h>: $HAVE_SECCOMP_H"
141echo " apparmor: $HAVE_APPARMOR"
120echo " global config: $HAVE_GLOBALCFG" 142echo " global config: $HAVE_GLOBALCFG"
121echo " chroot: $HAVE_CHROOT" 143echo " chroot: $HAVE_CHROOT"
122echo " bind: $HAVE_BIND" 144echo " bind: $HAVE_BIND"
@@ -128,6 +150,7 @@ echo " file transfer support: $HAVE_FILE_TRANSFER"
128echo " fatal warnings: $HAVE_FATAL_WARNINGS" 150echo " fatal warnings: $HAVE_FATAL_WARNINGS"
129printf " uid_min: "; grep UID_MIN uids.h 151printf " uid_min: "; grep UID_MIN uids.h
130printf " gid_min: "; grep GID_MIN uids.h 152printf " gid_min: "; grep GID_MIN uids.h
153printf " EXTRA_LDFLAGS: $EXTRA_LDFLAGS"
131echo 154echo
132 155
133 156
diff --git a/etc/firejail-default b/etc/firejail-default
new file mode 100644
index 000000000..609ab6c19
--- /dev/null
+++ b/etc/firejail-default
@@ -0,0 +1,129 @@
1#include <tunables/global>
2
3profile firejail-default {
4
5#####
6# D-Bus is a huge security hole, we disable it here. Uncomment this line if you
7# need D-Bus functionality.
8#
9#dbus,
10
11#####
12# Mask /proc and /sys information leakage. The configuration here is barely
13# enough to run "top" or "ps aux".
14#
15/ r,
16/[^proc,^sys]** mrwlk,
17
18/proc/ r,
19/proc/meminfo r,
20/proc/cpuinfo r,
21/proc/filesystems r,
22/proc/uptime r,
23/proc/loadavg r,
24/proc/stat r,
25/proc/@{pid}/ r,
26/proc/@{pid}/fd/ r,
27/proc/@{pid}/task/ r,
28/proc/@{pid}/cmdline r,
29/proc/@{pid}/comm r,
30/proc/@{pid}/stat r,
31/proc/@{pid}/statm r,
32/proc/@{pid}/status r,
33/proc/sys/kernel/pid_max r,
34/proc/sys/kernel/shmmax r,
35/sys/ r,
36/sys/bus/ r,
37/sys/bus/** r,
38/sys/class/ r,
39/sys/class/** r,
40/sys/devices/ r,
41/sys/devices/** r,
42
43/proc/@{pid}/maps r,
44/proc/@{pid}/mounts r,
45/proc/@{pid}/mountinfo r,
46/proc/@{pid}/oom_score_adj r,
47
48/{,var/}run/firejail/mnt/fslogger r,
49/{,var/}run/user/**/dconf/ r,
50/{,var/}run/user/**/dconf/user r,
51
52#####
53# Allow running programs only from well-known system directories. If you need
54# to run programs from your home directory, uncomment /home line.
55#
56/lib/** ix,
57/lib64/** ix,
58/bin/** ix,
59/sbin/** ix,
60/usr/bin/** ix,
61/usr/sbin/** ix,
62/usr/local/** ix,
63/usr/lib/** ix,
64/usr/games/** ix,
65/opt/** ix,
66#/home/** ix,
67
68#####
69# Allow all networking functionality, and control it from Firejail.
70#
71network inet,
72network inet6,
73network unix,
74network netlink,
75network raw,
76
77#####
78# There is no equivalent in Firejail for filtering signals.
79#
80signal,
81
82#####
83# Disable all capabilities. If you run your sandbox as root, you might need to
84# enable/uncomment some of them.
85#
86capability chown,
87capability dac_override,
88capability dac_read_search,
89capability fowner,
90capability fsetid,
91capability kill,
92capability setgid,
93capability setuid,
94capability setpcap,
95capability linux_immutable,
96capability net_bind_service,
97capability net_broadcast,
98capability net_admin,
99capability net_raw,
100capability ipc_lock,
101capability ipc_owner,
102capability sys_module,
103capability sys_rawio,
104capability sys_chroot,
105capability sys_ptrace,
106capability sys_pacct,
107capability sys_admin,
108capability sys_boot,
109capability sys_nice,
110capability sys_resource,
111capability sys_time,
112capability sys_tty_config,
113capability mknod,
114capability lease,
115capability audit_write,
116capability audit_control,
117capability setfcap,
118capability mac_override,
119capability mac_admin,
120
121#####
122# No mount/umount functionality when running as regular user.
123#
124mount,
125remount,
126umount,
127pivot_root,
128
129}
diff --git a/src/firejail/Makefile.in b/src/firejail/Makefile.in
index 21f415ba5..15253b5ab 100644
--- a/src/firejail/Makefile.in
+++ b/src/firejail/Makefile.in
@@ -18,19 +18,21 @@ HAVE_X11=@HAVE_X11@
18HAVE_FILE_TRANSFER=@HAVE_FILE_TRANSFER@ 18HAVE_FILE_TRANSFER=@HAVE_FILE_TRANSFER@
19HAVE_WHITELIST=@HAVE_WHITELIST@ 19HAVE_WHITELIST=@HAVE_WHITELIST@
20HAVE_GLOBALCFG=@HAVE_GLOBALCFG@ 20HAVE_GLOBALCFG=@HAVE_GLOBALCFG@
21HAVE_APPARMOR=@HAVE_APPARMOR@
22EXTRA_LDFLAGS +=@EXTRA_LDFLAGS@
21 23
22H_FILE_LIST = $(sort $(wildcard *.[h])) 24H_FILE_LIST = $(sort $(wildcard *.[h]))
23C_FILE_LIST = $(sort $(wildcard *.c)) 25C_FILE_LIST = $(sort $(wildcard *.c))
24OBJS = $(C_FILE_LIST:.c=.o) 26OBJS = $(C_FILE_LIST:.c=.o)
25BINOBJS = $(foreach file, $(OBJS), $file) 27BINOBJS = $(foreach file, $(OBJS), $file)
26CFLAGS += -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' -DPREFIX='"$(prefix)"' -DSYSCONFDIR='"$(sysconfdir)/firejail"' -DLIBDIR='"$(libdir)"' $(HAVE_X11) $(HAVE_SECCOMP) $(HAVE_GLOBALCFG) $(HAVE_SECCOMP_H) $(HAVE_CHROOT) $(HAVE_NETWORK) $(HAVE_USERNS) $(HAVE_BIND) $(HAVE_FILE_TRANSFER) $(HAVE_WHITELIST) -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIE -pie -Wformat -Wformat-security 28CFLAGS += -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' -DPREFIX='"$(prefix)"' -DSYSCONFDIR='"$(sysconfdir)/firejail"' -DLIBDIR='"$(libdir)"' $(HAVE_X11) $(HAVE_APPARMOR) $(HAVE_SECCOMP) $(HAVE_GLOBALCFG) $(HAVE_SECCOMP_H) $(HAVE_CHROOT) $(HAVE_NETWORK) $(HAVE_USERNS) $(HAVE_BIND) $(HAVE_FILE_TRANSFER) $(HAVE_WHITELIST) -fstack-protector-all -D_FORTIFY_SOURCE=2 -fPIE -pie -Wformat -Wformat-security
27LDFLAGS += -pie -Wl,-z,relro -Wl,-z,now -lpthread 29LDFLAGS += -pie -Wl,-z,relro -Wl,-z,now -lpthread
28 30
29%.o : %.c $(H_FILE_LIST) ../include/common.h ../include/euid_common.h ../include/libnetlink.h ../include/pid.h 31%.o : %.c $(H_FILE_LIST) ../include/common.h ../include/euid_common.h ../include/libnetlink.h ../include/pid.h
30 $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ 32 $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@
31 33
32firejail: $(OBJS) ../lib/libnetlink.o ../lib/common.o 34firejail: $(OBJS) ../lib/libnetlink.o ../lib/common.o
33 $(CC) $(LDFLAGS) -o $@ $(OBJS) ../lib/libnetlink.o ../lib/common.o $(LIBS) 35 $(CC) $(LDFLAGS) -o $@ $(OBJS) ../lib/libnetlink.o ../lib/common.o $(LIBS) $(EXTRA_LDFLAGS)
34 36
35clean:; rm -f *.o firejail firejail.1 firejail.1.gz 37clean:; rm -f *.o firejail firejail.1 firejail.1.gz
36 38
diff --git a/src/firejail/sandbox.c b/src/firejail/sandbox.c
index 0fd81979f..1502a0312 100644
--- a/src/firejail/sandbox.c
+++ b/src/firejail/sandbox.c
@@ -39,6 +39,9 @@
39# define PR_SET_NO_NEW_PRIVS 38 39# define PR_SET_NO_NEW_PRIVS 38
40#endif 40#endif
41 41
42#ifdef HAVE_APPARMOR
43#include <sys/apparmor.h>
44#endif
42 45
43 46
44static int monitored_pid = 0; 47static int monitored_pid = 0;
@@ -392,6 +395,7 @@ int sandbox(void* sandbox_arg) {
392 if (arg_debug && child_pid == 1) 395 if (arg_debug && child_pid == 1)
393 printf("PID namespace installed\n"); 396 printf("PID namespace installed\n");
394 397
398
395 //**************************** 399 //****************************
396 // set hostname 400 // set hostname
397 //**************************** 401 //****************************
@@ -503,7 +507,6 @@ int sandbox(void* sandbox_arg) {
503 else 507 else
504 fs_basic_fs(); 508 fs_basic_fs();
505 509
506
507 //**************************** 510 //****************************
508 // set hostname in /etc/hostname 511 // set hostname in /etc/hostname
509 //**************************** 512 //****************************
@@ -798,8 +801,13 @@ int sandbox(void* sandbox_arg) {
798 pid_t app_pid = fork(); 801 pid_t app_pid = fork();
799 if (app_pid == -1) 802 if (app_pid == -1)
800 errExit("fork"); 803 errExit("fork");
801 804
802 if (app_pid == 0) { 805 if (app_pid == 0) {
806#ifdef HAVE_APPARMOR
807 errno = 0;
808 if (aa_change_onexec("firejail-default"))
809 fprintf(stderr, "Warning: apparmor profile not loaded, errno %d\n", errno);
810#endif
803 prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); // kill the child in case the parent died 811 prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); // kill the child in case the parent died
804 start_application(); // start app 812 start_application(); // start app
805 } 813 }
diff --git a/todo b/todo
index 009f9fe99..7a96bb2c4 100644
--- a/todo
+++ b/todo
@@ -251,6 +251,7 @@ References
25123. AppArmor 25123. AppArmor
252 252
253$ sudo apt-get install apparmor apparmor-profiles apparmor-utils apparmor-notify 253$ sudo apt-get install apparmor apparmor-profiles apparmor-utils apparmor-notify
254$ sudo apt-get install libapparmor-dev
254 255
255$ sudo perl -pi -e 's,GRUB_CMDLINE_LINUX="(.*)"$,GRUB_CMDLINE_LINUX="$1 apparmor=1 security=apparmor",' /etc/default/grub 256$ sudo perl -pi -e 's,GRUB_CMDLINE_LINUX="(.*)"$,GRUB_CMDLINE_LINUX="$1 apparmor=1 security=apparmor",' /etc/default/grub
256$ sudo update-grub 257$ sudo update-grub
@@ -259,5 +260,7 @@ $ sudo reboot
259If you are using auditd, start aa-notify to get notification whenever a program causes a DENIED message. 260If you are using auditd, start aa-notify to get notification whenever a program causes a DENIED message.
260$ sudo aa-notify -p -f /var/log/audit/audit.log 261$ sudo aa-notify -p -f /var/log/audit/audit.log
261 262
263/sys/module/apparmor/parameters/enabled
264/sys/kernel/security/apparmor
262 265
263 266