42 Commits

Author SHA1 Message Date
tomFlowee c0f579ff6d add VPN feature
This allows a jail to have a VPN config associated and as a result we start
a new net namespace, completely isolating the jails networking.
We then start an openVPN client to route between the main network and the
jails' network.

The main limitation here is that we don't setup DNS, which basically means
that the VPN will route DNS calls to the other side, but since we don't
remount resolv.conf this depends on the vpn provider actually mapping the
nameserver we use. For people that use a nameserver like 192.168.100.1,
this most of the time works just fine.

Improvement is possible.
2026-04-11 15:06:44 +02:00
tomFlowee dae688f6d6 Allow various KDE apps to start in a jail.
This makes it possible to run apps that require dbus as a way to
avoid duplicates.
2026-04-11 15:05:19 +02:00
tomFlowee 8702fbe0cf Allow remount also in a dir where I have group rights
We now no longer deny 'writing' in a directory where the user
would be able to write due to her user-group matching what the
filesystem has.
2026-04-11 14:50:53 +02:00
tomFlowee 749e6c9323 use nullptr in c++ 2025-11-04 12:57:36 +01:00
tomFlowee b8bf5c7523 Fix various warnings. 2025-11-04 12:57:36 +01:00
tomFlowee 188e40df69 Remove not needed safety 'feature'.
This code now no longer makes tmpfs based mounts NOEXEC.

This was an optimization that didn't really add anything anyway
since those tmpfs would all be default be local to the jail anyway,
making any executable being placed there invisible to the rest
of the system. So what were we protecting?
2025-02-01 12:08:47 +01:00
tomFlowee 29694853bf Run cleanup thread to clean zombies
For apps that use shell we every now and then saw zombies appear as a
child of the jailer process. Presumably the shall re-parented those to
process 1, which is our jailer inside the jail.

This adds a forever loop to simply call wait() repeatedly which clears
the state (makes clear we don't care about their state, really) and thus
removes the zobie processes.
2024-09-06 19:21:11 +02:00
tomFlowee d046c171f6 New feature; add encrypt-at-rest
When a jail is encryted at rest using 'encfs' we detect that and ask for
a password upon starting the jail.

This sounded like a neat little idea which ended up taking nearly 4 days
to do...
EncFS needs to be running as root, as it is a FUSE system and it will
actually stop root from reading/writing files if it is running as a
user. It also is very picky about not running in a namespace, it manages
to hang indefinitely otherwise where a shutdown can't complete because
the process doesn't want to die :-)

So, it runs as root, takes the password via a pipe and we have a
watchdog proces to kill it when the jail is shut down.
2024-05-20 22:21:03 +02:00
tomFlowee 8888793de9 Fix list size calculation 2024-04-24 18:50:40 +02:00
tomFlowee 82a0f22d58 Add audio permission and copy kde session server
The audio permission allows hiding of pulse audio and pipewire sockets.

The kde session (ksmserver) socket and state files allowing some more
apps to run properly.
2024-02-26 10:49:40 +01:00
tomFlowee f7c9347c4c Process data sent from runner to listener
The pipe was always there, but we didn't really use it so far.
This now uses the pipe to send back the PID of the 'jailer' which we
store in a 'state' file.
2024-02-25 19:22:08 +01:00
tomFlowee b826503d86 Add init-script feature
When the profile has an init-script, we execute that with bash _before_
the actual executable is started.

This allows things like preparing the jail for a fresh run every time.

Notice that adding a second app in the same running jail skips the init
script.
2024-02-24 11:40:42 +01:00
tomFlowee eaedd64568 Re-view the process hierarchy
After introducing a new process that dispatches new processes _inside_
the jail, there is no point leaving the root owned 'runner' in memory.
So we move its functionality to the new mini-dispatcher (since renamed
to jailer) and remove it from the tree.
2024-02-21 14:25:15 +01:00
tomFlowee 4becd867af Allow sharing jails
When a request comes for a profile that already has someone running,
we now send a message to that jail and make them run the second
application in there directly.

The basis here is that it is impossible to recreate the 'jail' exactly
with things like tmpfs. So requests like "start a new firefox window in
the same process" need to actually run in the jail we created before.
So due to that I leave a process that I call 'mini-dispatch' which
itself lives inside of the jail, so it can trivially exec a new process
there.
2024-02-21 11:21:37 +01:00
tomFlowee e75359bcbe Rename the 'middle' process to dispatcher 2024-02-20 22:15:20 +01:00
tomFlowee 1df8778a60 Close pipes
The child runner isn't supposed to use the pipes its parent
owned, so simply close them and avoid everyone inheriting them.
2024-02-20 21:57:25 +01:00
tomFlowee 825dfb73bd Add dbus-proxy support
We re-route the dbus socket to a different location and then start
the dbus proxy in order to provide a filtered view of the world for our
jailed application.

DBus is a fantastic and a horrible system at the same time. It provides
only basic concepts and features which others can build on top of. Which
is great as many have done that building on top of it.
Unfortunately many apps have completely missed the idea of security and
hierarchy so its a mess now and you can't really open up most to apps...

Favourite stupid design, the org.freedesktop.Notifications has under
there the 'klipper' app. With an endpoint to destroy all its historical
data. Making 'just open the notifications, what could go wrong' end with
pain.
2024-02-20 19:14:25 +01:00
tomFlowee 317c491a15 fix argument passing to the final exe 2024-02-19 22:45:32 +01:00
tomFlowee 735abb7c1f Make a start with /run
this improves rbind to create the target dirs, if needed.
We also detect if the source is a socket and instead create a file to
mount on top of.
2024-02-19 12:22:45 +01:00
tomFlowee 11eee03993 Close channels.
If needed these might be nice to read and put into some database or log
file or something.
Might be. Maybe. It's not like I read the one from x EVER.
2024-02-17 22:09:38 +01:00
tomFlowee 2489e77a09 Fix copy command to be much more useful.
It can create directories now to copy into.
2024-02-17 21:53:28 +01:00
tomFlowee 846aa8f4a9 Add 'shared' and env vars
This moves the final mounts to the rules file and creates the default
setup where the app has the users homedir available under a 'shared'
subdir.

This also introduces environment variables support, filtering out all
easy targets and additionally setting the config / data dirs to not be
hidden dirs.
2024-02-17 18:11:48 +01:00
tomFlowee de6162b149 Do the backend work for env-vars cleanup 2024-02-17 01:03:43 +01:00
tomFlowee 1892740678 Wrap exec in bash, which makes this work.
Not entirely sure why, but starting bash and making it start
our app seems to make practically app apps work just fine.
2024-02-16 18:51:46 +01:00
tomFlowee 089c74ad01 Add copy and fix lots of issues 2024-02-16 16:54:09 +01:00
tomFlowee e1ac8745a6 Move policy rules to a rules file. 2024-02-15 23:39:04 +01:00
tomFlowee 44c29d2883 Add readme 2022-08-16 16:26:21 +02:00
tomFlowee 6b9759685e More complete /tmp solution. 2021-08-18 16:26:50 +02:00
tomFlowee fe4bc7c1d3 Remount /tmp 2021-08-18 12:30:11 +02:00
tomFlowee fb25419e52 Close stdin/out/err
No point in keeping them tied to the server.
At this point I also don't see the benefit of writing them to disk or
something.
2021-08-15 22:05:28 +02:00
tomFlowee f86b975714 Make error message clearer. 2021-08-15 21:30:32 +02:00
tomFlowee 7671492b31 Fix mount flags.
rbind mounting inherits all flags from the source.
2021-08-14 23:29:02 +02:00
tomFlowee 80320fc2b1 Add 'unmount' feature.
The security manager controller process can ask the runner to unmount
drives which will thus become invisible to the running process.
2021-08-14 23:03:01 +02:00
tomFlowee 0f2b1bada9 Remove fsType option.
bind-mount doesn't need that.
2021-08-14 22:53:51 +02:00
tomFlowee dea125149f Move rebind code.
This moves the homedir rebinding discovery out of the code that runs as
root and make that one do just the simplest logic possible.
2021-08-14 22:42:26 +02:00
tomFlowee 24873bbf60 Rework the message and its iterator.
This allows us to add more options and data fields.
2021-08-14 22:40:26 +02:00
tomFlowee e81cf7973f Fixlets and docs
Added plenty of small docs.
Changed the message to be pre-fixed with a message-size in order to allow
us to get interrupted on read() and know
if we need to read more.

Also fixes the bug that the server shuts down after one process as
reported by some.
2021-08-14 17:15:02 +02:00
tomFlowee f3870aec3f Redirect to namespaces
Instead of using a new user to run something secure, we now use
namespaces in order to isolate an application.
2021-05-25 14:24:44 +02:00
tomFlowee 13615be3a0 fixlets 2021-05-21 20:13:39 +02:00
tomFlowee e0a359534f Support starting apps with arguments. 2021-05-21 15:28:57 +02:00
tomFlowee bf53034748 Finish Proof of concept.
Starting this tool will now allow one to
- use dbus to request the running of an executable
- the tool creates assigns a userId and creates
  a dir in like /data/1100
- a tiny priviledged part changes ownerhip of that dir
  to the chosen userId.
- it also runs the executable in that dir with this uid.

The effect is that no applications or users (without root)
can read the private files from those apps and they can't
read them from each other.

Running them as different users additionally means all the
standard protections apply and RPC is private between
components of one app.
For instance useful if you have a neochat daemon that listens to the
network while the main app may or may not be running. All using the same
UID naturally.
2021-05-20 19:18:55 +02:00
tomFlowee 4d1e913d01 Make communication work better 2021-05-19 12:08:57 +02:00