Commit Graph

27 Commits

Author SHA1 Message Date
Simon McVittie
86c9d7d4c7 daemons, etc.: Use g_info() for messages that are enabled by -v
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-12-15 16:45:35 +00:00
Simon McVittie
de4de4dc44 automake: Consistently include $(AM_CFLAGS) in target-specific CFLAGS
When built for i386 with Autotools, this would have detected the format
string issue fixed in #5148.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-27 09:59:43 +01:00
Simon McVittie
9eb824f863 Add a Meson build system
Resolves: https://github.com/flatpak/flatpak/issues/2241
Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-10-24 16:12:14 +01:00
Phaedrus Leeds
600e18567c Add a vim modeline and .editorconfig
To make indentation work with less effort. The modeline was copied from
libostree with minor modification and the .editorconfig from GLib.

The advantage of having both a modeline and an editorconfig is we can
work out of the box on more editor setups, and the modeline allows us to
specify the style with a lot more fine grained control.
2022-08-22 19:48:10 -07:00
Simon McVittie
aef1442d54 icon-validator: Don't make flatpak_get_bwrap() extern
The Meson build files that I'm working on enable more compiler warnings
by default than Autotools does, and in particular -Wmissing-declarations
complains about global functions that are not predeclared. There's no
need for this one to be global.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2022-05-03 13:54:23 +02:00
Phaedrus Leeds
c3ca2c7010 icon-validator: Fix -Wformat-security warning 2022-03-15 10:27:50 +00:00
Phaedrus Leeds
8b3728addb icon-validator: Add a note on code sharing 2022-03-14 15:09:41 -07:00
Phaedrus Leeds
53267fc287 icon-validator: Print format and size to stdout
Having this patch here rather than in x-d-p means we don't have to carry
downstream changes to the file in x-d-p.

This commit also makes the validator error out if the icon is not
square, since it's simpler to parse one number, and in practice all
icons are square.
2022-03-14 15:09:41 -07:00
Bartłomiej Piotrowski
3be48f3098 icon-validator: Mount ld.so.cache only if it exists
On musl-based systems, /etc/ld.so.cache does not exist, causing icon validation to fail.

This has been improperly reported at [1] instead of Flatpak repo.

[1] https://github.com/flathub/com.valvesoftware.Steam/issues/638
2021-10-04 09:07:35 +02:00
a1346054
1f69e5b35c remove trailing whitespace
Signed-off-by: a1346054 <36859588+a1346054@users.noreply.github.com>
2021-08-23 12:19:03 +02:00
Simon McVittie
66aee5a342 icon-validator: Add lib32 to usrmerged_dirs, for completeness
This syncs it up with our other lists of /usr-merged directories.

In particular, this could matter on Arch Linux, which uses /usr/lib
and /usr/lib32 for 64- and 32-bit libraries (respectively), instead
of the more common /usr/lib64 and /usr/lib.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2020-02-14 15:41:59 +01:00
Simon McVittie
8deef94f9d icon-validator: Remove remnants of GSpawn error handling
Now that validate-icon uses execvpe(), status and error were never set,
so rerun_in_sandbox() would have crashed while dereferencing a NULL
error if execvpe() failed. This is reproducible with, for example:

    FLATPAK_BWRAP=/bin/nope flatpak-validate-icon --sandbox 48 48 /path/to/icon

execvpe() does not return on success (the process image is replaced),
and sets errno on failure, so behave accordingly.

Also print the error message to stderr, even if G_MESSAGES_DEBUG is not
set, since it's our only opportunity to indicate to a caller what has
gone wrong.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #2950
Approved by: alexlarsson
2019-06-12 06:51:53 +00:00
Simon McVittie
e360005d8b Check for missing sentinels in NULL-terminated varargs
Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #2876
Approved by: matthiasclasen
2019-05-02 16:58:36 +00:00
Simon McVittie
89dc344ccb icon-validator, portal: Guard against overlong symlink targets
If the buffer is too small, readlink() returns the number of bytes that
would have been stored if the buffer had been large enough.

Signed-off-by: Simon McVittie <smcv@collabora.com>

Closes: #2873
Approved by: matthiasclasen
2019-05-01 16:39:18 +00:00
Matthias Clasen
11aface66e icon-validator: Add the max size to the error
This helps to explain why an icon was rejected.

Closes: #2813
Approved by: alexlarsson
2019-04-10 06:58:13 +00:00
Bastien Nocera
32c5b15326 icon-validator: Don't check SVG size
The size is just a number, but the resulting GdkPixbuf could still be
quite big compared to the amount of data we're processing, so keep
4096x4096 as maximum dimensions.

Closes: #2747
Approved by: alexlarsson
2019-03-12 13:07:41 +00:00
Bastien Nocera
8008fe38a1 icon-validator: Check image format first
Closes: #2747
Approved by: alexlarsson
2019-03-12 13:07:41 +00:00
Matthew Leeds
e8816b7663 Remove extra newlines in variable definiton blocks
Uncrustify has an option "nl_func_var_def_blk" which is supposed to
ensure there's a newline character between the block of variable
definitions and the rest of the function body, but it gets confused and
thinks that the first instance of "g_autoptr" or "g_auto" being used on
a variable is the start of the function body. So this commit removes
those extra newline characters and removes that option in uncrustify.cfg
so they don't get re-added the next time uncrustify is run.

Here's the command I used:

perl -0777 -i -pe 's/\n(\n\s*g_auto\()/\1/g' `git ls-tree --name-only
-r HEAD | grep \\\.[ch]$ | grep -v common/valgrind-private.h |
grep -v app/flatpak-polkit-agent-text-listener\\\.[ch]`

I ran it again with "g_autoptr" in place of "g_auto", and made a few
manual edits to add back the newline when the g_auto* was in the middle
of a function body rather than at the top.

Closes: #2715
Approved by: matthiasclasen
2019-02-25 18:12:30 +00:00
Matthew Leeds
8d962a686f Run uncrustify
I had to make a few manual edits but other than those the changes look
reasonable.

Closes: #2715
Approved by: matthiasclasen
2019-02-25 18:12:30 +00:00
Matthias Clasen
2bf420b93a icon validator: Use exec for the sandboxing
We don't really need a separate process here, and
doing things this way makes output from the sandbox
appear outside, thereby giving us meaningful error
messages for invalid icons.

Related: #2669

Closes: #2677
Approved by: alexlarsson
2019-02-05 10:00:15 +00:00
Alexander Larsson
bcc53c2454 validate-icon: Search the path for bwrap
Closes: #2640
Approved by: alexlarsson
2019-01-28 09:40:22 +00:00
Matthias Clasen
57b55d9781 icon-validator: Use readlink() properly
This function helpfully does not 0-terminate the buffer,
so we have to do that ourselves. Also make the buffer
as large as possibly required, and handle errors.

Closes: #2630
Approved by: matthiasclasen
2019-01-23 12:44:38 +00:00
Matthias Clasen
ae1dc979df Make tests work
We can't look at the FLATPAK_VALIDATE_ICON environment variable
inside the sandbox. Use /proc/self/exe to find the binary to reexec.

Closes: #2618
Approved by: alexlarsson
2019-01-21 09:17:29 +00:00
Matthias Clasen
39152a6d40 Copy sandbox setup from libgnome-desktop
We need to handle source directories not existing, for example /lib64
on a pure 32-bit system.

Because relative symlinks in a directory that is itself a symlink do
not have the same meaning as the same relative symlink in a bind-mount
of that directory, ideally we want to use --symlink for /lib and /lib64
on merged-/usr systems, but --ro-bind on non-merged-/usr systems.

Also bind /etc/ld.so.cache into the sandbox.

This is especially important for libstdc++ on distributions that
don't have it directly in a libdir and the runtime linker doesn't
look where needed without /etc/ld.so.cache (e.g. if libstdc++ is
in a GCC per-version subdirectory handled via /etc/ld.so.conf.d/).

Changes originally made in libgnome-desktop by Iain Lane (see
<https://bugzilla.gnome.org/show_bug.cgi?id=787072>).

Adapted from https://github.com/flatpak/xdg-desktop-portal/pull/289
by Simon McVittie.

Closes: #2618
Approved by: alexlarsson
2019-01-21 09:17:29 +00:00
Matthias Clasen
81265f5115 Make the icon validator sandbox itself
Make the icon validator reexec itself inside a sandbos
if the --sandbox option is given. This lets us share
the sandbox setup between all users of this tool.

An additional advantage is that this makes the sandbox
setup code testable by iself.

Closes: #2618
Approved by: alexlarsson
2019-01-21 09:17:29 +00:00
Matthias Clasen
64958b4d80 icon validator: Fix an off-by-one
I meant to allow 16 as a size limit.
2019-01-18 07:47:38 -05:00
Matthias Clasen
730dab95f5 Add a utility to validate icons
This is copied from xdg-desktop-portal.

Closes: #2523
Approved by: alexlarsson
2019-01-17 07:27:31 +00:00