Commit Graph

16079 Commits

Author SHA1 Message Date
Ben Wiederhake
1e7adf5cb6 LibGUI: Resolve cyclic inclusion
Application.h includes Widget.h which includes Application.h. I'm not entirely
sure what the semantics are in this case, but avoiding this seems to be the
safer approach. In this case, Widget does not actually use Application, so let's
just remove the unused include.
2021-01-22 21:49:54 +01:00
Ben Wiederhake
1ec225f5ba LibCrypto: Make PEM.h able to stand alone
These headers should probably all be converted into proper functions of
LibCrypto, especially since we have shared objects.
2021-01-22 21:49:54 +01:00
Pierre
8e265b512a PixelPaint: adding an option to export as PNG 2021-01-22 20:39:25 +01:00
Pierre
a1d7739607 LibGfx: adding a very simple PNG writer
With this patch it is possible to create PNG files. Only minimal options
are supported. The PNG is created with one big IDAT chunk containing
only non-compressible DEFLATE blocks.
2021-01-22 20:39:25 +01:00
Nico Weber
d1ea418e43 LibGfx: Implement scaling support for draw_tiled_bitmap()
Closes #5017.
2021-01-22 20:39:14 +01:00
Andreas Kling
bfce0fccde su: Drop "id" pledge after switching user 2021-01-22 19:40:30 +01:00
Andreas Kling
2ab9083420 passwd: Drop "rpath" pledge after opening files
We needed this for mkstemp() since it used lstat() internally. Now that
it only uses open(), we don't need to pledge "rpath".
2021-01-22 19:39:44 +01:00
Andreas Kling
b0f19c2af4 LibC: Templatize unique filename enumeration for mkstemp() et al
This allows us to implement mkstemp() with open() directly, instead of
first lstat()'ing, and then open()'ing the filename.

Also implement tmpfile() in terms of mkstemp() instead of mktemp().
2021-01-22 19:39:44 +01:00
Andreas Kling
2cd07c6212 Kernel+Userland: Remove "dns" pledge promise alias
This was just an alias for "unix" that I added early on back when there
was some belief that we might be compatible with OpenBSD. We're clearly
never going to be compatible with their pledges so just drop the alias.
2021-01-22 19:39:44 +01:00
Linus Groh
421587c15c Everywhere: Fix typos 2021-01-22 18:41:29 +01:00
Linus Groh
7ad31651bd Meta: Use a bash shebang for text-to-cpp-string.sh
Previously we had /bin/sh, which might be bash but is run in POSIX mode
on some systems, causing read -r to not work correctly and inserting
newlines when encountering literal "\n" in the source.

Fixes #5040.
2021-01-22 18:41:08 +01:00
Linus Groh
5e95a777e0 Calculator: Give the '9' button a blue foreground color as well 2021-01-22 18:40:55 +01:00
Jonathan Turner
0bf5669ba3
Meta: Get building on NixOS (#5005) 2021-01-22 17:44:05 +01:00
Nico Weber
2fe6a313c2 LibGfx: Implement blit_offset() in terms of blit()
It's less code, and blit() already handles scaled painters.

Fixes the window server asserting in highdpi mode with a centered
background image. Part of #5017.
2021-01-22 17:32:44 +01:00
Maciej Zygmanowski
586c0aa043 LibDebug: Don't assert when running on non-existent executable 2021-01-22 17:00:24 +01:00
Nico Weber
c98055de75 LibGfx: Remove Painter::blit_scaled() in favor of Painter::draw_scaled_bitmap()
draw_scaled_bitmap() has a clearer API (just source and dest rects --
blit_scaled() took those and scale factors and then ignored width and
height on the source rect and it was less clear what it was supposed to
do), and they do mostly the same thing.

The draw_scaled_bitmap() API takes an IntRect as source rect, so it's
currently not always possible to split a big draw_scaled_bitmap() into
two (or more) smaller draw_scaled_bitmap() calls that do the same thing
-- that'd require FloatRects. The compositor kind of wants this to be
possible, but there's already a FIXME about this not looking quite right
with the previous approach either.

draw_scaled_bitmap() handles transparent sources, so after this change
wallpapers with transparency will be blended instead of copied. But that
seems fine, and if not, the Right Fix for that is to remove the alpha
channel from wallpapers after loading them anyways.

As an added bonus, draw_scaled_bitmap() already handles display scale,
so this fixes window server asserts for background images that are shown
as "stretch" (#5017). The window server still asserts for "tile" and
"offset" for now though.

Calling draw_scaled_bitmap() here exposed a bug in it fixed by #5041.
Before that is merged, this change here will cause smearing on the
background image when moving windows around.
2021-01-22 16:58:41 +01:00
Nico Weber
6a78e7e6a8 LibGfx: Correctly handle source rect offset in draw_scaled_bitmap
The do_draw_integer_scaled_bitmap() fastpath already handled this
correctly, but the arbitrary scale path did not.
2021-01-22 16:58:23 +01:00
Nico Weber
d5f403663b LibGfx: Compute hscale/vscale inside do_draw_scaled_bitmap instead of passing it in
They're both read only inside do_draw_scaled_bitmap(), so there's no
point in computing them earlier.

No behavior change.
2021-01-22 16:54:31 +01:00
Emanuele Torre
5df714cd22 Build: Replace explicit use of mv(1) in CMake file with file(RENAME).
Also fix code style: `else ()` -> `else()`.
2021-01-22 11:29:52 +01:00
Ben Wiederhake
7980268b7b Meta: Document QtCreator 'lic' auto-complete 2021-01-22 11:28:07 +01:00
Ben Wiederhake
58f25092c7 Meta: Fix silly copyright line 2021-01-22 11:28:07 +01:00
Tom
9943816e83 LibPthread: Fix asserting futex return value
FUTEX_WAIT returns the number of threads woken (if any).

Fixes #5032
2021-01-22 11:17:07 +01:00
Linus Groh
efc091df81 Ports: Build python3 with libffi
This makes building the _ctypes module succeed. We still can't import
it, but hey, that's progress! :^)
2021-01-22 11:10:01 +01:00
Doctor5555
6803d5dfbe passwd: Remove duplicate 'wpath' pledge 2021-01-22 11:09:44 +01:00
Tom
2830ce5383 Kernel: Unsupported TTY ioctls should return EINVAL gracefully
Fixes #4971
2021-01-22 09:25:04 +01:00
Andreas Kling
47a4a5ac1d Base: Add root to the /etc/shadow file
The password is still empty by default, but being present in the shadow
file is now a requirement for authentication.
2021-01-21 11:35:32 +01:00
Andreas Kling
3b80358142 LibCore: Always fail Account authentication on missing shadow entry
If a user is missing from /etc/shadow, we used to just allow anyone to
authenticate as that user without a password.

With this patch, authentication will instead always fail.
2021-01-21 11:34:39 +01:00
Andreas Kling
439f447ba8 LibCore+su+passwd: Don't keep /etc/passwd and /etc/shadow open
Now that we've moved to atomic replacement of these files when altering
them, we don't need to keep them open for the lifetime of Core::Account
so just simplify this and close them when they are not needed.
2021-01-21 11:17:06 +01:00
Andreas Kling
77e0598c6d passwd+LibCore: Make passwd replace /etc files atomically
Before this patch, we had a nasty race condition when changing a user's
password: there was a time window between truncating /etc/shadow and
writing out its new contents, where you could simply "su" to root
without using a password.

Instead of writing directly to /etc/passwd and /etc/shadow, we now
create temporary files in /etc and fill them with the new contents.
Those files are then atomically renamed to /etc/passwd and /etc/shadow.

Sadly, fixing this race requires giving the passwd program a lot more
privileges. This is something we can and should improve upon. :^)
2021-01-21 11:08:20 +01:00
Andreas Kling
c9a7f81dc3 Kernel: Create new files with the current process EUID/EGID
We were using the UID/GID and not the EUID/EGID, which didn't match
other systems.
2021-01-21 11:08:16 +01:00
Andreas Kling
928ee2c791 Kernel: Don't let signals unblock threads while handling a page fault
It was possible to signal a process while it was paging in an inode
backed VM object. This would cause the inode read to EINTR, and the
page fault handler would assert.

Solve this by simply not unblocking threads due to signals if they are
currently busy handling a page fault. This is probably not the best way
to solve this issue, so I've added a FIXME to that effect.
2021-01-21 00:14:56 +01:00
Andreas Kling
1f53dd0943 Ext2FS: Propagate I/O errors from Ext2FSInode::write_bytes() 2021-01-21 00:14:56 +01:00
Nico Weber
65570216b4 oss-fuzz: Try harder to fix build
Apparently memfd_create() is newish in glibc, and oss-fuzz
uses Ubuntu 16.04 as base for its docker images, which doens't
yet have memfd_create(). But, not to worry, it does have the syscall
define and that's all we really need :/
2021-01-20 23:41:38 +01:00
Andreas Kling
57ca15f126 Kernel: Remove commented-out code from Thread::dispatch_signal() 2021-01-20 23:27:23 +01:00
Andreas Kling
19d3f8cab7 Kernel+LibC: Turn errno codes into a strongly typed enum
..and allow implicit creation of KResult and KResultOr from ErrnoCode.
This means that kernel functions that return those types can finally
do "return EINVAL;" and it will just work.

There's a handful of functions that still deal with signed integers
that should be converted to return KResults.
2021-01-20 23:20:02 +01:00
Andreas Kling
e279b45aed Kernel: Make BlockBasedFS read/write functions return a KResult
This way, if something goes wrong, we get to keep the actual error.
Also, KResults are nodiscard, so we have to deal with that in Ext2FS
instead of just silently ignoring I/O errors(!)
2021-01-20 22:57:36 +01:00
Nico Weber
91aa0d9997 LibGfx/Painter: Keep translation and clip_rect in logical coordinates
Moves Painter away from general affine transport support a bit, but
this scale factor business does feel like it's a bit different.

This is conceptually cleaner (everything should use logical coordinates
as much as possible), and it means the code in GUI::Painter() will work
without changes due to that, but the draw function implementations
overall get a bit murkier (draw_rect() becomes nicer though). Still,
feels like the right direction.

No behavior change.
2021-01-20 21:01:48 +01:00
Nico Weber
362bde4a86 SystemServer.ini: Default to not showing network change notifications
Until someone has time to implement something for not showing the
very first network change at boot, let's turn off notifications for
network changes by default altogether. Having to dismiss this
notification at every boot gets old fast.
2021-01-20 21:01:21 +01:00
Linus Groh
17f90e72b4 CrashReporter: Show pledge violation in backtrace 2021-01-20 21:01:15 +01:00
Linus Groh
678919e9c1 Kernel: Set "pledge_violation" coredump metadata in REQUIRE_PROMISE()
Similar to LibC storing an assertion message before aborting, process
death by pledge violation now sets a "pledge_violation" key with the
respective pledge name as value in its coredump metadata, which the
CrashReporter will then show.
2021-01-20 21:01:15 +01:00
Nico Weber
7e5c49b755 Meta: Add some more documentation on oss-fuzz 2021-01-20 21:00:58 +01:00
Nico Weber
2f82854e4a Revert "LibCore: Try to fix fuzzer build"
This reverts commit c5709c0aed.
2021-01-20 21:00:46 +01:00
Nico Weber
8ccd8b4a6f LibJS: Include <typeinfo> in AST.cpp
Without this, the oss-fuzz build says:

../Userland/Libraries/LibJS/AST.cpp:58:34: error: member access into incomplete type 'const std::type_info'
    return demangle(typeid(*this).name()).substring(4);
                                 ^
2021-01-20 21:00:27 +01:00
Ben Wiederhake
de98f69bfe Userland: Implement shuf for basic shuffling 2021-01-20 19:19:34 +01:00
Ben Wiederhake
9c8efcd17e Userland: Fix broken newlines in 'sort' 2021-01-20 19:19:34 +01:00
Ben Wiederhake
ab07a713bf LibC: Implement uniform random sampling without modulo bias 2021-01-20 19:19:34 +01:00
Ben Wiederhake
e849c62f55 Conway: Don't run misleading srand()
The randomness is taken from arc4random() which is independent from srand/rand/rand_r,
so there's no need to call srand(). At best, it confuses the reader to think that
there would eventually be a call to rand().
2021-01-20 19:19:34 +01:00
Ben Wiederhake
c8465b4c1a Meta: Slightly improve image script 2021-01-20 19:19:34 +01:00
Nico Weber
e2dfd028f9 LibGfxScaleDemo: Add coverage for blit_with_alpha 2021-01-20 19:15:03 +01:00
Linus Groh
ea80ff882d Run: Fix newline in info label
This apparently was a workaround for escape sequences in GML at some
point (see #4937), but it now literally inserts "\n" and no newline, as
the backslash itself is escaped.
2021-01-20 19:14:40 +01:00