Commit graph

19733 commits

Author SHA1 Message Date
Brian Gianforcaro
fd0dbd1ebf Tests: Establish root Tests directory, move Userland/Tests there
With the goal of centralizing all tests in the system, this is a
first step to establish a Tests sub-tree. It will contain all of
the unit tests and test harnesses for the various components in the
system.
2021-05-06 17:54:28 +02:00
Mart G
6e641fadfa
Kernel: Resize Ext2FSInode when writing directory contents (#6897)
Ext2 directory contents are stored in a linked list of ext2_dir_entry
structs. There is no sentinel value to determine where the list ends.
Instead the list fills the entirety of the allocated space for the
inode.

Previously the inode was not correctly resized when it became smaller.
This resulted in stale data being interpreted as part of the linked list
of directory entries.
2021-05-06 17:53:59 +02:00
Linus Groh
f1791eca13 Ports: Always set Python MACHDEP to version-less 'serenityos'
This is used for `sys.platform`, so it's important to get it right and
ideally never change it again. When not cross-compiling this would
append the `uname -r` version number, so let's explicitly override the
generated value and set it to `serenityos`. Various other systems do
this as well.
2021-05-06 16:46:43 +01:00
Linus Groh
8cfbeb78ff Ports: Remove Python printf fraction length patch
This functionality was implemented in f0fe449, making the patch
unnecessary.
2021-05-06 15:26:49 +01:00
AnotherTest
ba6c9423b8 AK: Implement printf fraction length specification for strings
This adds support for '%.20s' and friends :^)
2021-05-06 15:20:31 +01:00
Linus Groh
9f970c3459 Ports: Register Browser in the Python webbrowser module
This makes the following work:

    >>> import webbrowser
    >>> webbrowser.open("http://serenityos.org")

As well as this well-known easter egg:

    >>> import antigravity

Pretty cool! :^)
2021-05-06 14:26:09 +01:00
Linus Groh
877996465a LibC: Update forkpty() master fd before fork()'s child branch 2021-05-06 14:04:07 +01:00
Linus Groh
5391836468 LibC: Remove 'int* aslave' parameter from forkpty()
Only keep track of that (and eventually close() it) internally instead.
This argument is not present on other systems, so we were running into
compatibility issues with ports.
Also bring the implementation closer to Linux and OpenBSD by making sure
to close the slave pty fd in the fork()'d child as well as _exit()'ing
on login_tty() failure - it's non-POSIX, so those are our references
here. :^)
2021-05-06 13:52:46 +01:00
Linus Groh
e76342e242 Ports: Update Python to 3.9.5
Released on 2021-05-03.
https://www.python.org/downloads/release/python-395/
2021-05-06 13:04:38 +01:00
Andreas Kling
6024617df3 LookupServer: Remove some unnecessary "rc" temporaries 2021-05-06 13:37:46 +02:00
Andreas Kling
f0629e29c9 LookupServer: Check the return value after calling unveil() 2021-05-06 13:34:36 +02:00
Andreas Kling
a7e44d8b3c Base: Remove unnecessary UID separation of multi-process Browser
After looking closely at this, I realized that we've been running
all the service processes under separate user accounts even though
there's actually no need to.

Since we already use pledge() and unveil() to limit the scope and
access of these programs, separating them to another UID doesn't
achieve anything meaningful. So let's bring them back to the "anon"
user account and simplify things.

Programs affected:

- ImageDecoder
- RequestServer
- WebContent
- WebSocket

Longer term, I'd like for all of these to get spawned for the current
desktop user somehow, possibly by some kind of session manager, or
perhaps by the Browser program itself. But for now they remain under
SystemServer's control.
2021-05-06 13:33:08 +02:00
Andreas Kling
434c190667 TextEditor: Minor cleanups in the FileArgument class
* Remove unnecessary #include statements
* Move it into the TextEditor namespace
* Mark the single-argument constructor explicit
* Use move() to avoid some unnecessary copies
2021-05-06 12:35:25 +02:00
Andreas Kling
297a2762cd TextEditor: Rename "file_name" => "filename" 2021-05-06 12:33:46 +02:00
Andreas Kling
f3091d89aa WindowServer: Don't let clients start resize of non-resizable windows
This came up in #6886. If resizing has been disabled for a window,
we shouldn't let clients bypass this via start_window_resize().
2021-05-06 12:09:03 +02:00
Andreas Kling
dfd8598bf7 LibGUI: Don't show resize corner in non-resizable window's statusbar
Fixes #6886.
2021-05-06 12:08:00 +02:00
Gunnar Beutner
3438829431 LibC: Lazily initialize malloc chunks
By default malloc manages memory internally in larger blocks. When
one of those blocks is added we initialize a free list by touching
each of the new block's pages, thereby committing all that memory
upfront.

This changes malloc to build the free list on demand which as a
bonus also distributes the latency hit for new blocks more evenly
because the page faults for the zero pages now don't happen all at
once.
2021-05-06 10:38:46 +02:00
Tom
3aaffa2c47 LibGUI: Move widget registration to LibCore
This also moves Widget::load_from_json into Core::Object as a virtual
function in order to allow loading non-widget objects in GML (e.g.
BoxLayout).

Co-authored-by: Gunnar Beutner <gbeutner@serenityos.org>
2021-05-06 08:50:39 +02:00
Gunnar Beutner
6e101adc28 DHCPClient: Handle invalid DHCP responses more gracefully 2021-05-06 08:49:35 +02:00
Gunnar Beutner
9213d1e926 Kernel: Truncate UDP packets on read
When reading UDP packets from userspace with recvmsg()/recv() we
would hit a VERIFY() if the supplied buffer is smaller than the
received UDP packet. Instead we should just return truncated data
to the caller.

This can be reproduced with:

    $ dd if=/dev/zero bs=1k count=1 | nc -u 192.168.3.190 68
2021-05-06 08:49:35 +02:00
Carlos César Neves Enumo
928f16d360 LibGUI: Remember modified state on undo/redo actions 2021-05-06 08:40:26 +02:00
Carlos César Neves Enumo
67537bfc80 LibGUI: Clear undo stack when opening a new document 2021-05-06 08:40:26 +02:00
Andreas Kling
88803b2e34 Meta: Add "Human language policy" to CONTRIBUTING.md 2021-05-05 23:15:08 +02:00
Spencer Dixon
0f89e47a1a
Kernel: Allow remapping Caps Lock to Control (#6883)
We use a global setting to determine if Caps Lock should be remapped to
Control because we don't care how keyboard events come in, just that they
should be massaged into different scan codes.

The `proc` filesystem is able to manipulate this global variable using
the `sysctl` utility like so:

```
# sysctl caps_lock_to_ctrl=1
```
2021-05-05 23:10:56 +02:00
Andreas Kling
18d344609f LibGUI: Add ScrollableContainerWidget :^)
This widget provides a scrollable view onto another (child) widget.
If the child is larger than the parent, scrollbars are provided for
panning around the child.
2021-05-05 22:17:33 +02:00
Andreas Kling
89f5f92b7e LibMarkdown: Convert a bunch of StringBuilder::appendf() => appendff() 2021-05-05 22:17:33 +02:00
Gunnar Beutner
beae2d5caa LibSQL: Fix incorrect return types
Right now RefPtr<T> is way more lenient than it should be. That might
change in the future though.
2021-05-05 22:00:57 +02:00
Timothy Flynn
e8b508516a Solitaire: Decrease new game animation delay
The current setting is an awful long time to wait for a game to start.
2021-05-05 21:38:45 +02:00
Timothy Flynn
a07c178a02 Solitaire: Add statusbar segment to display elapsed time
The timer begins after the new-game animation ends, and stops when
either the game-over animation begins or the new-game animation is
started again.
2021-05-05 21:38:45 +02:00
Timothy Flynn
ee1a4a06e0 LibGUI: Allow specifying GUI::Statusbar segment count in GML 2021-05-05 21:38:45 +02:00
Timothy Flynn
b2576b7e45 Solitaire: Add a GUI::Statusbar to the Solitaire window
This will display the score (instead of updating the window title) and
any hovered action text.
2021-05-05 21:38:45 +02:00
Timothy Flynn
59193dd6b3 Solitaire: Only start timer when the timer event is needed
The timer is no longer used to trigger a paint event for all updates; it
is only used to paint the new-game and game-over animations. So only run
the timer during those events.
2021-05-05 21:38:45 +02:00
Timothy Flynn
4fc9c1d710 Solitaire: Refactor painting logic to accomodate to-be-added widgets
A series of events led to this change: The goal is to add more widgets
to the Solitaire GML, such as a GUI::Statusbar. To do so without this
change, the window ends up with some black artifacts between the main
Solitaire frame and the added elements, because the GML specifies the
main widget to have fill_with_background_color=false. However, setting
that property to true results in the background color of the widget
interferring with the Solitaire frame trying to manually paint its
background green. This results in flickering and some elements in the
Solitaire frame being painted over by the main background color.

To avoid all of that behavior, this sets fill_with_background_color=true
and the Solitaire frame's background color to green in the GML. Further,
the frame now only queues a paint update on the specific Gfx::Rect areas
that need to be updated. This also means we no longer need to track if a
stack of cards is dirty, because we only trigger a paint event for dirty
stacks.
2021-05-05 21:38:45 +02:00
Timothy Flynn
bb7b76e505 Solitaire: Don't invoke srand multiple times
This doesn't need to be invoked each time the game wants something
random.
2021-05-05 21:38:45 +02:00
Timothy Flynn
a540ec3519 Solitaire: Convert Solitaire GUI to a frame
Looks a bit nicer as a frame with inset edges.
2021-05-05 21:38:45 +02:00
Timothy Flynn
0ff4eec8a8 Solitaire: Convert Solitaire window to be created from GML
No functionial change here, but this more easily allows for adding GUI
elements to the Solitaire window. This nests the SolitaireWidget as a
child of the main window's widget so that the SolitaireWidget does not
color the entire window green when it paints its background.
2021-05-05 21:38:45 +02:00
Timothy Flynn
e1492e9a62 Solitaire: Place files in Solitaire namespace and rename main widget
The purpose is to allow the Solitaire widget to be used in GML. The
macro to register a widget requires a namespace, so this moves all files
in the application to the Solitaire namespace. This also renames the
SolitaireWidget class to Game - this is to avoid the redundancy /
verbosity of typing "Solitaire::SolitaireWidget", and matches many other
games in Serenity (Breakout, 2048, etc.).
2021-05-05 21:38:45 +02:00
Timothy Flynn
15f0ee1727 Solitaire: Replace self-owned timer with Core::Object's timer
This is just a bit nicer than owning a separate timer in the Solitaire
application because LibCore will prevent timer events from firing when
e.g. the window is not visible. Therefore SolitaireWidget doesn't need
need to check for such conditions.
2021-05-05 21:38:45 +02:00
Timothy Flynn
cfc3a2ebac Solitaire: Bump stacked cards down to reveal suit
Stacks of cards currently cover the suit completely and players must
click-and-drag cards out of the way to see the suit beneath other cards.
This bumps the stacks down a bit to let players peek the suit without
having to take any action.
2021-05-05 21:38:45 +02:00
Brian Gianforcaro
83dca542bb Meta: Enable linting of shell scripts under Toolchain
Now that everything under Toolchain is shellcheck clean,
remove it from the exception list.
2021-05-05 21:26:37 +02:00
Brian Gianforcaro
8b856bd5a1 Toolchain: Fix expansion bugs and make BuildIt.sh shellcheck compliant
BuildIt.sh had a bunch of SC2086 errors, where we were not quoting
variables in variable expansions. The logic being:

    Quoting variables prevents word splitting and glob expansion,
    and prevents the script from breaking when input contains spaces,
    line feeds, glob characters and such.

    Reference: https://github.com/koalaman/shellcheck/wiki/SC2086

As bcoles noticed in #6772, shellcheck actually found a real bug here,
where the user's build directory included spaces.

Close: #6772
2021-05-05 21:26:37 +02:00
Brian Gianforcaro
f558a44610 Toolchain: Make BuildFuseExt2.sh shellcheck compliant
BuildFuseExt2.sh was saying it should be run under /bin/sh but it is
using bash extensions like pushd/popd, ${BASH_SOURCE[0]}, etc. So just
run it under bash to avoid any potential issues.
2021-05-05 21:26:37 +02:00
Brian Gianforcaro
b4927a753d Toolchain: Make BuildPython.sh shellcheck compliant
Shellcheck is unable to source non-literal includes,
so inform shellcheck to just ignore this include.
2021-05-05 21:26:37 +02:00
Sergey Bugaev
37a59f7f40 Base: Start LookupServer on boot
I can't say I like starting yet another thing on boot... but now that
LookupServer provides mDNS (and optionaly DNS) services to other hosts,
we have to start it on boot, not when the first local client connects.
2021-05-05 21:16:17 +02:00
Sergey Bugaev
bb06e720de LookupServer: Implement basic mDNS support :^)
The implementation is extremely basic, and is far from fully conforming
to the spec. Among other things, it does not really work in case there
are multiple network adapters.

Nevertheless, it works quite well for the simple case! You can now do
this on your host machine:

$ ping courage.local

and same on your Serenity box:

$ ping host-machine-name.local
2021-05-05 21:16:17 +02:00
Sergey Bugaev
fd76e07399 LookupServer: Implement DNSName::operator==() 2021-05-05 21:16:17 +02:00
Sergey Bugaev
78459b92d5 Kernel: Implement IP multicast support
An IP socket can now join a multicast group by using the
IP_ADD_MEMBERSHIP sockopt, which will cause it to start receiving
packets sent to the multicast address, even though this address does
not belong to this host.
2021-05-05 21:16:17 +02:00
Idan Horowitz
b9c367e13b Meta: Add action to tweet each commit on push 2021-05-05 21:12:09 +02:00
Spencer Dixon
2156c728cd
Kernel: Fix writes to ProcFS (#6879)
When using `sysctl` you can enable/disable values by writing to the
ProcFS. Some drift must have occured where writing was failing due to
a missing `set_mtime` call. Whenever one `write`'s a file the modified
time (mtime) will be updated so we need to implement this interface in
ProcFS.
2021-05-05 21:07:13 +02:00
Andreas Kling
773c17b6a0 Documentation: Update FAQ a bit and move it into Documentation/
This was hiding on the serenityos.org website previously, where not
many people found it. Let's put it in a more natural location, and
also make sure to link to it from the README.
2021-05-05 20:03:02 +02:00