Commit Graph

293 Commits (d667f4e81c5b673b7f673047359f183f426dc996)
 

Author SHA1 Message Date
Alexander Larsson cedcd0ab2b Move allow/forbid env setup to xdg-app-run.c 2015-02-13 10:53:19 +01:00
Alexander Larsson 453423c350 Add xdg_app_run_verify_environment_keys helper 2015-02-13 10:33:36 +01:00
Alexander Larsson 884040dfcc Move run helpers from builtin-run to xdg-app-run.c file 2015-02-13 10:29:41 +01:00
Alexander Larsson 0cb23de365 export: Ensure all exported files are prefixed by the app name
All exported regular files (not directories) need to have a filename
that starts with the application name, followed by either a dot or
any character that is invalid in an app name.

For instance, given an app name of org.gnome.gedit, these filenames
are exported:
org.gnome.gedit
org.gnome.gedit.png
org.gnome.gedit.plugin1.png
org.gnome.gedit-symbolic.svg (- is not a valid character)

However, these are not exported:

org.gnome.geditor
gedit.png

This has several advantages. First of all it ensures that there are no
conflicts between unrelated applications, secondly we also only allow
applications to install dbus services and desktop ids that are the
same as the app id, or sub-services of it.
2015-02-11 14:32:45 +01:00
Alexander Larsson d9c10e5103 export: keep the original name for modified desktop/service files
Rather than keeping around a symlink to the temporary file we rename
the temporary over the original name. Also we keep all seen
files and temporary files in a hashtable so we don't accidentally
process anything twice.
2015-02-11 14:30:53 +01:00
Alexander Larsson c1a0b41a7d Ensure all exported dbus service files have the right name
We're enforcing that the dbus name and the filename has to be the same,
or we're not exporting the file.
2015-02-11 14:29:16 +01:00
Alexander Larsson 1d2baf96d8 Verify app/runtime names and branches in various operations
Whenever we create, install, update, uninstall or run apps we
verify that all app names and branch names are valid.
2015-02-11 12:39:17 +01:00
Alexander Larsson baeb666215 Add utils to validate app/runtime names and branches
There are several reasons to verify these. First of all
we use these as filename elements, so we need to sure that dangerous
things like "..", "/" etc don't appear in them.

Secondly, we want to guarantee that app names are valid dbus well
known bus names as they are used as app-ids in e.g. desktop files.

We also want to enforce the app name as prefix for exported files to
avoid conflicts. This means we disallow two-element names like
"org.gnome", and we disallow "-" in app names, so that "-" can be used
to separate the app name prefix from the rest of the filename. In
particular, this is important for icons, like
"org.gnome.app-symbolic.svg", where we want the only valid prefix to be
org.gnome.app.
2015-02-11 12:31:53 +01:00
Alexander Larsson 29ccfbea89 Copy /etc/localtime instead of making a symlink
This way we inherit timezone updates from the host at
least for the current timezone.
2015-02-10 13:12:00 +01:00
Alexander Larsson cdeeaee4a9 Never mount /root in the app 2015-02-10 10:55:58 +01:00
Alexander Larsson a3e97d256a Make /dev and /dev/dri readonly 2015-02-10 10:55:44 +01:00
Alexander Larsson 72f1bd9b07 Merge pull request #50 from matthiasclasen/run-env2
Add an --allow option to the run command
2015-02-10 09:25:08 +01:00
Alexander Larsson cd3289e0cb Merge pull request #52 from matthiasclasen/repo-title
repo-title
2015-02-10 08:53:50 +01:00
Matthias Clasen f184fbb603 Improve completion
The options of the add-remote command were not being completed.
2015-02-09 17:40:37 +01:00
Matthias Clasen 1e69e3fc42 Make add-remote use title from summary
When we add a remote, load the summary from the repository, and
use the title if there is one. This at the same time serves as
(minimal) validation of the repository url.
2015-02-09 17:18:10 +01:00
Matthias Clasen 34dda64b95 Add a --title option to repo-update
This stores a human-readable title in the additional metadata
of the repo summary. We use xa.title as the key.
2015-02-09 17:17:19 +01:00
Matthias Clasen 2054f0e6f5 change load summary api
We want to call it before we have added a remote to the config,
so pass in the url directly instead of pulling it out of the
repo config.
2015-02-09 15:50:05 +01:00
Matthias Clasen 02b6300453 Fix a thinko 2015-02-09 15:21:52 +01:00
Matthias Clasen 4571eb85f7 Factor out summary loading 2015-02-09 15:21:23 +01:00
Matthias Clasen c07e917b5d Add --allow option to the run command
Allow to fully override the environment settings from the
application metadata. This can be useful for testing.
2015-02-09 13:24:19 +01:00
Matthias Clasen f4b9af3a40 Factor out a utility function 2015-02-09 13:03:39 +01:00
Alexander Larsson 4ff10fee86 Add support for --with-priv-mode=caps
This allows you to set the privs for the helper via file
capabilities instead of setuid.
You can also set the mode to none, but then you have to
manually set either setuid or filecaps (for instance via
a packaging script).
2015-02-08 23:37:47 +01:00
Alexander Larsson c8dd341440 Don't use g_ptr_array_insert
This is too cool for vbatts
2015-02-08 17:25:15 +01:00
Alexander Larsson 9a0dcf6470 Add copies of new glib APIs that we use 2015-02-08 17:08:11 +01:00
Alexander Larsson 3ef9c13598 Set PR_SET_NO_NEW_PRIVS
This means no process in the app can gain any kind of extra
privs during exec() (for instance setuid of file caps).
2015-02-08 11:32:17 +01:00
Alexander Larsson 79b12777bf Add all (unused) args to prctl call 2015-02-08 11:32:17 +01:00
Matthias Clasen a2f9562989 Teach completion about --runtime 2015-02-08 11:32:17 +01:00
Alexander Larsson 4fad768593 Merge pull request #48 from matthiasclasen/prefix-ostree-errors
Prefix many ostree error messages
2015-02-08 01:15:59 +01:00
Alexander Larsson 6a7b43a3c5 Merge pull request #49 from matthiasclasen/quote-args
Quote commandline arguments
2015-02-08 01:14:59 +01:00
Alexander Larsson b2ec77fb2f Don't run xdg-app-helper as root
Instead of running as root we setuid to the real user, after
having assured that we have the minimum amount of capabilities
required (which we then drop at the end).

This means we create all files as the actual user, and we never
risk somehow reading a file that otherwise only root could read.
2015-02-08 01:09:44 +01:00
Matthias Clasen f412d38458 Quote commandline arguments
We don't expect branch or arch names to contain spaces. But if
they do, we should not fall over needlessly.
2015-02-07 18:38:29 +01:00
Matthias Clasen 41ea4e4ebc Prefix many ostree error messages
Some of the ostree error messages don't contain sufficient detail
to be useful, so use g_prefix_error to add some context.
2015-02-07 18:02:04 +01:00
Alexander Larsson f8e4343ff5 Merge pull request #43 from matthiasclasen/remote-title
Add a --title option to add-remote
2015-02-07 15:10:30 +01:00
Alexander Larsson ab91bbf925 Merge pull request #46 from matthiasclasen/run-env
Add a --forbid option to run
2015-02-07 13:26:13 +01:00
Matthias Clasen 2a1246d136 Add a prefix to the config key
This seems to be the common practice for git addons.
Colin recommends that we do the same for ostree config keys.
2015-02-07 12:01:48 +01:00
Matthias Clasen 763b378590 Add some debug spew
Show the access we allow.
2015-02-06 17:43:53 +01:00
Matthias Clasen c313cafbae Add a --forbid option to run
This allows to restrict the access that the app gets out of
the sandbox. We allow an access if the app requests it (in its
metadata) and the user doesn't forbid it (with this option).
2015-02-06 17:39:20 +01:00
Alexander Larsson 0abf45b01b Merge pull request #44 from matthiasclasen/run-runtime
run-runtinme
2015-02-06 16:15:55 +01:00
Matthias Clasen e5ee197b81 Add a --runtime option to run
The --runtime option lets us completely override the runtime that
is specified in the application metadata. This is useful for testing
compatibility of an application with runtimes.
2015-02-06 12:11:26 +01:00
Alexander Larsson 287a93742f Put system installed apps/runtimes in localstatedir (/var) 2015-02-06 11:59:38 +01:00
Alexander Larsson 3afe98d614 Try /tmp for .xdg-app-root if /run/user not available 2015-02-06 11:58:57 +01:00
Alexander Larsson 61ababa60e Make /proc/sysrq-trigger /proc/irq, /proc/bus read-only
We should normally not have any rights to write here, but if
we do that is pretty bad, so might as well cover them read-only
like e.g. docker does.
2015-02-06 11:21:01 +01:00
Matthias Clasen 06608ba7d5 Add a --title option to add-remote
This stores a string in the remote configuration which can
be used in UIs when talking about the remote.
2015-02-06 11:11:10 +01:00
Alexander Larsson 4903fe100d Remove unused removed dirs after install/uninstall 2015-02-05 22:50:38 +01:00
Alexander Larsson 6ea2391583 During undeploy, keep files around if they are in use
We check for a lock on the .ref file to detect if anything
is using a partilular checkout before we remove it.
2015-02-05 22:47:48 +01:00
Alexander Larsson f1091127c5 Add locking of .ref files while a runtime/app is in use 2015-02-05 18:42:36 +01:00
Alexander Larsson 7c8fb83f20 Create files/.ref when deploying
This will be used later to avoid deleting active mounts.
They have to be created during deploy, because we are
then guaranteed to be able to write to the directory,
and we don't want the resulting file to be hardlinked
to any other deployment (as then locks could be shared).
2015-02-05 18:34:02 +01:00
Alexander Larsson c4324ab630 Use a pid namespace
For the fully sandboxed case we *need* a pid sandbox, so we might as
well always use one to get the same setup always. There should really
be no need for a normal "app" to see host processes.

The other nice thing about this is that we get somewhere to run code
when the app stops, which means we can do things like delay uninstall
while apps are running.

The unfortunate drawback of this is that we get 2 extra processes per
app, one is the pid1 in the sandbox, and the other is the monitor
process to return the exit code to the spawner of xdg-appp-helper.
2015-02-05 17:36:43 +01:00
Alexander Larsson 6f023b4ee3 Clean up namespace initialization
Rather than do the fork workaround we make / rslave, which means
we will still get new mounts/unmounts propagated to us from the root,
but will not leak any mounts to the host.

We also use a single directory in the users run dir as the mountpoint
for the tmpfs.
2015-02-05 11:34:43 +01:00
Alexander Larsson 55a3f413c2 build-finish: Don't error out on exports
gs_shutil_cp_a dies if the target exists, so only create the
parent dir before copying.
2015-02-03 10:53:02 +01:00