4370 Commits

Author SHA1 Message Date
Alexander Larsson
fa08646371 Update pofiles for release 1.1.0 2018-11-16 14:37:22 +01:00
Alexander Larsson
03732121db Make sure we dist flatpak-instance-private.h 2018-11-16 14:34:15 +01:00
Alexander Larsson
420281414d Mention 1.2 expected release date in NEWS 2018-11-16 14:30:40 +01:00
Alexander Larsson
9fd6451fb9 Update NEWS for 1.1
This also includes the NEWS posts from 1.0.3 to 1.0.6 first
to avoid duplication and since it makes sense for users. After
all, 1.1 is released after 1.0.6 was released.
2018-11-16 14:28:16 +01:00
Alexander Larsson
35598f46a5 extra-data: Don't allow creating files with non-canonical permissions in apply_extra
When installing a flatpak with extra-data we execute the apply_extra
script from the flatpak to extract the extra data files we
created. This script runs with very little filesystem acces, but it
does have write permissions to the location that will eventually be
/app/extra in the finished flatpak. This is especially problematic for
the systemwide install case, because the script is then run as root,
so it could potentially create a setuid file there.

Such a file would not be usable inside the sandbox (because setuid is
disabled in the sandbox), but it could potentially be a problem if the
user could be tricked into running the file directly on the host. This
is the same behaviour as e.g. rpm or deb which both can install setuid
files, but we want to guarantee that flatpak is better than that.

The fix is to run the script with all capabilities dropped (bwrap
--cap-drop ALL) which removes a bunch of possible attack vectors (for
instance setting file capabilities). However, even without
capabilities, it is possible for a user to make any file setuid to the
same user, so we also need to canonicalize the permissions of all
files generated by running the script.

Additionally, while running the script we set the toplevel directory
only be accessible to the user, meaning we will not temporarily leak
any potential setuid files to other users.

Note, this commit actually goes furthen than that and completely
canonicalizes all the file permissions to be the same as those
otherwise used by flatpak. For example we fix up cases where the
script creates files writable or unreadable by non-root users.

Closes: #2323
Approved by: alexlarsson
2018-11-16 10:20:20 +00:00
Alexander Larsson
1ce0246b0d dir: Match pre-existing remotes better wrt collection-id
If you have a pre-existing remote configured its exact definition
might differ from the one specified in a flatpakrepo file and yet
be the same.

For example, i have:

$ flatpak --user remotes -d
Name      Title      URL                            Collection ID          Priority Options
flathub   Flathub    https://dl.flathub.org/repo/   org.flathub.Stable     1

Yet when i install a flatpakref:

$ flatpak --user install http://flathub.org/repo/appstream/org.gnome.gedit.flatpakref
The application org.gnome.gedit depends on runtimes from:
  https://dl.flathub.org/repo/
Configure this as new remote 'flathub-1' [y/n]:

Because the flathub flatpakrepo does not yet have the collection id specified.

So, we need to be more lenient when matching the pre-configured remotes.

Closes: #2324
Approved by: alexlarsson
2018-11-16 10:06:22 +00:00
Matthew Leeds
348fcc3f97 Add a DeployCollectionID key to replace CollectionID
This commit adds a key called DeployCollectionID to the flatpakref and
flatpakrepo file formats, which is intended to replace the CollectionID
key (which is still supported but deprecated). The reason for the change
is the same as for the metadata key change from xa.collection-id to
ostree.deploy-collection-id, which is that old versions of Flatpak
(roughly 0.9.8 through 1.0.1 depending on compile time options) hit
various bugs when collection IDs are in use. Flathub will soon enable
the metadata key to deploy collection IDs, and this change means Flathub
can also deploy the collection ID in flatpakref and flatpakrepo files
without affecting old clients.

Adding DeployCollectionID to the flatpakref and flatpakrepo files will
mean the flathub remote can be automatically configured with a
collection ID without depending on the metadata key to do that.

Closes: #2329
Approved by: alexlarsson
2018-11-16 09:17:07 +00:00
Matthew Leeds
eda5dee589 doc/flatpakref: Fix a typo 2018-11-15 15:35:47 -08:00
Matthew Leeds
af8da20426 doc: Fix a mistake in the RuntimeRepo docs 2018-11-15 14:07:24 -08:00
Matthew Leeds
6b975f3c09 uninstall: Fix a typo 2018-11-15 13:42:39 -08:00
Erick555
0af71792b4 Mount x11_socket as read-only
Fixes https://github.com/flatpak/flatpak/issues/2315
Closes: #2316
Approved by: alexlarsson
2018-11-15 12:24:00 +00:00
Matthias Clasen
9e6287aa0e Document the --delete-data option
Useful functionality should be documented.

Closes: #2314
Approved by: matthiasclasen
2018-11-14 17:15:42 +00:00
Matthias Clasen
a886c9cdf1 uninstall: Add a --delete-data option
When --delete-data is passed when uninstalling an app,
remove its app data directory in ~/.var/app/. When
--delete-data is used without a ref, remove all 'unowned'
app data directories.

Closes: #2314
Approved by: matthiasclasen
2018-11-14 17:15:42 +00:00
Matthias Clasen
ca109c14f8 Export a reset-permission utility
This will be reused for uninstall --delete-data.

Closes: #2314
Approved by: matthiasclasen
2018-11-14 17:15:42 +00:00
Kukuh Syafaat
9ada2721de Update Indonesian translation
Closes: #2318
Approved by: matthiasclasen
2018-11-14 16:07:31 +00:00
Michael Catanzaro
68a5a46cbf flatpak-coredumpctl: launch flatpak with --filesystem=home
This is a debugging tool so there's no need for a strict sandbox. I
want to be able to extract backtraces from gdb using 'set logging on'
and it's not currently possible without using
--extra-flatpak-args="--filesystem=home".

Closes: #2313
Approved by: matthiasclasen
2018-11-14 12:35:31 +00:00
Philip Withnall
9e9b8b75fc ref: Fix a typo in a documentation string
Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #2317
Approved by: matthiasclasen
2018-11-14 12:34:30 +00:00
Matthias Clasen
c4572c17f8 Merge pull request #2311 from matthiasclasen/name-validation
Name validation
2018-11-14 00:12:16 -05:00
Matthias Clasen
fc77535212 Remove a wrong statement from uninstall docs
We do not have code to remove the apps data directory.

Closes: #2309

Closes: #2312
Approved by: matthiasclasen
2018-11-13 14:12:28 +00:00
Matthias Clasen
3a536f3878 Clarify FlatpakInstallation docs
Several doc comments were mistakenly talking
about a 'system installation'.

Closes: #2310
Approved by: matthiasclasen
2018-11-13 00:29:55 +00:00
Matthias Clasen
54f38284f6 Validate custom installation IDs
We want to avoid unnecessary confusion and complications,
so we rule out IDs that are problematic because they will
clash with the default installations.

At the same time, make the error messages for parsing
custom installations more informative.
2018-11-12 19:25:34 -05:00
Matthias Clasen
91f88dd204 Don't allow empty remote names
Prevent remotes from having empty names. This can only lead
to confusion and unnecessary complications.
2018-11-12 19:18:07 -05:00
Matthias Clasen
bf7af547aa Small fixes to many man pages
Make synopses more concise in various place, improve
consistency of formatting, and fix some small mistakes
and oversights.

Closes: #2307
Approved by: matthiasclasen
2018-11-12 14:28:41 +00:00
Philip Withnall
4a1c11dba9 dir: Factor out code to load AppStream cache for a remote
This is currently only used in the ‘search’ built-in command, but will
need to be used in upcoming parental controls filtering changes in
Endless OS (which will go upstream eventually) too.

This introduces no functional changes.

The CFLAGS/LIBADD changes are necessary because of the new
AppStream #includes.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #2296
Approved by: matthiasclasen
2018-11-12 13:13:09 +00:00
Philip Withnall
a478ee8de3 app: Update a FIXME comment to mention the upstream bug
And hence provide at least a little bit of hope that this doesn’t become
permanent technical debt.

Signed-off-by: Philip Withnall <withnall@endlessm.com>

Closes: #2296
Approved by: matthiasclasen
2018-11-12 13:13:09 +00:00
Alexander Larsson
7078a7f087 Make per-app generated files read-only
We generate various configuration files for each sandbox instance,
and expose them to the sandbox using flatpak_bwrap_add_args_data,
which in the end passed --bind-data to bwrap. These files are not
sensitive or shared, but it still doesn't really make sense for
the sandbox to allow them to be modified, so lets switch them
to --ro-bind-data.

This affects these files in the sandbox:

 $HOME/.var/app/$APPID/config/user-dirs.dirs
 /etc/group
 /etc/ld.so.conf
 /etc/passwd
 /etc/pkcs11/modules/p11-kit-trust.module
 /etc/pkcs11/pkcs11.conf
 /etc/timezone
 /run/flatpak/ld.so.conf.d/*.conf
 /run/user/$UID/pulse/config
 /run/user/$UID/Xauthority
2018-11-12 14:13:05 +01:00
Alexander Larsson
6711d7ae99 Don't allow writes to runtime files in /etc
We mistakenly bind-mounted the runtime /usr/etc files read-write in
/etc, which means that application could modify some parts of the
runtimes (at least when using a per-user installed runtime). Fix
this by using a --ro-bind.
2018-11-12 14:13:05 +01:00
Matthias Clasen
40854e00df Fix misleading error message
The error messages here make it appear that values can
be prepended with a '!', but a few lines down we throw
an error if thats the case.

Closes: #2298
Approved by: matthiasclasen
2018-11-10 16:09:47 +00:00
Matthew Leeds
610bc8a532 app: Fix a copy-paste error in comments
These comments were copied from the install command implementation
(which since changed REPOSITORY to REMOTE).
2018-11-08 17:09:24 -08:00
Umang Jain
94969d5057 Installation: Add flatpak_installation_get_min_free_space_bytes
A convenience wrapper around ostree_repo_get_min_free_space_bytes().
Clients programs like gnome-software can get the value of minimum free
space as defined in the OSTree repo. This can be useful in various
disk-space checks these client program can implement.

At Endless, we have downstream heuristics in gnome-software which
determine the success/failure likelihood of an install/update
operation to some extend. Depending upon the likelihood of the
success/failure we dispatch install/update/auto-update operations.

With client programs gaining features such as auto-updates, it makes
sense to have a min-free-space API so that these programs can check
free-space availablity vs minimum free space defined by user inside
OSTree's repo before auto-updating. Although, OSTree will certainly
fail operations over-stepping min-free-space's value; It's just a
matter of convenience to provide a way to query the value to client
programs as well.

Closes: #2274
Approved by: matthiasclasen
2018-11-07 12:02:14 +00:00
Matthias Clasen
add199a1f9 Amend the policy comments further
As pointed out in #1269, we also install polkit rules
which affect this.

Closes: #2287
Approved by: matthiasclasen
2018-11-06 11:38:13 +00:00
Matthias Clasen
0a9a6abdf7 Update polkit policy descriptions
Update the user-visible messages to include some of
the details that are available. An informed user is
a happy user.

String change!

Closes: #2287
Approved by: matthiasclasen
2018-11-06 11:38:13 +00:00
Matthias Clasen
cac9167558 Correct polkit policy comments
Make the security comments for our polkit rules match
the actual defaults.

Closes: #2287
Approved by: matthiasclasen
2018-11-06 11:38:13 +00:00
Matthew Leeds
a22dfbd7c1 Default to only choice in multiple choice prompts
This commit implements a feature in the multiple choice prompt that
mirrors the behavior in the yes/no prompt where it can default to "yes"
when the user only presses Enter. In the case of the multiple choice
prompt, it only defaults to the first choice on Enter if there's only
one option (e.g. you're asked if you want to install from the "flathub"
remote as opposed to being asked to choose between the "flathub" and
"eos-apps" remotes).

This feature can be turned off on a per-prompt basis if we want explicit
user input for something but I didn't find that necessary for any of the
existing prompts.

Also note that as with the yes/no prompt defaulting to yes on Enter,
this only applies for interactive terminals. If Flatpak is being run by
a script no choice will be made automatically.

This should save users unnecessary keystrokes, such as when they use
"flatpak install devhelp" and are asked to confirm that the Flathub
remote is the one to use (now they can just press Enter).

Closes: #2288
Approved by: matthiasclasen
2018-11-06 02:48:06 +00:00
Matthew Leeds
e6f9353f64 install: Mention remote in "similar refs" prompt
Currently when the install command has to prompt the user to resolve
ambiguity over which ref to install, the prompt only mentions the
(partial) ref that was specified. If a remote was specified or the user
chose one in a prompt, this is probably fine. But if the user didn't
specify a remote and used the --assumeyes/-y option so that one would be
chosen for them, there's no way to tell which remote is being used at
the point when the ref ambiguity is being resolved. So this commit adds
information about the remote name and flatpak installation to the
"Similar refs found" prompt.

Closes: #2288
Approved by: matthiasclasen
2018-11-06 02:48:06 +00:00
Matthew Leeds
85b7eea4f1 install: Prompt when multiple remotes match
Currently if the user doesn't specify a remote name to the install
command, Flatpak chooses the first one that has a matching ref, either
with or without user interaction depending on whether --assumeyes/-y was
used. Then if more than one remote ref is similar to the one specified,
the user is prompted to choose between them. I think this asymmetry
doesn't make much sense; why not have the user choose between remotes
just as they choose between refs?

For example, the string "libre" matches refs from both flathub and
eos-apps, so if I do "flatpak install -y libre" a remote is arbitrarily
chosen for me but I'm still prompted to choose between the refs (since
-y can't choose for you when there are mutliple choices).

So this commit changes the install command implementation to present the
user with a list of remotes that have matching refs all at once rather
than one at a time. The reason I didn't implement it this way at first
is that I was worried about the performance impact, but in testing I'm
not able to measure a difference between stopping at the first remote
with a match and checking every remote (although the story might be
different if you have many remotes or don't have up-to-date metadata
downloaded).

If there's an error searching a remote, it's treated as a warning so
that one misconfigured remote doesn't take down the whole operation with
it.

This commit also updates the unit tests so they continue to succeed.

Closes: #2288
Approved by: matthiasclasen
2018-11-06 02:48:06 +00:00
Matthew Leeds
6efcfb574f remote-ls: Rename and modify helper struct
This commit changes the struct "RemoteDirPair" to "RemoteStateDirPair"
so that an upcoming commit can make another struct called
"RemoteDirPair" in flatpak-builtins-utils.[ch] which will just have the
remote name and dir without a state. This commit also removes the
"remote_name" member, because it makes more sense to use the remote_name
field in the state object.

Closes: #2288
Approved by: matthiasclasen
2018-11-06 02:48:06 +00:00
Matthew Leeds
3ad0124ff9 install: Update --help output
Put brackets around the "LOCATION/REMOTE" argument to the install
command, because the remote name is now optional. It's difficult to
summarize all the forms supported by the command in one line, but this
seems more accurate than it was before.

Closes: #2288
Approved by: matthiasclasen
2018-11-06 02:48:06 +00:00
Matthew Leeds
5ddca0fc36 common: Document that get_latest_commit() can return NULL
It's possible for the "latest_commit" field of a FlatpakInstalledRef to
be NULL, which I think happens if the ref is no longer in the
remote.[1][2][3] So this commit documents the possibility of
flatpak_installed_ref_get_latest_commit() returning NULL.

[1] https://github.com/flatpak/flatpak/issues/309
[2] https://github.com/flatpak/flatpak/commit/6b4402b60
[3] https://github.com/flatpak/flatpak/commit/230e18db7

Closes: #2289
Approved by: matthiasclasen
2018-11-03 01:04:34 +00:00
Matthew Leeds
27a611d4eb doc/flatpak-install: Make arg name consistent throughout
Closes: #2113
Approved by: matthiasclasen
2018-10-31 22:48:56 +00:00
Matthew Leeds
7b1a5c4fb9 Allow yes/no prompt to default to yes
Currently when the Flatpak command line prompts the user with a yes or
no question, the user must type "y" or "n" to respond. This commit
changes it so that the prompt can assume "yes" if the user just presses
Enter. In that case the prompt ends in "[Y/n]" rather than "[y/n]". If
there are some operations that are considered dangerous, we can still
require explicit user input on those, but as far as I can tell those
criteria don't apply to any existing prompts.

This behavior of allowing the user to just press Enter is consistent
with how apt works for example.

Note that this is distinct from the "--assume-yes" option we have, since
that won't prompt the user at all when a decision needs to be made.

Closes: #2113
Approved by: matthiasclasen
2018-10-31 22:48:56 +00:00
Matthew Leeds
02d1a4ed30 install: Make the REMOTE arg optional
Currently the install command requires the user to specify the remote
name in addition to each ref that is to be installed. This commit
implements an auto-detection feature so that the user can specify only
refs (or partial refs) and Flatpak will try to determine the remote to
use.

The Flatpak security model does not consider all remotes equally
trustworthy, but that's okay because the user is asked to confirm the
remote choice before it's used.

The way it's implemented is that we look at only the first ref (even if
there are several) and iterate through each remote in each installation
trying to find it, stopping at the first one where it's found and asking
for confirmation of it. There's a trade-off here between efficiency and
accuracy, since it could be pretty costly to search every remote in
every installation. I think this should be good enough for most use
cases, and the user is still free to specify a remote and avoid that
code path.

This should hopefully save people a bit of typing and make the Flatpak
CLI a bit friendlier.

Closes: #2113
Approved by: matthiasclasen
2018-10-31 22:48:56 +00:00
Matthew Leeds
7fb57f7221 install: Implement a typo helper
This commit implements a "typo helper" for the install command, so that
if you don't get the app ID exactly correct you're prompted with
similarly named apps available in the remote that you can choose from.
Essentially this allows you to do "flatpak install flathub devhelp"
instead of "flatpak install flathub org.gnome.Devhelp".

The choice is only made for you in two cases: 1. If it's an exact match
and there's only one match, it is used as before this commit.  2. If the
-y/--assume-yes option was used and there's only one match, it is used.
Presumably scripts would always specify the full app ID, so this should
only affect users on the command line who choose to use that option.

In the future we may want to use the groundwork laid in this commit to
add similar functionality to other commands, like perhaps remote-info
and run.

This is a partial fix for https://github.com/flatpak/flatpak/issues/1258

Closes: #2113
Approved by: matthiasclasen
2018-10-31 22:48:56 +00:00
Matthew Leeds
7c86f12262 Move Levenshtein distance implementation
This moves the implementation of the Levenshtein "edit distance"
algorithm from app/ to common/ so it can be used in an upcoming commit.

Closes: #2113
Approved by: matthiasclasen
2018-10-31 22:48:56 +00:00
Matthew Leeds
c7772f3504 dir: Remove outdated comments
flatpak_dir_find_remote_refs() and flatpak_dir_find_remote_ref() have
support for finding remote refs via P2P means because
flatpak_dir_list_all_remote_refs() uses the list of refs in the xa.cache
in that case. So remove the outdated comments.

Closes: #2113
Approved by: matthiasclasen
2018-10-31 22:48:56 +00:00
Yuri Chornoivan
f5c6f80c2d Update Ukrainian translation
Closes: #2280
Approved by: matthiasclasen
2018-10-29 22:40:44 +00:00
Matthias Clasen
f024e95362 Check that wayland-0 is a socket
This is a little better than just checking that the file
exists. Still does not protect against a stale socket.

Closes: #2258

Closes: #2271
Approved by: matthiasclasen
2018-10-27 13:49:51 +00:00
Cheng-Chia Tseng
7fc8fa0c31 add Chinese (Taiwan) translation
Closes: #2276
Approved by: matthiasclasen
2018-10-25 18:07:07 +00:00
Matthew Leeds
a4683a4328 installation: Respect configured set of repo finders
OSTree now has a repo config option to set which repo finders (that is,
sources for refs) will be used, and API which exposes the default set
(which was either configured by the user or decided by libostree). So
this commit changes flatpak_installation_list_remotes_by_type() to
respect that configuration, since that's the only place flatpak passes a
set of OstreeRepoFinder instances to libostree.

See also https://github.com/ostreedev/ostree/pull/1758/

Closes: #2264
Approved by: pwithnall
2018-10-24 16:38:16 +00:00
Matthias Clasen
070e07c6f2 Merge pull request #2255 from matthiasclasen/cmdline-errors
Commandline errors
2018-10-24 13:25:29 +01:00