]> git.ipfire.org Git - pakfire.git/log
pakfire.git
3 years agoexecute: Drop old environment
Michael Tremer [Wed, 3 Aug 2022 15:32:53 +0000 (15:32 +0000)] 
execute: Drop old environment

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Unify the wait logic for processes and use pidfd
Michael Tremer [Wed, 3 Aug 2022 15:21:49 +0000 (15:21 +0000)] 
jail: Unify the wait logic for processes and use pidfd

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agopython: Rework Pakfire.execute() using jail
Michael Tremer [Wed, 3 Aug 2022 14:22:43 +0000 (14:22 +0000)] 
python: Rework Pakfire.execute() using jail

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Export in libpakfire
Michael Tremer [Wed, 3 Aug 2022 10:27:47 +0000 (10:27 +0000)] 
jail: Export in libpakfire

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Move pakfire_execute_shell/ldconfig
Michael Tremer [Wed, 3 Aug 2022 10:22:27 +0000 (10:22 +0000)] 
jail: Move pakfire_execute_shell/ldconfig

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Add option to collect stdout
Michael Tremer [Wed, 3 Aug 2022 10:17:37 +0000 (10:17 +0000)] 
jail: Add option to collect stdout

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Drop unused pakfire_execute_script function
Michael Tremer [Wed, 3 Aug 2022 09:35:41 +0000 (09:35 +0000)] 
execute: Drop unused pakfire_execute_script function

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agobuild: Replace pakfire_execute_script with new jail functions
Michael Tremer [Wed, 3 Aug 2022 09:32:17 +0000 (09:32 +0000)] 
build: Replace pakfire_execute_script with new jail functions

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoscriptlets: Use new jail functions to run scripts
Michael Tremer [Wed, 3 Aug 2022 09:27:13 +0000 (09:27 +0000)] 
scriptlets: Use new jail functions to run scripts

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Add convenience function to run scripts
Michael Tremer [Wed, 3 Aug 2022 09:26:56 +0000 (09:26 +0000)] 
jail: Add convenience function to run scripts

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Configure UID/GID mapping correctly for root
Michael Tremer [Wed, 3 Aug 2022 09:08:07 +0000 (09:08 +0000)] 
jail: Configure UID/GID mapping correctly for root

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Create fds for logging as non-blocking straight away
Michael Tremer [Wed, 3 Aug 2022 09:01:38 +0000 (09:01 +0000)] 
jail: Create fds for logging as non-blocking straight away

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Use struct in execution context
Michael Tremer [Wed, 3 Aug 2022 08:59:35 +0000 (08:59 +0000)] 
jail: Use struct in execution context

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Move completed_fd into ctx
Michael Tremer [Wed, 3 Aug 2022 08:47:17 +0000 (08:47 +0000)] 
jail: Move completed_fd into ctx

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agobuild: Use factory function to create jail
Michael Tremer [Wed, 3 Aug 2022 08:44:05 +0000 (08:44 +0000)] 
build: Use factory function to create jail

This jail can be configured and customised for the build process.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Replace old code with new jail
Michael Tremer [Wed, 3 Aug 2022 08:42:18 +0000 (08:42 +0000)] 
execute: Replace old code with new jail

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agobuild: Drop separate logging callback
Michael Tremer [Tue, 2 Aug 2022 18:26:51 +0000 (18:26 +0000)] 
build: Drop separate logging callback

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Drop unused pakfire_execute_command function
Michael Tremer [Tue, 2 Aug 2022 18:12:32 +0000 (18:12 +0000)] 
execute: Drop unused pakfire_execute_command function

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Use pakfire_jail_run() to call ldconfig
Michael Tremer [Tue, 2 Aug 2022 18:09:46 +0000 (18:09 +0000)] 
execute: Use pakfire_jail_run() to call ldconfig

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Use convenience function to run shell
Michael Tremer [Tue, 2 Aug 2022 18:09:27 +0000 (18:09 +0000)] 
execute: Use convenience function to run shell

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Add convenience function to run simple commands
Michael Tremer [Tue, 2 Aug 2022 18:07:12 +0000 (18:07 +0000)] 
jail: Add convenience function to run simple commands

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Use new jail to run shell
Michael Tremer [Tue, 2 Aug 2022 17:58:25 +0000 (17:58 +0000)] 
execute: Use new jail to run shell

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Add interface to simply execute scripts
Michael Tremer [Tue, 2 Aug 2022 17:48:45 +0000 (17:48 +0000)] 
jail: Add interface to simply execute scripts

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Add function to import environment
Michael Tremer [Tue, 2 Aug 2022 17:40:22 +0000 (17:40 +0000)] 
jail: Add function to import environment

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Set default logging callback
Michael Tremer [Tue, 2 Aug 2022 17:32:44 +0000 (17:32 +0000)] 
jail: Set default logging callback

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Implement changing logging callback
Michael Tremer [Tue, 2 Aug 2022 17:30:07 +0000 (17:30 +0000)] 
jail: Implement changing logging callback

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Import logging stuff from execute.c
Michael Tremer [Tue, 2 Aug 2022 17:27:28 +0000 (17:27 +0000)] 
jail: Import logging stuff from execute.c

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Fix signal handling
Michael Tremer [Tue, 2 Aug 2022 16:37:41 +0000 (16:37 +0000)] 
jail: Fix signal handling

We need to stricly send uint64_t.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agomount: Add /dev/shm
Michael Tremer [Tue, 2 Aug 2022 16:23:40 +0000 (16:23 +0000)] 
mount: Add /dev/shm

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agomount: Bring back /tmp to jail
Michael Tremer [Tue, 2 Aug 2022 16:21:52 +0000 (16:21 +0000)] 
mount: Bring back /tmp to jail

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agomount: Mount a new instance of /dev/pts
Michael Tremer [Tue, 2 Aug 2022 16:09:25 +0000 (16:09 +0000)] 
mount: Mount a new instance of /dev/pts

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agomount: Make /dev/mqueue available in jail
Michael Tremer [Tue, 2 Aug 2022 16:03:57 +0000 (16:03 +0000)] 
mount: Make /dev/mqueue available in jail

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agomount: Fix mounting any file systems from the host system
Michael Tremer [Tue, 2 Aug 2022 16:01:40 +0000 (16:01 +0000)] 
mount: Fix mounting any file systems from the host system

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Try bind-mounting device nodes when we cannot use mknod()
Michael Tremer [Tue, 2 Aug 2022 15:30:28 +0000 (15:30 +0000)] 
jail: Try bind-mounting device nodes when we cannot use mknod()

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Apply syscall filter
Michael Tremer [Tue, 2 Aug 2022 14:47:34 +0000 (14:47 +0000)] 
jail: Apply syscall filter

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Execute command
Michael Tremer [Tue, 2 Aug 2022 14:44:38 +0000 (14:44 +0000)] 
jail: Execute command

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Drop capabilities
Michael Tremer [Tue, 2 Aug 2022 14:40:09 +0000 (14:40 +0000)] 
jail: Drop capabilities

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Set open file limit
Michael Tremer [Tue, 2 Aug 2022 14:36:22 +0000 (14:36 +0000)] 
jail: Set open file limit

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Set personality
Michael Tremer [Tue, 2 Aug 2022 14:35:12 +0000 (14:35 +0000)] 
jail: Set personality

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Mount all default filesystems
Michael Tremer [Tue, 2 Aug 2022 14:17:34 +0000 (14:17 +0000)] 
jail: Mount all default filesystems

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Fix setting UID/GID in namespace
Michael Tremer [Tue, 2 Aug 2022 14:11:08 +0000 (14:11 +0000)] 
jail: Fix setting UID/GID in namespace

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Make the client process wait until the parent has finished initialization
Michael Tremer [Tue, 2 Aug 2022 11:07:47 +0000 (11:07 +0000)] 
jail: Make the client process wait until the parent has finished initialization

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Perform UID/GID setup for new namespace
Michael Tremer [Tue, 2 Aug 2022 10:50:41 +0000 (10:50 +0000)] 
jail: Perform UID/GID setup for new namespace

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Implement first steps of running a command in jail
Michael Tremer [Tue, 2 Aug 2022 10:35:30 +0000 (10:35 +0000)] 
jail: Implement first steps of running a command in jail

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoMakefile: Define TEST_STUB_ROOT in testsuite
Michael Tremer [Tue, 2 Aug 2022 10:29:49 +0000 (10:29 +0000)] 
Makefile: Define TEST_STUB_ROOT in testsuite

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Introduce interactive jails
Michael Tremer [Tue, 2 Aug 2022 09:11:39 +0000 (09:11 +0000)] 
jail: Introduce interactive jails

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Add flags
Michael Tremer [Tue, 2 Aug 2022 09:02:54 +0000 (09:02 +0000)] 
jail: Add flags

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Add prototype for execution function
Michael Tremer [Tue, 2 Aug 2022 08:59:53 +0000 (08:59 +0000)] 
jail: Add prototype for execution function

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Set some default environment variables
Michael Tremer [Tue, 2 Aug 2022 08:55:09 +0000 (08:55 +0000)] 
jail: Set some default environment variables

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Implement setting environment variables
Michael Tremer [Tue, 2 Aug 2022 08:50:48 +0000 (08:50 +0000)] 
jail: Implement setting environment variables

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Log when jails are created/destroyed
Michael Tremer [Tue, 2 Aug 2022 08:23:21 +0000 (08:23 +0000)] 
jail: Log when jails are created/destroyed

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: Add a simple test for jails
Michael Tremer [Tue, 2 Aug 2022 08:13:22 +0000 (08:13 +0000)] 
tests: Add a simple test for jails

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agojail: Add basic type
Michael Tremer [Tue, 2 Aug 2022 08:01:46 +0000 (08:01 +0000)] 
jail: Add basic type

The goal is to split execute.c into a more flexible API.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Split creation of namespaces into two steps
Michael Tremer [Tue, 2 Aug 2022 07:46:33 +0000 (07:46 +0000)] 
execute: Split creation of namespaces into two steps

This is needed to create a new user namespace first in which we can do
some first stage of initialization. Then, we will start a new process in
that new namespace which will finish initialization.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Add flags to the environment
Michael Tremer [Fri, 22 Jul 2022 09:11:04 +0000 (09:11 +0000)] 
execute: Add flags to the environment

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Drop creating a new cgroup in the parent process
Michael Tremer [Fri, 22 Jul 2022 09:09:44 +0000 (09:09 +0000)] 
execute: Drop creating a new cgroup in the parent process

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: execute: Check if the process has received PID 1
Michael Tremer [Fri, 22 Jul 2022 08:39:50 +0000 (08:39 +0000)] 
tests: execute: Check if the process has received PID 1

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: execute: Add test to catch exceptions in logger
Michael Tremer [Thu, 21 Jul 2022 10:40:38 +0000 (10:40 +0000)] 
tests: execute: Add test to catch exceptions in logger

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: command: Print PID
Michael Tremer [Thu, 21 Jul 2022 10:36:23 +0000 (10:36 +0000)] 
tests: command: Print PID

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: command: Build a fork bomb
Michael Tremer [Thu, 21 Jul 2022 10:34:20 +0000 (10:34 +0000)] 
tests: command: Build a fork bomb

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: execute: Check if logger returned the correct output
Michael Tremer [Thu, 21 Jul 2022 10:23:15 +0000 (10:23 +0000)] 
tests: execute: Check if logger returned the correct output

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: command: All option to exhaust all memory
Michael Tremer [Thu, 21 Jul 2022 10:12:59 +0000 (10:12 +0000)] 
tests: command: All option to exhaust all memory

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: execute: Generate some random output for tests
Michael Tremer [Thu, 21 Jul 2022 09:57:42 +0000 (09:57 +0000)] 
tests: execute: Generate some random output for tests

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: execute: Replace former dummy commands
Michael Tremer [Thu, 21 Jul 2022 08:32:02 +0000 (08:32 +0000)] 
tests: execute: Replace former dummy commands

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: execute: Add test to return environment variables
Michael Tremer [Thu, 21 Jul 2022 08:30:47 +0000 (08:30 +0000)] 
tests: execute: Add test to return environment variables

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: execute: Add a simple echo command that prints lines
Michael Tremer [Thu, 21 Jul 2022 08:25:53 +0000 (08:25 +0000)] 
tests: execute: Add a simple echo command that prints lines

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: execute: Replace exit code tests with the stub command
Michael Tremer [Thu, 21 Jul 2022 08:18:48 +0000 (08:18 +0000)] 
tests: execute: Replace exit code tests with the stub command

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: Run execute tests in the stub environment
Michael Tremer [Thu, 21 Jul 2022 08:18:21 +0000 (08:18 +0000)] 
tests: Run execute tests in the stub environment

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: Build scaffolding for a simple statically linked command
Michael Tremer [Tue, 19 Jul 2022 16:39:56 +0000 (16:39 +0000)] 
tests: Build scaffolding for a simple statically linked command

This can then be used to test the execution container.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agosnapshot: Show throughput and ETA in progress bar
Michael Tremer [Tue, 19 Jul 2022 16:27:59 +0000 (16:27 +0000)] 
snapshot: Show throughput and ETA in progress bar

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoutil: Drop any custom timespec functions
Michael Tremer [Tue, 19 Jul 2022 16:23:13 +0000 (16:23 +0000)] 
util: Drop any custom timespec functions

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoprogressbar: Make this a lot smoother
Michael Tremer [Tue, 19 Jul 2022 16:20:38 +0000 (16:20 +0000)] 
progressbar: Make this a lot smoother

Previously, the progress bar was redrawn very often which did not look
great on the terminal. We are now redrawing the bar about 20 times a
second which gives us a smooth experience.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years ago_pakfire: Adjust flag to enable/disable ccache
Michael Tremer [Tue, 19 Jul 2022 14:40:33 +0000 (14:40 +0000)] 
_pakfire: Adjust flag to enable/disable ccache

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years ago_pakfire: Adjust flag to enable/disable snapshot
Michael Tremer [Tue, 19 Jul 2022 14:39:23 +0000 (14:39 +0000)] 
_pakfire: Adjust flag to enable/disable snapshot

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: Remove unneeded stuff from snapshot.c
Michael Tremer [Tue, 19 Jul 2022 14:34:02 +0000 (14:34 +0000)] 
tests: Remove unneeded stuff from snapshot.c

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agosnapshot: Include pakfire.h
Michael Tremer [Tue, 19 Jul 2022 14:33:46 +0000 (14:33 +0000)] 
snapshot: Include pakfire.h

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: Check if snapshot has something in it
Michael Tremer [Tue, 19 Jul 2022 14:31:57 +0000 (14:31 +0000)] 
tests: Check if snapshot has something in it

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agomount: Don't return error in foreach when there are no mountpoints
Michael Tremer [Tue, 19 Jul 2022 14:29:32 +0000 (14:29 +0000)] 
mount: Don't return error in foreach when there are no mountpoints

The loop returned 1 by default when there were no mountpoints to process
which is not what we need here.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agosnapshots: Protect against invalid inputs
Michael Tremer [Tue, 19 Jul 2022 14:21:28 +0000 (14:21 +0000)] 
snapshots: Protect against invalid inputs

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agotests: Add a test that creates and restores a snapshot
Michael Tremer [Tue, 19 Jul 2022 14:11:53 +0000 (14:11 +0000)] 
tests: Add a test that creates and restores a snapshot

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoRevert "mount: Adjust mount flags for unprivileged users"
Michael Tremer [Tue, 19 Jul 2022 11:55:22 +0000 (11:55 +0000)] 
Revert "mount: Adjust mount flags for unprivileged users"

This reverts commit c92f710524a370d8e910b74d7ba062373d02d7a6.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agomount: Adjust mount flags for unprivileged users
Michael Tremer [Tue, 19 Jul 2022 09:38:40 +0000 (09:38 +0000)] 
mount: Adjust mount flags for unprivileged users

Bind-mounts require us to set MS_REC and remounting any mountpoint
requires us to now downgrade on noexec/nodev/nosuid.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agomount: Use mount(2) to perform any mount operations
Michael Tremer [Tue, 19 Jul 2022 09:37:30 +0000 (09:37 +0000)] 
mount: Use mount(2) to perform any mount operations

libmount did too much voodoo here which prevented us from running
smoothly for unprivileged users.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoarchive: Don't use path in error message
Michael Tremer [Mon, 18 Jul 2022 18:28:55 +0000 (18:28 +0000)] 
archive: Don't use path in error message

path seems to have been freed after the extraction has been started and
therefore we cannot use it any more.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agomount: Don't mount /tmp in container
Michael Tremer [Mon, 18 Jul 2022 17:31:16 +0000 (17:31 +0000)] 
mount: Don't mount /tmp in container

If /tmp is a ramdisk, any temporary files written during the build
process will be lost between stages. That is rather unintuitive and we
might use excess memory.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Copy scripts into /
Michael Tremer [Mon, 18 Jul 2022 17:30:16 +0000 (17:30 +0000)] 
execute: Copy scripts into /

Formerly they were created in /tmp which could be overlayed by a tmpfs.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agofile: Make the static analyzer happy
Michael Tremer [Mon, 18 Jul 2022 09:40:03 +0000 (09:40 +0000)] 
file: Make the static analyzer happy

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agopakfire: Move cache directory into user's home
Michael Tremer [Mon, 18 Jul 2022 09:24:54 +0000 (09:24 +0000)] 
pakfire: Move cache directory into user's home

This is only happening when running as an unprivileged user.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoutil: Fix permissions of temporary directories
Michael Tremer [Mon, 18 Jul 2022 09:24:24 +0000 (09:24 +0000)] 
util: Fix permissions of temporary directories

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoMove all temporary files directly into /var/tmp
Michael Tremer [Mon, 18 Jul 2022 08:52:12 +0000 (08:52 +0000)] 
Move all temporary files directly into /var/tmp

When running Pakfire as an unprivileged user, we cannot create temporary
files in a subdirectory which has been created earlier by a different
user.

Hence we now put everything directly into /var/tmp where everyone should
have write permissions all of the time.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoutil: Store errno when running pakfire_rmtree()
Michael Tremer [Mon, 18 Jul 2022 08:24:32 +0000 (08:24 +0000)] 
util: Store errno when running pakfire_rmtree()

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agopakfire: Store UID of running user
Michael Tremer [Mon, 18 Jul 2022 08:16:31 +0000 (08:16 +0000)] 
pakfire: Store UID of running user

This patch also moves the root permission check into the safety check
function.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoUse sane directory/file permissions throughout
Michael Tremer [Sun, 17 Jul 2022 18:56:46 +0000 (18:56 +0000)] 
Use sane directory/file permissions throughout

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Only try umounting after we actually mounted something
Michael Tremer [Sun, 17 Jul 2022 18:39:40 +0000 (18:39 +0000)] 
execute: Only try umounting after we actually mounted something

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Use existing function to check if we are running in /
Michael Tremer [Sun, 17 Jul 2022 18:38:35 +0000 (18:38 +0000)] 
execute: Use existing function to check if we are running in /

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agomount: Remove unused variable
Michael Tremer [Sun, 17 Jul 2022 18:38:17 +0000 (18:38 +0000)] 
mount: Remove unused variable

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agomount: Move pakfire_bind() into mount.c
Michael Tremer [Sun, 17 Jul 2022 18:34:09 +0000 (18:34 +0000)] 
mount: Move pakfire_bind() into mount.c

There are no functional changes, but this function rather belongs here,
and as a bonus, we get to make pakfire_mount() static and declutter
pakfire.c slightly.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agomount: Mount the interpreter every time
Michael Tremer [Sun, 17 Jul 2022 18:25:48 +0000 (18:25 +0000)] 
mount: Mount the interpreter every time

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Mount all file systems only in namespace
Michael Tremer [Sun, 17 Jul 2022 18:16:04 +0000 (18:16 +0000)] 
execute: Mount all file systems only in namespace

If Pakfire is running as an unprivileged user, we cannot call mount() in
the original namespace. However, it is difficult to spawn a new process
in a new namespace first and then perform loads of actions in there.
Embedded Pakfire would become more difficult.

At the cost of losing the option to create an environment in a
dynamically created ramdisk, we can only mount everything when we enter
the container.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
3 years agoexecute: Switch back to chroot()
Michael Tremer [Sun, 17 Jul 2022 18:09:29 +0000 (18:09 +0000)] 
execute: Switch back to chroot()

pivot_root() seems to be very complicated to use and will require us to
have the container run on a different file system. That is however not
possible when Pakfire is running as an un-privileged user.

Since pivot_root() does not seem to offer any advantages over chroot(),
we switch back to chroot() which is easier to use.

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>