[GH-ISSUE #1908] Error installing and running services in sudo firejail no profile overlay #1281

Closed
opened 2026-05-05 07:46:56 -06:00 by gitea-mirror · 6 comments
Owner

Originally created by @oxwivi on GitHub (Apr 24, 2018).
Original GitHub issue: https://github.com/netblue30/firejail/issues/1908

apt seems to be able to run and install packages, but service units provided by the installed packages seems to be missing:

$ sudo firejail --overlay-tmpfs --noprofile 
Parent pid 14361, child pid 14362
The new log directory is /proc/14362/root/var/log
OverlayFS configured in /run/firejail/mnt directory
Warning: failed to unmount /sys
Child process initialized in 17.48 ms
# apt install ntp postfix
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libopts25
Suggested packages:
  ntp-doc procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre
  sasl2-bin dovecot-common postfix-cdb postfix-doc
The following NEW packages will be installed:
  libopts25 ntp postfix
0 upgraded, 3 newly installed, 0 to remove and 11 not upgraded.
Need to get 1,728 kB of archives.
After this operation, 5,489 kB of additional disk space will be used.
Do you want to continue? [Y/n] 
Get:1 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libopts25 amd64 1:5.18.7-3 [57.8 kB]
Get:2 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 ntp amd64 1:4.2.8p4+dfsg-3ubuntu5.8 [518 kB]
Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 postfix amd64 3.1.0-3ubuntu0.3 [1,152 kB]
Fetched 1,728 kB in 2s (667 kB/s)
Preconfiguring packages ...
Selecting previously unselected package libopts25:amd64.
(Reading database ... 213287 files and directories currently installed.)
Preparing to unpack .../libopts25_1%3a5.18.7-3_amd64.deb ...
Unpacking libopts25:amd64 (1:5.18.7-3) ...
Selecting previously unselected package ntp.
Preparing to unpack .../ntp_1%3a4.2.8p4+dfsg-3ubuntu5.8_amd64.deb ...
Unpacking ntp (1:4.2.8p4+dfsg-3ubuntu5.8) ...
Selecting previously unselected package postfix.
Preparing to unpack .../postfix_3.1.0-3ubuntu0.3_amd64.deb ...
Unpacking postfix (3.1.0-3ubuntu0.3) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for systemd (229-4ubuntu21.2) ...
Processing triggers for ureadahead (0.100.0-19) ...
ureadahead will be reprofiled on next reboot
Processing triggers for man-db (2.7.5-1) ...
Processing triggers for ufw (0.35-0ubuntu2) ...
Setting up libopts25:amd64 (1:5.18.7-3) ...
Setting up ntp (1:4.2.8p4+dfsg-3ubuntu5.8) ...
Failed to start ntp.service: Unit ntp.service not found.
invoke-rc.d: initscript ntp, action "start" failed.
● ntp.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)
dpkg: error processing package ntp (--configure):
 subprocess installed post-installation script returned error exit status 5
Setting up postfix (3.1.0-3ubuntu0.3) ...
Adding group `postfix' (GID 131) ...
Done.
Adding system user `postfix' (UID 122) ...
Adding new user `postfix' (UID 122) with group `postfix' ...
Not creating home directory `/var/spool/postfix'.
Creating /etc/postfix/dynamicmaps.cf
Adding group `postdrop' (GID 132) ...
Done.
setting myhostname: 6720s
setting alias maps
setting alias database
mailname is not a fully qualified domain name.  Not changing /etc/mailname.
setting destinations: $myhostname, 6720s, localhost.localdomain, , localhost
setting relayhost: 
setting mynetworks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
setting mailbox_size_limit: 0
setting recipient_delimiter: +
setting inet_interfaces: all
setting inet_protocols: all
/etc/aliases does not exist, creating it.
WARNING: /etc/aliases exists, but does not have a root alias.

Postfix is now set up with a default configuration.  If you need to make 
changes, edit
/etc/postfix/main.cf (and others) as needed.  To view Postfix configuration
values, see postconf(1).

After modifying main.cf, be sure to run '/etc/init.d/postfix reload'.

Running newaliases
Failed to restart postfix.service: Unit postfix.service not found.
invoke-rc.d: initscript postfix, action "restart" failed.
● postfix.service
   Loaded: not-found (Reason: No such file or directory)
   Active: inactive (dead)
dpkg: error processing package postfix (--configure):
 subprocess installed post-installation script returned error exit status 5
Processing triggers for libc-bin (2.23-0ubuntu10) ...
Processing triggers for systemd (229-4ubuntu21.2) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for ufw (0.35-0ubuntu2) ...
Errors were encountered while processing:
 ntp
 postfix
E: Sub-process /usr/bin/dpkg returned an error code (1)

Same error with all three overlay. overlay-tmpfs and --overlay-named=name.

$ firejail --version 
firejail version 0.9.53

Compile time support:
	- AppArmor support is disabled
	- AppImage support is enabled
	- bind support is enabled
	- chroot support is enabled
	- file and directory whitelisting support is enabled
	- file transfer support is enabled
	- networking support is enabled
	- overlayfs support is enabled
	- private-home support is enabled
	- seccomp-bpf support is enabled
	- user namespace support is enabled
	- X11 sandboxing support is enabled
Originally created by @oxwivi on GitHub (Apr 24, 2018). Original GitHub issue: https://github.com/netblue30/firejail/issues/1908 `apt` seems to be able to run and install packages, but service units provided by the installed packages seems to be missing: ``` $ sudo firejail --overlay-tmpfs --noprofile Parent pid 14361, child pid 14362 The new log directory is /proc/14362/root/var/log OverlayFS configured in /run/firejail/mnt directory Warning: failed to unmount /sys Child process initialized in 17.48 ms # apt install ntp postfix Reading package lists... Done Building dependency tree Reading state information... Done The following additional packages will be installed: libopts25 Suggested packages: ntp-doc procmail postfix-mysql postfix-pgsql postfix-ldap postfix-pcre sasl2-bin dovecot-common postfix-cdb postfix-doc The following NEW packages will be installed: libopts25 ntp postfix 0 upgraded, 3 newly installed, 0 to remove and 11 not upgraded. Need to get 1,728 kB of archives. After this operation, 5,489 kB of additional disk space will be used. Do you want to continue? [Y/n] Get:1 http://us.archive.ubuntu.com/ubuntu xenial/main amd64 libopts25 amd64 1:5.18.7-3 [57.8 kB] Get:2 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 ntp amd64 1:4.2.8p4+dfsg-3ubuntu5.8 [518 kB] Get:3 http://us.archive.ubuntu.com/ubuntu xenial-updates/main amd64 postfix amd64 3.1.0-3ubuntu0.3 [1,152 kB] Fetched 1,728 kB in 2s (667 kB/s) Preconfiguring packages ... Selecting previously unselected package libopts25:amd64. (Reading database ... 213287 files and directories currently installed.) Preparing to unpack .../libopts25_1%3a5.18.7-3_amd64.deb ... Unpacking libopts25:amd64 (1:5.18.7-3) ... Selecting previously unselected package ntp. Preparing to unpack .../ntp_1%3a4.2.8p4+dfsg-3ubuntu5.8_amd64.deb ... Unpacking ntp (1:4.2.8p4+dfsg-3ubuntu5.8) ... Selecting previously unselected package postfix. Preparing to unpack .../postfix_3.1.0-3ubuntu0.3_amd64.deb ... Unpacking postfix (3.1.0-3ubuntu0.3) ... Processing triggers for libc-bin (2.23-0ubuntu10) ... Processing triggers for systemd (229-4ubuntu21.2) ... Processing triggers for ureadahead (0.100.0-19) ... ureadahead will be reprofiled on next reboot Processing triggers for man-db (2.7.5-1) ... Processing triggers for ufw (0.35-0ubuntu2) ... Setting up libopts25:amd64 (1:5.18.7-3) ... Setting up ntp (1:4.2.8p4+dfsg-3ubuntu5.8) ... Failed to start ntp.service: Unit ntp.service not found. invoke-rc.d: initscript ntp, action "start" failed. ● ntp.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead) dpkg: error processing package ntp (--configure): subprocess installed post-installation script returned error exit status 5 Setting up postfix (3.1.0-3ubuntu0.3) ... Adding group `postfix' (GID 131) ... Done. Adding system user `postfix' (UID 122) ... Adding new user `postfix' (UID 122) with group `postfix' ... Not creating home directory `/var/spool/postfix'. Creating /etc/postfix/dynamicmaps.cf Adding group `postdrop' (GID 132) ... Done. setting myhostname: 6720s setting alias maps setting alias database mailname is not a fully qualified domain name. Not changing /etc/mailname. setting destinations: $myhostname, 6720s, localhost.localdomain, , localhost setting relayhost: setting mynetworks: 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 setting mailbox_size_limit: 0 setting recipient_delimiter: + setting inet_interfaces: all setting inet_protocols: all /etc/aliases does not exist, creating it. WARNING: /etc/aliases exists, but does not have a root alias. Postfix is now set up with a default configuration. If you need to make changes, edit /etc/postfix/main.cf (and others) as needed. To view Postfix configuration values, see postconf(1). After modifying main.cf, be sure to run '/etc/init.d/postfix reload'. Running newaliases Failed to restart postfix.service: Unit postfix.service not found. invoke-rc.d: initscript postfix, action "restart" failed. ● postfix.service Loaded: not-found (Reason: No such file or directory) Active: inactive (dead) dpkg: error processing package postfix (--configure): subprocess installed post-installation script returned error exit status 5 Processing triggers for libc-bin (2.23-0ubuntu10) ... Processing triggers for systemd (229-4ubuntu21.2) ... Processing triggers for ureadahead (0.100.0-19) ... Processing triggers for ufw (0.35-0ubuntu2) ... Errors were encountered while processing: ntp postfix E: Sub-process /usr/bin/dpkg returned an error code (1) ``` Same error with all three `overlay`. `overlay-tmpfs` and `--overlay-named=name`. ``` $ firejail --version firejail version 0.9.53 Compile time support: - AppArmor support is disabled - AppImage support is enabled - bind support is enabled - chroot support is enabled - file and directory whitelisting support is enabled - file transfer support is enabled - networking support is enabled - overlayfs support is enabled - private-home support is enabled - seccomp-bpf support is enabled - user namespace support is enabled - X11 sandboxing support is enabled ```
gitea-mirror 2026-05-05 07:46:56 -06:00
Author
Owner

@netblue30 commented on GitHub (Apr 24, 2018):

Your command will work fine for regular user programs. For example, I install blockout2 (Tetrix clone) and run it as a regular user:

$ sudo firejail --overlay-tmpfs --noprofile
# apt install blockout2
[...]
# su netblue
$ blockout2
[...]

Watch what happens if you try to install some server program (lighttpd - simple http server):

$ sudo firejail --overlay-tmpfs --noprofile
#  apt install lighttpd
[...]
Unpacking lighttpd (1.4.45-1) ...
Selecting previously unselected package spawn-fcgi.
Preparing to unpack .../spawn-fcgi_1.6.4-1+b1_amd64.deb ...
Unpacking spawn-fcgi (1.6.4-1+b1) ...
Setting up spawn-fcgi (1.6.4-1+b1) ...
Setting up lighttpd (1.4.45-1) ...
Failed to preset unit: File lighttpd.service: No such file or directory
/usr/bin/deb-systemd-helper: error: systemctl preset failed on lighttpd.service: No such file or directory
Failed to start lighttpd.service: Unit lighttpd.service not found.
invoke-rc.d: initscript lighttpd, action "start" failed.
Unit lighttpd.service could not be found.

This is systemd failing to start the service. Systemd runs in a different filesystem namespace and it won't find your new server. In such cases you will have to start your service manually from the command line, bypassing anything related to systemd or the regular UNIX init in /etc/init.d directory.

Other problems you could run into are related to seccomp. seccomp is enabled by default in overlay setups, and it will kill your process if debian install tries to load new kernel modules or to mount/unmount files in the filesystem.

<!-- gh-comment-id:383924855 --> @netblue30 commented on GitHub (Apr 24, 2018): Your command will work fine for regular user programs. For example, I install blockout2 (Tetrix clone) and run it as a regular user: ````` $ sudo firejail --overlay-tmpfs --noprofile # apt install blockout2 [...] # su netblue $ blockout2 [...] ````` Watch what happens if you try to install some server program (lighttpd - simple http server): ````` $ sudo firejail --overlay-tmpfs --noprofile # apt install lighttpd [...] Unpacking lighttpd (1.4.45-1) ... Selecting previously unselected package spawn-fcgi. Preparing to unpack .../spawn-fcgi_1.6.4-1+b1_amd64.deb ... Unpacking spawn-fcgi (1.6.4-1+b1) ... Setting up spawn-fcgi (1.6.4-1+b1) ... Setting up lighttpd (1.4.45-1) ... Failed to preset unit: File lighttpd.service: No such file or directory /usr/bin/deb-systemd-helper: error: systemctl preset failed on lighttpd.service: No such file or directory Failed to start lighttpd.service: Unit lighttpd.service not found. invoke-rc.d: initscript lighttpd, action "start" failed. Unit lighttpd.service could not be found. ````` This is systemd failing to start the service. Systemd runs in a different filesystem namespace and it won't find your new server. In such cases you will have to start your service manually from the command line, bypassing anything related to systemd or the regular UNIX init in /etc/init.d directory. Other problems you could run into are related to seccomp. seccomp is enabled by default in overlay setups, and it will kill your process if debian install tries to load new kernel modules or to mount/unmount files in the filesystem.
Author
Owner

@oxwivi commented on GitHub (Apr 24, 2018):

Is there any workaround to allow systemd manage services in firejail namespace? Security is not a concern here, I want to use firejail like a container to isolate the filesystem and services in the sandbox so I can easily get rid of it and restart if need be.

I'd use a container if I could use the operating system's root directory as the base, but none of the container tech I know of allows me to.

<!-- gh-comment-id:383940462 --> @oxwivi commented on GitHub (Apr 24, 2018): Is there any workaround to allow `systemd` manage services in `firejail` namespace? Security is not a concern here, I want to use `firejail` like a container to isolate the filesystem and services in the sandbox so I can easily get rid of it and restart if need be. I'd use a container if I could use the operating system's root directory as the base, but none of the container tech I know of allows me to.
Author
Owner

@netblue30 commented on GitHub (May 2, 2018):

There could be a workaround, since systemd seems to be integrated with containers such as Docker, but I've never tried it.

<!-- gh-comment-id:386004254 --> @netblue30 commented on GitHub (May 2, 2018): There could be a workaround, since systemd seems to be integrated with containers such as Docker, but I've never tried it.
Author
Owner

@chiraag-nataraj commented on GitHub (Jul 25, 2018):

Here's some info regarding how systemd interfaces with containers: https://www.freedesktop.org/wiki/Software/systemd/ContainerInterface/

<!-- gh-comment-id:407925945 --> @chiraag-nataraj commented on GitHub (Jul 25, 2018): Here's some info regarding how systemd interfaces with containers: https://www.freedesktop.org/wiki/Software/systemd/ContainerInterface/
Author
Owner

@chiraag-nataraj commented on GitHub (May 21, 2019):

@oxwivi, has this been resolved?

<!-- gh-comment-id:494403043 --> @chiraag-nataraj commented on GitHub (May 21, 2019): @oxwivi, has this been resolved?
Author
Owner

@rusty-snake commented on GitHub (Jun 26, 2019):

@oxwivi
I'm closing here due to inactivity, please fell free to reopen if you have more questions.

<!-- gh-comment-id:505819585 --> @rusty-snake commented on GitHub (Jun 26, 2019): @oxwivi I'm closing here due to inactivity, please fell free to reopen if you have more questions.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/firejail#1281
No description provided.